[Resolved] is_home() doesn't work on Blog Posts Page

Home Forums Support is_home() doesn't work on Blog Posts Page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1271847
    Annika Thierfeld

    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' );
    		} );
    	};
    #1272414
    Tom
    Lead Developer
    Lead Developer

    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 🙂

    #1273206
    Annika Thierfeld

    Hi, Tom,

    thank you so much that works. 🙂

    #1274122
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.