WordPress.org

Forums

Display Page AND Post List (4 posts)

  1. lowray
    Member
    Posted 8 years ago #

    Hello! I currently use the Filosofo Home-Page Control to make one of my pages display as the default home page, instead of showing a list of the most recent posts. I was wondering if there was a way to somehow do both by creating a new index.php template.

    Basically hard-code a page to display and then display the last few posts. I've tried doing it although end up having a problem because certain variables have already been set...

    Any thoughts?

    Thanks!

  2. thornomad
    Member
    Posted 8 years ago #

    I use this function:

    <?php function include_page ($post_id, $filter=TRUE) {
    global $wpdb;
    $pages = $wpdb->get_results ("SELECT " .
    "post_content " .
    "FROM $wpdb->posts " .
    "WHERE ID = " . $post_id);
    if ($pages):
    foreach ($pages as $page):
    if ($filter):
    $page->post_content = apply_filters('the_content',stripslashes($page->post_content));
    else:
    $page->post_content = stripslashes($page->post_content);
    endif;
    echo $page->post_content;
    endforeach;
    endif;
    } ?>

    Then call it (<?php include_page('2'); ?>) above the loop in the home.php file in your template.

  3. lowray
    Member
    Posted 8 years ago #

    This is excellent and just what I was looking for!

    THANK YOU!!!

  4. lowray
    Member
    Posted 8 years ago #

    I know I'm probably asking for a lot, but would you know how to change this so the page information didn't display on any of the 'previous' pages?

Topic Closed

This topic has been closed to new replies.

About this Topic