0

I have a custom Post Type and I am running a regular WordPress loop in single-move.php page to display the textual content of the page only. now while the post has an image gallery I am getting the Gallery Shortcode in the page like [gallery ids="16,14,15"]

[gallery ids="16,14,15"] In a world obsessed with slim and ......

Here is my code

if ( have_posts() ) {
    while ( have_posts() ) {
        $meta = get_post_custom($post->ID);
        the_post(); 
        echo '<section class="title-section">';
          echo '<div class="container text-center">';
          echo '<span class="icon-vlogo title-logo"></span>';
              echo '</div>';
          echo '<h3 class="text-center page-title">'. get_the_title().'</h3>';
       echo '<div class="container"><div class="hr"></div> </div>';
      echo '</section>';

    echo '<div class="container" style="padding:12px; ">';

    echo '<p class="p-paragraph" style="text-align:left">'. get_the_content().'</p>'; 

    echo '</div>';

        if ( get_post_gallery() ) {
                      echo '<div class="row" style="padding-top:60px; padding-bottom:60px;">';
     echo '<section class="title-section">';
          echo '<div class="container text-center">';
          echo '<span class="icon-vlogo title-logo"></span>';
              echo '</div>';
          echo '<h3 class="text-center page-title"> Check out Our Job</h3>';
       echo '<div class="container"><div class="hr"></div> </div>';
      echo '</section>';
        echo '</div>'; 
        echo '<div class="container">'; 
             echo '<div class="col-xs-12 xol-sm-12 col-md-offset-2 col-md-8">';
            ?>
            <div id="carousel-example-generic" class="carousel slide post-carousel" data-ride="carousel">


  <div class="carousel-inner" role="listbox">
       <?php 
         add_filter( 'shortcode_atts_gallery','wp_full_size_gallery' );
         $gallery = get_post_gallery( get_the_ID(), false );
        remove_filter( 'shortcode_atts_gallery','wp_full_size_gallery' );
          foreach( $gallery['src'] AS $src ) {
              echo '<div class="item">';
              echo '<img src="'.$src .'" alt="Vancouver Best Laser Center" />';
    echo '</div>';


          }
             }
           ?>
  </div>

can you please let me know why this is happening and how I can fix it to not see the array in the page

2

All filters applied to the 'the_content' hook (including shortcode rendering) are not applied when you call get_the_content().

This is why you get raw shortcode from your content.

You could use the_content() instead, or use apply_filters directly in your template.

In other words, replace this line:

echo '<p class="p-paragraph" style="text-align:left">'. get_the_content().'</p>'; 

with either (preferred method):

echo '<p class="p-paragraph" style="text-align:left">';
the_content();
echo '</p>'; 

or alternatively:

echo '<p class="p-paragraph" style="text-align:left">' . apply_filters( 'the_content', get_the_content() ) . '</p>'; 

To learn more about these functions, you may look at the documentation and source code at the_content(), get_the_content() and 'the_content' hook

  • Thanks for reply Iceable, I am geeing the images on the page like a wordPress native galley but I just need to get their URL – Behseini Aug 3 '18 at 4:02
  • Then you could de-register the shortcode and re-register it for this template only so with a dummy callback so it doesn't display anything. Does that sound like what you need? – Iceable Aug 3 '18 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.