Find answers, ask questions, and connect with our
community around the world.

Forums Forums Web Design WordPress Troubleshooting 404 in my theme. I use pre_get_posts to sort by a meta value. While this function exists, the home page loads but navigating to any other page throws 404.php. I presume I need to add !is_SOMETHING to my if statement. What am I missing? Thx.

  • Troubleshooting 404 in my theme. I use pre_get_posts to sort by a meta value. While this function exists, the home page loads but navigating to any other page throws 404.php. I presume I need to add !is_SOMETHING to my if statement. What am I missing? Thx.

    updated 11 months, 3 weeks ago 0 Member · 1 Post
  • SharonP

    Member
    December 9, 2021 at 11:48 am

    This is a followup to https://www.hq overview.com/r/Wordpress/comments/rc456w/all_pages_except_my_home_page_404_i_have_a/ By switching away from my theme to another I was able to determine my 404s are unrelated to permalinks or .htaccess. It is clearly specific to my functions.php. Here is the function that is causing the problem: function the_main_query( $query ) { if( $query->is_main_query() && !is_admin() ) { $meta_query = array( ‘relation’ => ‘OR’, array( ‘key’ => ‘lot_number’ /* , ‘value’ => time(), ‘compare’ => ‘>’ */ ), array( ‘key’ => ‘lot_number’, ‘compare’ => ‘NOT EXISTS’, ‘value’ => ‘null’ ) ); $query->set( ‘meta_query’, $meta_query ); $query->set( ‘orderby’, ‘meta_value_num meta_value’ ); $query->set( ‘meta_key’, ‘lot_number’ ); $query->set( ‘order’, ‘ASC’ ); $query->set( ‘join’, ‘LEFT OUTER’); } } add_action( ‘pre_get_posts’, ‘the_main_query’ ); – by /hq/djuggler – –

Viewing 1 of 1 replies
Reply to: SharonP
Your information:

Cancel
Original Post
0 of 0 posts June 2018
Now