How can edit the code so only a certain amount of categories show on the homepage?
I want to edit the code so no matter how many categories i select the homepage will only show two.
Sorry that our previous solution was a bit confusing and not really helpful.
Please find my new solution here:
Step 1 Open wp-content/themes/dw-argo/index.php file with a Code editor (Sublime text 2 or Notepad++)
Step 2 Find those codes (See screenshot: http://i.imgur.com/pqMP9Zt.jpg):
<?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php dw_paging_nav(); ?> <?php else : ?> <?php get_template_part( 'content', 'none' ); ?> <?php endif; ?>
Then change to (See screenshot: http://i.imgur.com/oNgVqhd.jpg):
<?php $wp_query = new WP_Query('post_type=post&category_name=coding');?> <?php if ( $wp_query->have_posts() ) : ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php dw_paging_nav(); ?> <?php else : ?> <?php get_template_part( 'content', 'none' ); ?> <?php endif; ?> <?php wp_reset_postdata(); ?>
Note: Remember to change category_name=coding with your category as you want to display to the homepage.
You can find categories name by go to Dashboard > Posts > Categories. Then see the column Slug. See screenshot: http://i.imgur.com/xEu5NbI.jpg
Another thing, to use multiple categories, you just add more slug like: category_name=coding, wordpress, design
Hope this helps,
Jackie
Please login or Register to submit your answer