query_string的一个示例是: testdev.com/test-results/?Title=166
我在下面有以下代码。我无法弄清楚如何设置最后一个数组来获取ID,然后相应地生成正确的帖子。 (关系可以忽略,我拥有的其他数组正在工作,并且不需要该示例)
任何提示/帮助将不胜感激
<?php
**THIS IS WHERE I TRIED TO GET THE ID**
$queryTitle = $_GET['Title'];
$pageTitle = the_title();
$args = array(
// all your args here
'post_type' => 'resorts',
'meta_query' => array(
'relation' => 'OR',
array( **THIS IS WHERE I TRIED TO GET THE TITLE FROM THE URL**
'key' => $pageTitle,
'value' => $queryTitle,
'compare' => '=',
),
)
);
$query = new WP_Query( $args );
if($query->have_posts()) : while ($query->have_posts()): $query->the_post(); ?>
content etc goes here
<?php endwhile; else : ?>
<p>No results found, modify your search criteria and try again!</p>
<?php endif; ?>
答案 0 :(得分:0)
get_page()
:
$queryTitle = $_GET['Title'];
$your_page = get_page($queryTitle);
echo $your_page->post_title;