Home › Forums › Pro Support › Shortcodes within Post Content
Tagged: Post Content, Shortcodes, WP Show Posts
- This topic has 5 replies, 2 voices, and was last updated 5 years, 2 months ago by
Tom.
-
AuthorPosts
-
June 24, 2018 at 4:17 pm #5013
Janek
ParticipantHi Tom/Leo
Just wondering if theres a way to inject a shortcode into posts?
Not sure if I should post this here or in the Generate Press forum, but at the moment I’m using WP Show Posts Pro in Generatepress to display a feed from CPTs. I’ve used the after entry title hook and the following PHP which relates to the mp3 Jplayer plugin:
<?php mp3j_addscripts(); ?>
<?php mp3j_put( ‘[audio mp3][/audio]‘ ); ?>
The first code enables the second code which basically displays a jplayer of that posts mp3 attachment, however it doesnt appear in the WP show posts and only appears on single post pages. I’m not sure if this is because entry-title only exists on single post pages and not in the posts content section which WP Show Posts displays?
I sent my site login details to Tom via the general support email on
Mon 18 JunSearch under http://janek-dev.flywheelsites.com
If you want to have a look at how this is behaving currently on the site just click through the podcast episode title till you arrive on a single post page and see the mp3 jplayer below the title.Ideally I’d like this shortcode to run so it appears on single post pages and within the WP Show posts feed.
Thanks in advance for your time and help, I know I’m not always asking the easiest questions.
June 24, 2018 at 10:02 pm #5022Tom
KeymasterHi there,
You can try this hook:
add_action( 'wpsp_before_content', 'tu_add_before_wpsp_content' ); function tu_add_before_wpsp_content() { // Add your code in here }
Let me know if that does it 🙂
June 27, 2018 at 4:23 am #5050Janek
ParticipantHey Tom, Thanks for your reply!
I’ve given that code a crack and it works great, I even put a conditional ‘is front_page’ on it which I was proud of. 😛
Just wondering if I can make this target specific instance of WP show posts?
At the moment I have 2 instances/lists on the homepage and one I want the player to show up on and the other I dont?
My code at the moment is:
add_action( 'wpsp_before_content', 'tu_add_before_wpsp_content' ); function tu_add_before_wpsp_content() { if ( is_front_page()) { echo do_shortcode("[audio mp3]"); } }
June 27, 2018 at 8:09 pm #5054Tom
KeymasterYou can check the ID.
For example:
add_action( 'wpsp_before_content', 'tu_add_before_wpsp_content' ); function tu_add_before_wpsp_content( $settings ) { if ( is_front_page() && 123 === $settings['list_id'] ) { echo do_shortcode("[audio mp3]"); } }
In that example, 123 is the ID of the WPSP list.
June 29, 2018 at 3:20 am #5069Janek
ParticipantCheers, that did the trick! Sorry for the late reply, I’m working on this site outside of my day job so I’m finding it hard to keep track of my support threads. Really appreciate all the time you and Leo put in to helping customers.
June 29, 2018 at 8:51 pm #5074Tom
KeymasterGlad I could help! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.