• On this site https://nurdit.com/spungold/project/wogam-now-then/ Where it says ‘You Might Also Like’ is there a way to orderby genre/category rather than ‘rand’ to show other portfolios of the same category?

    <!--Portfolio-->
    
    <section id="portfolio">
    
    	<div class="wrap clearfix">
    
    		<h1><?php _e( 'You Might Also Like', 'mighty' ); ?></h1>
    
    		<?php
    			if( is_singular( 'portfolio' ) ) :
    				$current = $post->ID;
    				$loop = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => 3, 'orderby' => 'rand', 'post__not_in' => array( $current ) ) );
    			else :
    				$loop = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => 3, 'orderby' => 'rand' ) );
    			endif;
    
    			$count = 1;
    		?>
    
    	<?php if ( $loop->have_posts() ) : ?>
    
    		<div class="clearfix">
    
    		<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    			<!-- Article -->
    			<article class="post<?php if( $count %3 == 0 ) { echo ' last'; }; $count ++; ?>" itemscope="itemscope" itemtype="https://schema.org/CreativeWork" itemprop="associatedArticle">
    
    				<?php if ( has_post_thumbnail() ) : ?>
    
    					<a href="<?php the_permalink(); ?>" title="<?php _e( 'View more of', 'mighty' ); ?> - <?php the_title(); ?>" rel="bookmark">
    						<?php the_post_thumbnail( 's' ); ?>
    						<div class="overlay"></div>
    						<span><?php the_title(); ?></span>
    					</a>
    
    				<?php endif; ?>
    
    			</article>
    
    		<?php endwhile; ?>
    
    		</div>
    
    		<?php wp_reset_postdata(); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    </section>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘orderby => question’ is closed to new replies.