Page-template: speciális lista

Ha szükséged van olyan bejegyzéslistákra, amik nem a szokásos bejegyzéslistát tartalmazzák, megoldhatod a problémát egy oldal-template-tel. A bejegyzés címétől (slug) függően más-más lekérési szabályokat hozhatsz létre az $args változó módosításával.

http://codex.wordpress.org/Page_Templates
http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
http://blog.blackmill.eu/special-list-test/

<?php
/*
Template Name: List page special
*/

get_header(); 

echo('<div id="main-content" class="main-content">');


  if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
    // Include the featured content template.
    get_template_part( 'featured-content' );
  }

echo('	<div id="primary" class="content-area">
		<div id="content" class="site-content" role="search">');

			
        // Start the Loop.
        while ( have_posts() ) : the_post();

          // Include the page content template.
          get_template_part( 'content', 'page' );
        endwhile;
				
        wp_reset_query();
				
        // http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
					
        //	Set the $args for different pages here.
			
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        if( preg_match('/^(\/special-list-test\/)/',$_SERVER['REQUEST_URI']) ){
          $args = array(
            'post_type' => 'post',
            'tag' => 'php',
            'paged' => $paged,
          );
        }
        $wp_query = new WP_Query( $args );

        if ( $wp_query->have_posts() ) : 
        /* The loop */
          while ( $wp_query->have_posts() ) : $wp_query->the_post();
            // Display content of posts 
            global $more;    // Declare global $more (before the loop).
            $more = 0;       // Set (inside the loop) to display content above the more tag.
					 
            get_template_part( 'content', get_post_format() ); 
          endwhile; 
          // Previous/next page navigation.
          twentyfourteen_paging_nav();
        else :
          get_template_part( 'content', 'none' ); 
        endif;
				
        wp_reset_query();
				
        while ( have_posts() ) : the_post();
          // If comments are open or we have at least one comment, load up the comment template.
          if ( comments_open() || get_comments_number() ) {
            comments_template();
          }
        endwhile;
echo('		</div><!-- #content -->
	</div><!-- #primary -->');
  get_sidebar( 'content' ); 
echo('</div><!-- #main-content -->');


get_sidebar();
get_footer(); 

Minden vélemény számít!

Az email címet nem tesszük közzé. A kötelező mezőket * karakterrel jelöljük.

A következő HTML tag-ek és tulajdonságok használata engedélyezett: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>