[resolved] Page contents or widget in header (7 posts)

  1. Harv27
    Posted 6 years ago #

    Just started using WP this week and trying to modify a theme.
    I'd like to add an "about" snippet to the header area and would like to know what is the better way to do so.

    Create a page and use queryposts to load the contents.
    Create a new widget area and use a text widget.

  2. esmi
    Forum Moderator
    Posted 6 years ago #

    If you don't need WYSIWYG and/or are happy using raw markup, I'd go with the widget route myself. Otherwise you will need a page plus get_posts or query_posts. If you use the latter, just remember to reset the query before the main Loop.

  3. Harv27
    Posted 6 years ago #

    Thanks, for the reply.
    I'd like to try both, in the meantime I tried the page approach.

    using the following code I keep getting the first post.

    // retrieve one post with an ID of 5

    global $more;
    // set $more to 0 in order to only get the first part of the post
    $more = 0;

    // the Loop
    while (have_posts()) : the_post();
    // the content of the post
    the_content('Read the full post ยป');
    got this code from

    Any suggestions?

  4. esmi
    Forum Moderator
    Posted 6 years ago #

    Assuming your About page has a page id of 23, try using:

     $about_page = get_posts('page_id=23');
     foreach($about_page as $about) :
     <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
     <?php the_content(); ?>
     <?php endforeach; ?>
  5. Harv27
    Posted 6 years ago #

    This seems to get the current pages content, not the about page. Am I doing something wrong? Is there a particular area I should be putting the code?

  6. esmi
    Forum Moderator
    Posted 6 years ago #

    You need to place the code in header.php after the opening <body> tag but well before any other Loop. Make sure that you are using the correct id for the About page.

  7. Harv27
    Posted 6 years ago #

    esmi, That's exactly where I placed it.
    I've given up on this route for now - it ignores the page id and loads the current page still. I following your suggestion on another post and used a sidebar widget. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic