• Phillip

    (@phillustration)


    Hi there,

    I am having trouble getting only an excerpt of a page to display on the home page. I am using the following code to pull through the page data and title etc.

    <h2 class="entry-title">
    <?php
    $page_id = 2;
    $page_data = get_page( $page_id );
    $title = $page_data->post_title;
    echo $page_data->post_title;
    ?>
    </h2>
    <?php
    $page_id = 2;
    $page_data = get_page( $page_id );
    $content = $page_data->post_content;
    echo $page_data->post_content;
    ?>

    The page that the information is being pulled from has a <!–more–> tag on it so that only a sentence is displayed on the home page. However, all of the information on the page is still being pulled through.

    Is this the right way to achieve this?

    Thanks in advance,

    Phillustration

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Phillip

    (@phillustration)

    Hi esmi,

    Thanks for this link, I’m afraid I am still confused though.

    The Codex page says to add the code:

    <?php
    global $more;
    $more = 0;
    ?>

    Before the content tag:

    <?php the_content('Continue Reading'); ?>

    Forgive, but will this appear like this?

    <?php
    global $more;
    $more = 0;
    ?>
    <?php
    $page_id = 2;
    $page_data = get_page( $page_id );
    $title = $page_data->post_title;
    echo $page_data->post_title;
    ?>
    <?php
    $page_id = 2;
    $page_data = get_page( $page_id );
    $content = $page_data->post_content;
    echo $page_data->post_content;
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Read more not working on pages’ is closed to new replies.