Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
How to get the values of a date field?
Problem: I would like to get the values of a repeating date custom field, and output a custom data structure including the formatted dates.
$post_id = 1234; $start_dates = get_post_meta($post_id, 'wpcf-start-tour-date', false);
Note that the Types field slug includes a wpcf- prefix here. This will return an array of date values in Unix timestamp format.
To get a single field value, like the number of tour nights, you can use get_post_meta again like so:
$number_of_tour_nights = get_post_meta($post_id, 'wpcf-number-of-tour-nights, true);
Once you have those values, you can loop over the repeating values and create your own array of information to output. You'll need a way to format dates based on Unix timestamps. You can use PHP's date function for this. For example, to format a date like 2021-08-31 from a Unix timestamp like 1630368000, you can use the date function like so:
$timestamp = 1630368000; $formatted_date = date('Y-m-d', $timestamp);
If you want to calculate a date in the future based on the start date and number of nights, you can use the number of seconds in a day (60 seconds per minute * 60 minutes per hour * 24 hours per day) in your PHP calculations, then format the end date:
$start_date = 1630368000; $number_of_nights = 4; $end_date = $start_date + (60 * 60 * 24 * $number_of_nights); $formatted_end_date = date( 'Y-m-d', $end_date);
|2||6||1 month, 2 weeks ago|
|How to translate select fields in a CRED post form||3||5||3 months ago|
|How to "connect" a post type (listing) with "super user" / member?||3||4||4 months, 4 weeks ago|
|How to translate "strings" in custom code?||2||15||5 months ago|
How to add a reCaptcha field in the expert mode?
Problem: How to add a reCaptcha field in the expert mode?
Solution: You can add the reCaptcha field in expert mode using the [cred_field] shortcode.
You can find the proposed solution in this case with the following reply: => https://toolset.com/forums/topic/how-to-add-a-recaptcha-field-in-the-expert-mode/#post-1788993
Relevant Documentation: https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field
|2||3||5 months, 1 week ago|
|Showing post titles as select dropdown in views search form||2||11||6 months, 1 week ago|
|those reviews not showing "automatically" respectively after publishing the review on the tour||2||10||9 months, 1 week ago|
I just need to do some design stuff
on each tour post, and showing only those related review posts.
The reference field is based on one-to-many relationship, so in a single "cycling-tour" post, you can create a post view:
- Query reviews posts
- Filter by post relationship between "cycling-tour" and "reviews", the relationship name is same as your custom reference field.
- In view's loop, display the "reviews" post information
|2||13||9 months, 1 week ago|
I have a cred form and like to have in a select field other CPT title and post i
In a CRED form I have a select field, where I like to have title and post id populated from another CPT we have.
You just need to setup a reference field.
Then put above reference field into your post form, it should be able to display as a select field,
|3||7||10 months ago|
|How to code and get field value from a category||2||5||10 months ago|
|Custom fields not showing in the custom post type||2||3||10 months ago|
|How to php code to get a specific field||3||7||1 year, 3 months ago|
|We like to have an image slider, and need the best approach||2||5||1 year, 4 months ago|
|If a user choose a category or anything in the search form, it not shows correct 1 2||2||23||1 year, 5 months ago|
Need to create a shortcode function, with “echo” content out
Problem: Need to create a shortcode function, with "echo" content out
Solution: You should add the custom shortcode to your current theme's functions.php file or Custom Code section offered by Toolset.
You can find the proposed solution in this case with the following reply: https://toolset.com/forums/topic/need-to-create-a-shortcode-function-with-echo-content-out/#post-1344827
Relevant Documentation: => https://toolset.com/documentation/adding-custom-code/how-to-create-a-custom-shortcode/ => https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
|2||16||1 year, 5 months ago|