WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 created CPT ( Custom Post Type ) called Recipes.

I want to display all me recipe in Vertical Tabs.

For Example; check the image below i have created. Image Example Click Here

On the left hand side as in image i want to display Post title of CPT Recipes & on right hand side i want to display the content of that recipe.

How can i do that in Wordpress ? Anyone please help.

I have tried many tutorials, but all in vain.

This is code which i am trying now. close but not perfect.

     <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
     <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>

    <div id="tabs">
        <?php //WordPress loop for custom post type
             $my_query = new WP_Query('post_type=training_courses');
                 while ($my_query->have_posts()) : $my_query->the_post(); 

                <a href="#<?php the_ID(); ?> "><?php the_title(); ?></br>
                <?php endwhile; ?>

               <div class="side-tc">    
                   <div id="<?php the_ID(); ?> ">
                       <?php the_title(); ?></br>
                   <?php wp_reset_query();?>

<script type="text/javascript">
    .addClass('ui-tabs-vertical ui-helper-clearfix');

But On Right Side ( Content ), it show all the recipes content. Not the one selected.

Please help me fix this or if you can suggest me to any tutorial.


Appreciate your help.


share|improve this question

You should run WP Query twice. Once for the li elements and the other for the div elements. You do not seem to be doing this? If you want to use jQuery tabs or accordion you may have to run the wp query twice or save the query results in an array and use a for/while loop. The later is better as it has less impact on the database.

share|improve this answer
No need to query twice. You can loop thru the result as many times as you like. Once to build an array of titles only (for the list elements and once for the contents on the side. – jdm2112 Nov 5 '15 at 15:48

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.