[Resolved] Automatically adding shortcode underneath post title

Home Forums Support [Resolved] Automatically adding shortcode underneath post title

Home Forums Support Automatically adding shortcode underneath post title

  • This topic has 8 replies, 4 voices, and was last updated 7 years ago by Tom.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #375936
    Mike

    Hello,

    Is it possible to automatically add a shortcode just underneath my posts titles? So whenever I create a blog post it automatically adds another line underneath the title which contains a shortcode?

    Thanks,
    Mike

    #376141
    Leo
    Staff
    Customer Support

    Hi Mike,

    You can use the After Entry Title hook:
    http://demo.generatepress.com/hook-locations/
    https://docs.generatepress.com/article/hooks-overview/

    With conditional tag like this so it only shows up on single posts:

    <?php if ( is_single() ) { ?>
        Content in all single post pages
    <?php } ?>

    Make sure execute PHP is checked.

    #376273
    Mike

    Hello,

    Thanks for the response! Is there any way I can make this appear above the date and autor info?

    Thanks,
    Mike

    #376321
    Mike

    Hello,

    I already managed to achive this with a bit of playing about. This is what I came up with,

    <?php if ( in_category(‘news’) ) { ?>
    <?php if ( is_single() ) { ?>
    <h2>[wpbitly]</h2>

    <?php } ?>
    <?php } ?>

    I also added an extra line of code to check the category first. I then simply had to disable the other byline elements in the customizer and voila!

    Thanks!

    #376342
    Leo
    Staff
    Customer Support

    Glad you found the solution! Thanks for sharing ๐Ÿ™‚

    #390840
    Joseph

    I have several Categories and want to title the single posts with a title belonging to the category the post is under.
    I used this condition and it works fine the main post page. ‘latest-publications’ is the category.

    <?php if ( is_category (‘latest-publications’) ) : ?>
    Content in all single post pages
    <?php } ?>

    I am having trouble making this condition work for all of the single posts in the ‘latest-publication’ posts.

    <?php if ( is_single() ) { ?>
    Content in all single post pages
    <?php } ?>

    Any help is appreciated.

    #390844
    Tom
    Lead Developer
    Lead Developer

    Try:

    <?php if ( is_single() && in_category( 'latest-publications' ) ) { ?>
    
    <?php } ?>
    #390856
    Joseph

    Tom, I bow down to you. That did the trick.

    Thank you so much!!

    #391023
    Tom
    Lead Developer
    Lead Developer

    You’re welcome! ๐Ÿ™‚

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