• Resolved 94luca

    (@94luca)


    Hi everyone!
    I know, there are dozens of posts with similar problems and I’ve tried all the possibile solutions (probably just missing the right one.. haha)

    Like the title, i want to order the posts in a specific category by a custom field created by Types plugin and called “position” (it’s a numeric value, like “20150220”)

    Now, in the “category.php” page I’ve try this code:

    if(is_category('77')){
    	query_posts('cat=77&meta_key=position&orderby=meta_value&order=ASC');}

    and then the page continues with:

    <?php if ( have_posts() ) : ?>
    	<?php while ( have_posts() ) : the_post(); ?>
    		<?php
    		/* Get the content template */
    		get_template_part( 'content', get_post_format() );
    		?>
    	<?php endwhile; ?>
    <?php else : ?>
    	<?php
    	/* Get the none-content template (error) */
    	get_template_part( 'content', 'none' );
    	?>
    <?php endif; ?>

    But the result is: “No articles found”

  • The topic ‘How to order posts by custom field in a specific category’ is closed to new replies.