Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
|How to get related posts with a dynamic parent post ID||2||4||2 months, 4 weeks ago|
How to access single fields from a CPT with relationship in php
The issue here is that the use wanted to display custom fields values from their Parent/Child Posts on the frontend
Solution: If it is a custom field value on a related item then you can use our [types field='my-field'][/types] shortcode with the item attribute.
See our documentation below on the item attribute. https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
|2||5||2 months, 4 weeks ago|
|How to order per dates||2||3||3 months, 1 week ago|
|How to get dates into a dropdown with a given parent ID (product id)||3||10||3 months, 1 week ago|
|Possible to have different field group on WooCommerce Products based on category||2||3||3 months, 1 week ago|
|How to get value of a field from a custom post with parent post reference field||2||7||3 months, 1 week ago|
How to get product title in a view, with a given ID field from it’s relationship
I have a view, where I do show different part for a review. Now I like to add the product title and it's url with a given ID.
The Review custom post type and the products are in a relationship.
If it is one-to-many relationship between "Products" and "Review", you can display the parent "Products" post information with "item" attribute, for example:
|2||3||3 months, 2 weeks ago|
PHP Warning – disabled for security reasons
Problem: PHP Warning - disabled for security reasons
Warning: getcwd() has been disabled for security reasons in /mnt/disk1/home/chillicyclingksb/public_html/wp-content/plugins/types/vendor/toolset/toolset-common/lib/Twig/src/Loader/FilesystemLoader.php on line 34
Solution: Can you please check with your hosting/server authority if they have block such functions.
|2||3||3 months, 2 weeks ago|
|How to filter dates in a view||2||7||3 months, 3 weeks ago|
|How to show all dates, inclusive post title plus some fields||2||14||4 months, 2 weeks ago|
|How to translate select fields in a CRED post form||3||6||5 months, 1 week ago|
|How to show futures dates – each on one line?||2||3||6 months, 1 week ago|
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||8 months ago|
|How to "connect" a post type (listing) with "super user" / member?||3||4||11 months, 2 weeks ago|
|How to translate "strings" in custom code?||2||15||11 months, 3 weeks ago|