SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I properly display posts on homepage

    I'm having trouble displaying posts from a single category on the homepage the way I want them to appear. The theme I'm using uses a 3 column layout for the homepage and a content-sidebar layout for the blog page.

    Basically I want the homepage ( http://music1.netlabs.co.za/ ) to display exactly like the blog page ( http://music1.netlabs.co.za/?cat=7 ), but include the slider. So what I did was just copy the code from category.php and pasted it into a new custom page template titled hompage.php and set that as my homepage.

    But for some reason its not displaying any posts and I have no idea why.

    category.php
    http://pastebin.com/ZuNVHqg7

    loop.php
    http://pastebin.com/Hi6bsTvF

    Any help would be much appreciated!

  2. #2
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Posts not displaying properly on homepage

    I'm having trouble displaying posts from a single category on the homepage the way I want them to appear. The theme I'm using uses a 3 column layout for the homepage and a content-sidebar layout for the blog page.

    Basically I want the homepage to display exactly like the category archive page, but include the slider. So what I did was just copy the code from `category.php` and pasted it into a new page template titled `front-page.php` and set that as my homepage. The theme uses a loop.php to pull the loop and calls it using "get_template_part()" into the content section as shown in the code below.

    But for some reason its not displaying any posts and I have no idea why.
    Here are some snapshots of what's happening:

    Current Front Page:
    front-page-current.png

    Desired Front Page:
    front-page-desired.jpg


    Here's the code:

    category.php

    PHP Code:
        <?php
        
    /**
         * The template for displaying Category pages.
         *
         */
        
    $settings get_option"ntl_theme_settings" );
        
    get_header(); ?>
         
         
         
                <div class="outer">
                        <div class="frameset container clear">
                                <?php if ($settings['ntl_disable_audio'] != 'off'){     ?>
                                <div class="clear headtop">    
                                        <div class="page-title" >
                                                <h1 class="vfont"><?php single_cat_title(); ?></h1>
                                        </div>
                                                                                       
                                        <?php echo lets_get_albumselector(); ?>                                        
                                        <?php echo lets_get_musicplayer(); ?>
                                               
                                </div>                         
                                <?php } else { ?>
                               
                                <div class="clear headtop" style="height: auto;">                                      
                                        <div class="page-title" style="width: 100%; margin-bottom: 40px;">
                                                <h1 class="vfont"><?php single_cat_title(); ?></h1>
                                        </div>                 
                                </div>
                               
                                <?php ?>
                               
                                <?php if (!$settings['ntl_show_timer']) { ?>
                                        <div class="cdowntop"> 
                                        <?php echo get_for_timer(''); ?>
                                <?php } else { ?>
                                        <div class="cdownnone">
                                <?php ?>
         
        <div class="bodymid hfeed hpage">
                <?php if ($settings['ntl_disable_audio'] != 'off'){     ?>
                        <div class="drawer">&nbsp;</div>
                <?php ?>
                <div id="main">
                        <div id="content" role="main">
                                <div class="container clear">
                                        <div class="grid8 first">              
                                                <div id="content" role="main">
                                                        <?php get_template_part'loop''category' ); ?>                              
                                                        <?php adminace_paging(); ?>
                                                </div>
                                        </div>
                                        <?php get_sidebar(); ?>
                                </div>
                        </div>
                </div>
        </div>
        </div>
        <?php lets_make_carousel(); ?>
         
         
        <?php get_footer(); ?>
    loop.php

    PHP Code:
        <?php
        
    /**
         * The loop that displays posts.
         *
         */
         
        
    ?>
        
        <?php /* If there are no posts to display */ ?>
        <?php if ( ! have_posts() ) : ?>
                <div id="post-0" class="post error404 not-found">
                        <h1 class="entry-title"><?php _e'Not Found''localize' ); ?></h1>
                        <div class="entry-content">
                                <p><?php _e'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.''localize' ); ?></p>
                                <?php get_search_form(); ?>
                        </div><!-- .entry-content -->
                </div><!-- #post-0 -->
        <?php endif; ?>
         
        <?php
                
    /* Start the Loop.
                 *
                 *
                 * Without further ado, the loop:
                 */ 
    ?>
        <?php while ( have_posts() ) : the_post(); ?>
         
         
                        <div id="post-<?php the_ID(); ?><?php post_class(); ?>>
                       
                                <?php if ( !is_search() ) { ?>
                                <h3 class="entry-title excpts vfont" style="margin: 0px;"><?php the_title(); ?></h3>
                                <div class="vmeta smallfont">
                                        <?php ntl_posted_on(); ?><a href="<?php echo get_author_posts_urlget_the_author_meta'ID' )); ?>"><?php echo get_the_author(); ?></a>
                                </div>
                                <?php
                                $pphoto 
    '';
                                
    $pphoto get_the_post_thumbnail($post->ID'imlink');
                                if (
    $pphoto) {
                                
    ?>
                               
                                <div class="excpt">
                                        <?php the_excerpt(); ?>
                                       
                                </div>
                                <div class="menu-content" style="width: 286px; position: relative;">
                                <div class="mencontent">
                                        <div class="imgblock" ><div class="imlk imgoverlink6 menimg">
                                        <?php the_post_thumbnail('imlink'); ?>
                                        <a href="<?php the_permalink(); ?>"><span class="imgblockover imgoverlink6">&nbsp;</span></a>
                                        </div></div>
                                        <div class="ctime clear smallfont">
                                <?php the_time('j'?>
                                <?php the_time('M'?>
                                        </div> 
                                </div>
                                </div>
                                <?php } else { ?>
                                <?php the_excerpt(); ?>
                                <?php ?>
                               
                                <?php } else { ?>
                                <div class="foodmenu searchresult">
                                <h2 class="entry-title vfont excpts"><?php the_title(); ?></h2>
                                <?php the_excerpt(); ?>
                                <a href="<?php the_permalink(); ?>">Read More</a>
                                <span class="clear"></span>
                                </div>
                                <?php ?>
         
                        </div>
         
                        <?php comments_template''true ); ?>
         
        <?php endwhile; ?>
    And the theme:
    http://music1.netlabs.co.za/
    http://music1.netlabs.co.za/?cat=7



    Any suggestions would be much appreciated!
    Last edited by Mittineague; Apr 28, 2014 at 18:25. Reason: reformatting bbcode tags

  3. #3
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try naming the file home.php or front-page.php

  4. #4
    SitePoint Member
    Join Date
    Jun 2014
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is a solution which you don't have to touch any line of code.
    Just use Content Views plugin http://wordpress.org/plugins/content...lay-post-page/

    It has option for you to query posts by category, and display posts any where you want just by past shortcode.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •