-
AuthorPosts
-
August 29, 2022 at 4:23 pm #1363062
Hi,
Using WordPress 6.0.1, Enfold 5.1.1 with Classic Editor (theme version) for posts, but ALB for pages.
My client presented a problem where related posts do not show. Upon investigation, it seems that the index.php template is being used instead of single.php. Related posts have been tagged.
get_post_type() returns ‘post’
( https://developer.wordpress.org/reference/functions/get_post_type/ )
global $template returns …’/wp-content/themes/enfold/index.php’ (should return …’/wp-content/themes/enfold/single.php’)
get_single_template() returns empty (should return …’/wp-content/themes/enfold/single.php’)
( https://developer.wordpress.org/reference/functions/get_single_template/ )
get_query_template(‘single’) returns empty (should return …’/wp-content/themes/enfold/single.php’)
( https://developer.wordpress.org/reference/functions/get_query_template/ )This is all according to https://developer.wordpress.org/themes/basics/template-hierarchy/
Is there a reason for this inconsistency?
August 29, 2022 at 4:41 pm #1363068On my own site:
Using WordPress 6.0.1, Enfold 4.9 with Classic Editor (theme version) for posts, but ALB for pages.
get_post_type() returns ‘post’
( https://developer.wordpress.org/reference/functions/get_post_type/ )
global $template returns …’/wp-content/themes/enfold/single.php’ (correct)
get_single_template() returns …’/wp-content/themes/enfold/single.php’ (correct)
( https://developer.wordpress.org/reference/functions/get_single_template/ )
get_query_template(‘single’) returns …’/wp-content/themes/enfold/single.php’ (correct)
( https://developer.wordpress.org/reference/functions/get_query_template/ )August 30, 2022 at 2:46 am #1363124Hi,
Thank you for the inquiry.
Did you check the plugins in the client’s site? We added the following code in the functions.php file and all functions return the appropriate values.
add_action('wp_head', function() { global $template, $post; echo '<pre>' . var_export($template, true) . '</pre>'; // returns single.php echo '<pre>' . var_export(get_post_type(get_the_ID()), true) . '</pre>'; // returns post echo '<pre>' . var_export(get_single_template() , true) . '</pre>'; // returns single.php echo '<pre>' . var_export(get_query_template('single'), true) . '</pre>'; // returns single.php });Tested on Enfold 5.1.1 and WordPress 6.0.1.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.
