WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can't change order of custom posts (3 posts)

  1. csimpson
    Member
    Posted 2 years ago #

    Hi everyone

    new here and been searching everywhere for the answer before coming here, hopefully someone with experience can help me swiftly.

    I have been unable to change the order of my custom "portfolio" posts. I would like the order to be ascending by title - not in reverse by creation date as default.

    I think I have found the right file and code but cannot correctly modify it, I appreciate and welcome any changes to code,

    regards Craig

    <div id="content" class="grid_23 prefix_1">
    	<?php include_once (TEMPLATEPATH . '/title.php');?>
      <?php global $more;	$more = 0;?>
      <?php $values = get_post_custom_values("category-include"); $cat=$values[0];  ?>
      <?php $catinclude = 'portfolio_category='. $cat ;?>
    
      <?php $temp = $wp_query;
    	$wp_query= null;
    	$wp_query = new WP_Query(); ?>
      <?php $wp_query->query("post_type=portfolio&". $catinclude ."&paged=".$paged.'&showposts=9'); ?>
      <?php if ( ! have_posts() ) : ?>
    	<div id="post-0" class="post error404 not-found">
    		<h1 class="entry-title"><?php _e( 'Not Found', 'theme1417' ); ?></h1>
    		<div class="entry-content">
    			<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'theme1417' ); ?></p>
    			<?php get_search_form(); ?>
    		</div><!-- .entry-content -->
    	</div><!-- #post-0 -->
    <?php endif; ?>
  2. President McCheese
    Member
    Posted 2 years ago #

    $wp_query->query("post_type=portfolio&". $catinclude ."&paged=".$paged.'&showposts=9&orderby=title&order=asc'); ?>

  3. csimpson
    Member
    Posted 2 years ago #

    worked an absolute treat, thank you so much Jason. I do plan to learn PHP as soon as possible now as developing sites with wordpress is so good. Would you mind me asking if I would be better off starting learning PHP as opposed to any specific wordpress courses/style of language?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.