[resolved] Sorting on taxonomy page : the chalenge! (2 posts)

  1. romuloctba
    Posted 3 years ago #

    Hi everyone.
    This is a chalenge like post because no one ever knows this :S
    I thought i was doing right, this code even worked on a archive page and in a loop-somethin.php file, but in taxonomy-name.php didn't. I'll show you, so you see if you can help me. Any help will be appreciated.
    opened by url query: alanaimoveis.com.br/cidade/matinhos/?post_type=imovel-para-venda
    it shows all post (from imovel-para-venda type, assigned with CIDADE (taxonomy) matinhos)
    What I need, is to order them by price (custom field wpcf-imovel-preco, created with beautifull plugin named Types)So i did this (after some research)

           	      		$argsvs = array(
           	      		'meta_key' => 'wpcf-imovel-preco',
           	      		'orderby' => 'meta_value',
           	      		'order' => 'ASC',
    			'posts_per_page' => 0
    	query_posts($argsv . $query_string);
    <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>

    as I said, it works beautifully on a archive page, the same code, except that I use a different kind of loop:

    $loop = new WP_Query( $argsvs );
    while ( $loop->have_posts() ) : $loop->the_post();
    see the difference?
    could you help me please?

  2. romuloctba
    Posted 3 years ago #

    Well, if anyone need something like this, i made it with

           	      		 $args = array_merge( $wp_query->query, array(
        'posts_per_page' => 0,
        'meta_key' => 'wpcf-imovel-preco' ,
        'orderby' => 'meta_value',
        ) );
        query_posts( $args );

    got this tip from http://www.shilling.id.au/2012/03/21/re-order-a-taxonomy-archive-page-using-a-custom-field/

    BUT, it works like this:
    post1) 120.000,00 post2) R$ 130.000,00, post3) R$ 140.000,00 and so on, until postx) 200.000,00 then postx+1) R$ 35.000,00 postx+2) R$ 350.000,00 postx+3) R$ 76.025,00
    any ideas?
    I think i'll make another post in the forum, because the question I made in this one is solved. If anyone knows what happened with the values, pls help me by MP or in my new post

Topic Closed

This topic has been closed to new replies.

About this Topic