Article du fil d'actualités de CreaWeb2B

N'hésitez pas à commenter et partager

Use a DIVI built layout for Category page

by | 15 Jul,2016 | DIVI, Tutorials, WORDPRESS

Would you like to use the DIVI Builder to create a layout for your Categories pages ?

Let’s go to the DIVI Library and let’s add a new MODEL.

ajoutsectiondivi1

You must select “LAYOUT” when creating your new model (otherwise it won’t work well)

modele
You can add anything you want in your layout, but don’t forget that you must insert a blog module targetting only the category you’re working on, if you don’t the posts won’t appear on your archive page (we are going to remove all content but the header, this layout and the footer)

For instance, here is the layout i use for my “Tutoriels” category page (You can’t see this page in english version, but iuf you want a demo for this tutorial, here is a link to the french “Tutoriels” archive page)

section-tuto

— IMPORTANT UPDATE !!! March 14th 2017 —

The following of my post is about adding a given php template for each category you have in your blog.

But Pierre Sudarovich just made things easier than ever by creating an automatic category template, that will get your category model right from divi library.

So i let my code in place for record but i encourage everyone to follow this NEW WAY TO USE A LAYOUT FOR CATEGORY

(Don’t be afraid, the post is in french at the beggining but english translation follows in the second part of his post)

Just download Pierre Sudarovich ‘category.php’ file and name your DIVI library category layout using the category slug.

For instance, if you have a category named cars, just save your divi library layout with the name of “category cars” and you’re done…

Have fun !

— The following is for record purpose , you have no more reason to use that 🙂 —

Let’s have a look at the address bar and note the layout number (url is showing post=XXXX where XXXX is the number you’ll use to call your layout. (here 198)

ajoutsectiondivi13

Next, open your usual text editor and type the following PHP code :

<?php 
get_header();
echo do_shortcode('[et_pb_section global_module="xxxx"][/et_pb_section]');
get_footer(); 
?>

Don’t forget to replace XXXX with your post number.

Save file using the following structure : “category-YOURCATEGORY.php”

So if your category is “automotive” you’ll save “category-automotive.php”

Put this file inside your child theme folder and… Yes it’s a short tuto and everyone that was wondering how to have a nice looking category page should like it.

Feel free to ask if you need further explanation.