Menaka S. on "[Theme: Customizr] different categories in one page"

ساخت وبلاگ

Hi all, how can show different post for different categories in one page? I use this code but show all post of site.

<?php

/*

* Template Name: News

*/

/* Configuration */

$design_layout = 'grid';
$show_page_title = true; /* or false */

$number_of_posts = 6; /* -1 stays for unlimited, 0 will use the Maximum number of posts per page settings */

/* bind a page to a category*/

$page_category = array();

/* or set up as

$page_category = array(

// page_id => cat_id

'200' => '8',
'200' => '14',
'200' => '18',
'200' => '10',

);*/

/* will be overridden by the setting Show metas in home (if true) if you display this tempalate in home */

$show_posts_metas = true; /* or false */

/* query parameters here: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters */

$tc_posts_page_template_the_query = array(

'post_type' => 'post',

'post_status' => 'publish',

'posts_per_page' => $number_of_posts ? $number_of_posts : get_option('posts_per_page'),

'paged' => get_query_var('paged') ? get_query_var('paged') : 1,

);

/* End of configuration */

if ( array_key_exists( get_the_ID(), $page_category ) )

$tc_posts_page_template_the_query = array_merge( $tc_posts_page_template_the_query, array( 'cat' => $page_category[get_the_ID()] ) );

if ( ! defined('CUSTOMIZR') )

define('CUSTOMIZR', get_template_directory());

/* are we displaying this template in home? TODO handle pagination properly */

if ( get_queried_object_ID() == get_option( 'page_on_front' ) && get_option('show_on_front') == 'page' ){

/* display headings */

if ( method_exists('TC_headings', 'tc_set_post_page_heading_hooks') ) {

add_filter('tc_display_customizr_headings', '__retu_false');

TC_headings::$instance -> tc_set_post_page_heading_hooks();

}

/* Note: as for now if you display this template in home the pagination will not work properly let's hide it then, so just the posts_per_page number of posts will be displayed */

add_filter( 'tc_show_post_navigation' , '__retu_false' );

}

if ( 'alteate' == $design_layout )

add_filter('tc_post_list_controller', '__retu_true');

else

add_filter('tc_is_grid_enabled', '__retu_true');

if ( $show_page_title )

add_action('__before_loop', 'print_page_title', 1);

if ( $show_posts_metas )

add_filter('tc_show_post_metas', '__retu_true');

add_filter('tc_content_headings_separator', '__retu_false');

function print_page_title(){

?>

<header class="entry-header">

<h1 class="entry-title"><?php echo apply_filters('tc_the_title', get_the_title() ); ?></h1>

<hr class="featurette-divider __before_content">

</header>

<?php

}

add_action('__before_loop', 'tc_posts_page_template_query', 1);

add_action('__after_loop', 'tc_posts_page_template_reset_query', 9999);

function tc_posts_page_template_query() {

global $wp_query, $tc_posts_page_template_the_query;

$wp_query = new WP_Query(

$tc_posts_page_template_the_query

);

}

function tc_posts_page_template_reset_query(){

global $wp_query, $wp_the_query;

$wp_query = $wp_the_query;

}

/* Include the Customizr(-Pro) index.php */

require_once(CUSTOMIZR . '/index.php');

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 210 تاريخ : سه شنبه 15 تير 1395 ساعت: 12:07