Skip Navigation

[Resolved] How to get view to appear on same line as other content?

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

Problem:
Get clean output from a view.

Solution:

The code below should be able to assist you.

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
 
function prefix_clean_view_output( $out, $id ) {
    if ( $id == '375' ) {
        $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;
}

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

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by davidR-12 5 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#1105556

I have created a taxonomy view that displays terms. I want this view to display the terms on the same line as other content. However, as the view is contained in a <div> and doesn't seem to have a definitive class (Each iteration of the view has its own class and I am using the view a lot) I cant see a way to do this. I was provided with a solution to this before but I cannot see it in my support archive.

Regards,

David

#1105633

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

What you might need to do is to wrap each of those view shortcodes in separate divs like this.

<div>shortcode</div>
<div>shortcode</div>

Then style those wrapper divs to get them aligned horizontally .

Thanks,
Shane

#1106522

Hi Shane,

That doesnt fix the issue. Toolset is generating a <div> that has no fixed class so I cant style it. I need to remove the div that the view is creating and replace it with a <span> (which I am convinced I have done before but cannot find on my help ticket feed) or I need to be able to give the view a fixed class so I can target it wherever it appears on the site.

Regards,

David

#1106694

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

I believe this is the code that you are referring to.

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );

function prefix_clean_view_output( $out, $id ) {
    if ( $id == '375' ) {
        $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;
}

This should remove the div around the view.

Thanks,
Shane

#1107508

Hi Shane,

YES! Thats the one thank you. I have saved it this time to my code repository as I know I will need it again at some point.

Regards,

David

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