Not sure how to explain this, so bear with me... I have two different pages (each has its own category name 1) news 2) blog), and both of these pages have three sub-categories for types of posts. These sub-category names are shown on the left side of the page. When someone visits either of the two pages, they see all of the posts from that page's sub-category. If they click on one of the sub-category names on the left, then only that set of posts loads.
Posts are styled through their own php, and so are the pages. I also have index.php which contains the following:
The index.php only lists the category for News (123), so if I visit the Blog (456) page, then it will still list News' sub-category links, so it wouldn't load the correct posts when I click on one sub-category. Is there some way to get this working? I have them set to 123 and 456 in their "template name: " and "template posts: " files, but index.php is giving me issues, since it's just one file.
Basically I'd like to display the sub-category names&links of the currently activate page on the left, and allow the links to take me to their appropriate sub-category posts.
Edit: I tried to replace 123 with $parent, but that shows all of the sub-categories, not just the three for the particular page.
Posts are styled through their own php, and so are the pages. I also have index.php which contains the following:
Code:
<?php
//get terms (e.g. categories or post tags), then display all posts in each retrieved term
$taxonomy = 'category';// e.g. post_tag, category
$param_type = 'category__in'; // e.g. tag__in, category__in
$term_args=array(
'orderby' => 'name',
'order' => 'ASC',
[b]'child_of' => 123[/b]
);
$terms = get_terms($taxonomy,$term_args);
if ($terms) {
foreach( $terms as $term ) {
$args=array(
"$param_type" => array($term->term_id),
'post_type' => 'post',
'post_status' => 'publish',
'showposts' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo '<h1 style="text-decoration:none;padding-bottom:30px;font-weight:normal;"><a href="' . get_category_link( $term->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name. '</a></h1> ';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
endwhile;
}
}
}
wp_reset_query();
?>
The index.php only lists the category for News (123), so if I visit the Blog (456) page, then it will still list News' sub-category links, so it wouldn't load the correct posts when I click on one sub-category. Is there some way to get this working? I have them set to 123 and 456 in their "template name: " and "template posts: " files, but index.php is giving me issues, since it's just one file.
Basically I'd like to display the sub-category names&links of the currently activate page on the left, and allow the links to take me to their appropriate sub-category posts.
Edit: I tried to replace 123 with $parent, but that shows all of the sub-categories, not just the three for the particular page.
Last edited: