Support » Fixing WordPress » Include content of a static page on the main blog page?

  • Resolved StrangeAttractor


    I guess this is a variation of the “sticky post” idea, but I’m having trouble turning up info in my searches.

    I’d like to have a static announcement at the top of my blog page, before the start of the loop. I’d like this to be something can be editable and changed through the wp-admin, so I want it to be the content of a page or a post.

    Also I’d like to be able to style this announcment via the stylesheet (so perhaps I’d put it in its own div).

    I’m thinking along the lines of inserting the content of a page (as opposed to a post) because the function is more like a page — something that would be edited once in a while, but would mostly be static.

    Is there a way to stick the content of a page in before the loop starts? I’ve been looking at the template tags but not sure how I’d call up a page.

Viewing 8 replies - 1 through 8 (of 8 total)
  • I used this plugin several times when I needed exactly what you described above:

    Thanks, Moshu! That looks it would be ideal for what I want to do.

    I’ll try it out and see how it works.

    <? $my_id = 3; $post_id_7 = get_post($my_id); print $title = $post_id_7->post_content; ?>

    i use this in teh template to include the post3 or page3 with $my_id = 3;

    Thanks mundgerecht.

    I am still testing out solutions. I will come back and post what worked for me.

    i use this

    thats how i put the three category image links at the top of my home page. you can put text, images, whatever. its styled through its own style in my style sheet. the page where you edit the content looks just like a post page.

    Thanks boober — that also looks like a great option. I notice it’s made by the same author as the plugin recommended by Moshu.

    I appreciate all the responses from everyone to my question, and it’s great to have several options.

    Thank you all for your help.

    I’m installing this for a client, so needed a solution that was both user-friendly and flexible (because I needed to be able to heavily style the intro area).

    The “Welcome visitor” plugin recommended by Boober was promising because of being integrated into the admin panel, but was not flexible enough for my purposes.

    The best solution turned out to be Moshu’s recommendation of the “Get a Post” plugin — user friendly because it can also get pages (and the client can edit the page like any other), but flexible because it allows me to control where it appears on templates, and I can wrap it up in divs, etc.

    Thanks again, everyone.

    I thought I would add a little extra about what I did, for anyone interested in doing the same thing.


    1) On a site where the blog is the home page, I wanted to have a intro “Welcome” section before the blog posts which could be surrounded with divs, etc. so that I could style it with CSS.

    2) Also, I wanted this intro to appear ONLY on the main page of the site, and if users clicked the “blog” link on the pages nav menu, they would not see the intro (because if they are on the site, they have already seen it). To restate this: even though the home page IS the blog page, I only wanted them to see the intro when first arriving at the site, but not when clicking on “blog” (or for that matter on “previous entries” at the bottom of the home page).

    This is what I did:

    1) installed get-a-post plugin (see Moshu’s post above for link)

    2) put this code before the loop on my home.php template:

    <?php get_a_post(16); //this uses the get_a_post plugin to pull up a page with id=16, which contains my Welcome entry ?>
    <!-- this area pulls up the title and content of entry, and is surrounded with divs that allow me to style the entry with background images etc. via the stylesheet  -->
    <div id="welcome">
    	  <h3><span><?php the_title(); ?></span></h3>
    	  <?php the_content(); ?>
         <div class="welcome_footer"></div>
    <!-- Normal WordPress loop goes under here  -->

    3) Problem: the intro shows up on every page of the blog. I only want it on the first page, and also, I don’t want it to show when someone clicks the “blog” link on the pages menu (which goes to

    Solution: Make sure that only page the intro shows up on is the naked URL of the WordPress site (e.g. or but NOT or etc.).

    Found the code for this on a post on Kolossus Interactive, which uses $_SERVER[’REQUEST_URI’] to compare the location of the site to the url pulled up by get_bloginfo('url').

    4) So now the whole thing looks like this (I’ve removed some of the annotation from the code above for brevity):

    $request_loc = '';
    $request_loc .= $_SERVER['REQUEST_URI']; //request_uri is a relative url
    $blog_loc = get_bloginfo('url');
    $blog_loc .= '/'; //wordpress' blog url variable has no trailing slash, so add it
    <?php if ( $request_loc == $blog_loc ): ?>
       <?php get_a_post(16); ?>  
       <div id="welcome">
    	   <h3><span><?php the_title(); ?></span></h3>
    	   <?php the_content(); ?>
            <div class="welcome_footer"></div>
    <?php endif; ?>
    <!-- Normal WordPress loop goes under here  -->

    It works – the intro will show up ONLY if the user is on the home page, but not on the blog’s paged “previous entries” nor if the user clicks “blog” from the pages menu.

    There may be simpler ways of doing this, but this worked for me.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Include content of a static page on the main blog page?’ is closed to new replies.