• Resolved Jenxi Seow

    (@jenxi)


    The widget allows the portfolio types to be displayed. How can I achieve this in the portfolio archive as well?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor Nick C

    (@modernnerd)

    Hi, @jenxi!

    You could add this PHP code to the bottom of your active theme’s functions.php file to output the types on the archive too:

    add_action( 'genesis_before_while', 'sp_amend_portfolio_archive' );
    /**
     * Add the portfolio post type links under the portfolio title.
     */
    function sp_amend_portfolio_archive() {
    	if ( is_post_type_archive( 'portfolio' ) ) {
    		add_action( 'genesis_entry_footer', 'sp_add_type_to_portfolio' );
    	}
    }
    
    /**
     * Output portfolio post type links.
     */
    function sp_add_type_to_portfolio() {
    	$terms = get_the_term_list( get_the_ID(), 'portfolio-type' );
    
    	if ( ! $terms ) {
    		return;
    	}
    
    	genesis_markup(
    		array(
    			'open' => '<p %s>',
    			'close' => '</p>',
    			'context' => 'entry-meta',
    			'content' => genesis_strip_p_tags( do_shortcode( "[post_terms taxonomy='portfolio-type' before='']" ) ),
    		)
    	);
    }
    Thread Starter Jenxi Seow

    (@jenxi)

    Hey Nick! Thanks! This works but it places the tags below the title. How can I achieve the same look as the widget?

    Plugin Contributor Nick C

    (@modernnerd)

    @jenxi

    You can show the tags above the title (but below the image, more like the widget) by changing this line from the above code:

    
    add_action( 'genesis_entry_footer', 'sp_add_type_to_portfolio' );
    

    To look like this:

    
    add_action( 'genesis_entry_content', 'sp_add_type_to_portfolio' );
    

    Or show the tags above the image by changing the same line to this:

    
    add_action( 'genesis_entry_content', 'sp_add_type_to_portfolio', 9 );
    
    Thread Starter Jenxi Seow

    (@jenxi)

    Hey Nick,

    I tried that but the tag gets hidden behind the title.

    Plugin Contributor Nick C

    (@modernnerd)

    @jenxi The code is working in my tests. Please could you link to your site so we can help?

    Thread Starter Jenxi Seow

    (@jenxi)

    Hey Nick, it is hidden behind the page title.

    https://rubycoded.com/portfolio/

    Plugin Contributor Nick C

    (@modernnerd)

    Thanks for the link, @jenxi — that’s been a big help!

    To match the homepage widget styling for the Breakthrough Pro theme, you can try this code instead of anything you’ve added already (it’s the same as above except for the first add_action line):

    add_action( 'genesis_before_while', 'sp_amend_portfolio_archive' );
    /**
     * Add the portfolio post type links under the portfolio title.
     */
    function sp_amend_portfolio_archive() {
    	if ( is_post_type_archive( 'portfolio' ) ) {
    		add_action( 'genesis_after_entry_content', 'sp_add_type_to_portfolio', 9 );
    	}
    }
    
    /**
     * Output portfolio post type links.
     */
    function sp_add_type_to_portfolio() {
    	$terms = get_the_term_list( get_the_ID(), 'portfolio-type' );
    
    	if ( ! $terms ) {
    		return;
    	}
    
    	genesis_markup(
    		array(
    			'open' => '<p %s>',
    			'close' => '</p>',
    			'context' => 'entry-meta',
    			'content' => genesis_strip_p_tags( do_shortcode( "[post_terms taxonomy='portfolio-type' before='']" ) ),
    		)
    	);
    }

    You’ll also need to add this to your theme’s style.css or at Appearance → Customize → Additional CSS if you want the terms to appear uppercase on the portfolio archive, like they do on the homepage:

    .genesis-pro-portfolio.post-type-archive .entry-header .entry-meta {
    	text-transform: uppercase;
    }
    
    Thread Starter Jenxi Seow

    (@jenxi)

    Hey Nick,

    That worked! Thanks!

    The new add_action worked. However, the CSS needed some tweaking.

    I had to use this instead:

    .genesis-pro-portfolio .entry-header .entry-meta {
    	text-transform: uppercase;
    }
    Plugin Contributor Nick C

    (@modernnerd)

    Great, thanks for the update, @jenxi!

    Hey @modernnerd, I’m having this same issue but with the Business Pro theme, I’ve tried all of the above but can’t get the portfolio types menu to show up on my archive page. Can you help? Sorry for hijacking thread.

    Plugin Contributor Nick C

    (@modernnerd)

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Show portfolio type in portfolio archive’ is closed to new replies.