wppizza / markup / loop / theme-wrapper.php
Menu items Theme Wrapper Template – to be used in conjunction with Install Option 2
or if you want to use the Navigation widget WP -> Appearance -> Widgets -> WPPizza : Type=Navigation
display menu categories dynamically utilising your theme’s layout/templates
NOTE: although the below would work the same way with your normal/main theme the below assumes you are using a child theme. If you are not using a child theme, now would be a good time to create one to allow you to update your main theme when an update becomes available without loosing any of your changes or additions you make now or in the future. If you do not know how to create a child theme or why to use one, please refer to the wordpress codex here.
HOWTO:
- create the following directory structure in your child theme:
wppizza/markup/loop
so your whole structure will look something like this/[path]/[to]/[my]/[child-theme]/wppizza/markup/loop
- copy your theme’s “page.php” file into the above created directory directory(if your theme does not have a page.php file, look for archive.php or even index.php)
- rename this file to “theme-wrapper.php”, so the structure will now look something like this:
/[path]/[to]/[my]/[child-theme]/wppizza/markup/loop/theme-wrapper.php
- open this “theme-wrapper.php” file in a suitable text editor
- typically you will find something like
while ( have_posts() ) : the_post(); //stuff inside the loop endwhile; // end of the loop.
- REPLACE that whole loop – including the “while ( have_posts() …. etc …. endwhile; ” – with simply
echo $do_wppizza_loop;
and save - the whole file will now be similar to this
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly get_header(); ?> <div id="primary" class="site-content"> <div id="content" role="main"> <?php echo $do_wppizza_loop; ?> </div><!-- #content --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
- alternatively – it depends on your theme – you might find your sidebars and various other things also being included within that loop along the following lines:
<?php while ( have_posts() ) : the_post(); ?> <!-- Two Columns --> <div class="row two-columns"> <!-- Main Column --> <?php if($mytheme_pages_sidebar == 1) { ?> <div class="main-column <?php if($mytheme_sidebar_size == 0) { ?> col-md-8 <?php } else { ?> col-md-9 <?php } ?>"> <?php } else { ?> <div class="main-column col-md-12"> <?php } ?> <!-- Page Content --> <div id="page-<?php the_ID(); ?>" <?php post_class('entry entry-page'); ?>> //some page content code like displaying title, featured images etc </div> <!-- /Page Content --> <!-- Page Comments --> <?php if ( comments_open() ) : ?> <hr /> <?php comments_template(); ?> <?php endif; ?> <!-- /Page Comments --> </div> <!-- /Main Column --> <?php if($mytheme_pages_sidebar == 1) get_sidebar(); ?> </div> <!-- /Two Columns --> <?php endwhile; ?>
- if this is the case, you should REMOVE the loop start
while ( have_posts() ) : the_post();
and loop endendwhile;
declarations, the comments section and REPLACE the page section withecho $do_wppizza_loop;
so the resulting replacement code of the above would look like this<!-- Two Columns --> <div class="row two-columns"> <!-- Main Column --> <?php if($mytheme_pages_sidebar == 1) { ?> <div class="main-column <?php if($mytheme_sidebar_size == 0) { ?> col-md-8 <?php } else { ?> col-md-9 <?php } ?>"> <?php } else { ?> <div class="main-column col-md-12"> <?php } ?> <?php echo $do_wppizza_loop; ?> </div> <!-- /Main Column --> <?php if($mytheme_pages_sidebar == 1) get_sidebar(); ?> </div> <!-- /Two Columns -->
depending on your theme, this might look somewhat different and you will have to adjust this accordingly