Skip Navigation

[Résolu] Remove outer div

This support ticket is created Il y a 7 années. 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.

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)

Marqué : ,

Ce sujet contient 1 réponse, a 2 voix.

Dernière mise à jour par Minesh Il y a 7 années.

Assisté par: Minesh.

Auteur
Publications
#592317

Hi - I have a view almost displaying what I want - it outputs this

<div class="js-wpv-view-layout js-wpv-layout-responsive js-wpv-view-layout-13267-TCPID15020" data-pagination="{"id":"13267","base_permalink":"/?page_id=15020&wpv_view_count=13267-TCPID15020&wpv_paged=WPV_PAGE_NUM","query":"normal","type":"disabled","effect":"fade","duration":"500","speed":"5","pause_on_hover":"disabled","stop_rollover":"false","cache_pages":"enabled","preload_images":"enabled","preload_pages":"enabled","preload_reach":"1","spinner":"builtin","spinner_image":"lien caché","callback_next":"","manage_history":"disabled","has_controls_in_form":"disabled","infinite_tolerance":"0","max_pages":0,"page":1,"loop":{"type":"","name":"","data":[],"id":0}}" data-permalink="/?page_id=15020&wpv_view_count=13267-TCPID15020" data-viewnumber="13267-TCPID15020" id="wpv-view-layout-13267-TCPID15020">
lien caché">Pui Hang, lien caché">David, lien caché">Dan, lien caché">Kevin, lien caché">Sean, lien caché">John, lien caché">Johnny, lien caché">Robin, lien caché">Jayne, lien caché">Ian, lien caché">Neil, lien caché">Ian,
</div>

But, all I actually want is the inner part

lien caché">Pui Hang, lien caché">David, lien caché">Dan, lien caché">Kevin, lien caché">Sean, lien caché">John, lien caché">Johnny, lien caché">Robin, lien caché">Jayne, lien caché">Ian, lien caché">Neil, lien caché">Ian,

How to I stop the outer part being returned?

I don't mind calling a function to grab the content of a view and manipulating it in there - in fact - I do need to change the last but one commas to ' or ' and remove the final comma - so grabbing the content of a view via a function may be best for me

#592349

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

To get only text output from view you need to add following code 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 == '9999' ) { //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;
}

Where:
please replace '9999' with your View ID.

Could you please confirm it helps to resolve your issue.