Forums

Order posts by category (3 posts)

  1. 2ne
    Member
    Posted 2 years ago #

    Hello i have created a php page called catergory-28.php to call in my portfolio catergory which consists of to children (my vidoes and my designs). I would like to know how to make it so it shows my vidoes then my design posts. Thanks in advance.

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header(); ?>
    
    <div class="catpost";>
    <h2>My Portfolio<p></h2><small>Hello</small>
    </div>
    
    	<div id="content" class="musiccolumn" role="main">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="designpost" id="designpost-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
            <small>my portfolio</small>   
    
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    			</div>
    		</div>
    <?php endwhile; ?>
    
    		<div class="navigation">
    <?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_footer(); ?>
  2. 2ne
    Member
    Posted 2 years ago #

  3. MichaelH
    Volunteer
    Posted 2 years ago #

    I would like to know how to make it so it shows my vidoes then my design posts.

    Maybe this will give you an idea. Change the 'include'=>'1,2,3' to be your categories:

    <?php
    $taxonomy = 'category';//  e.g. post_tag, category
    $param_type = 'category__in'; //  e.g. tag__in, category__in
    $term_args=array(
      'include' => '1,2,3',
      'orderby' => 'name',
      'order' => 'ASC'
    );
    $terms = get_terms($taxonomy,$term_args);
    if ($terms) {
      foreach( $terms as $term ) {
        $args=array(
          "$param_type" => array($term->term_id),
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => -1,
          'caller_get_posts'=> 1
          );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo 'List of Posts in '.$taxonomy .' '.$term->name;
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
          endwhile;
        }
      }
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.