Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Wordpress theme only displaying 1 post

  • 31-07-2012 11:35PM
    #1
    Registered Users, Registered Users 2 Posts: 289 ✭✭


    Hi all,

    I am working on a Wordpress them, and need to have a couple of pages displaying posts.

    Currently I have the default page to display posts set to my homepage, however I need another page to display items in posts style for a list of drivers. Each post is a driver.

    The code I am using for the template is as follows:

    [PHP]<?php
    /*
    Template Name: Drivers
    */
    ?>
    <?php get_header(); ?>
    <div class="container_12_wrap">
    <div class="container_12_wrap_inside">

    <div class="container_12">
    <div id="content" class="grid_8">

    <?php
    query_posts('cat=6');
    while (have_posts()) : the_post();
    endwhile;
    ?>

    <?php get_template_part( 'content-drivers' ); ?>


    </div> <!-- end #content -->
    <?php get_sidebar(); ?>
    </div>

    </div>
    </div>
    <?php get_footer(); ?>[/PHP]However I can only get it to display the single oldest post, as opposed to all of them?

    The template 'Content-Drivers' looks as follows:

    [PHP]<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <?php $entry_title = ( 'page' == get_post_type() && radius_post_edit_link() == "" )? 'entry-title entry-title-page' : 'entry-title'; ?>
    <h1 class="<?php echo $entry_title; ?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr( 'Permalink to %s' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>

    <?php if ( 'post' == get_post_type() ) : ?>

    <div class="entry-meta">
    <?php if ( is_sticky() ) : printf( '<span class="entry-meta-sep"> ⋅ </span> <span class="entry-meta-featured">%1$s</span>', __( 'Featured', 'radius' ) ); endif; ?>
    <?php echo radius_post_edit_link(); ?>
    </div>
    <!-- .entry-meta -->

    <?php elseif ( 'page' == get_post_type() && radius_post_edit_link() != "" ) : ?>
    <div class="entry-meta">
    <?php echo radius_post_edit_link(); ?></div>

    <?php endif;?>

    <div class="entry-content">
    <?php radius_featured_image(); ?>
    <?php radius_post_style(); ?>
    <?php echo radius_link_pages(); ?>
    <div class="clear"></div>
    </div> <!-- end .entry-content -->
    <!-- .entry-meta-bottom -->

    </div> <!-- end #post-<?php the_ID(); ?> .post_class -->[/PHP]This file works fine as 'content' when being used to manage the default news page.

    Any help would be much appreciated.

    Rgds,

    Paul.
    Tagged:


Comments

  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    You need to output within your posts loop:

    [PHP]<?php
    query_posts('cat=6');
    while (have_posts()) : the_post();

    // output your posts here...

    endwhile;
    ?>[/PHP]


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    Hi there,

    Thanks a million for that.

    I've copied your code and merged it with what I have posted above, obviosuly not duplicating anything I'm getting the same result, only 1 post (the oldest one) being displayed.

    Any further assistance much appreciated.

    Regards,

    Paul

    PS: New code below (Template name has been updated to ensure I was using the correct new code!)

    [PHP]<?php
    /*
    Template Name: Drivers NEW
    */
    ?>
    <?php get_header(); ?>
    <div class="container_12_wrap">
    <div class="container_12_wrap_inside">

    <div class="container_12">
    <div id="content" class="grid_8">

    <?php
    query_posts('cat=6');
    while (have_posts()) : the_post();

    // output your posts here...

    endwhile;
    ?>

    <?php get_template_part( 'content-drivers' ); ?>


    </div> <!-- end #content -->
    <?php get_sidebar(); ?>
    </div>

    </div>
    </div>
    <?php get_footer(); ?> [/PHP]


  • Registered Users, Registered Users 2 Posts: 342 ✭✭adm


    Move get_template_part inside the while loop:

    [PHP]
    <?php
    /*
    Template Name: Drivers NEW
    */
    ?>
    <?php get_header(); ?>
    <div class="container_12_wrap">
    <div class="container_12_wrap_inside">

    <div class="container_12">
    <div id="content" class="grid_8">

    <?php
    query_posts('cat=6');
    while (have_posts()) : the_post();

    // output your posts here...
    get_template_part( 'content-drivers' );

    endwhile;
    ?>




    </div> <!-- end #content -->
    <?php get_sidebar(); ?>
    </div>

    </div>
    </div>
    <?php get_footer(); ?> [/PHP]


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    Hi adm,

    That was perfect!

    Thanks a million to yourself and fcrossen for your help.

    Rgds,

    Paul.


Advertisement