Last active
August 29, 2018 11:15
-
-
Save ebi3102/c246f3b1bc4ee53edb8243523c121103 to your computer and use it in GitHub Desktop.
custom post list for wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Wordpress Theme | |
* @subpackage wordpress-theme | |
* @since Wordpress Theme 1.0 | |
* Template Name: Template-post-list | |
*/ | |
/* How to Use it | |
for use of this file you should copy it into your theme directory | |
then create a page in your wordpress admin dashboard and set it's template | |
to " Template-post-list". | |
*/ | |
?> | |
<?php get_header() ; ?> | |
<?php //define table for showing post list ?> | |
<style> | |
table { | |
border-collapse: collapse; | |
} | |
table, th , td { | |
border: 1px solid black; | |
} | |
</style> | |
<table> | |
<tr>Rows</th> | |
<th>Custom Post Title</th> | |
<th>Custom Post Cat...</th> | |
<th>Related Post Cat...</th> | |
</tr> | |
<?php | |
$args = array( | |
'post_type' => 'article',//it can be any cpt | |
'post_status' => 'publish', | |
'paged' => $paged, | |
'posts_per_page' => 400,//you can change it to show more post | |
'caller_get_posts' => 1, | |
'order' => 'DESC' | |
); | |
$i=1; | |
$wp_query->query($args); | |
if ( $wp_query->have_posts() ) : while ($wp_query->have_posts() ) : $wp_query->the_post(); | |
?> | |
<tr> | |
<td><?php echo $i ; ?></td> | |
<td><a href="<?php the_permalink() ?>"> | |
<?php the_title(); ?> | |
</a></td> | |
<td><?php the_terms( $post->ID, 'rat', '', ' / ' ); ?></td> | |
<td><?php the_terms( $post->ID, 'classes', '', ' / ' ); ?></td> | |
</tr> | |
<?php $i++ ; ?> | |
<?php endwhile; endif; ?> | |
</table> | |
<?php get_footer() ; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment