[Support request] Dynamic Text List Of Terms showing only one term

Home Forums Support [Support request] Dynamic Text List Of Terms showing only one term

Home Forums Support Dynamic Text List Of Terms showing only one term

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2431553
    Tim Taricco

    I’m using the Dynamic Text List Of Terms in a Page Hero element type, and only one of the two terms of the taxonomy shows, although there are posts in both categories. This page https://dev4.mywebsiteserver.com/portfolio/ (PW: alittleaccent) shows the problem where only the “Commercial” category (https://dev4.mywebsiteserver.com/project-type/commercial/) is showing when there are posts in the “Residential” category (https://dev4.mywebsiteserver.com/project-type/residential/) too.

    #2432088
    Fernando
    Customer Support

    Hi Tim,

    To clarify, are you opting to show all “Portfolio Types” on your Portfolio Archive page?

    If so, using a GB Headline wouldn’t work. It’s only meant to be used for single posts, or individual posts in the Blog/Archive pages.

    You’ll need custom code to achieve this. Try adding this PHP snippet:

    add_shortcode( 'insert_portfolio_types', function() {
        ob_start();
        // Start your PHP below
      
       $cterms = get_terms( array( 
        'taxonomy' => 'portfolio_type'
     ) );
    // var_dump($cterms);
    if($cterms){
    	echo '<div class="custom-terms"><ul>';
    	foreach( $cterms as $cterm ) {
     		echo '<li class="custom-term"><a href="' . get_term_link( $cterm ) . '">' . $cterm->name . '</li>';
    	}
    	echo '</ul></div>';
    }
    
      
        // End your PHP above
        return ob_get_clean();
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    This should give you a Shortcode – [insert_portfolio_types] that insert your Portfolio types. You can now add this Shortcode through a WordPress Shortcode Block.

    We’ll need custom CSS to fix how it looks afterward.

    #2433560
    Tim Taricco

    Thank you, Fernando, that solution works. You likely see my logic in thinking that the dynamic content in the Headline block should work. That should be a future update.

    #2437998
    Fernando
    Customer Support

    You’re welcome Tim!

    As for having such functionality in a future update, you may raise a feature request here: https://community.generateblocks.com/c/feature-requests/6

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.