Home › Toolset Professional Support › [Resolved] Adding outpts from two views
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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 33 replies, has 3 voices.
Last updated by Minesh 5 months, 3 weeks ago.
Assisted by: Minesh.
- Random order: yes, that was my choice, otherwise some banners would never show high in sequence
- Theme: updated, no problem
- "build your original constant" : I don't understand this, please explain
- Optimizations plugin: the only one I use is Smush for images, I deactivated it and the blue banner becomes bigger like the others. Yellow and Orange banners still never show. Smush is not supposed to optimize JS afaik ...
- "build your original constant" : I don't understand this, please explain
===>
The view you are working on must be test view so I suggest you build your original view output.
Yellow and Orange banners still never show.
==>
I'm not sure why, because at this end it shows. Please check the following video:
- hidden link
Yes, it's a test page , but once the view works here it will work everywhere, I will set it on every page and pass parameters to show banners in certain position using view shortcodes. For this solution distorts the banner size (I don't know why) and I confirm that orange and yellow banners never show on mine (while I see they do on yours !) I was thinking if it could be better to change the output block, using Toolset slider or any other slider instead of the container background. Any suggestion ?
I tried to add a Toolset slider block in the view loop but it's impossible to select a source ... (see picture)
I'm not sure what could be the issue as you do not see the orange and yellow banners at your end.
For image slider - you will require repeating image field not the single image. That is totally different thing than what structure you have currently.
Please make sure to delete the cache if any and make sure the code snippet must be active that is added to "Custom Code" section.
Minesh,
I spotted something strange on line 19 of the code you posted at 9:50am today, please repost the correct code thanks
Here is the code that I shared:
function func_merge_non_geo_banners( $query_results, $view_settings, $view_id ){ $target_views = array( 21628 ); // Edit to add IDs of Views to add this to if ( in_array( $view_id, $target_views ) ) { $non_geo_banners = get_posts( array( 'post_type' => 'banner', // Types custom post type 'numberposts' => -1, 'meta_query' => array( array( 'key' => 'wpcf-banner-address', // Types Date custom field 'value' => '', 'compare' => '=')) )); $final_result = $query_results->posts + $non_geo_banners; $query_results->posts = $final_result; $query_results->found_posts = count($final_result); $query_results->post_count = count($final_result); } return $query_results; } add_filter( 'wpv_filter_query_post_process', 'func_merge_non_geo_banners', 999, 3 );
Minesh,
it looks like this line is wrong
$query_results->found_posts = couninal_result);;
Can you change that line to:
$query_results->found_posts = count($final_result);
Minesh,
I updated the code but still see two sliders and no yellow banner, please have a look
thanks
I've chosen different approach now as "wpv_filter_query_post_process" is not appropriate for slider kind views and even when you have distance search added for current user location.
I've added the following view:
- hidden link
The above view is used to get the current user location post(s).
Then I've added the following view's hook "wpv_filter_query" to code snippet "combine-nongeo-banners" added to the "Custom Code" section:
function func_combine_geo_and_non_geo_posts( $view_args, $view_settings, $view_id ){ $target_view_ids = array(21628 ); if ( in_array( $view_id, $target_view_ids ) ) { $geo_result = array(); $result = do_shortcode("[wpv-geolocation][wpv-view name='get-geolocated-banners' cached='off'][/wpv-geolocation]"); $geo_result = explode(",",trim($result)); $non_geo_args = array( 'post_type' => 'banner', 'fields'=>'ids', 'post_status' => 'publish', 'numberposts' => -1, 'meta_query'=>array(array('key'=>'wpcf-banner-address', 'value'=>'')) ); $non_geo_posts = get_posts( $non_geo_args ); $combined_result = array_merge($geo_result,$non_geo_posts); $view_args['post__in'] = $combined_result; } return $view_args; } add_filter( 'wpv_filter_query', 'func_combine_geo_and_non_geo_posts', 99, 3 );
Can you please confirm it works as expected now.
Hello Minesh,
I see one slider only now, ok, but:
1. the first banner that shows is of correct size, others are smaller, why ?
2. rotation works properly if Ordering is by Post Date, if I set Random order (that I need) rotation becomes weird, some banners show twice others don't show ...
thanks
Correction, to point 1: even the first banner is smaller than original: Original = 867x60; first banner = 623x60; other banners = 623x43
1. the first banner that shows is of correct size, others are smaller, why ?
- You can adjust all banner size by adding image block instead of the setting container's background image. Can you try to use image block and set your desired size of image or you can add custom CSS code to your view's output to adjust the image size.
2. rotation works properly if Ordering is by Post Date, if I set Random order (that I need) rotation becomes weird, some banners show twice others don't show ...
===>
Thats random order. We can not predict as it's selected by random mechanism. Maybe you have smaller number of posts for now that is why you see such otherwise you will have to set order by post ID or something else.
As per our support policy, We entertain only one question per ticket. As your original issue with combining images from two view is fixed, You can mark resolve this ticket.
I urge you to open a new ticket with every new question you may have. This will help us to write correct problem resolution summery as well as help others searching on the forum for a specific issue.
Thank you for understanding and have a great time.
Hello Minesh,
The banner size issue is solved, I found out that the View loop was set to 3 columns instead of 1, so the image was adapted to fit the first column. Now it's ok.
Randomized sort works fine, although sometimes some banners don't show up, you need to reload the page to ranomize again and possibly fix. I suppose there might be a bug in the randomization algorithm excluding some posts instead of just sorting all of them randomly, unless you find another reason.
I have added a new filter to the view(s) like "Banner page is a number equal to [wpv-post-id]" (current page ID), but it doesn't work as expected. In page aa3 I have set the three banners to be shown but adding this filter (I did it on the mid banner, 4464 is the contact page) they disappear, meaning that there is something wrong in the filter. Please try yourself. Any idea why this happens? could the filter fail due to those annoying question marks appearing sometimes ?
Working on the aa3 page I also noticed that dragging/moving/copying-pasting or duplicating a view to other Kadence Row Layouts or Toolset Containers turns the Update button to blue and it never comes back to white so there is no way to save, can just reload the page and loose every chenges. Please try yourself in page aa3.
Another strange thing: in the editor the output of the first view (the banner) is shown, the other two aren't, but they work on the page ....!?!?!
thanks
Glad to know that the banner size issue is fixed.
As I shared before - As per our support policy, We entertain only one question per ticket. As your original issue with combining images from two view is fixed, You can mark resolve this ticket.
I urge you to open a new ticket with every new question you may have. This will help us to write correct problem resolution summery as well as help others searching on the forum for a specific issue.
Thank you for understanding.