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 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">
        <ul>
        <?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(); 
        ?>

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

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

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

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.

Thanks

Appreciate your help.

Rajiv

share|improve this question
add comment

1 Answer

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
add comment

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.