Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://www.wpbeginner.com/wp-tutorials/how-to-display-recent-posts-from-a-specific-category-in-wordpress/
- ======================
- MASTER SCRIPT KODE:
- ======================
- <?php
- $catquery = new WP_Query( 'cat=3&posts_per_page=10' );
- while($catquery->have_posts()) : $catquery->the_post();
- ?>
- BENTUK LOOP POST disini
- <?php endwhile; ?>
- KETERANGAN:
- 1. Angka 3 adalah ID Category
- 2. Angka 10 adalah banyaknya tampilan post
- CONTOH PEMAKAIAN:
- 1. Seperti Home Buku
- <?php
- $catquery = new WP_Query( 'cat=1&posts_per_page=10' );
- while($catquery->have_posts()) : $catquery->the_post();
- ?>
- <div class="post-box">
- <div class="view view-seventh">
- <img src="/img/cover/<?php the_title(); ?>.jpg" style="width:164px;" onError="this.src='/nocover.jpg';">
- <div class="mask">
- <h2>
- <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'themater' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
- <?php the_title(); ?></a>
- </h2>
- <p><span class="meta_tags">by <?php the_tags('', ', ', ''); ?></span> <span class="meta_date"><?php echo get_the_date(); ?></span> <span class="meta_categories"><?php the_category(', '); ?></span> <span class="meta_edit"><?php edit_post_link(); ?></span></p>
- <a href="<?php the_permalink(); ?>" class="info">Read More</a>
- </div>
- </div>
- </div>
- <?php endwhile; ?>
- 2. Asli Bawaan Contoh Sumber
- <?php
- $catquery = new WP_Query( 'cat=3&posts_per_page=10' );
- while($catquery->have_posts()) : $catquery->the_post();
- ?>
- <ul>
- <li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
- <ul><li><?php the_content(); ?></li>
- </ul>
- </li>
- </ul>
- <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement