/** * Loops through an array of posts objects and displays them using a given loop template * * @param string $template Name of the loop template * @param array $posts Array of post objects ( optional ) */ function try_posts_loop($template, $posts = null) { global $post; // If a posts array is not provided grab the globally set default array from the main query if (!$posts) { global $posts; } // Loop through post objects and display them with a loop template foreach ($posts as $post) { setup_postdata($post); try_get_template_part('partials', 'loop-' . $template); } // Reset query back to main if posts array was provided if ($posts) { wp_reset_query(); } }
?> " </h1> <ol class="posts-list"> <?php if (have_posts()) { while (have_posts()) { the_post(); ?> <?php try_get_template_part('partials', 'loop-post'); ?> <?php } } else { ?> <?php try_get_template_part('partials', 'loop-post-not-found'); ?> <?php } ?> </ol> <?php try_get_template_part('partials', 'pagination'); ?> </div> </section> </div>
/** * Loads comment template * * @param object $comment The comment object * @param array $args Comment arguments * @param int $depth The depth of the current comment */ function try_comment_list($comment, $args, $depth) { $args = array('comment' => $comment, 'args' => $args, 'depth' => $depth); try_get_template_part('partials', 'comment', true, $args); }
/** * Returns template for email share */ function get_form_email() { global $post; echo try_get_template_part('partials/form', 'email'); exit; }
<div class="container"> <section class="article row"> <article class="userFormatted col-sm-8"> <h1 class="userFormatted-title"><?php the_title(); ?> </h1> <?php the_content(); ?> </article> <?php try_get_sidebar(); ?> </section> </div> --> <?php // check if the flexible content field has rows of data if (have_rows('sections')) { $ctr = 0; // loop through the rows of data while (have_rows('sections')) { the_row(); $sectionType = get_row_layout(); //get_template_part( 'partials/' . $sectionType ); try_get_template_part('partials', $sectionType, true, array('ctr' => $ctr)); //try_get_template_part('partials', 'related-posts', true, array('type' => 'Articles') ); $ctr++; } }
echo bloginfo('name'); ?> </a> </h1> <?php } else { ?> <a class="header-logo" href="<?php echo bloginfo('url'); ?> "><?php echo bloginfo('name'); ?> </a> <?php } ?> <div class="header-menu"> <?php wp_nav_menu(array('theme_location' => 'header', 'container' => 'nav', 'container_class' => 'mainMenu-menu', 'menu' => 'Header', 'menu_class' => 'mainMenu-list')); ?> </div> <div class="search-form"> <?php try_get_template_part('partials', 'search-form'); ?> </div> </div> </header>