Hi Andrei,
Yes, we have used td_data_source.php in our child theme.
Yes, the custom code work fine before with this file in our child theme.
It looks like td_block.php is not working on the child theme, doesn’t it?
This implementation has stopped working since upgrading to Newsmag 3.0
Any thought guys?
Hey,
We were able to add config to each of the block settings (in visual composer) using a function hooked to admin_init. This allows the user to specify a list of terms in that taxonomy and filter the results by those terms.
function extendCustomTaxonomyOptions() {
// Check if Visual Composer is installed
if ( ! defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Retrieve all Lifestyle taxonomy
$terms = get_terms('name_of_your_custom_taxonomy_here');
if( !is_wp_error( $terms ) && count( $terms ) > 0 ) {
$dropdown = array(
'Disabled' => 'disabled',
'All Custom Taxonomy Terms' => 'all'
);
foreach( $terms as $term ) {
$dropdown["- {$term->name}"] = $term->term_id;
}
// Param to be added
$new_param = array(
'type' => 'dropdown',
'heading' => 'Filter based on custom taxonomy',
'param_name' => 'adv_filtering_custom_taxonomy',
'group' => 'Filter',
'admin_label' => true,
'value' => $dropdown,
'description' => __( 'If selected, will further filter the posts based on the custom taxonomy', 'vc_extend' )
);
// Integrate and add new parameter to the options available from the parent theme
// See https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524335 for more info
for ( $i = 1; $i <= 16; $i++) {
vc_add_param( "td_block_{$i}", $new_param);
}
vc_add_param( "td_block_slide", $new_param);
}
}
Then we added some custom code in a child theme copy of the td_data_source class to read those settings and filter the results. This was added to the end of the td_data_source::shortcode_to_args() function, just before returning the $wp_query_args:
if( array_key_exists( 'adv_filtering_custom_taxonomy', $atts ) ) {
if( $atts['adv_filtering_custom_taxonomy'] != 'disabled' && !empty( $atts['adv_filtering_custom_taxonomy'] ) ) {
// Add new taxonomy in the query
$query = array_merge( $wp_query_args, array(
'tax_query' => array(
array(
'taxonomy' => 'name_of_your_custom_taxonomy_here',
'field' => 'term_id',
'terms' => $atts['adv_filtering_custom_taxonomy']
)
)
));
}
}
Hope that helps!
Simply copying td_data_source.php into the child theme and modifying also works. This is the approach we are using, nice and simple!
Thanks Emil!
I think that will work for us. I’ll try it tomorrow and let you know how I get on.
Basically I can replace the implementation of td_data_source with our own implementation in our child theme. Love it 🙂
add_action(‘td_wp_booster_loaded’, ‘hook_td_booster_loaded’);
function hook_td_booster_loaded(){
td_api_autoload::add(‘td_data_source’, CHILD_THEME . ‘/includes/wp-booster/td_data_source.php’);
}
Hi Emil,
Thanks for your reply. We’ve looked at solution 1…manually setting the parameters used by the render method. But the problem is that the query is created in the td_data_source->shortcode_to_args() function which takes the $atts array and creates the query. That function does not support custom taxonomies.
And as far as we can tell, its not possible to override the td_block and td_data_source files in a child theme. It would be nice if we could pass in extra query filters via $atts which td_data_source->shortcode_to_args() would then add to the generated query.
OR allow us to override td_block and td_data_source 🙂
That’s a shame. Custom taxonomies are commonly used for categorising posts and its something we make heavy use of on our site.
What about the possibility of allowing the block query to be modified before the query is run? i.e. allow us to pass in values to parent::render($atts) which modify the query.
Right now we have an ugly hack in place where we run our own query right after the block query executes and then we use the result of our query to pass to the modules. But obviously this is very inefficient!
Thanks Alin!
Thanks Lucian.
Is it possible to change the placement of the review ratings? Right now they always appear at the bottom of the page in the footer.
Thanks for the replies Lucian and mpindado.
One approach I am considering is building my own admin section for review ratings. There is other functionality I need such as restricting the theme to only display ratings as star ratings and having a predefined set of rating categories. When the post is saved, I will save my ratings out of 20 in a custom meta field and also save the ratings data to the td_review meta. This should work for my purposes although obviously it is not ideal and means extra work for me.