WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;
share|improve this question
up vote 0 down vote accepted

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());

        return do_shortcode($aaa);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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