WordPress.org

Ready to get started?Download WordPress

Forums

Show only 12 post for each categories - portfolio (2 posts)

  1. il_cordio
    Member
    Posted 9 months ago #

    Goodmorning,
    I want to show only 12 post for each categories in my portfolio page.
    I've read some solutions but I'm very confused.
    if anyone can help me I would be very grateful
    This is my code:
    ...

    <?php
    			$portfolio_args = array(
    				'post_type' => 'project',
    				//'posts_per_page' => 12,
    				'showposts' => (int) et_get_option('flexible_homepage_numposts_projects'),
    				'tax_query' => array(
    					array(
    						'taxonomy' => 'project_category',
    						'field' => 'id',
    						'terms' => (array) et_get_option('flexible_homepage_exlcats_projects'),
    						'operator' => 'NOT IN'
    					)
    				)
    			);
    
    			$categories = get_terms( 'project_category', array( 'exclude' => (array) et_get_option('flexible_homepage_exlcats_projects') ) );
    
    			if ( $categories ){
    				echo '<ul id="et_portfolio_sort_links">';
    					//echo '<li class="active">' . '<a href="#">' . __( 'All', 'Flexible' ) . '</a>' . '';
    					foreach ( $categories as $category ){
    						echo '
    <li>' . '<a href="#">term_taxonomy_id ) . '">' . esc_html( $category->name ) . '</a>' . '</li>
    ';
    					}
    				echo '';
    			}
    		?>
    
    		<div id="portfolio-grid" class="clearfix">
    		<?php
    			$portfolio_query = new WP_Query( apply_filters( 'et_home_portfolio_args', $portfolio_args ) );
    			while ( $portfolio_query->have_posts() ) : $portfolio_query->the_post();
    				get_template_part( 'includes/entry', 'portfolio' );
    			endwhile;
    			wp_reset_postdata();
    		?>
    		</div> <!-- end #portfolio-grid -->
    	</section> <!-- end #portfolio -->
    <?php } ?>
    ...

    [Moderator Note: Please post code or markup between backticks or use the code button. Or better still - use a pastebin. Your posted code may now have been permanently damaged by the forum's parser.]

    Thank you!

  2. il_cordio
    Member
    Posted 9 months ago #

    Sorry, I re-post the code:

    <?php
    			$portfolio_args = array(
    				'post_type' => 'project',
    				//'posts_per_page' => 12,
    				'showposts' => (int) et_get_option('flexible_homepage_numposts_projects'),
    				'tax_query' => array(
    					array(
    						'taxonomy' => 'project_category',
    						'field' => 'id',
    						'terms' => (array) et_get_option('flexible_homepage_exlcats_projects'),
    						'operator' => 'NOT IN'
    					)
    				)
    			);
    
    			$categories = get_terms( 'project_category', array( 'exclude' => (array) et_get_option('flexible_homepage_exlcats_projects') ) );
    
    			if ( $categories ){
    				echo '<ul id="et_portfolio_sort_links">';
    					//echo '<li class="active">' . '<a href="#" data-categories_id="all">' . __( 'All', 'Flexible' ) . '</a>' . '</li>';
    					foreach ( $categories as $category ){
    						echo '<li>' . '<a href="#" data-categories_id="' . esc_attr( 'project_cat_' . $category->term_taxonomy_id ) . '">' . esc_html( $category->name ) . '</a>' . '</li>';
    					}
    				echo '</ul>';
    			}
    		?>
    
    		<div id="portfolio-grid" class="clearfix">
    		<?php
    			$portfolio_query = new WP_Query( apply_filters( 'et_home_portfolio_args', $portfolio_args ) );
    			while ( $portfolio_query->have_posts() ) : $portfolio_query->the_post();
    				get_template_part( 'includes/entry', 'portfolio' );
    			endwhile;
    			wp_reset_postdata();
    		?>
    		</div> <!-- end #portfolio-grid -->
    	</section> <!-- end #portfolio -->
    <?php } ?>

Reply

You must log in to post.

About this Topic