Tag Info

New answers tagged

0

Figured it out! The culprit was the plugin "Add Categories to Pages" which one of my editors had added to the site. In addition to registering post_tag and category for the page post type, it also modified the archive.php and tag.php queries to only look in the post and page types---yet another solution for the issue of including posts, pages, and ...


3

Here is another approach with pre_get_posts. Use get_posts() ( x2 queries ) to get all the post ids of each post type according to its requirements. Add the fields parameter ('fields' => 'ids') to your query arguments to just fetch post ids as this is what we need, nothing else. This will drastically improve performance and will not be that tough on ...


0

Couple of things - avoid query_posts, use a new query object or the get_posts function (read all about it). And the_ID() echo's the ID, use get_the_ID() instead. However, you can save some memory and processing by simply iterating over an array of posts (i.e. not using a proper "loop" and setting up the global post), and just grab the ID directly: ...


3

Is this possible via query args? I don't think so. Is this possible via 'posts_where'? It is probably doable using some 'posts_*' filters, not only with 'posts_where'. Or maybe using 'posts_request' filter to completely oveeride the query. Do I need to run a separate query and then somehow merge the results? That would be the simplest ...


1

The WP_Query documentation on the codex specifically says: 'attachment' - an attachment. Whilst the default WP_Query post_status is 'publish', attachments have a default post_status of 'inherit'. This means no attachments will be returned unless you also explicitly set post_status to 'inherit' or 'any'. I am not sure why it was working before ...


0

You can use a tax query with include_children set to false: $query = new WP_Query( array( 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => 'your-category-slug', 'include_children' => false, ), ), ) );


0

After a lot of guess work and research I've managed to come up with a simple solution. function column_orderby( $vars ) { $vars['orderby'] = 'date'; $vars['order'] = 'desc'; return $vars; } add_filter( 'request', 'column_orderby' ); This will sort all of the columns by 'date' as well as order them by 'desc'! Hope it helps anyone in the same ...


1

You can store the counts as key and link a value and sort them before display like this : $sort_tab = array(); while (have_posts()) : the_post(); if ( has_post_thumbnail() ) { the_post_thumbnail( array(40,40) ); } $url = get_the_permalink(); $json = file_get_contents( ...



Top 50 recent answers are included