• First off, I’m a bit of a WP noob, but my PHP and CSS skills are pretty good. I have done some googling for this issue but no luck finding exactly what I’m looking for.

    I have a site set up with WordPress acting as a CMS for the majority of the content. My issue is that I have a custom post category consisting of 10-15 posts, all of which I want to display on a page (using a page template) as a navigation. I will be using a thumbnail image and a title from the post for this nav. When clicked, I would like to display the full contents of that single post, but also retain the navigation.

    I have created a loop that queries the post category and populates a navigation, but I am having trouble with creating the body of this page (which again, is made up of one single post of the same category). I have tried passing the post id from the navigation to a second loop, which would query the database for only the post with that id, but it’s not working.

    Am I making this too complicated? Perhaps there is an easier way to achieve this? I am developing this locally, so I cannot yet post a link, but I would very much appreciate some wisdom here. Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi:

    There are a few ways that you could create the functionality you desire.

    1) create a page template that outputs the navigation as desired based on the post category. Then when an option is clicked do an AJAX call (passing the post id) to a custom feed you create that will return the post content that you can then display on the same page.

    2) create the page template that outputs the navigation as desired. Then modify your single.php file such that if the post is of the category that should have the navigation you query WordPress for all posts of the category and display the navigation.

    There are of course other ways to do this but I think the above is the most straight forward methods.

    Thread Starter badbrains

    (@badbrains)

    Thanks for the reply! I think I am going to try your second suggestion for this page. In my single.php file, would I add the navigation as a include, or would I just repeat the same query that I used in my page template?

    *edit*
    as I am trying this, I have inserted the query for the navigation into my single.php file, and it works. But I am now getting all of the posts, instead of just the desired single post. Perhaps I am using the wrong methods for my queries. How do I query a category for all posts (to populate the nav) and then do a second query for the single desired post?

    Your first example seems like it would be a good solution for another part of the site I am developing. Are there any good plugins for wordpress that manage asynchronous refreshes?

    Thank you again.

    Thread Starter badbrains

    (@badbrains)

    Just a follow-up in case anyone has this same problem. I used mdbitz’s second option. I edited single.php to display the single post, then created a new query object for the same category that returned all posts for that category to populate the navigation. Works out swell!

    If anyone has a suggestion for plugins to manage AJAX loads, I would appreciate it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘trouble with WP as CMS – query variables’ is closed to new replies.