- This topic has 8 replies, 4 voices, and was last updated 8 years, 6 months ago by
Tom.
-
AuthorPosts
-
August 30, 2017 at 4:35 am #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,
MikeAugust 30, 2017 at 9:19 am #376141Leo
StaffCustomer SupportHi 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.
August 30, 2017 at 11:55 am #376273Mike
Hello,
Thanks for the response! Is there any way I can make this appear above the date and autor info?
Thanks,
MikeAugust 30, 2017 at 12:51 pm #376321Mike
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><p><?php the_time(‘jS F Y’); ?> by <?php the_author_posts_link(); ?></p><?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!
August 30, 2017 at 1:49 pm #376342Leo
StaffCustomer SupportGlad you found the solution! Thanks for sharing 🙂
September 23, 2017 at 10:46 pm #390840Joseph
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.
September 23, 2017 at 10:56 pm #390844Tom
Lead DeveloperLead DeveloperTry:
<?php if ( is_single() && in_category( 'latest-publications' ) ) { ?> <?php } ?>September 23, 2017 at 11:51 pm #390856Joseph
Tom, I bow down to you. That did the trick.
Thank you so much!!
September 24, 2017 at 8:39 am #391023Tom
Lead DeveloperLead DeveloperYou’re welcome! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.