Content Not Displaying Shortcodes (3 posts)

  1. BTDmedia
    Posted 4 years ago #

    I am having trouble displaying shortcodes correctly on my main post content. (Example - You can see all the [soundcloud id='']. I know it's not a problem with the plugin because no shortcodes work.)

    Instead of using:

    <?php the_content(); ?>

    I am currently using:

    <?php echo preg_replace("/\< *[img][^\>]*[.]*\>/i","",get_the_content(),1); ?>

    which hides the first image from each post because my featured image is automatically displayed on top. However, even when I replaced what I'm currently using back with the normal 'php the_content' code it is still not displaying my shortcodes correctly. Is there a way to filter the first image out and include shortcodes via function.php OR some other workaround? I feel like it's something easy I'm overlooking causing this error.

    Thanks in advance!

  2. Michael
    Forum Moderator
    Posted 4 years ago #

    you could try:

    <?php echo apply_filters('the_content', preg_replace("/\< *[img][^\>]*[.]*\>/i","",get_the_content(),1) ); ?>


    <?php echo preg_replace("/\< *[img][^\>]*[.]*\>/i","",apply_filters('the_content',get_the_content()),1); ?>


    <?php echo preg_replace("/\< *[img][^\>]*[.]*\>/i","",do_shortcode(get_the_content()),1); ?>


  3. BTDmedia
    Posted 4 years ago #

    Everyone of them seemed to do the trick.

    Wow, I couldn't thank you enough! I appreciate it!

Topic Closed

This topic has been closed to new replies.

About this Topic