Category page layout
-
Hi
Apologies if this is answered elsewhere, I can’t find a relevant thread.
I have set a 3 column layout for my blog list. This works perfectly on the main blog page, but when a category is clicked in the blog post the category list is in a single column.
Is there a way to make category list pages obey the same 3 column layout?
I canny link to the page in question because it is not on a live site.
Thanks in advance for your help.
Ian
-
Hi @cihomewood
News & Blog Designer Pack is created with shortcode and widgets. You can add them in your desired page to get the output.
At this stage it does not handle theme category or archive page layout automatically because they are designed according to your theme layout.
But we can modify it via child theme and we can add plugin layout in your theme category or archive page.
Can you please let me know which theme and shortcode (layout) are you using?
Thanks for the quick and helpful response. I am using the Astra theme and the following shortcode:
[bdp_post grid=”3″ show_tags=”false” show_comments=”false” media_size=”medium” limit=”15″]
I already have a child theme active.
Ian
Hi @cihomewood
That’s great that you are using child theme so it will be easy for you. Please take a look at the below code.
<?php $category = get_queried_object(); $category_id = $category->term_id; echo do_shortcode('[bdp_post design="design-1" grid="3" category=".'$category_id'."]');You can replace this code with while loop under archive/category.php. You can use any shortcode and it’s parameter in this file only dynamic variable category=”.’$category_id’.” will be there.
Note : To change the file you should have some knowledge of coding. Any mistake in this file can cause the error.
Hi @cihomewood
Any update on this please? Does it work for you?
Hi
Sorry for the delay in replying, I have been away from my computer.
Can you confirm that this code will work automatically for any category, I don’t need to explicitly state the category. I think that is the case but would like to confirm before I edit the php file.
Many thanks.
Ian
Hi
I didn’t check it yet as I was waiting for your reply. Thanks for confirming, I will try out the solution this week and let you know whether I am able to get it working.
Thanks
Ian
Hi
Sorry this is taking so long, I’m not getting much time to look at the issue at the moment.
I have searched for a category.php file and cannot find one in the theme, only in various plugins. I think I will just have to put up with a single column.
If you have any more ideas I would appreciate hearing them, but thanks for your help so far.
Ian
Hi
I have checked several different themes and they all behave the same way, showing the category related posts in single column format. I still can’t find a category.php file to edit, can you offer any more information?
Thanks
Ian
Hi @cihomewood
Thanks for your response.
Just want to double confirm that you are using Astra theme as per your previous response. right?
Is it a lite version? So I can take a look at the theme structure and provide you better support.
Hi
Yes the theme being used is Astra and it is not a lite version. It is reporting version 3.6.2.
Regards
Ian
Hi @cihomewood
Thanks for the info. Let me take a look. I will update you about it.
Hello @cihomewood
Please navigate to
wp-content/themes/Astrafile structure and open archive.php file: http://prntscr.com/19poebzNow you need to place the code like this:
<main id="main" class="site-main"> <div class="ast-row"> <div style="margin: 0;padding: 5.34em 6.67em; background:#fff;"> <?php $category = get_queried_object(); $category_id = $category->term_id; echo do_shortcode('[bdp_post design="design-1" grid="2" category="'.$category_id.'"]'); ?> </div> </div> </main>Please place this code after
<?php astra_archive_header(); ?>and before<?php astra_primary_content_bottom(); ?>and here is screenshot of it http://prntscr.com/19powtiI hope this will work for you. You can change the shortcode as per your need.
Note : You can create the child theme, copy the archive.php file in that and change the code as suggested. So you can easily update your parent main theme without any issue.
Thank you. I am away at the moment so won’t be able to try this for a few days but will respond as soon as I can.
Ian
Hi
I have just tried that and am getting an error, code I have is:
<div id="primary" <?php astra_primary_class(); ?>> <?php astra_primary_content_top(); ?> <?php astra_archive_header(); ?> <main id="main" class="site-main"> <div class="ast-row"> <div style="margin: 0;padding: 5.34em 6.67em; background:#fff;"> <?php $category = get_queried_object(); $category_id = $category-term_id; echo do_shortcode('[bdp_post design="design-1" grid="2" category="'.$category_id.'"]'); ?> </div> </div> </main> 'Error is:
Warning: Use of undefined constant term_id – assumed ‘term_id’ (this will throw an Error in a future version of PHP) in /homepages/43/d870750008/htdocs/app870755497/wp-content/themes/Child-01/archive.php on line 33
Warning: A non-numeric value encountered in /homepages/43/d870750008/htdocs/app870755497/wp-content/themes/Child-01/archive.php on line 33
I can’t work out what I have done wrong.
Ian
The topic ‘Category page layout’ is closed to new replies.