Wordpress - problem Single.php is used instead of the home.php template - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Wednesday, October 11, 2023

Wordpress - problem Single.php is used instead of the home.php template

I have a problem because WP is not using the correct file to render the content.

The only code that changes my redirects I attach below:

add_action( 'pre_get_posts', 'wpse_include_my_post_type_in_query' );
function wpse_include_my_post_type_in_query( $query ) {

 // Only noop the main query
 if ( ! $query->is_main_query() )
     return;

 // Only noop our very specific rewrite rule match
 if ( 2 != count( $query->query )
 || ! isset( $query->query['page'] ) )
      return;

  // Include my post type in the query
 if ( ! empty( $query->query['name'] ) )
      $query->set( 'post_type', array( 'post', 'page', 'remedio__case__study' ) );
 }

The blog on my site but uses single.php instead of home.php But if I edit the site via Customize > Homepage settings > Blog Page the preview correctly uses home.php but when I save again the page renders via single.php

I use a custom theme.



source https://stackoverflow.com/questions/77268492/wordpress-problem-single-php-is-used-instead-of-the-home-php-template

No comments:

Post a Comment