WordPress.org

Forums

secondary loop on home page (2 posts)

  1. jrcollins
    Member
    Posted 1 year ago #

    I'm using a Woocommerce theme that has a post at the top of the page, then a featured products section, and a recent products section at the bottom.

    I want to remove the recent products section and replace it with a second loop to show post excerpts but excluding the category of the post already shown at the top of the page.

    So far I've only been getting errors. The code I'm using for the second loop is as follows:

    <?php query_posts('cat=-83'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    The code I'm using to actually display the posts is the same as that used to display the "featured post" at at the top of the page, which is:

    <article>
    <?php post_class(); ?>>
    <?php if ( isset( $woo_options['woo_post_content'] ) && $woo_options['woo_post_content'] != 'content' ) { woo_image( 'width=' . $woo_options['woo_thumb_w'] . '&height=' . $woo_options['woo_thumb_h'] . '&class=thumbnail ' . $woo_options['woo_thumb_align'] ); } ?>
    <header>
    <h2>
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    </h2>
    </header>
    <section class="entry">
    <?php if ( isset( $woo_options['woo_post_content'] ) && $woo_options['woo_post_content'] == 'content' ) { the_content( __( 'Continue Reading →', 'woothemes' ) ); } else { the_excerpt(); } ?></section>
    </article><!-- /.post -->

    So the code in its entirety is as follows:

    <?php query_posts('cat=-83'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <article <?php post_class(); ?>>
    <?php if ( isset( $woo_options['woo_post_content'] ) && $woo_options['woo_post_content'] != 'content' ) { woo_image( 'width=' . $woo_options['woo_thumb_w'] . '&height=' . $woo_options['woo_thumb_h'] . '&class=thumbnail ' . $woo_options['woo_thumb_align'] ); } ?>
    <header>
    <h2>
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    </h2>
    </header>
    <section class="entry">
    <?php if ( isset( $woo_options['woo_post_content'] ) && $woo_options['woo_post_content'] == 'content' ) { the_content( __( 'Continue Reading →', 'woothemes' ) ); } else { the_excerpt(); } ?></section>
    </article><!-- /.post -->
    <?php endwhile; ?>

    This is the error I'm getting:
    Parse error: syntax error, unexpected $end in...

  2. Michael
    Forum Moderator
    Posted 1 year ago #

    assuming that your theme is not from https://wordpress.org/themes/, please contact the developer of your theme for support.

    this forum does not support commercial themes; http://codex.wordpress.org/Forum_Welcome#Commercial_Products

    for secondary loops, please review http://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts?rq=1
    and for loops in general http://codex.wordpress.org/The_Loop

Topic Closed

This topic has been closed to new replies.

About this Topic