1. I have the following code that I am hoping to use to automatically populate my select field of the name "Media Type Auto" with a list of items from my Custom Taxonomy Slug "media-type".
I am getting the following error:
"syntax error, unexpected '$options' (T_VARIABLE) in /home/glancelo/public_html/arrirental/wp-content/toolset-customizations/media-type-auto.php on line 16
A problem occurred when executing snippet "media-type-auto". The result of include_once is: ""
Lines 1 to 33 of the Code Snippet entered into the "Toolset Custom code" snippets modules are listed below:
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
// Prepopulate Select Field with Custom Taxonomy Values
add_filter( 'wpt_field_options', 'fill_select', 10, 3);
function fill_select( $options, $title, $type ){
switch( $title ){
// Select Field Name not the Slug
case 'Media Type Auto':
$options = array();
$terms = get_terms( array(
// Custom Post Type Taxonomy Slug not the Name
'taxonomy' => 'media-type',
'hide_empty' => false,
) );
Tell us what you are trying to do?
I am trying to have a select field in a custom post type be dynamically populated by the values of a custom taxonomy.
You are actually familiar with this project because you really helped me out with it a day ago! We really appreciate that help too!
Currently in our custom post type we have a select field to group Credit Details together. We have wordpress Taxonomies and are having to manually reenter those taxonomies into the Select Field. But if we could automate that process, every addition or change to the Media Type taxonomy would automatically be reflected in the Media Type Auto Select Field as opposed to the users having to manually synchronize the Media Type Auto Select field with the Media Type Taxonomy.
If this is done, why would we not be able to continue to use this field to filter or layout / group our views?
If it a frontend filter, lets say a Parametric search then the values wouldn't be picked up by views. This is because views will be pulling the select field options from Types.
However if its a static filter you are adding then it should work.
I fixed the code and noticed that you are using this in a RFG . From what I can see now it is slowing down the loading of the RFG or causing it to not load at all.
There is a test field that I created to ensure the code works and it does but because the fields are in a RFG it is causing issues.
I would recommend doing a manual population of the fields to avoid this.
1. It will only be a static filter which I will use within a custom post type from the admin side;
2. Thank-you for fixing the code, I will study it and figure out how you did it - thanks!
3. If the processing cost is too steep we will continue to manually populate the field - the taxonomy CPT won't be excessively large or exceedingly dynamic.
Thank you so much for your efforts - I will message back here if there are additional questions!