Display Posts (any custom post type), Terms (any custom taxonomy), Users (any role) on Content or Widget Areas by placing a shortcode. Select what to show and design how to show it. Using the plugin is really easy. You will find Tinymce button on post/page editor to quickly inset a list. Also, there’s a separate page for creating or editing list.
Faqs:
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.
function w4pl_extra_shortcode( $s ) {
$s['my_dynamic_field'] = array(
'group' => 'Post',
'callback' => 'my_dynamic_field_action',
'desc' => ''
);
return $s;
}
add_filter( 'w4pl/get_shortcodes', 'w4pl_extra_shortcode', 30 );
function my_dynamic_field_action( $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;
}
- my_dynamic_field: This is the name of the shortcode that you will use on Template field. Like
[my_dynamic_field]
- 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.