Skip Navigation

[Resolved] Why is my views wrapped in new div?

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to display plain view without wrapping additional divs

Solution:
Since Views 1.11 we have had to wrap Views loop outputs in default HTML and CSS/JS in order to support things like infinite scrolling, and future to come features like "Front End Sorting and Ordering".

To return a "clean" Loop output is using the filter 'wpv_filter_wpv_view_shortcode_output' to your current theme's functions.php file.

Relevant Documentation:

This support ticket is created 8 years, 5 months ago. 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.

Our next available supporter will start replying to tickets in about 2.41 hours from now. Thank you for your understanding.

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)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by thomasS-11 8 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#349144

Hi. I noticed that some recent update had all views wrapped inside a div with class="js-wpv-view-layout js-wpv-layout-responsive" and a aweful lot of data-attributes... How comes?

Please do not change structural dom like this without a heads-up - a single div like this can wreck a whole website if the CSS and JS is directly called (i.e. body > article or stuff like that).

Now that you have added it - how do i remove the div wrapped around my view? Its really uneccessary to have it in my case, it will just cause me more work..

#349168

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I apologize deeply the inconveniences you are facing due to this issue. I will try to help you as fast and effective as possible.

Since Views 1.11 we have had to wrap Views loop outputs in default HTML and CSS/JS in order to support things like infinite scrolling, and future to come features like "Front End Sorting and Ordering"

This will not be reverted, and it is not a BUG per se but basically it was never intended to use Views as a Data Provider.

Though, given the large usage of Views as a Data Provider, our DEV Team is currently developing a specific View Setting in order to do exactly this:
Provide raw data for later use.

This is a new feature and I can not state any ETA on this, other than that it is under development for future releases.

By now, the only way to return a "clean" Loop output is using the below filter to your current theme's functions.php file:

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
 
function prefix_clean_view_output( $out, $id ) {
    if ( $id == '375' ) { //Please adjust to your Views ID
        $start = strpos( $out, '<!-- wpv-loop-start -->' );
        if ( 
            $start !== false
            && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
        ) {
            $start = $start + strlen( '<!-- wpv-loop-start -->' );
            $out = substr( $out , $start );
            $end = strrpos( $out, '<!-- wpv-loop-end -->' );
            $out = substr( $out, 0, $end );
        }
    }
    return $out;
}

*** Note ***
This above code will not allow any settings in a View like parametric Search, AJAX Updates, scrolling, pagination, etc. It will provide bare, raw results.

#349287

Okay thanks alot

#481154

This code stopped working all of a sudden?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.