Types is a WordPress plugin that lets you quickly create custom post types, taxonomies and fields in your website through the WordPress admin screen instead of adding PHP code to your theme. Types User Guides include detailed documentation for setting up your custom content.
When you ask for help or report issues, make sure to tell us the versions of the Toolset plugins that you have installed and activated.
Viewing 15 topics - 2,011 through 2,025 (of 2,533 total)
Problem: I am trying to create a custom post type with the slug "downloads" but I see a message that the word is already in use, or reserved. I have a custom Page with the slug downloads already.
Solution: You must rename the custom Page slug to something else before you can reuse the slug "downloads" for a custom post type. In this case, the site also uses WPML to translate posts. The downloads slug must be changed in all languages before it is possible to reuse the slug elsewhere.
Problem: In my Form, I would like to include a select field with options for each Country, so Users can select their Country of origin when registering for the site.
Solution: Toolset does not include built-in Country select fields, but another User has created a module that includes information for importing such a field. You may import information from that module as a starting point.
Problem: I am using a shortcode from the e2PDF plugin that displays a Types custom field value. However, my field allows multiple instances and I would like to display one specific index of that field. How can I customize the shortcode to work with Types repeating field values?
Solution: Response from e2PDF support: As for now you can try to hook default output with adding filter to your theme functions.php:
add_filter('e2pdf_model_shortcode_e2pdf_wp_response', 'e2pdf_toolset_types_repeater', 10, 3);
function e2pdf_toolset_types_repeater($response, $atts, $value) {
if (isset($atts['key']) && $atts['key'] == 'wpcf-listing-photo' && isset($atts['index'])) {
$id = isset($atts['id']) ? $atts['id'] : false; // Post ID
$index = $atts['index']; // Index attribute
$field = str_replace('wpcf-', '', $atts['key']); // Converting field key to slug needed for Tooset Types
if ($id) {
//php function to render value
$response = types_render_field($field, array("post_id" => $id, "size" => "thumbnail", "index" => $index));
} else {
$response = '';
}
}
return $response;
}
After adding function you must be able to use shortcode as follows:
For correct usage "types_render_field" function must return "empty" value in case index not exists or url for image if image found, so maybe it will be need to add some parameters to "types_render_field". Unfortunately we can't test it on our side as we do not have yet access to Toolset Types plugin.
Problem:
The main issue that I can't get my head around is this.
I will create one course post with only one set of chapters for one course.
Users will not be the author of this post so how can I assign this same post to all users who sign up to my website as seperate posts so i can begin to work on how to capture each user's progress.
Solution:
In my reply to your previous ticket, I talked about assigning a post to a user by making the user the author of that post. A post has only ONE author, so we can't assign a post to multiple users using the author field.
What we can do instead, is creating another custom post type, let's call it "Subscription" or "Enrollment", this post will be linked to the "Course" or the "Chapter" custom post type using a One-to-many relationship, and make the user the post's author. This way, a "Course" or "Chapter" will have multiple "Subscription" posts linked to it. Each "Subscription" post will have an enrolled user as the author.
On the "Course" or "Chapter" post page, we'll use a view that will query "Subscription" posts linked to this "Course" or "Chapter" that are created by the current user. If the user has already an existing post, we will use this post to track to progress. If the user does not have any posts, we can offer him a Toolset Form(may have only the submit button) to let the user enroll in this course/chapter by creating the "Subscription" post. Does it make sense?
Please note that Toolset relationships are only between two custom post types, so we can't have a relationship between Course, Chapter, and Subscription. We can only have it between a Course and a Subscription, or a Chapter and a subscription.
Problem:
The user would like to expose some related posts as a field in the REST API responses.
Solution:
I run a small test and I found out that the issue in your code is the dash in the REST field name "parent-page", the code works with an underscore "parent_page". Check this screenshot http://prntscr.com/vr8azl
I used the following and slugs:
Parent slug: "parent-cpt".
Child slug: "child-cpt".
Relationship slug:
function get_parent_page_for_api_bonos( $object ) {
//get the id of the post object array
$post_id = $object['id'];
//return the post meta
return toolset_get_related_post( $post_id, 'parent-cpt-child-cpt');
}
add_action( 'rest_api_init', 'create_api_posts_meta_field_bonos');
function create_api_posts_meta_field_bonos() {
register_rest_field(
'child-cpt',
'parent_page',
array(
'get_callback' => 'get_parent_page_for_api_bonos',
'schema' => null,
)
);
}