Upload
Download free for 30 days
Login
Submit Search
Секреты WP_Query
1 like
5,249 views
Konstantin Kovshenin
1 of 32
Download now
Downloaded 12 times
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
More Related Content
PDF
Knowlage
Afaf A. Habib
PDF
Iteratory
Łukasz Kużyński
PDF
PHPのすべらない話#3
Moriyoshi Koizumi
PDF
Адаптация TInyMCE редактора под нужды клиента by Vitaly Nikolaev
WordCamp Kyiv
PDF
Add tag shortcode
Peter Baylies
DOCX
Simular un next del recordset en php de forma rudimentaria
jbersosa
PPTX
8. CodeIgniter move2
Razvan Raducanu, PhD
PDF
Dušan Kasan - Zrefaktoruj cykly na kolekce
Konference PHPlive
Knowlage
Afaf A. Habib
Iteratory
Łukasz Kużyński
PHPのすべらない話#3
Moriyoshi Koizumi
Адаптация TInyMCE редактора под нужды клиента by Vitaly Nikolaev
WordCamp Kyiv
Add tag shortcode
Peter Baylies
Simular un next del recordset en php de forma rudimentaria
jbersosa
8. CodeIgniter move2
Razvan Raducanu, PhD
Dušan Kasan - Zrefaktoruj cykly na kolekce
Konference PHPlive
What's hot
(20)
KEY
jQuery プラグインの作り方
Takeru Suzuki
PDF
Jquery2
Inbal Geffen
PDF
Analizador sintáctico de Pascal escrito en Bison
Egdares Futch H.
PDF
Making DSL with []
Yuya Takeyama
PDF
Templating WordPress
Konstantin Kovshenin
PDF
BABELで、ES2015(ES6)を学ぼう!
Toshio Ehara
TXT
With enter
Ani Mikaelyan
PDF
12 PREMIO “1ER LUGAR” 9NA COPA GRUNDY.PDF
Randy Mujica
PDF
PHP Profiling
Sungbum Hong
TXT
Miniray.php
maeeeng69
PDF
jQuery PLUGIN
blueweb_sk
PDF
Quiz Component For Joomla
guestebb21a
PDF
Sumahexavector
jbersosa
ODP
Jquery Plugin
Simone Gentili
PDF
certs.PDF
Masood Inayat RRPT
PDF
Feeds. использование и создание плагинов. Feeds API
Alex S
TXT
Minishell
hacker indonesia
PDF
Working With Ajax Frameworks
Jonathan Snook
PDF
Web Programming - Toko Bunga Red Flower
Doni Andriansyah
PPS
Ftp
guestd1c59ac
jQuery プラグインの作り方
Takeru Suzuki
Jquery2
Inbal Geffen
Analizador sintáctico de Pascal escrito en Bison
Egdares Futch H.
Making DSL with []
Yuya Takeyama
Templating WordPress
Konstantin Kovshenin
BABELで、ES2015(ES6)を学ぼう!
Toshio Ehara
With enter
Ani Mikaelyan
12 PREMIO “1ER LUGAR” 9NA COPA GRUNDY.PDF
Randy Mujica
PHP Profiling
Sungbum Hong
Miniray.php
maeeeng69
jQuery PLUGIN
blueweb_sk
Quiz Component For Joomla
guestebb21a
Sumahexavector
jbersosa
Jquery Plugin
Simone Gentili
certs.PDF
Masood Inayat RRPT
Feeds. использование и создание плагинов. Feeds API
Alex S
Minishell
hacker indonesia
Working With Ajax Frameworks
Jonathan Snook
Web Programming - Toko Bunga Red Flower
Doni Andriansyah
Ftp
guestd1c59ac
Ad
Viewers also liked
(9)
PDF
P2
Konstantin Kovshenin
PDF
The Settings API
Konstantin Kovshenin
PDF
Пожиратели памяти в WordPress
Konstantin Kovshenin
PDF
WordPress под нагрузкой: масштабирование и отказоустойчивость
Konstantin Kovshenin
PDF
Memory Management in WordPress
Konstantin Kovshenin
PDF
7 убийц производительности WordPress
Konstantin Kovshenin
PDF
Почему HTTPS соединение необходимо реализовать на Вашем сайте?
Alexey Vidanov
PDF
Основые безопасности WordPress
Konstantin Kovshenin
PDF
Цикл разработки WordPress
Konstantin Kovshenin
P2
Konstantin Kovshenin
The Settings API
Konstantin Kovshenin
Пожиратели памяти в WordPress
Konstantin Kovshenin
WordPress под нагрузкой: масштабирование и отказоустойчивость
Konstantin Kovshenin
Memory Management in WordPress
Konstantin Kovshenin
7 убийц производительности WordPress
Konstantin Kovshenin
Почему HTTPS соединение необходимо реализовать на Вашем сайте?
Alexey Vidanov
Основые безопасности WordPress
Konstantin Kovshenin
Цикл разработки WordPress
Konstantin Kovshenin
Ad
More from Konstantin Kovshenin
(7)
PDF
Scaling out with WordPress
Konstantin Kovshenin
PDF
Будущее WordPress (SPB, 2014)
Konstantin Kovshenin
PDF
Road to Platform @ WordPress.com VIP Workshop 2014
Konstantin Kovshenin
PDF
Будущее WordPress
Konstantin Kovshenin
PDF
Как повысить скорость вашего сайта на WordPress
Konstantin Kovshenin
PDF
Things I Wish I Had Known Before Developing a WordPress Theme
Konstantin Kovshenin
PDF
7 Tips for Better WordPress Theme Development
Konstantin Kovshenin
Scaling out with WordPress
Konstantin Kovshenin
Будущее WordPress (SPB, 2014)
Konstantin Kovshenin
Road to Platform @ WordPress.com VIP Workshop 2014
Konstantin Kovshenin
Будущее WordPress
Konstantin Kovshenin
Как повысить скорость вашего сайта на WordPress
Konstantin Kovshenin
Things I Wish I Had Known Before Developing a WordPress Theme
Konstantin Kovshenin
7 Tips for Better WordPress Theme Development
Konstantin Kovshenin
Секреты WP_Query
1.
WP_Query
2.
is_home() is_single() is_page()
3.
query_posts()
4.
if ( have_posts()
) while ( have_posts() ) the_post();
5.
query_posts( 'cat=-5' ); $posts
= get_posts( 'cat=-5' ); $posts = new WP_Query( 'cat=-5' );
6.
10 posts
7.
10 posts
+ 10 posts cat = -5
8.
max_num_pages = 3
index.php 404.php max_num_pages = 5
9.
pre_get_posts
10.
add_action( 'pre_get_posts', 'my_func'
); function my_func( $query ) { $query->set( 'cat', '-5' ); }
11.
$query->is_main_query()
12.
add_action( 'pre_get_posts', 'my_func'
); function my_func( $query ) { if ( $query->is_main_query() ) $query->set( 'cat', '-5' ); }
13.
add_action( 'pre_get_posts', 'my_func'
); function my_func( $query ) { if ( $query->is_main_query() ) if ( $query->is_search() ) $query->set( 'post_type', 'post' ); }
14.
add_action( 'pre_get_posts', 'my_func'
); function my_func( $query ) { if ( $query->is_main_query() ) if ( $query->is_search() ) $query->set( 'posts_per_page', 30 ); }
15.
add_action( 'pre_get_posts', 'my_func'
); function my_func( $query ) { if ( $query->is_main_query() ) if ( $query->is_home() ) $query->set( 'post_type', array( 'post', 'book', ) ); }
16.
query_posts(); $posts = get_posts(); $posts
= new WP_Query();
17.
$popular = new
WP_Query( 'cat=3' ); while ( $popular->have_posts() ) { $popular->the_post(); ... }
18.
$popular = new
WP_Query( 'cat=3' ); while ( $popular->have_posts() ) { $popular->the_post(); ... } // Основной запрос while ( have_posts() ) { the_post(); ... }
19.
// Основной запрос while
( have_posts() ) { the_post(); ... $category = get_the_category(); $related = new WP_Query( 'cat=' ... ); while ( $related->have_posts() ) { $related->the_post(); ... } }
20.
query_posts()
21.
$wp_query
22.
function have_posts() {
global $wp_query; return $wp_query->have_posts(); }
23.
$wp_query =& $wp_the_query;
24.
function &query_posts( $query
) { ... unset( $wp_query ); $wp_query = new WP_Query(); return $wp_query->query( $query ); }
25.
function wp_reset_query() {
... unset( $wp_query ); $wp_query =& $wp_the_query; }
26.
$popular = new
WP_Query( 'cat=3' ); while ( $popular->have_posts() ) { $popular->the_post(); ... } // Основной запрос while ( have_posts() ) { the_post(); ... }
27.
query_posts( 'cat=3' ); while
( have_posts() ) { the_post(); ... } wp_reset_query(); // Основной запрос while ( have_posts() ) { the_post(); ... }
28.
Если нужно изменить
основной запрос pre_get_posts
29.
Если нужен вторичный
запрос new WP_Query; get_posts()
30.
Если нужна головная
боль query_posts()
Download