Community Forums › Forums › Archived Forums › Design Tips and Tricks › Executive Theme – Add page title to Portfolio archive
Tagged: executive portfolio page title
- This topic has 8 replies, 2 voices, and was last updated 10 years, 12 months ago by Brad Dalton.
-
AuthorPosts
-
April 27, 2013 at 5:04 am #38032Susan NelsonParticipant
I'm using Executive 2.0 and I would love to add the page title of "Portfolio" to the top of the portfolio archive page. As you can see, the demo does not include the page title.
Here's what's included in archive-portfolio.php:
<?php /** * The custom portfolio post type archive template */ /** Force full width content layout */ add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); /** Remove the breadcrumb navigation */ remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); /** Remove the post info function */ remove_action( 'genesis_before_post_title', 'genesis_post_info' ); /** Remove the post content */ remove_action( 'genesis_post_content', 'genesis_do_post_content' ); /** Remove the post image */ remove_action( 'genesis_post_content', 'genesis_do_post_image' ); /** Add the featured image after post title */ add_action( 'genesis_post_title', 'executive_portfolio_grid' ); function executive_portfolio_grid() { if ( has_post_thumbnail() ){ echo '<div class="portfolio-featured-image">'; echo '<a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">'; echo get_the_post_thumbnail($thumbnail->ID, 'portfolio' ); echo '</a>'; echo '</div>'; } } /** Remove the post meta function */ remove_action( 'genesis_after_post_content', 'genesis_post_meta' ); genesis();
I've fiddled around with this code, but nothing I've tried works. Help? Thanks!
April 27, 2013 at 5:46 am #38034Brad DaltonParticipantHello Susan.
Please link to the exact portfolio page in question and i will provide the custom function.
I need to grab the page i.d
It will be something like this and there's different ways to do this also.
Code not displaying? Grab it on Github.
April 27, 2013 at 6:20 am #38043Susan NelsonParticipantHi Brad,
I can't provide a link just yet, so would it be possible for you to use the demo as an example? And there isn't a page id since this is a custom post type. There's no Portfolio page in the admin.
Here are the body classes for the archive:
<body class="archive post-type-archive post-type-archive-portfolio logged-in custom-header header-image header-full-width full-width-content">
April 27, 2013 at 6:25 am #38047Brad DaltonParticipantI'll need to test which conditional works with the post-type-archive-portfolio so thats the solution you can try and then add the code in the conditional above if you like.
if( is_page_template('archive-portfolio.php') )
This should work according to the Codex but it doesn't. http://codex.wordpress.org/Conditional_Tags#Is_a_Page_Template
April 27, 2013 at 6:42 am #38052Brad DaltonParticipantGot it Susan. The Codex is a little bit off.
And i also updated the first code snippet above which also works but this one is probably better.
Code not displaying? Grab it on Github.
April 27, 2013 at 6:59 am #38054Brad DaltonParticipantWhooops! Looks like its close but not quite the archive. Let me work on this for awhile.
April 27, 2013 at 8:39 am #38067Brad DaltonParticipantActually the conditional tag is correct but the hook needs to be changed to genesis_after_header otherwise the titles will be added to all portfolio items rather than just the portfolio archives page.
I have updated the code above and suggest you use the first snippet for a single portfolio.
April 27, 2013 at 9:13 am #38072Susan NelsonParticipantBrad, I cannot thank you enough for your generosity! This works perfectly with a little CSS help:
function add_portfolio_page_title() { if ( is_post_type_archive( 'portfolio' ) ) echo '<h1 class="entry-title">Portfolio</h1>'; }; add_action('genesis_before_content', 'add_portfolio_page_title');
I changed the hook to genesis_before_content and it's just perfect.
Thanks so much!
SusanApril 27, 2013 at 9:19 am #38073Brad DaltonParticipantNo worries Susan.
I added the styling in the code and updated it.
Couldn't use the genesis_post_title hook for some reason.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.