WordPress - Custom posts generator
In this article
With this dynamic slide generator you can show the contents of your custom posts.
What are custom posts?
Plugins, which are storing multiple datas are usually saving down their contents as custom posts. For example WooCommerce's products are custom posts, Events Manager's events are custom posts and you could even use this generator to display them. In WordPress this appears the same way your regular WordPress pages and WordPress posts are displayed in a list. (By the way WordPress pages are custom posts as well.) This means, if you have a plugin, which shows your datas the same way in the admin area, then most likely you will be able to use our slider to display its contents.
There are plugins like Custom Post Type UI, which are allowing you to create custom posts and also a lot of themes are creating custom post types for specific purposes. For example, if you have a real estate theme, you might have an "apartments" or similar custom post type in it and if you have a cinema theme, you might have "movies" custom post type.
Tutorial
- 1
-
Creating a new dynamic slide
To get started, go to any Slider Settings page and add a new dynamic slide. Select
Posts
, and and choose one of the Custom generators. - 2
-
Configuring the generator
Set up your generator. Choose the settings you want. Popular options you probably want to configure: category where your content will be pulled from, the number of slides you want to have, the ordering of the content.
You can also click on the View Records button to see the data you'll be creating your slide with.
When you're done, click on
Add
. - 3
-
Editing the dynamic slide
After you saved your generator, you'll be redirected to the Slide Editor to set up the look of your slide. You can create your content by using variables.
Not sure what are the variables or how to use them? Learn how to work with variables.
Custom Posts (post)/Pages (page)
Creates slides from the following post type: post/page.
Configuration
You can use these options to set what you want your generator to show.
Filter
Taxonomies
Custom posts can have taxonomies, for example a post's category is a taxonomy, a tag is a taxonomy, etc., so the groups of your custom posts. You can filter based on these taxonomies and with the relation option you can select wether you want to get posts, where all the selected taxonomies are applied or where either one or the other applies. The relation option only works between the different taxonomies, not within one taxonomy. For example if you only have categories taxonomy and you select two categories, the relation between them will always be OR. If you have two taxonomies, like categories and tags, select one category and one tag, you can use this relation option to choose AND or OR relation between them.
Post IDs To Display
You can make your generator display only the posts with the set ID. No other post will be fetched, even if they match the set filters. Write one ID per line.
Exclude posts
The selected post IDs won't appear in the generator, even if they they match the set filters. Write one ID per line.
Post status
Posts can have different statuses, like "published", "pending", "confirmed" etc.. You can filter based on these.
Post Meta Comparison
Custom posts have meta keys, for example a product's price can be a meta key, and an event's starting date, too. Basically these are the datas of your posts. You can compare these keys with values, for example you could show posts, where the "onstock" value is "yes".
Field name
You can select a custom field name here. Only show posts, where the given meta key is equal to the given meta value.
Compare method
You can compare the field name with the field value. You can select from more methods.
Field value
Besides manually written texts or numbers, you can use some keywords, too.
Field type
It does matter whether you are comparing to for example words, numbers or dates. This field gives you all available type options your meta data can have.
Meta comparison
You can create other comparison based on the previous "Field name" and "Compare method" options. Use the following format: published||=||yes||CHAR
. You can manually write down any number of comparisons. Write one comparison per line.
Post option
You can select a post option here.
Post relationship with selected option
You can choose to only display posts, which are selected to be IN or NOT IN this option.
Tip for Post Meta Comparison
All meta datas of your posts are being asked down to create variables from them. The Post Meta Comparison works with the same meta datas. So if at the generator's settings you press the View records button, you can find all meta field names, just they will be called a little differently, like underlines are being removed or the word 'meta' will be added to them.
The reason why this helps is, because you can see their values. For example if you are not sure what comparison should happen with _stock_status to only ask down those product based posts, which are on stock, then check the variables and you will immidiately see, that 'instock' should be used in my example.
Date Configuration
You can make our code try to identify your date and time values to format + translate them. For the formatting you can find the usable characters here. (There isn't a PHP function, that can identify datetime values, because for example a simple number, like 1
could represent a time value too. So this is just a function written by us, which seems to work in most cases, but it is not a 100% working solution.)
Identify Datetime
Our system tries to identify the date and time in your variables.
Datetime Format
You can use any PHP date format.
Translate Dates
Write one per line in the following format: from||to
. E.g.: Monday||Montag
.
Replace Variables
Timestamp Variables
Timestamps cannot be identified, as any positive number can be a timestamp, but if you enter the timestamp variable's name, like starttime
, then you can make our code turn them into dates, using the given format. The "Datetime format" will be used to create dates from the given timestamp containing variables. Separate them with comma.
File Variables
If you have IDs of files, you can replace those variables with the urls of the files instead. Separate them with comma.
Remove Duplicate Results
You can remove results based on one variable's uniqueness. For example if you want the images to be unique, you could write the image
variable into this field.
This code has to happen after the custom posts were asked down, so the "Slides" number at your generator's settings represents all the slides and the not unique values will be removed from that. To be able to manage this better, you could write a bigger number into the "Slides" field, to surely have the number of slides you want and with the Maximum slide count option you would be able to set the number of slides you actually want.
Order
Field
The field which decides the ordering of your content.
- Post date
- ID
- Title
- Modification date
- Random
- Given IDs - If you used the "Only display these posts" option, you can make them appear with the given order.
- Menu order - Posts can have manual ordering in WordPress and this would show your posts in that order.
Order
The order direction.
- Ascending
- Descending
Custom Field Name
If this option is used, the Field setting won't be used anymore! Instead the meta data of the posts will be used. For example your events probably have EventStartDate
or similar meta datas, which would allow you to show the events in the order they are happening. Other example is, that your products have prices and you could show your cheapest products.
Order
Since you can store numeric and alphabetic values too, you have to select which one are you currently using for the ordering.
- Numeric
- Alphabetic
Generator Settings
Learn about the Generator Settings
at the Generator Settings documentation.
Variables
These are the available variables you can use to build your dynamic slide content in the Slide Editor.
Not sure what are the variables or how to use them? Learn how to work with variables.
- id - The id of the post.
- url - Url to the post.
- title - The title of the post.
- excerpt - Excerpt of the post.
WordPress automatically adds a "read more" link to excerpts in some cases. If you see this and you don't want it, you should rather use the description variable with split by chars. - modified - Date of the last modification.
- content, description - The content of the post.
- author, author_name - The display name of the post's author.
- author_url - Url to the website of the post's author.
- category_name - The name of the post's category.
- category_name_[x] - The name of the post's category. This variable was made, if you have multiple categories selected for your post, you can show more, not just the first one.
- category_link - Url to the post's category.
- category_link_[x] - Url to the post's category. This variable was made, if you have multiple categories selected for your post, you can show more, not just the first one.
- image, thumbnail, featured_image - The featured image of the post.
- image_[size] - Different image sizes for the featured image of the post.
- Advanced custom field variables. Advanced custom field stores their variables in many different ways, so it is not 100% that you can get all your variables!
ACF variables are asked down as meta variables too, so you can find duplicated variables:
- example
- examplevariable
- metaexample
- acf_example
- example_variable
In this example the ACF code created variables are the ones with "acf_" beginning and with "_" signs:
- acf_example
- example_variable
and you will have to use them, not the first three. The first three could have wrong values when you leave their fields empty.
- The meta datas of the post. Meta data can be stored in many different ways, so it is not 100% that you can get all your meta datas!
All custom posts
Creates slides from the posts of all your post types.
Configuration
You can use these options to set what you want your generator to show.
Filter
Post types
You can select a custom post type.
Taxonomies
Custom posts can have taxonomies, for example a post's category is a taxonomy, a tag is a taxonomy, etc., so the groups of your custom posts. You can filter based on these taxonomies and with the relation option you can select wether you want to get posts, where all the selected taxonomies are applied or where either one or the other applies. The relation option only works between the different taxonomies, not within one taxonomy. For example if you only have categories taxonomy and you select two categories, the relation between them will always be OR. If you have two taxonomies, like categories and tags, select one category and one tag, you can use this relation option to choose AND or OR relation between them.
Post IDs to display
You can make your generator display only the posts with the set ID. No other post will be fetched, even if they match the set filters. Write one ID per line.
Sticky
Posts can have options, like a post can be sticky or not.
Post status
Posts can have different statuses, like "published", "pending", "confirmed" etc.. You can filter based on these.
Post Meta Comparison
Custom posts have meta keys, for example a product's price can be a meta key, and an event's starting date, too. Basically these are the datas of your posts. You can compare these keys with values, for example you could show posts, where the "onstock" value is "yes".
Field name
You can select a custom field name here. Only show posts, where the given meta key is equal to the given meta value.
Compare method
You can compare the field name with the field value. You can select from more methods.
Field value
Besides manually written texts or numbers, you can use some keywords, too.
Field type
It does matter whether you are comparing to for example words, numbers or dates. This field gives you all available type options your meta data can have.
Meta comparison
You can create other comparison based on the previous "Field name" and "Compare method" options. Use the following format: published||=||yes||CHAR
. You can manually write down any number of comparisons. Write one comparison per line.
Order
Field
The field which decides the ordering of your content.
- Post date
- ID
- Title
- Modification date
- Random
- Given IDs - If you used the "Only display these posts" option, you can make them appear with the given order.
- Menu order - Posts can have manual ordering in WordPress and this would show your posts in that order.
Order
The order direction.
- Ascending
- Descending
Generator Settings
Learn about the Generator Settings
at the Generator Settings documentation.
Variables
These are the available variables you can use to build your dynamic slide content in the Slide Editor.
Not sure what are the variables or how to use them? Learn how to work with variables.
- id - The id of the post.
- url - Url to the post.
- title - The title of the post.
- excerpt - Excerpt of the post.
- modified - Date of the last modification.
- content, description - The content of the post.
- author, author_name - The display name of the post's author.
- author_url - Url to the website of the post's author.
- category_name - The name of the post's category.
- category_name_[x] - The name of the post's category. This variable was made, if you have multiple categories selected for your post, you can show more, not just the first one.
- category_link - Url to the post's category.
- category_link_[x] - Url to the post's category. This variable was made, if you have multiple categories selected for your post, you can show more, not just the first one.
- image, thumbnail, featured_image - The featured image of the post.
- image_[size] - Different image sizes for the featured image of the post.
- Advanced custom field variables. Advanced custom field stores their variables in many different ways, so it is not 100% that you can get all your variables!
ACF variables are asked down as meta variables too, so you can find duplicated variables:
- example
- examplevariable
- metaexample
- acf_example
- example_variable
In this example the ACF code created variables are the ones with "acf_" beginning and with "_" signs:
- acf_example
- example_variable
and you will have to use them, not the first three. The first three could have wrong values when you leave their fields empty.
- The meta datas of the post. Meta data can be stored in many different ways, so it is not 100% that you can get all your meta datas!
Keywords
At the Post Meta Comparison option you can use these keywords as the "Field value":
current_date
This value is generated by the WordPress given current_time function:
current_time('mysql');which produces this format:
2005-08-05 10:41:13
You can compare this to dates having the same format.
current_date_timestamp
This value is generated by the WordPress given current_time function:
current_time('timestamp');
which produces a Unix timestamp similar to this:
1557130874
You can compare this to dates stored as timestamps.