Community Forums › Forums › Archived Forums › Design Tips and Tricks › Override default archive template
Tagged: WPAverts
- This topic has 4 replies, 3 voices, and was last updated 6 years, 11 months ago by photoaddictsa.
-
AuthorPosts
-
May 31, 2017 at 1:57 am #207196photoaddictsaMember
I have no idea if that title was correct but let me explain, this might get lengthy so please bare with me.
I'm using the plugin WPAdverts, I've been having one particular issue I can't solve, the category pages do not display the ads in that category, see here: http://inthebunch.co.za/classifieds/road/
After chatting to the plugin developer he came to the following conclusion;
Hi, it looks like your theme is not 100% compatible with WPAdverts you will need to create a taxoonomy-advert_category.php file for your theme as explained here https://wpadverts.com/documentation/child-themes-and-templates/ in part Custom Taxonomy Template
According to the instructions, I should create "taxoonomy-advert_category.php" and copy over the content of archive.php and then replace
while(have_posts()) ... endwhile;
with the following;<?php global $wp_query; remove_filter("the_content", "adverts_the_content"); echo shortcode_adverts_list(array( "category" => $wp_query->get_queried_object_id() )); ?>
I'm a bit new with this one, Genesis advises against editing framework files directly but rather in child theme, my question is how would I go about following his suggestion without having to copy over the archive.php content?
May 31, 2017 at 6:26 am #207211Victor FontModeratorThis is the purpose of child themes. You create the new template and place it in your child theme directory. This overrides anything in the framework if done correctly. You may want to take the time to learn more about the WordPress template hierarchy: https://developer.wordpress.org/themes/basics/template-hierarchy/
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?May 31, 2017 at 7:19 am #207215photoaddictsaMemberHi Victor,
The hierarchy thing I get, it's the "if done correctly" bit I was battling with.
I had to call the header and footer for the code to end up working.
<?php /** * Template Name: Custom classifieds Archive * * */ get_header(); ?> <?php global $wp_query; remove_filter("the_content", "adverts_the_content"); echo shortcode_adverts_list(array( "category" => $wp_query->get_queried_object_id() )); ?> <?php get_footer(); ?>
May 31, 2017 at 8:02 am #207218Brad DaltonParticipantYou could hook it in using a custom function
add_action( 'your_hook', 'your_function' ); function your_function() { global $wp_query; remove_filter( 'the_content', 'adverts_the_content' ); echo shortcode_adverts_list(array('category' => $wp_query->get_queried_object_id() )); }
Swap out your_hook in the above code with the genesis hook you want to use.
May 31, 2017 at 8:04 am #207219photoaddictsaMemberNever even thought of that one, thanks Brad.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.