• 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

Adding custom text in single post entry 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 › Adding custom text in single post entry meta

This topic is: resolved

Tagged: .post-info, entry-meta, monochrome pro

  • This topic has 8 replies, 2 voices, and was last updated 5 years, 2 months ago by danielleB.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • March 13, 2018 at 8:53 am #217844
    danielleB
    Participant

    I'm creating a "press review" blog page to publish titles/summary from various articles on our services that appeared in news publications. My typical post entry meta includes the publication date and author (FPAdmin).

    POST TITLE

    PUBLISHED ON 2017-10-03 | FPAdmin
    --

    Instead of FPAdmin, I'd like to include the name of the originating publication in the entry meta location next to the post-date, which means that each single post would output custom text in that area.

    POST TITLE

    PUBLISHED ON 2017-10-03 | New York Times
    --

    Can anyone think of an easy way of doing this, if this is possible at all?

    Many thanks,


    Danielle

    http://www.fibrepontiac.ca
    March 13, 2018 at 1:21 pm #217851
    danielleB
    Participant

    I found this useful primer online, but it simply doesn't work for me. I'm using monochrome.pro. I tried the code in both the functions.php file and the single.php, but it returns an error.

    I need to learn PHP.

    🙁


    Danielle

    March 13, 2018 at 10:28 pm #217868
    Brad Dalton
    Participant

    Filter the default post info and add it in there or create your own custom shortcode


    Tutorials for StudioPress Themes & WooCommerce.

    March 13, 2018 at 10:34 pm #217869
    Brad Dalton
    Participant

    Something like this should get you started https://gist.github.com/braddalton/9bb2f4d76c99e4b5faae54b32d3c5625


    Tutorials for StudioPress Themes & WooCommerce.

    March 19, 2018 at 9:50 am #218101
    danielleB
    Participant

    Thank you for this braddalton. I spent a lot of time trying it with the shortcode generator (great tool, by the way!) I'm learning a lot from the example you provided, but I can't quite get it to do what I need it to do.

    Ideally, I'd like to add a shortcode at the beginning of the post: e.g., [publisher name="..."] that would return the appropriate credits in the entry meta. I would then use the Genesis 'quick edits' tool to add the shortcode to my posts. Using your example as a starting point, I tried to do this, but I can't get it to return variable content.

    What am I missing?

    Many thanks in advance for your help.


    Danielle

    March 19, 2018 at 9:53 am #218102
    Brad Dalton
    Participant

    How are you adding the content?


    Tutorials for StudioPress Themes & WooCommerce.

    March 19, 2018 at 10:54 am #218104
    danielleB
    Participant

    I added it to the theme's functions.php file, near the end, before the:

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

    This is what the code looks like:

    // Add Shortcode
    function publisher_shortcode() {

    return '<span class="custom-entry-meta" itemprop="name"> | MRC Pontiac</span>';

    }
    add_shortcode( 'publisher', 'publisher_shortcode' );

    add_filter( 'genesis_post_info', 'sp_post_info_filter' );
    function sp_post_info_filter($post_info) {
    $post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit] [publisher]';
    return $post_info;
    }

    Then, in the body of the post, I added the shortcode as follows: [publisher name="MRC Pontiac"] (MRC Pontiac was the publisher in this case, but not in every case.) This code returns "MRC Pontiac" in the entry.meta as well as the body of the post. What I need it to do, is return a variable entry in the entry.meta location only.

    This is what it looks like:

    Single post

    By the way, I tried replacing MRC Pontiac (publisher name) with an empty ' ' in the code, but that doesn't work.

    Danielle


    Danielle

    March 19, 2018 at 9:01 pm #218117
    Brad Dalton
    Participant

    To add the variable content use a custom field like

    genesis_get_custom_field('key');

    To add the custom field value to the post info, create a custom shortcode or filter the post_info.


    Tutorials for StudioPress Themes & WooCommerce.

    March 20, 2018 at 9:04 am #218133
    danielleB
    Participant

    That worked! Thank you, Brad.


    Danielle

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Adding custom text in single post entry meta’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 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