-
AuthorPosts
-
April 19, 2014 at 11:36 am #35114
Jack SParticipantHello,
I’m building a site with a custom post type, and have hooked in the template file for the single post as follows:
function get_custom_post_type_template($single_template) { global $post; if ($post->post_type == 'event') { $single_template = dirname(__FILE__).'/single-event.php'; } return $single_template; } add_filter('single_template','get_custom_post_type_template');This is because I do not wish to modify the x theme directory at all, including adding files.
The issue I’m having is that there I have no control over the page title for single-event.php as it is already set by the theme previously via get_header(). There is a title there but it’s whatever’s defined in the theme options for the title of the blog page, rather than the current post title (like the_title()), which is what I need.
For clarification: this is what I need to change:
<header class="x-header-landmark"> <div class="x-container-fluid max width"> <div class="x-landmark-breadcrumbs-wrap"> <div class="x-landmark"> <h1 class="h-landmark"><span>Blog Title</span></h1> </div> </div> </div> </header>What would be the best way to fix this?
Thank you,
JApril 19, 2014 at 9:42 pm #35254
RadModeratorHi Jack,
Thank you for posting in! You could create another header on your child theme.
The best way is copying some x theme files.For example.
1. Copy x theme’s header.php and rename it into header-event.php, and place it in your child theme.
Then you can just call it like :
get_header('event');2. In your header-event.php code, you should change it into :
<?php x_get_view( x_get_stack(), 'wp', 'header-event' ); ?>3. Then copy your /x/framework/views/{STACK}/wp-header.php into /x-child-{STACK}/framework/views/{STACK}/wp-header-event.php
4. Edit your wp-header-event.php and find something like :
<?php x_get_view( '{STACK}', '_landmark-header' ); ?>
and edit it into :
<?php x_get_view( '{STACK}', '_landmark-header-event' ); ?>5. Copy your /x/framework/views/{STACK}/_landmark-header.php into /x-child-{STACK}/framework/views/{STACK}/_landmark-header-event.php
6. Then edit your new _landmark-header-event.php 🙂
Hope this helps.
April 20, 2014 at 11:51 am #35333
Jack SParticipantHello,
Thanks for your reply. Unfortunately, I’m not using a child theme (I haven’t ever) – I am just using X, and I have my custom post type & the templates in a plugin. I’m going to try the instructions you’ve provided however, only with the plugin rather than a child theme. My only concern is that I want to be able to update the X theme version in the future – will that be a problem if I copy and paste the code from header.php? Would I have to update the custom header file every time I update the theme?
Thanks,
JackApril 21, 2014 at 1:12 am #35493
SupportMemberHi,
Thank you for the update.
I’m sorry but you can’t preserve this modification without using a child theme. You can edit the title for the custom post type on framework > views > {stack} > _landmark-header.php. Find this code on line 34:
<?php if ( is_singular( 'x-portfolio' ) ) : ?> <h1 class="h-landmark"><span><?php echo get_theme_mod( 'x_portfolio_title' ); ?></span></h1> <?php else : ?> <h1 class="h-landmark"><span><?php echo get_theme_mod( 'x_renew_blog_title' ); ?></span></h1> <?php endif; ?>Replace it with this:
<?php if ( is_singular( 'x-portfolio' ) ) : ?> <h1 class="h-landmark"><span><?php echo get_theme_mod( 'x_portfolio_title' ); ?></span></h1> <?php elseif ( is_singular( 'event' ) ) : ?> <h1 class="h-landmark"><span><?php $title = get_the_title(); echo $title; ?></span></h1> <?php else : ?> <h1 class="h-landmark"><span><?php echo get_theme_mod( 'x_renew_blog_title' ); ?></span></h1>I hope that helps.
April 13, 2016 at 1:34 pm #880586
awschroParticipantThis reply has been marked as private.April 13, 2016 at 11:09 pm #881379 -
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-35114 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
