Support » Fixing WordPress » Pull a page's excerpt and featured image into my sidebar

  • Resolved LucyRyder


    Hello, I am trying to pull the first 10 words of text , and the featured image from 1 page, in to my sidebar on all pages.

    I have used get_posts before to pull in posts form a a particular category setting the except length before like this:

    $args = array( ‘numberposts’ => 1, ‘category_name’=> ‘Commission work’, ‘order’=> ‘DESC’, ‘orderby’ => ‘post_date’ );
    $postslist = get_posts( $args );
    foreach ($postslist as $post) : setup_postdata($post); ?>

    <?php the_post_thumbnail(‘thumbnail’); ?>

    <div class=”callp”>
    ” rel=”bookmark” title=”Permanent Link to
    <?php the_title_attribute(); ?>”><?php the_title(); ?>

    $excerpt = get_the_excerpt();
    echo string_limit_words($excerpt,8);

    – and want to do the same but pulling from a particular page instead of a post in a category. I cannot see how to do this although i have seen the get_page_with_title page on here but cannot work out how to swap over easily!

    Any suggestions for the code i need to use in my sidebar.php?

    Many thanks in advance for all help!!


Viewing 1 replies (of 1 total)
  • I have actually just found the Plugin ” Super Post and Page Widget ” – which has done exactly what i wanted!

Viewing 1 replies (of 1 total)
  • The topic ‘Pull a page's excerpt and featured image into my sidebar’ is closed to new replies.