Order Posts by meta value AND published date

I want to order WP posts by meta key named “sort_date” and if it doesn’t exist it should use the post’s published date to order posts. Below is the code i am currently using function pre_get_posts_custom($wp_query) { if ( !is_admin() && $wp_query->is_main_query() && !is_page() ) { $meta_key = ‘sort_date’; $wp_query->set( ‘post_type’, array( ‘post’, ‘article’ ) … Read more

Page queried instead of a custom taxonomy

When I try to get an archive for a custom taxonomy, WP searches for a page and doesn’t find anything. The Setup My code from the functions.php: add_action( ‘init’, ‘register_store_taxonomy’ ); function register_store_taxonomy() { $args = array ( ‘hierarchical’ => TRUE , ‘label’ => ‘Store’ , ‘public’ => TRUE , ‘query_var’ => ‘store’ , ‘rewrite’ … Read more

Display posts with comments closed, with pagination?

i’m using a custom query, which needs to display all posts with closed comments. I have this <?php $the_query = new WP_Query(‘showposts=-1’); ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <?php if (!comments_open()) : ?> //some posts fomatting <?php endif; ?> <?php endwhile;?> So, basically, this loops through all posts, and then … Read more

Pagination working everywhere but the index page

No idea why but pagination on my homepage isn’t working although it works in every other place..custom templates, archive, searches. I’ve tried every version of pagination possible it seems. I’ve used wp_query, query_posts, get_posts. I’ve tried the method of setting temp wp_query and wp_query to null and then adding it again after the pagination. I’ve … Read more