• 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

How to add image source into post meta

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 › How to add image source into post meta

This topic is: not a support question

Tagged: shortcode

  • This topic has 1 reply, 2 voices, and was last updated 13 years, 1 month ago by cehwitham.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • April 10, 2013 at 10:47 am #34572
    Santel
    Participant

    Hello everyone,

    I believe most of us at least use one image in the blog post. I usually go to search for creative commune licensed photo on the Flickr. Previously I insert a link manually back to image source inside the image caption.

    Now I want to add image source directly inside the post meta. Here are the step by step guide if you want to do the same thing:

    1. Add a custom field from the blog post, I named it "image_source", then put the url of the image source

    2. Create a short code to get the custom field as below:

    add_shortcode( 'image_source', 'genesis_image_source_shortcode' );
    /**
     * Add source code for image source.
     */
    function genesis_image_source_shortcode( ) {
        $image_source = genesis_get_custom_field( 'image_source' );
    
        if ( ! $image_source )
            return;
    
        $output = sprintf( '<span class="image_source">Credit: <a href="' . genesis_get_custom_field( 'image_source' ) .'" target="_blank" rel="nofollow">Image Source</a></span>');
    
        return apply_filters( 'genesis_image_source_shortcode', $output );
    }
    

    3. Add shortcode to the meta

    add_filter( 'genesis_post_meta', 'post_meta_filter' );
    /**
     * Customize the post meta function.
     */
    function post_meta_filter( $post_meta ) {
        if ( ! is_page() )
            $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "][image_source] ';
    
        return $post_meta;
    }
    

    I am very new to php but this work for me. Hopefully you will find it useful.


    Blogging Tips – KhmerBird.com

    April 28, 2013 at 3:33 pm #38269
    cehwitham
    Participant

    Thanks for sharing this useful tip.


    Twitter: cehwitham Web: cehwitham.com

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 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