For this functionality I implemented the shortcode. So you can add it in your page/post or widgetized page. Click here to see the live preview of this functionality. Checkout the step-by-step instruction at below:
Initializing the [filter_by_category] shortcode by “init” hook. This hook is calling after WordPress has finished loading but before any headers are sent. [filter_by_category] shortcode have four parameters: ids, onload, limit and show_pagination. These parameters are explained in PHP scripts. You will add the following code in your functions.php file.
Showing the some examples of [filter_by_category] shortcode. So you can easily use it on your site (post/page or widget area).
- Without pagination: [filter_by_category ids=’23,45,26′ limit=’5′]
- With pagination: [filter_by_category ids=’23,45,26′ onload=’45’ limit=’3′ show_pagination=’yes’].
- ids: these are categories id.
- limit: Showing 3 posts per page
- onload: When page is loading for first time, then posts will load from this category. If you do not use it, posts will load from first category ID (here it will be 23)
- show_pagination: if you set “yes” then “load more” button will appear and Ajax based pagination will work. Default is “no”.
If you need help, feel free to contact me via the contact page.