WordPress.org

Ready to get started?Download WordPress

Forums

Can't get blog index to show on combined home page using get_post (1 post)

  1. volvoV70guy
    Member
    Posted 1 year ago #

    I am developing a single page site for a client using twentyeleven.

    This is my function (in functions.php):

    function homePageCombine(){
    $my_id = 69;
    $post_id_69 = get_post($my_id);
    $content = $post_id_69->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    $todisplay = $content;
    
    $my_id = 53;
    $post_id_53 = get_post($my_id);
    $content = $post_id_53->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    $todisplay .= $content;
    
    $my_id = 55;
    $post_id_55 = get_post($my_id);
    $content = $post_id_55->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    $todisplay .= $content;
    
    return $todisplay;
    }
    
    add_shortcode('homePageCombine', 'homePageCombine');

    Everything works as expected except that the blog does not appear (that's post 53) Its page content before the loop does, however. I have tried making another function that contains the index code, but no matter what I do, it displays an infinite loop of every page on the site, instead of just showing the post loop.

    Ideally, the blog part of this page would just show two posts, but that's easy enough to make happen; I just want the posts to show up at all on the home page.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags