Wordpress通过URL排序

时间:2015-10-21 23:23:27

标签: wordpress

$p_args = array(
    "post_type" => "post",
    "v_sortby" => "date",
    "numberposts" => 10,
    "showposts" => 10,
    "posts_per_page" => 10
    );

我可以通过

这样的网址对其进行排序
www.example.com/?post_type=post&v_sortby=date&numberposts=10&showposts=10

然后我如何将这些写入URL表单?

$args = array(
        "post_type" => "post",
        "meta_query" => array (
            array (
              "key" => "quality",
              "value" => "hd",
              "compare" => "IN"
            )
          ) 
    );

2 个答案:

答案 0 :(得分:0)

您想在网址中传递这些查询参数吗?

http_build_query()

或者您是否尝试从网址获取值?

$_GET

答案 1 :(得分:0)

我使用http_build_query()为以下参数生成url

<?php
$args = array(
        "post_type" => "post",
        "meta_query" => array (
            array (
              "key" => "quality",
              "value" => "hd",
              "compare" => "IN"
            )
          ) 
    );

echo http_build_query($args);
?>

在我的页面上回显了url查询。