Category page template

Posted in: Newspaper
Post count: 24

Any help related to category page.
Suppose we have a main category Parent and its sub categories child, test and xyz.

Now when user click on main category page, it mix up with parent and child category post but i want to show it like example below

Category Page :
Main Category Heading
Sub Category1 Heading and post below
Sub Category2 and post below
Sub Category 3 Heading and posts
and so on

Post count: 20688

Hi,

That is the functionality of the category pages, at the moment. When on parent category the page will display posts from it as well as from it’s sub-categories.
There is no sorting available to order the posts like that on initial loading, the only post sorting setting for category pages would be the pull-down filter
https://www.screencast.com/t/lbAwuzywDJX

Thanks

Post count: 24

But it mixup all post of parent and child right now, i need something link below :

http://www.screencast.com/t/h5hwWDEvE8Ud

Post count: 20688

Hi,

Maybe in future updates there will be more options regarding category pages, but for the moment that is how they will be displayed. Sorry if this is an inconvenience for you.

Thanks

Post count: 24

Thanks for your reply

Post count: 24

After exploring a bit I found the code for category page is coming from td_module.php and loop.php

if (have_posts()) {
while ( have_posts() ) : the_post();
echo $td_template_layout->layout_open_element();

if (class_exists($td_module_class)) {
$td_mod = new $td_module_class($post);
echo $td_mod->render();
} else {
td_util::error(__FILE__, ‘Missing module: ‘ . $td_module_class);
}

echo $td_template_layout->layout_close_element();
$td_template_layout->layout_next();
endwhile; //end loop

echo $td_template_layout->close_all_tags();

Can you please provide any help in showing category page by order of subcategories seperately. Example

Category page:
Category Name
Subcategory Name 1- Posts of 1
Subcategory Name 2- Posts of 2
Subcategory Name 3- Posts of 3

And can you please tell where is a query for fetching categories and there posts?

http://qc.round.glass/blossom/category/make-them-eat-eat-n-grow/

Post count: 20688

Hi,

That is a post loop – https://codex.wordpress.org/The_Loop
It is used on category pages and Latest posts sections
https://www.screencast.com/t/XOBhw3hd6g
If you know what you are doing you could make modifications to the loop. There could be online solutions as well.
As I said before, there are plans to add more functionality to the category pages in the future.

Thanks

Post count: 24

when you are planing to release new update?

Post count: 20688

Hi,

I could not give you an exact time span for the theme updates. As soon as the current tasks will be completed it will be available. Note that the plans I mentioned may not be for the next theme update. It is on the list and will be implemented in the future.

Thanks

Post count: 24

lol ok , i know how to do it using loop.php, but is there any way to do it in category module. For example for category page i am using td_module_2.php

++ i just want to do it for parent category pages and not for sub categories. Any help will be really appreciable as i already wasted my hours and default category templates of newspaper look so weird

SubCat1 Post 1 Post 2

SubCat2 Post 1 Post 2

SubCat3 Post 1 Post 2

loop.php

http://www.screencast.com/users/MayankKapahi/folders/Default/media/d09b737c-946a-4ee3-a528-5ad024d64133

` if(is_category()){
$categories = get_the_category();
$catID = $categories[0]->category_parent;
$subcats = get_categories(‘child_of=’ . $catID);
foreach($subcats as $subcat) {
echo ‘<h3>’ . $subcat->cat_name . ‘</h3>’;
echo ‘<ul>’;
$subcat_posts = get_posts(‘cat=’ . $subcat->cat_ID);
foreach($subcat_posts as $subcat_post) {
$postID = $subcat_post->ID;
echo ‘<li>’;
echo ‘<a href=”‘ . get_permalink($postID) . ‘”>’;
echo get_the_title($postID);
echo ‘</a></li>’;
}
echo ‘</ul>’;
}
}`

Post count: 20688

Hi,

Maybe there would be a different solution to this. You could simply create a redirect of for the parent category page URL, to a page that you can build in the composer and filter the way you like with blocks and grids that have these options
http://www.wpbeginner.com/beginners-guide/beginners-guide-to-creating-redirects-in-wordpress/
This could be a solution if you want to have this level of control on particular category pages.

Thanks

Post count: 24

not a right approach to create it manually , i think it is better to modify td_module.php code instead creating redirect for every category page.

if (is_category()) {
$catID = $categories[0]->category_parent;
$subcats = get_categories(‘child_of=’ . $catID);
foreach ($categories as $category) {
if ($category->term_id == get_query_var(‘cat’)) {
$selected_category_obj = $category;
break;
}
}
}

Viewing 12 posts - 1 through 12 (of 12 total)
The forum ‘Newspaper’ is closed to new topics and replies.