Forums

How to show content from pages in my theme? (2 posts)

  1. jbiddulph
    Member
    Posted 1 year ago #

    Can someone please help, I would like to be able to show Page Content in my theme, what php code do I use?

  2. MichaelH
    Volunteer
    Posted 1 year ago #

    <?php
    $mypage = = 237; //put your page id here
    $args=array(
      'page_id' => $mypage,
      'post_type' => 'page',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      the_content();
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Also see:
    query_posts()
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

Topic Closed

This topic has been closed to new replies.

About this Topic