0

I have 3 post, post1=text, post2=text and gallery1, post3, text and galery2

I like to list ALL the post from one category, and the result is all the data get out, but the gallery associated with the post is ALL THE SAME. yep the second post and post#3 have the same picture...

the problem, the shortcode of gallery is associated with post, but with all the post display in a single page, the gallery are not specific

what i have done wrong ?

some code :

//Add a ShorCode to get a page/post content
add_shortcode ('page','get_page_content');
   function get_page_content ($att) {
       if (is_array($att)) { $req_id = $att['id']; }
       else { $req_id = $att; }
       $post = get_page($req_id); 
       $content = apply_filters('the_content', $post->post_content);
       return $content;
   } 

1 Answer 1

0

Hourray : find it : do_shortcode do the trick !

here is the final code :

// --------------------------------------------------------------------------------------------------------------------
//Add a ShorCode to get a page/post content
add_shortcode ('post_cat3','get_post_cat3');
   function get_post_cat3 ($att) {

       $query = new WP_Query( 'cat=36' );
       if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();

        $aaa .= '<p>------------</p>'.do_shortcode(get_the_content());

        endwhile; 
        endif; 
        return do_shortcode($aaa);
   } 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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