• hi there

    I have a publishing website on which I place posts on behalf of others. Each post includes a meta value “Author Name”, I also create a page for each Author of the format “Author Name”, eg the slug is “author-name”.

    Using

    str_replace(” “, “-“,
    strtolower(get_post_meta($post->ID, “Author Name”, 1)))

    I can therefore create a link to the page, however I would like to extract the content of the page and place a shortened version of it (using substr() or suchlike) on the sidebar oof the relevant post.

    So basically I want to be able to get_page() based on the Page Title, and grab the content from that page. I can’t work out how to do this with pages, they don’t show up in the loop in the normal manner like posts do… thank you for any help you can provide.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tadramgo

    (@tadramgo)

    Okay, so I’ve done some more hours and hours of digging to find something likely to work:

    <?php

    $query = “pagename=”;
    $query .= $page_slug;

    $pageArray = query_posts($query); //retrieves the about $query page only
    setup_postdata($pageArray);
    $PageID = $pageArray[0]->ID;
    echo $about_PageID;

    ?>

    This seems fine to me, basically I should end up with the page ID, from which I can grab any content I want. Or indeed I could grab the content straight out of pageArray.

    However when this is placed within The Loop it produces a infinite loop. Which is a bummer.

    Any insights?

    Tom

    thx.
    this was extremely helpfull!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Including Page Content On Posts’ is closed to new replies.