टेम्पलेट के अंदर नई क्वेरी के साथ उत्तर कस्टम पोस्ट प्रकारों के साथ सही ढंग से काम नहीं करेंगे।
लेकिन documentation किसी भी प्रश्न पर हुक करने की पेशकश करता है, चेक यह मुख्य प्रश्न है, और इसे निष्पादन से पहले संशोधित करें। यह टेम्पलेट कार्यों के अंदर किया जा सकता है:
function my_post_queries($query) {
// do not alter the query on wp-admin pages and only alter it if it's the main query
if (!is_admin() && $query->is_main_query()) {
// alter the query for the home and category pages
if(is_home()){
$query->set('posts_per_page', 3);
}
if(is_category()){
$query->set('posts_per_page', 3);
}
}
}
add_action('pre_get_posts', 'my_post_queries');
स्रोत
2015-09-07 13:26:54
यह बढ़िया है! अच्छा काम करता है। धन्यवाद! – ray
ऐसा लगता है कि पेजिनेशन अब और काम नहीं करेगा! कोई उपाय? – ray
'post_per_page' को 'showposts' में बदलें? – Gipetto