I have a blog that has pages that are structured such that I have page content and post content on the same page.
I have set it up so that I have categories for my posts that correspond to the slug for the relative page so that I can display posts for a particular category that shares the same slug as a page name.
So far… so good.
What I’d like to do is have the sidebar content display the following:
top section – pages and children – so far this is working
middle section – most recent 7 or so blog postings for category
bottom section – archives of blog postings for category
Its the middle and bottom section that aren’t working properly.
On the middle section I have been pulling the category id by doing the following
$categories = get_the_category($my_query->ID); $category_ID = $categories->cat_ID;
This is pulling the category ID from the category of the posts on the page. Not such a huge problem unless the post is assigned multiple categories. What I’d really like to do is use the category based on the slug from the page to obtain the category id to use.
I suppose this applies to the archive section as well.
Is this possible?
Thanks in advance!
- The topic ‘Get Blog posts by Category – using page slug’ is closed to new replies.