[catposts cat-name="post-category-name"]
The above shortcode should be added to the page,where you want to display posts from a particular category say Sports in a news portal
[catposts cat-name="Sports"]If you want certain number of posts to be displayed in a particular page then mention the posts count as illustrated below
[catposts cat-name="Sports" posts-count="12"]h6>Dependencies to get striped and centered table include
materializecss.min.cssto the head of your page . To enable the shortcode goto the functions.php of your theme and add this code
include( get_stylesheet_directory() . '/dynamicposts.php' );
upload this dynamicposts.php file to root folder of your website's currently active theme . Note:
post-category-name
must be replaced with the desired common category name .
e.g., we added the shortcode [catposts cat-name="IR"]
and got the display as below,
With the increase of the posts in a particular category the table rows will be generated dynamically, displaying specific post data as shown below
⇓
Replace the code
<td>Not Set</td>
</tr>';
By the below code ⇓
';?> <td>//start
<?php
$custom = get_post_custom();
if(isset($custom['YOUR-CUSTOM-FIELD-NAME']))
echo $custom['YOUR-CUSTOM-FIELD-NAME'][0];
else
echo 'Not Set';
?></td>
<?php echo '</tr>'; //end