Support » Theme: Neve » is_home not set

  • Resolved Harm10

    (@harm10)


    Hi!
    I have custom scripts that look at the type of content displayed. For the Home page I use property is_home to deduce that the home page is displayed.
    In theme Neve this property is not set while the Home page is displayed.

    Can this be corrected?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    I’m not really sure I understand the issue. Could you please give me more details?
    Neve shouldn’t interfere in any way with is_home. That’s coming from the core.

    Regards,
    Rodica

    I beg to differ with you. is_home (or the alternative is_front_page) are query vars.
    When building the front page from the set page in the customizer the theme knows that this is not a “normal” page but the Home page.
    So additional to the is_page being true which is normal for any page displayed I expect the theme to set is_home. This is quite easy to do with set_query_var(‘is_home’, true);
    A similar thing applies to the posts page. Whether or not the allocated page is “promoted” to posts page should also be reflected in the query var is_posts_page.
    So you are free to change the query vars if there is a special situation the case.
    That is where the query vars are for.

    Does this make the issue more clear?

    I have to edit this: using set_query_var sets a query var and is_home is not a query var but part of query itself. So coding $wp_query->is_home = true; is the way to go.

    • This reply was modified 2 months, 2 weeks ago by Harm10.

    I would like to add something here: apparently is_home should be set for Blog home page. In Neve this is correctly done on the page you select as Blog page. So far so good! 🙂
    But on the front page is_front_page should be set (read here).
    In Neve this is not done (yet). Can this be added?

    For now the workaround is to compare the id value in get_option( ‘page_on_front’ ) with the global id to deduce this page is the front page.
    But as stated is_front_page should be set.

    Hi,

    Thanks for the details, but I’m still not sure where you think the “is_front_page should be set” in Neve. Neve does not interfere with those functions from the core.

    If you are trying to add some custom code and want to select the frontpage maybe you can try
    <?php if( 'page' == get_option( 'show_on_front' ) && is_front_page() ) : ?>
    or also add wp_reset_query() before as explained here
    http://subharanjan.com/is_home-is_front_page-not-working-solved/

    Regards,
    Rodica

    I think the explanation on is_front_page says it all: “Determines whether the query is for the front page of the site.”
    The theme sets the front page and builds the query including the is_front_page in my view.
    If this does not happen then the query creation is at fault?

    Anyway I used the workaround already to use the option value combined with global id to deduce that I am on the front page.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.