We're merging with GenerateBlocks! Learn more here.

[Resolved] Shortcodes within Post Content

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Shortcodes within Post Content

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #5013
    Janek
    Participant

    Hi 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 Jun

    Search 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.

    #5022
    Tom
    Keymaster

    Hi 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 🙂

    #5050
    Janek
    Participant

    Hey 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]");
        }
    }
    #5054
    Tom
    Keymaster

    You 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.

    #5069
    Janek
    Participant

    Cheers, 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.

    #5074
    Tom
    Keymaster

    Glad I could help! 🙂

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