function test_largo_get_partial_by_post_type()
 {
     $ret = largo_get_partial_by_post_type('foo', 'bar', 'baz');
     $this->assertEquals($ret, 'foo');
     // dummy test so that this test will run. Mostly we're just asserting that the function doesn't cause errors.
     $this->markTestIncomplete();
 }
Exemple #2
0
		<?php 
    if (have_posts()) {
        get_search_form();
        ?>

			<h3 class="recent-posts clearfix">
				<?php 
        printf(__('Your search for <span class="search-term">%s</span> returned ', 'largo'), get_search_query());
        printf(_n('%s result', '%s results', $wp_query->found_posts), number_format_i18n($wp_query->found_posts));
        printf('<a class="rss-link" href="%1$s"><i class="icon-rss"></i></a>', get_search_feed_link());
        ?>
			</h3>

			<?php 
        while (have_posts()) {
            the_post();
            $partial = largo_get_partial_by_post_type('search', get_post_type($post), 'search');
            get_template_part('partials/content', $partial);
        }
        largo_content_nav('nav-below');
    } else {
        get_template_part('partials/content', 'not-found');
    }
}
?>
</div><!--#content-->

<?php 
get_sidebar();
get_footer();
 /**
  * Renders markup for a page of posts and sends it back over the wire.
  *
  * @global $opt
  * @global $_POST
  * @uses largo_load_more_posts_choose_partial
  * @uses largo_get_partial_by_post_type
  */
 function largo_load_more_posts()
 {
     global $opt;
     $paged = isset($_POST['paged']) ? $_POST['paged'] : 1;
     $context = isset($_POST['query']) ? json_decode(stripslashes($_POST['query']), true) : array();
     $args = array_merge(array('paged' => (int) $paged, 'post_status' => 'publish', 'posts_per_page' => intval(get_option('posts_per_page')), 'ignore_sticky_posts' => true), $context);
     // Making sure that this query isn't for the homepage
     if (isset($_POST['is_home'])) {
         $is_home = $_POST['is_home'] == 'false' ? false : true;
     } else {
         $is_home = true;
     }
     // num_posts_home is only relevant on the homepage
     if (of_get_option('num_posts_home') && $is_home) {
         $args['posts_per_page'] = of_get_option('num_posts_home');
     }
     if ($is_home) {
         $args['paged'] = $args['paged'] - 1;
         if (of_get_option('cats_home')) {
             $args['cat'] = of_get_option('cats_home');
         }
     }
     $args = apply_filters('largo_lmp_args', $args);
     $query = new WP_Query($args);
     if ($query->have_posts()) {
         // Choose the correct partial to load here
         $partial = largo_load_more_posts_choose_partial($query);
         // Render all the posts
         while ($query->have_posts()) {
             $query->the_post();
             // Use largo_get_partial_by_post_type here as well as in the search archive,
             // to ensure that LMP posts will be using the partial set by the child theme for that post type.
             $post_type_partial = largo_get_partial_by_post_type($partial, get_post_type(), $partial);
             get_template_part('partials/content', $post_type_partial);
         }
     }
     wp_die();
 }