Archived topic
is_home() doesn't work on Blog Posts Page
3 replies · Started by Annika on May 6, 2020
Hello,
i'm trying to get the metadata for the blog posts page from the .entry-header and insert it before the content. The change should only be made on the blog overview page, but not on the individual page.
I have selected a static page for the blog posts in the Wordpress read options. Unfortunately the if condition "is_home();" does not work.
I use GeneratePress 2.4.2 and Pro 1.10.0 with a child theme.
I have already deactivated all other plugins.
Without the query is_home() it works, but then also for single posts.
What could be the problem?
if ( is_home() ){
add_action( 'after_setup_theme', function() {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
add_action( 'generate_after_entry_header', 'generate_post_meta' );
} );
};
Hi there,
Try this:
add_action( 'wp', function() {
if ( is_home() ) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
add_action( 'generate_after_entry_header', 'generate_post_meta' );
}
} );
Let me know :)
Hi, Tom,
thank you so much that works. :)
You're welcome :)