Get Post Parent if run from a template
-
I am using WordPress as a CMS for most of the site, but I still have a blog in 2 sections. I did this by creating a page called “press”, and then set this page to use a “press.php” template that calls query_posts() to pull all posts for a particular category. I have a subnav that shows all the 2nd level pages which is queried by wp_list_pages() showing the post_parent. This works great.
However, I run into problems when I click on a post permalink. The template switches from press.php to index.php and since this is a straight blog post there is no template or page hierarchy. The blog post doesn’t know where it belongs, and so doesn’t know which subnav items to display, etc.
My question is, how can this blog post know that it is part of a Pages hierarchy with parent/child pages.
I have cheated by passing a parentID in the query string, but this doesn’t work when using the_content/read more.
Alternatively, is there a way to keep the permalink detail page at press.php instead of switching to index.php?
My apologies if I haven’t explained this correctly, but I look forward to your response.
- The topic ‘Get Post Parent if run from a template’ is closed to new replies.