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.

Basically I am coding my own theme, and I would like to have my titles listed on the left hand side, so that on clicking the title, the corresponding body opens up on the right. How can I list these two interlinked items separate from each other, but still have the title reference the right post. The problem I'm anticipating is that I might have to construct a different loop for the titles section and the body section each. Once I've done this, I don't see how I can link them together so that the jQuery I use would link the title to the corresponding body.

Much thanks in advance

share|improve this question
    
Need more info. Are you coding a new theme or you are one of those default theme. Surely its not a problem if you know some php and wordpress coding.. –  Sisir May 18 '12 at 8:26
    
It is a new theme I am coding. I have just made the edit to the question. I know PHP and wordpress coding, but the solution to my question still eludes me. –  Seedorf May 18 '12 at 8:46
add comment

1 Answer

up vote 0 down vote accepted

Here is an idea:

  1. Use get_posts() to get posts you want.
  2. On the right hand side show titles via foreach.
  3. use setup_postdata() on right hand side loop to get post content.
  4. You can use jquery tabs to show and hide post content or just use jquery.
  5. Don't do get_posts() twice or use ajax because you already got contents when you did get_posts() on no. 1

How do you relate contents:

So you have content of same posts on two part of the page. How do you relate them to use on jquery. Well, you can use post id off course. Check for same id on the content area if id matches with title show the content.

<h1 id="post_<?php the_ID(); ?>><?php the_title(); ?></h1>
...
...

<div id="post_content_<?php the_ID(); ?>>the_content();</div>
...
...
share|improve this answer
    
Thanks a lot Sisir. This solved my problem nicely –  Seedorf Jul 18 '12 at 18:58
    
Glad it worked! :) –  Sisir Jul 20 '12 at 10:05
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.