从 query_string 页 ID 输出页面


Output page from Page ID in query_string

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; ?>
可以使用

get_page()

$queryTitle = $_GET['Title'];
$your_page = get_page($queryTitle);
echo $your_page->post_title;