W4 Post List – WordPress Plugin

Straight to an example:

Below we are displaying our posts in table. We have included date, feature image & post title.

Do you see the table has css styles ? Great. However, those styles aren’t coming from plugin, rather it’s coming from our themes stylesheet. The theme use bootstrap, so we have just used few class names to a table element. And w4 post list have provided us with all of the flexibility to create a template matching our needs. It’s just simple.

More examples, more digging in..

Plugin Usage: 1 Plugin Usage: 2 Plugin Usage: 3


Use shortcode [nav]. The [nav] shortcode support two arguments – type & ajax. type=”plain” will put pagination made with a tags, nothing around it. type="list" will display pagination within a ul > li list. by default it will display previous or next page link. Now, setting ajax=1 will make the pagination work without redirecting the page. That mean it will use ajax call to get the next page content and replace the current content. Leaving it empty will make the pagination word with a query variable. The query variable is a little bit ugly, but it has been use so that you can maintain multiple list pagination used on the same page without conflict.
This is the complete template of your list. You can use HTML plain text and shortcodes there. There are multiple shortcodes you can use there, but two common shortcodes are – [nav] and [posts]. Where [nav] is replaced by pagination/navigation and [posts] is replaced by the posts
There many of them, you can view the on your have installed the plugin on your WordPress site. When the plugin is active, go to the W4 Post List Documentation page to find out which tags are available. Alternatively, when you are creating/editing a post list, you can view them under the “Loop Template” field by clicking on “View Shortcodes”
To display posts grouped by category, use the Group By option. If selected post type supports categories, post_tags, you will be able to see it on the list. Available option automatically changes based on the post type. You also need to use group shortcode to display group information and blocks.

Creating a New Shortcode

Our plugin only allow shortcodes provided by itself. So no regular shortcode get parsed when you use them on Template field. But, you can create a new shortcode tag using a simple filter.

To register a new shortcode for W4 Post list, use w4pl/get_shortcodes filters.

add_filter('w4pl/get_shortcodes', 'w4pl_extra_shortcode', 30);
function w4pl_extra_shortcode( $s ){
	$s['myDynamicField'] = array(
		'group' 	=> 'Post',
		'callback' 	=> 'myDynamicFieldAction',
		'desc' 		=> ''
	return $s;
  • myDynamicField: This is the name of the shortcode that you will use on Template field. Like [myDynamicField]
  • group: this is where it will be visible on template group. not important
  • callback: required. A php callback function name, Or a public static class method name. Which will be used to replace the content of the shortcode.
  • desc: textual description of the shortcode, it’s displayed on the Documentation page.

The following function is similar to WP’s basic shortcode callback function.

function myDynamicFieldAction( $attrs, $content ){
	$return = '';
	$return .= 'Good ';
	if( date('h') > 5 && date('h') < 11 ){
		$return .= 'Morning';
	elseif( date('h') < 17 ){
		$return .= 'Afternoon';
	elseif( date('h') < 20 ){
		$return .= 'Evening';
	elseif( date('h') < 20 ){
		$return .= 'Night';
	return $return;