WordPress.org

Ready to get started?Download WordPress

Forums

Category based post (1 post)

  1. praveen68
    Member
    Posted 1 year ago #

    Hi, I am designing a custom wordpress site on wamp server. It has to go up soon. This is my first wordpress custom project so please bare with me if I am being silly. Thanks.
    I have created a category catering_menu. A template single-category_catering_menu.php for displaying 1 post on that category. I have modified a single.php. Created a single_default.php as well. I am facing few issues like;
    When I preview a new post it shows but when i press previous post link it displays the same new post but the address bar shows previous post link.
    When I edit an older post it has the same issue.
    When I change the theme to twentytwelve theme it shows properly and next previous working properly.
    What am I doing wrong. What is missing.
    Please help. Below are the files' codes.

    --File single-category_catering_menu.php---
    <?php get_header(); ?>
    <div class="grid-6">Catering</div>
    <div class="grid-6 nextPrev">Next Previous</div>
    <div class="grid-8 planMenuBgd">
    <?php query_posts('cat=10&posts_per_page=1'); ?>
    <?php if (have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <h2 class="title"><?php the_title(); ?></h2>
    <div class="entry">
    <?php the_content(); ?>
    </div>
    <div class="navigation">
    <span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'FaitMaison' ) . '</span> %title', 'TRUE' ); ?></span>
    <span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'FaitMaison' ) . '</span>', 'TRUE' ); ?></span>
    </div><!-- end navigation -->

    <?php endwhile; endif; ?>
    </div>
    <div class="grid-4"><?php get_sidebar(); ?></div>
    <?php get_sidebar('catering'); ?>
    <?php get_footer(); ?>

    --single.php
    <?php
    $post = $wp_query->post;
    if (in_category('catering_menu')) {
    include(TEMPLATEPATH.'/single-category_catering_menu.php');
    }
    else{
    include(TEMPLATEPATH.'/single_default.php');
    }
    return;
    ?>

    -- file single_default.php
    <?php
    get_header(); ?>

    <div class="grid-8 planMenuBgd">
    <?php while ( have_posts() ) : the_post(); ?>
    <?php the_content(); ?>
    <div class="navigation">
    <span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'FaitMaison' ) . '</span> %title', 'TRUE' ); ?></span>
    <span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'FaitMaison' ) . '</span>', 'TRUE' ); ?></span>
    </nav><!-- .nav-single -->
    <?php endwhile; // end of the loop. ?>
    </div><!-- END GRID-8 -->

    <?php get_sidebar(blog); ?>
    <?php get_footer(); ?>

    ---file category.php---
    <?php get_header(); ?>

    <div class="grid-8 planMenuBgd">

    <?php if ( have_posts() ) : ?>
    <header class="archive-header">
    <h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'FaitMaison' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>

    <?php if ( category_description() ) : // Show an optional category description ?>
    <div class="archive-meta"><?php echo category_description(); ?></div>
    <?php endif; ?>
    </header><!-- .archive-header -->

    <?php
    /* Start the Loop */
    while ( have_posts() ) : the_post();
    <?php the_content(); ?>

    endwhile;
    ?>

    <?php else : ?>
    <?php get_template_part( 'content', 'none' ); ?>
    <?php endif; ?>

    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thank you in Advance. :-)

Topic Closed

This topic has been closed to new replies.

About this Topic