WordPress.org

Ready to get started?Download WordPress

Forums

Hemingway
[resolved] Where can i put the wp_query to get it work? (3 posts)

  1. Li Chong
    Member
    Posted 4 months ago #

    I want to modify some things in the theme, and i need to query some tags. But, when i put the <?php wp_query_posts() ?> the output explodes.

    So, where i put the query in the loop to get it working?

    For reference, this is the code i was working (is not modificated, is from index.php)

    <?php if (have_posts()) : ?>

    <div class="posts">

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $total_post_count = wp_count_posts();
    $published_post_count = $total_post_count->publish;
    $total_pages = ceil( $published_post_count / $posts_per_page );

    if ( "1" < $paged ) : ?>

    <div class="page-title">

    <h4><?php printf( __('Page %s of %s', 'hemingway'), $paged, $wp_query->max_num_pages ); ?></h4>

    </div>

    <div class="clear"></div>

    <?php endif; ?>

    <?php while (have_posts()) : the_post(); ?>

    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php
    foreach((get_the_category()) as $category) {
    echo '<img class="aligncenter" src="http://nefasto.cl/cat/' . $category->slug .'.jpg" alt="' . $category->cat_name . '" width="70%"/>';
    }
    ?>
    <?php get_template_part( 'content', get_post_format() ); ?>

    </div> <!-- /post -->

    <?php endwhile; ?>

    <?php endif; ?>

    </div> <!-- /posts -->

    <?php if ( $wp_query->max_num_pages > 1 ) : ?>

    <div class="post-nav archive-nav">

    <?php echo get_next_posts_link( __('« Leer los artículos<span> más antiguos</span>', 'hemingway')); ?>

    <?php echo get_previous_posts_link( __('Vea los<span> Artículos más recientes</span> »', 'hemingway')); ?>

    <div class="clear"></div>

    </div> <!-- /post-nav archive-nav -->

    <?php endif; ?>
    `

  2. Li Chong
    Member
    Posted 4 months ago #

    More info:

    If you can't understood what i need, i need to do a custom query.

    So, Where i put the custom query on the loop of Hemingway.

    That's all.
    Thanks for your time.

  3. Anders Noren
    Member
    Theme Author

    Posted 3 months ago #

    Hi Li Chong,

    I think that the content of this page will answer your question. You'll have to either reset the query or (preferably) use get_posts or create multiple query loops.

Reply

You must log in to post.

About this Theme

About this Topic