Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #184422

    oikosdigital
    Participant

    Hi,

    I’m using a child theme (based on x-child-renew) and I have a custom post type that I want to style single pages for.

    I’ve created a single-my_post_type.php in the child theme and I’ve put

    <?php get_header(); ?>

    at the top (as well as some other stuff that I copied from framework/views/renew/wp-single.php)

    This always adds a <header class="x-header-landmark"> when is_single() is true and it adds this as the <h1>:

    <h1 class="h-landmark"><span><?php echo x_get_option( 'x_renew_blog_title' ); ?></span></h1>
    

    This code is added by framework/views/renew/_landmark_header.php

    What’s the recommended way to remove the landmark header elements from my single-my_post_type.php template? The only way I can see is to swap:

    <?php get_header(); ?>

    for code copied from framework/views/renew/wp-header.php:

    <header class="<?php x_masthead_class(); ?>" role="banner">
        <?php x_get_view( 'global', '_topbar' ); ?>
        <?php x_get_view( 'global', '_navbar' ); ?>
    </header>

    Is this the right approach? Or is there something I can call or a filter I can add?

    Thanks

    Ross

    #184967

    Christian
    Moderator

    Hey Ross,

    That is fine. The header landmark code is outputted because of the code in views/renew/_landmark_header.php

              <?php elseif ( is_home() || is_single() ) : ?>
                <?php if ( x_is_portfolio_item() ) : ?>
    
                  <h1 class="h-landmark"><span><?php echo x_get_parent_portfolio_title(); ?></span></h1>
    
                <?php else : ?>
    
                  <h1 class="h-landmark"><span><?php echo x_get_option( 'x_renew_blog_title' ); ?></span></h1>
    
                <?php endif; ?>

    You can modify the condition that checks if it is home or any single post (any post type) there like

    <?php elseif ( is_home() || is_single() && !is_singular('your-custom-post-type') ) : ?>

    to make it not display the header landmark on your custom post type. See the links below for more info on is_single and is_singular conditional tags

    http://codex.wordpress.org/Function_Reference/is_single
    http://codex.wordpress.org/Function_Reference/is_singular

    Hope that helps. 🙂

    #185178

    oikosdigital
    Participant

    That’s fine. I’m happy with what I’ve got. Can I just feedback that it would be great to have a filterable title. So, for example, the code in _landmark_header.php could be:

    <?php elseif ( is_home() || is_single() ) : ?>
                <?php if ( x_is_portfolio_item() ) : ?>
    
                  <h1 class="h-landmark"><span><?php echo apply_filters('x_landmark_header_title', x_get_parent_portfolio_title()); ?></span></h1>
    
                <?php else : ?>
    
                  <h1 class="h-landmark"><span><?php echo apply_filters('x_landmark_header_title', x_get_option( 'x_renew_blog_title' )); ?></span></h1>
    
                <?php endif; ?>
    

    Then I could do:

    add_filter('x_landmark_header_title', 'custom_post_title');
    function custom_post_title($title) {
      if (is_singular('my-custom-post-type')) {
        return 'My Title';
      } else {
        return $title;
      }
    }
    

    That would be sweet. Just sayin’

    Thanks

    Ross

    #185758

    Rad
    Moderator

    Hi Ross,

    Sure, added your requests. It’s nice to have filters that can be use anytime.

    Thanks for sharing 😉

    #771887

    bjoern_s
    Participant

    Hi

    One year has passed by, but the suggestion of Ross wasn’t implemented yet. Would be great, if this gets into the next release of X.

    Kind regards
    Björn

    #772476

    Rue Nel
    Moderator

    Hello Björn,

    We certainly appreciate the feedback! This is something we can add to our list of feature requests. This way it can be taken into consideration for future development. All of these items are discussed with our team internally and prioritized based on the amount of interest a particular feature might receive.

    Thanks!