开发者

WordPress - How to pull data (title, thumb) from a specified page?

I've got a list of links being generated by wp_list_pages that are displaying all the children of a certain page. Each of these pages has the usual: title and a paragraph.

Instead of loading the page separately, I was planning on setting each link to be ?id=XXX where XXX is the page's slug. From there, I would have a PHP function in the content area pulling the title and copy of a page depending if the slug matched the id=XXX.

How would I go about querying a single page with specific arguments so I make sure that the page that loads has the slug that matches the id=XXX?

Nav:

<li><a href="?id=SLUGOFLINK1">Link 1</a></li>
<li><a href="?id=SLUGOFLINK2">Link 2</a></li>
<li><a href="?id=SLUGOFLINK3">Link 3</a></li>

Content:

<?php
if($_GET['id']){

$theID = $_GET['id'];
if ($theID 开发者_运维问答= 'SLUGOFLINK3')
{
// display SLUGOFLINK3's title and paragraph
}

}


To display the content depending on the link click you could do the following...

    <?php
    if(isset($_GET['id'])){
    $id = $_GET['id'];
    $post_id = get_post($id); 
    $title = $post_id->post_title;
    $content = $post_content->post_title;
//print title and content
    echo "<h2>$title</h2>";
    echo $content;
    } else {
    //if no id found print links
    }
    ?>

If I misunderstood, my apologizes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜