日期:2015-04-16 阅读:2165
dmandwp系统 - wordpress系统和DM系统区块建站>>
$wp_query->query_vars['post_type']--会得到什么呢?
htps://codex.wordpress.org/WordPress_Query_Vars
-----------------
function themeslug_query_vars( $qvars ) {
$qvars[] = 'custom_query_var';
return $qvars;
}
add_filter( 'query_vars', 'themeslug_query_vars' , 10, 1 );
https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars
https://wordpress.org/support/topic/query_vars-filter-doesnt-work
------------------
// This would output '/client/?s=word&foo=bar'
echo esc_url( add_query_arg( 'foo', 'bar' ) );
https://codex.wordpress.org/Function_Reference/add_query_arg
http://simonwheatley.co.uk/2009/02/adding-get-params-to-a-url-in-wordpress/
---------------
<?php $paged = get_query_var( 'paged', 1 ); ?>
<h1>Currently Browsing Page <?php echo $paged; ?></h1>
https://codex.wordpress.org/Function_Reference/get_query_var
-----------------
下面这个代码会出现什么?
$args = array(
'post_type' => 'post',
'posts_per_page' => 2,
'post_status' => 'publish'
);
$args['prices'] = 22222222;
$posts_query = new WP_Query($args);
echo '<pre>'.print_r($posts_query,1).'</pre>';
if ( isset($posts_query->query_vars['prices']) ) echo $posts_query->query_vars['prices'];
可以通过 remove_query_arg 来移除。
如图: