Link post to blog from a static page

Welcome to WordPress! I’m going to assume you’re creating your first theme. I would start by reading about The Loop http://codex.wordpress.org/The_Loop which is a crucial concept for WordPress themes. If you designed your homepage within the WordPress admin by going to Pages, adding a new page, and putting your static homepage markup in the content … Read more

Query post category & remove any post id

If you are trying to omit posts 1,3,5 from category 3 on your blog, you can use the following code $query = new WP_Query( array(‘cat’ => 3, ‘post_type’ => ‘post’, ‘post__not_in’ => array(1,3,5) ) ); The query results will not show posts with ids 1,3,5 of category 3.

How to add a class to links inside posts text

Is it possible? Sure. You just need to re-declare the wpLink function that generates the link from the button. For example like this function wpse_181706_overwrite_wpLink() { if (wp_script_is(‘quicktags’)){ ?> <script type=”text/javascript”> var wpLink;!function(e){var t,i,n,s,l={},a={},r=”ontouchend”in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:””,textarea:””,init:function(){l.wrap=e(“#wp-link-wrap”),l.dialog=e(“#wp-link”),l.backdrop=e(“#wp-link-backdrop”),l.submit=e(“#wp-link-submit”),l.close=e(“#wp-link-close”),l.url=e(“#url-field”),l.nonce=e(“#_ajax_linking_nonce”),l.title=e(“#link-title-field”),l.openInNewTab=e(“#link-target-checkbox”),l.search=e(“#search-field”),a.search=new n(e(“#search-results”)),a.recent=new n(e(“#most-recent-results”)),a.elements=l.dialog.find(“.query-results”),l.queryNotice=e(“#query-notice-message”),l.queryNoticeTextDefault=l.queryNotice.find(“.query-notice-default”),l.queryNoticeTextHint=l.queryNotice.find(“.query-notice-hint”),l.dialog.keydown(wpLink.keydown),l.dialog.keyup(wpLink.keyup),l.submit.click(function(e){e.preventDefault(),wpLink.update()}),l.close.add(l.backdrop).add(“#wp-link-cancel a”).click(function(e){e.preventDefault(),wpLink.close()}),e(“#wp-link-search-toggle”).on(“click”,wpLink.toggleInternalLinking),a.elements.on(“river-select”,wpLink.updateFields),l.search.on(“focus.wplink”,function(){l.queryNoticeTextDefault.hide(),l.queryNoticeTextHint.removeClass(“screen-reader-text”).show()}).on(“blur.wplink”,function(){l.queryNoticeTextDefault.show(),l.queryNoticeTextHint.addClass(“screen-reader-text”).hide()}),l.search.keyup(function(){var e=this;window.clearTimeout(i),i=window.setTimeout(function(){wpLink.searchInternalLinks.call(e)},500)})},open:function(i){var n;wpLink.range=null,i&&(window.wpActiveEditor=i),window.wpActiveEditor&&(this.textarea=e(“#”+window.wpActiveEditor).get(0),”undefined”!=typeof tinymce&&(n=tinymce.get(wpActiveEditor),t=n&&!n.isHidden()?n:null,t&&tinymce.isIE&&(t.windowManager.bookmark=t.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),l.wrap.show(),l.backdrop.show(),wpLink.refresh(),e(document).trigger(“wplink-open”,l.wrap))},isMCE:function(){return t&&!t.isHidden()},refresh:function(){a.search.refresh(),a.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),r?l.url.focus().blur():l.url.focus()[0].select(),a.recent.ul.children().length||a.recent.ajax()},mceRefresh:function(){var e;(e=t.dom.getParent(t.selection.getNode(),”A”))?(l.url.val(t.dom.getAttrib(e,”href”)),l.title.val(t.dom.getAttrib(e,”title”)),l.openInNewTab.prop(“checked”,”_blank”===t.dom.getAttrib(e,”target”)),l.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){wpLink.isMCE()?t.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),l.backdrop.hide(),l.wrap.hide(),e(document).trigger(“wplink-close”,l.wrap)},getAttrs:function(){return{href:l.url.val(),title:l.title.val(),target:l.openInNewTab.prop(“checked”)?”_blank”:””,”class”:”myclass”}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,i,n,s,l,a,r=wpLink.textarea;r&&(e=wpLink.getAttrs(),e.href&&”http://”!=e.href&&(t=”<a href=””+e.href+'”‘,e.title&&(l=e.title.replace(/</g,”&lt;”).replace(/>/g,”&gt;”).replace(/”/g,”&quot;”),t+=’ title=”‘+l+'”‘),e.target&&(t+=’ target=”‘+e.target+'”‘),e[“class”]&&(t+=’ class=”myclass”‘),t+=”>”,document.selection&&wpLink.range?(r.focus(),wpLink.range.text=t+wpLink.range.text+”</a>”,wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):”undefined”!=typeof r.selectionStart&&(i=r.selectionStart,n=r.selectionEnd,a=r.value.substring(i,n),t=t+a+”</a>”,s=i+t.length,i==n&&(s-=”</a>”.length),r.value=r.value.substring(0,i)+t+r.value.substring(n,r.value.length),r.selectionStart=r.selectionEnd=s),wpLink.close(),r.focus()))},mceUpdate:function(){var e,i=wpLink.getAttrs();return wpLink.close(),t.focus(),tinymce.isIE&&t.selection.moveToBookmark(t.windowManager.bookmark),e=t.dom.getParent(t.selection.getNode(),”a[href]”),i.href&&”http://”!=i.href?(e?t.dom.setAttribs(e,i):t.execCommand(“mceInsertLink”,!1,i),void t.selection.collapse()):void t.execCommand(“unlink”)},updateFields:function(e,t){l.url.val(t.children(“.item-permalink”).val()),l.title.val(t.hasClass(“no-title”)?””:t.children(“.item-title”).text())},setDefaultValues:function(){var e=t&&t.selection.getContent(),i=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,n=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ “]*$/i;l.url.val(e&&i.test(e)?”mailto:”+e:e&&n.test(e)?e.replace(/&|&#0?38;/gi,”&”):”http://”),l.title.val(“”),l.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var … Read more

Allowing Users to Delete Their Posts

I don’t know what “it’s not working” you mean. It gives error or what? Maybe you should echo $_REQUEST[‘p_id’] first before delete it, just make sure you got the request. Or create a variable to store wp_delete_post and check if it works or not.

How to get images only attached from edit post page

I´m using this code to load all images I uploaded via edit post page: function get_gallery_images(){ global $wpdb,$post; $ids = “”; $counter = 0; $number_of_posts = 12; $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => 12, ‘post_status’ => null, ‘orderby’ => ‘rand’, ‘post_parent’ => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as … Read more