-
AuthorPosts
-
January 16, 2015 at 8:09 am #184422
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
January 17, 2015 at 4:38 am #184967Hey 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_singularHope that helps. 🙂
January 17, 2015 at 2:10 pm #185178That’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
January 18, 2015 at 7:23 pm #185758Hi Ross,
Sure, added your requests. It’s nice to have filters that can be use anytime.
Thanks for sharing 😉
January 30, 2016 at 7:13 am #771887Hi
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örnJanuary 30, 2016 at 7:40 pm #772476Hello 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!
-
AuthorPosts