Having pages after specifying post_type post

Your cat_n_tag_archives() function is adding pages to all category and tag results indiscriminately. What you probably want (and I am guessing a little) is to restrict that filter to the main query only: function cat_n_tag_archives($wp_query) { if (!$wp_query->is_main_query()) return; // This bit checks for the main query $ary_one = array(‘post’, ‘page’); if ($wp_query->get(‘category_name’) || $wp_query->get(‘cat’)) … Read more

When moving a WordPress installation to a new server, why do I have to update each post before content shows?

jdm2112 identified the issue as being caused by missing tables as part of the migration process within the comments for the original question: You imported just the single table into another WordPress DB? THAT is the problem. Post IDs are unique between sites… I would avoid working with individual tables unless absolutely necessary After migrating … Read more

All categories displays the same posts

query_posts breaks the main query object ($wp_query) which holds the query object and all relevant query info which breaks all conditional tags and pagination and page functionality, which simply means that it is totally useless trying to use any info regarding the main query object as it was all corrupted by query_posts resetting the main … Read more

Audio post format with Advanced Custom Fields

Advanced Custom Field plugin uses get_field() to retrieve values. Your code should be something like: $audio = get_field(‘audio_post_format_url’, $post->ID); var_dump( $audio ); # To make sure you’re retrieving the right value echo wp_oembed_get( $audio ); Note that get_field() does not need a second parameter, it will take the current post ID if omitted. If var_dump( … Read more

Retrieve post in AJAX Callback

It’s possible to capture the $post_id using a combination of wp_get_referer() and url_to_postid() then reset the $post using setup_postdata. That should work easy enough for the front-end. But on the admin side we’ll need to pull the query with parse_url and grab the ID using parse_str. For good measure we should double check if we’re … Read more

How to have one page show posts reverse-chronologically, but the others chronologically?

You want a filter on pre_get_posts restricted to the home page. Something like: function pregp_wpse_214875($qry) { if (is_home() && $qry->is_main_query()) { $qry->set(‘order’,’ASC’); } } add_action(‘pre_get_posts’,’pregp_wpse_214875′); You may need something other than is_home(), depending on how your “home page” is set up. The other most likely option would be is_front_page()