Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

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

Your Answer

 
discard

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.