• Resolved 3Plumes

    (@3plumes)


    All,

    I’m working on a custom theme and need to return details from a specific page as a summary on the home page. I’m fairly new to WP, so I’m not sure what I’m doing wrong. I tried following the description on the Codex Function Reference/get post entry, but I haven’t been successful.

    I need to return the page’s Title, permalink, and the page excerpt (which I’ve already enabled).

    Any help will be greatly appreciated.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • try to use get_page() http://codex.wordpress.org/Function_Reference/get_page

    the example in the codex link might get you started; for details, please ask again, if you have some code to work from.

    Thread Starter 3Plumes

    (@3plumes)

    This is what I have:

    <?php get_page( $page_id='5' );
                            while (have_posts()) : the_post();?>
                            <h3><?php the_title(); ?><br /><span>all about the spa and the team</span></h3>
                       <p><?php the_excerpt(); ?></p>
                            <p><a href="<?php the_permalink(); ?>">Continue reading</a></p>
                           <?php endwhile; ?>

    It only returns the current page though, which is the home page, and not post id #5

    following the example in here http://codex.wordpress.org/Function_Reference/get_page, your code might look like:

    <?php $this_page = get_page( $page_id='5' ); ?>
                            <h3><?php echo $this_page->post_title; ?><br /><span>all about the spa and the team</span></h3>
                       <p><?php echo apply_filters('the_excerpt', $this_page->post_excerpt); ?></p>
                            <p><a href="<?php echo get_permalink($this_page->ID); ?>">Continue reading</a></p>

    (assuming that the page has a handwritten excerpt)

    alternatively, if you want to use a while(have_posts()) loop structure, you better use a query to get your page;

    example:

    <?php query_posts('post_type=page&page_id=5');
                            while (have_posts()) : the_post();?>
                            <h3><?php the_title(); ?><br /><span>all about the spa and the team</span></h3>
                       <p><?php the_excerpt(); ?></p>
                            <p><a href="<?php the_permalink(); ?>">Continue reading</a></p>
                           <?php endwhile; wp_reset_query(); ?>

    (untested)

    Thread Starter 3Plumes

    (@3plumes)

    Nice!!! I used your second example and it works like a charm!! Thanks very much.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Query Confusion’ is closed to new replies.