Skip Navigation

[Gelöst] Types Set-up

This support ticket is created vor 6 Jahren, 9 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Artikel
#615846

Is this the reason why you recommended jayzerbe.com/portfolio/ecollage ?
I mentioned this URL structure as an example of one way you could organize these concepts in Toolset. There was no reason, really, except that it is possible.

Can it be jayzerbe.com/portfolio/ecollage/title ?
Your earlier question was about this similar structure:
jayzerbe.com/portfolio/painting/title-of-artwork
Neither is supported because there are three levels in this URL structure, each separated by a forward slash. You can only have two levels: post-type-slug/post-slug. You cannot have any of these, or any other combination of 3 levels:
- post-type-slug-1/post-type-slug2/post-slug
- post-type-slug/taxonomy-term-slug/post-slug
- post-type-slug-1/post-slug-1/post-slug-2
Any modification to these URL structure rules will require custom code, or another plugin.

Would the site visitor be able to select between Painting, Collage, and eCollage from the search form if "Portfolio" was the custom post type and Painting, Collage, and eCollage were grouped as fields?
If you are referring to a custom search View of Portfolios, then yes, you can filter by custom fields associated with the Portfolio post type. However, if you are referring to a View of Projects, then no. You cannot filter a View of post type A by custom fields applied to post type B.

It's hard to keep everything in your head without any hands-on application of these concepts. In my experience, it helps to start a test site and begin trying some different configurations. Sometimes it's not easy to understand how things fit together until you see it in place. If you do not have a test environment available, we offer a sandbox at discover-wp.com where you can take any reference site for a test run. While the sites may already have some irrelevant content, you can add your own post types, taxonomies, custom fields, and Views as needed, and see the results of different configurations.

#615853

I very much appreciate your assistance and I feel that I could catch on to it eventually. However, in every client case I can see using Toolset with will need to be able to identify the type of art / followed by the title in separate sections of the URL.

The ideal structure would be jayzerbe.com/ecollage/post-title-slug
The problem here is that I need to allow the visitor to search by type which is also the post in the above sample and that is not possible with Toolset search. Is there another WP.org registered plugin that you are aware of that would work with Toolset and include the post type in the search?

You say it isn't possible without the use of another plug-in but another possible ideal structure would be jayzerbe.com/portfolio/ecollage/post-title-slug are there any known plug-ins that I can use to enable the third level?

#616033

Is there another WP.org registered plugin that you are aware of that would work with Toolset and include the post type in the search?
No, I'm not aware of one to recommend. After consulting with some other supporters they were able to provide a custom code solution that will allow you to include a post type filter. The only stipulation is that this approach requires you to use AJAX to update the View results. If that's okay, you can add the following code to your child theme's functions.php file:

add_filter( 'wpv_filter_query', 'post_type_filter_func', 10, 3 );

function post_type_filter_func( $query_args, $settings, $view_id ) {
    $views = array( 1234,5678 );
    if ( in_array( $view_id,$views) && isset($_GET['wpv-post-type'][0]) && !empty($_GET['wpv-post-type'][0]) ) {
        $query_args['post_type'] = $_GET['wpv-post-type'][0];
    }
    return $query_args;
}

Replace 1234,5678 with a comma-separated list of View IDs where you want to apply the post type filter. Then in the Views' Filter Editor(s), you can include a custom post type filter with this code:

[wpml-string context="wpv-views"]Post Type:[/wpml-string] [wpv-control url_param="wpv-post-type" type="select" values=",post-type-slug-1,post-type-slug-2,post-type-slug-3" display_values="All Types,Post Type 1,Post Type 2,Post Type 3"]

Replace the post type slugs and post type names as needed.

another possible ideal structure would be jayzerbe.com/portfolio/ecollage/post-title-slug are there any known plug-ins that I can use to enable the third level?
I don't have a recommendation, but the WordPress plugin repository lists several plugins related to permalinks:
https://wordpress.org/plugins/search/permalink/

#616042

Thank you. Providing the code was outstanding. I will discuss it with my hosting support.

I will update the ticket once this has been done.

#616080

Can I use Code Snipets plugin for the funtion.php that you provided?

#616094

Is

$views = array( 1234,5678 );

the same

$views = array( paintings,ecollage,collage );

in my case?

My hosting server support was able to help me add the following code to the function.php file for jayzerbe.com

add_filter( 'wpv_filter_query', 'post_type_filter_func', 10, 3 );

function post_type_filter_func( $query_args, $settings, $view_id ) {
$views = array( painting,ecollage,collage );
if ( in_array( $view_id,$views) && isset($_GET['wpv-post-type'][0]) && !empty($_GET['wpv-post-type'][0]) ) {
$query_args['post_type'] = $_GET['wpv-post-type'][0];
}
return $query_args;
}

The site appears to have accepted the added script without negative interference.

#616155

Can I use Code Snipets plugin for the funtion.php that you provided?
Yes, that's fine, or you can use a child theme and add it to the child theme's functions.php file.

$views = array( paintings,ecollage,collage );
No, this array should hold numeric View IDs. Yours seems to hold post type slugs now, so you should replace those with numeric View IDs. You can find each View's ID in wp-admin. Go to Types > Views to find the numeric ID corresponding to each View in the list. If you only have one View where you want to use these post type filters, you only need to include one number–the ID of this one View.

#619246

Hello,

I just upgraded my Toolset license. Hopefully, I might better learn the system while working on different site cases.

On the subject of Types and Fields, I have a question regarding the use of a "Select" fields. In an application where there is a long list of options to select from, how are the options displayed on the Views page, hopefully not in one long static drop-down list?

#619503

If you're using a "select" type filter, then all the options will appear in a single standard select field. If you have additional questions feel free to create separate tickets for each question so we can discuss in more detail.