SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Sploghm bronze trophy Victorinox's Avatar
    Join Date
    Nov 2008
    Posts
    749
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Parse shortcode in post called in a template? [Wordpress]

    I'm inserting a specific post in a template using the following:

    Code PHP:
    $post_id = 99;
    $queried_post = get_post($post_id);
    echo wpautop($queried_post->post_content);
    Is it possible to also parse a shortcode that's in the post, without having to hard code it in the template?

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,222
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Victorinox View Post
    I'm inserting a specific post in a template using the following:

    Code PHP:
    $post_id = 99;
    $queried_post = get_post($post_id);
    echo wpautop($queried_post->post_content);
    Is it possible to also parse a shortcode that's in the post, without having to hard code it in the template?
    I think you want to use do_shortcode

    PHP Code:
    $post_id 99;
    $queried_post get_post($post_id);
    echo 
    wpautop(do_shortcode($queried_post->post_content)); 

  3. #3
    Sploghm bronze trophy Victorinox's Avatar
    Join Date
    Nov 2008
    Posts
    749
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Beautiful! Thanks very much.

    I'm new to tweaking Wordpress, so will probably have some more Qs.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •