• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Filter post format in loop and link the title to an external site.

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Filter post format in loop and link the title to an external site.

This topic is: not resolved

Tagged: filter loop, link, post format

  • This topic has 3 replies, 2 voices, and was last updated 9 years, 8 months ago by AJD.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • June 7, 2016 at 4:49 pm #187124
    AJD
    Member

    I am creating a section of the blog for "link" post formats.

    I have enabled post format link and image and created custom fields for the link and a short description. I would like to filter the post loop so that the title of the post is linked to the external site and then the description is just below.

    Here is the general idea, but my coding is not great:

    $linkUrl = get_field('link_to_external_site_or_video');
    
    $linkDescription =get_field('link_description');
    
    if (is_post_format('link')){
    	
    		// filter the loop...
    		
    		echo '<a href="$linkUrl">' . the_title() . '</a>' ;
    		echo $linkDescription;
    }

    Does anyone have tips on how to achieve this?

    Thanks

    June 7, 2016 at 6:03 pm #187128
    Victor Font
    Moderator

    You almost had it. $linkUrl is a variable that needs to be concatenated into the line:

    echo '<a href="'. $linkUrl . '">' . the_title() . '</a>' ;


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    June 7, 2016 at 8:09 pm #187132
    AJD
    Member

    Thanks!
    The other thing that I haven't figured out is where or how to apply that snippet to filter the output of the loop.

    I think it may need two filters:

    genesis_post_title_output, or genesis_post_title_text

    This one to set the new link on the title.

    and

    genesis_custom_loop_args

    June 7, 2016 at 8:28 pm #187136
    AJD
    Member

    EDITED: Added working icon using font awesome.

    I figured out how to filter the title and add my custom link, however now because I am using genesis post format images, the link image still has the old link... need to figure out how to filter it.
    There were a couple other errors: is_post_format() should be has_post_format().

    Then I needed to hook the filter into the genesis_header action.

    
    //* Add post format images - Instead of using post format images, added font-awesome icon in the title. 
    //add_theme_support( 'genesis-post-format-images' );
    
    //Filter the Link Post Title to add the custom link
    
    function link_post_format_title_filter() {
    	
    	if (has_post_format('link')){
    		
    		function aamet_post_title_output( $title ) {
    			
    				$title = '
    <h1 class="entry-title"><i class="fa fa-external-link" aria-hidden="true"></i><a href="' . get_field('link_to_external_site_or_video') .'"  target="_blank" title=" ' . get_the_title() .'"> ' . get_the_title() . '</a></h1>';
    		
    			return $title;
    			
    		}
    		add_filter( 'genesis_post_title_output', 'aamet_post_title_output', 15 );
    	}
    }
    add_action('genesis_header', 'link_post_format_title_filter');
  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble