This plugin allows you to fetch posts.
Allows you to fetch posts from the database on the basis of the parameters you passed in the shortcode.
-
Download the plugin zip file from the given link(https://github.com/ShubhamGupta05/custom-shortcode)
-
Click on Code button and select Download Zip.
-
Once the file gets downlaoded. Go to your site dashboard.
-
Click on the Plugin tab in the left panel.
-
Click on Add New plugin.
-
Click on the Upload Plugin button.
-
Select the file you downloaded and click on Install now.
-
Once the plugin is install. It will ask for the activation.
-
Click on Activating plugin button.
-
Once the plugin is activated. You are ready to use it.
-
Open a page or a post on which you want to display the post.
-
Add the shortcode block to the page or post.
-
In the short code block add this [custom_shortcode posts_per_page=4 post_type='post'] in the shortcode name field.
-
Publish the page or post.
List of the parameters that can be passed while calling the shortcode:
- Posts_per_page ( Pass the number of posts you want to display. Maximum limit is set to 100)
(Optional)(Number)
Example:- [custom_shortcode posts_per_page = 5] - Post_type ( Pass the post type for which you need the post )
(Required*)(String)
Example:- [custom_shortcode post_type = 'post'] - Name ( Pass the name of the post you want to display)
(Optional)(String)
Example:- [custom_shortcode name = 'this is my first post'] - Author_name (Pass the name of the author whose post you want to display)
(Optional)(String)
Example:- [custom_shortcode author_name = 'Shubham'] - post_status (Pass the status of the post which you want to display example: published, draft, revision, attachement)
(Optional)(String)
Example:- [custom_shortcode post_status = 'published'] - order (Pass Asc or Desc to display your posts in the order you want)
(Required)(String)
Example:- [custom_shortcode order = 'DESC'] - Orderby ( Pass the keyvalue on the basis of which you want to sort you posts)
(Optional)(String)
Example:- [custom_shortcode orderby = 'date'] - Post__not_in (Pass post id's to exclude that post)
(Optional)(Array of Id's)
Example:- [custom_shortcode post__not_in = 'array(1,2,3)'] - Date_query_after (Pass the date to show the posts created after this date)
(Optional)(Date format in mm-dd-yy)
Example:- [custom_shortcode date_query_after = 'September 1st, 2021'] - Date_query_before (Pass the date to show the posts created before this date)
(Required with the date_query_after parameter)(Date format in mm-dd-yy)
Example:- [custom_shortcode date_query_after = 'September 1st, 2021' date_query_before = 'September 30th, 2021'] - Date_query_inclusive (Pass the value in true or false to tell whether the exact value should be matched or not)
(Required with the date_query_after parameter)(Boolean Value)
Example:- [custom_shortcode date_query_after = 'September 1st, 2021' date_query_before = 'September 30th, 2021' date_query_inclusive = 'true'] - Pagename (Pass the name of the page you wish to display)
(Optional)(String)
Example:- [custom_shortcode pagename = 'checkshortcode'] - Search (s) (Pass the value you want to search in the post)
(optional)(string)
Example:- [custom_shortcode s = 'this'] - Category_name (Pass the category slug name to show the posts related to this category)
(Optional)(String)
Example:- [custom_shortcode category_name = 'mypost'] - category__not_in (Pass category id's to exclude the posts from these categories)
(Optional)(Array of category Id's)
Example:- [custom_shortcode category__not_in = 'array(1,2,3)'] - Tag (Pass the tag slug name to show all the posts related to this tag)
(Optional)(String)
Example:- [custom_shortcode tag = 'action'] - Tag__not_in (Pass tag id's to exclude the posts having that tags)
(Optional)(Array of tag Id's)
Example:- [custom_shortcode tag__not_in = 'array(1,2,3)'] - comment_count (Pass the value to see the posts having this much number of commets )
(Optional)(Number)
Example:- [custom_shortcode comment_count = '2'] - tax_query_taxonomy (Pass the name of the custom taxonomy from which you want to display the posts)
(Optional)(String)
Example:- [custom_shortcode tax_query_taxonomy = 'movie'] - tax_query_field (Pass the slug value of the taxonomy added in the tax_query_taxonomy parameter)
(Required with tax_query_taxonomy)(string)
Example:- [custom_shortcode tax_query_taxonomy = 'movie' tax_query_field = 'movie'] - tax_query_terms (Pass the value from the taxonomy terms)
(Required with the tax_query_taxonomy parameter)(string)
Example:- [custom_shortcode tax_query_taxonomy = 'movie' tax_query_field = 'movie' tax_query_field = 'action'] - meta_key (Pass string value)
(Optional)(String)
Example:- [custom_shortcode meta_key = 'price'] - meta_value_num ( Works in conjuntion with orderby)
(Required with meta_key parameter)(String)
Example:- [custom_shortcode meta_key = 'price' meta_value_num = 100] - meta_compare ( Pass compare key such as “>” “<” “!=” etc while comparing two or more meta value)
(Required with meta_key & meta_value_num parameter)(String)
Example:- [custom_shortcode meta_key = 'price' meta_value_num = 100 meta_compare = '>'] - post_mime_type ( Pass the Type of Attachment which you wish to show)
(Optional)(String)
Example:- [custom_shortcode post_mime_type = 'array('jpg','png','gif')']
If no parameters are passed to a shortcode, it will fetch posts according to the default parameters given.