Executive Theme – Add page title to Portfolio archive

Community Forums Forums Design Tips and Tricks Executive Theme – Add page title to Portfolio archive

This topic is: resolved

This topic contains 8 replies, has 2 voices, and was last updated by  braddalton 1 year, 4 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #38032

    Susan Nelson
    Participant
    Post count: 207

    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]
    <?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();
    [/php]

    I’ve fiddled around with this code, but nothing I’ve tried works. Help? Thanks!


    Susan Nelson | Oh, Hello Designs | Twitter | Facebook

    #38034

    braddalton
    Participant
    Post count: 9782

    Hello 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.


    #38043

    Susan Nelson
    Participant
    Post count: 207

    Hi 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:

    [html]
    <body class="archive post-type-archive post-type-archive-portfolio logged-in custom-header header-image header-full-width full-width-content">
    [/html]


    Susan Nelson | Oh, Hello Designs | Twitter | Facebook

    #38047

    braddalton
    Participant
    Post count: 9782

    I’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.
    [php]
    if( is_page_template(‘archive-portfolio.php’) )
    [/php]
    This should work according to the Codex but it doesn’t. http://codex.wordpress.org/Conditional_Tags#Is_a_Page_Template


    #38052

    braddalton
    Participant
    Post count: 9782

    Got 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.


    #38054

    braddalton
    Participant
    Post count: 9782

    Whooops! Looks like its close but not quite the archive. Let me work on this for awhile.


    #38067

    braddalton
    Participant
    Post count: 9782

    Actually 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.


    #38072

    Susan Nelson
    Participant
    Post count: 207

    Brad, I cannot thank you enough for your generosity! This works perfectly with a little CSS help:

    [php]
    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’);
    [/php]

    I changed the hook to genesis_before_content and it’s just perfect.

    Thanks so much!
    Susan


    Susan Nelson | Oh, Hello Designs | Twitter | Facebook

    #38073

    braddalton
    Participant
    Post count: 9782

    No worries Susan.

    I added the styling in the code and updated it.

    Couldn’t use the genesis_post_title hook for some reason.


Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.