Skip Navigation

[Resolved] How to insert taxonomy term in post view

This support ticket is created 7 years 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
- 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 Minesh 7 years ago.

Assisted by: Minesh.

Author
Posts
#462531
distort.jpg

I am trying to: insert taxonomy "category" term "spalva" in post view

I visited this URL: local development

I expected to see: taxonomy "category" term "spalva" displayed in post view

Instead, I got: empty if i insert [types termmeta='spalva'][/types]

If I create and insert taxonomy view it distorts whole design

<div class="col-xs-1"><div style="background-color:[wpv-view name="skelbimai-taxonomy-colour"];"></div></div>

you can see it in screenshot

#462627

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand you want to just display plain text output from your view. If this is correct - to display plain text only output with view's 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 == '999' ) { //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:
Replace '9999' with your original view ID.

#463028

Thank you ! it works like a charm.
Is there a possibility to add 2 or more view ID's in same function?

#463057

Minesh
Supporter

Languages: English (English )

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

Yes - you can use the following code:

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
   
function prefix_clean_view_output( $out, $id ) {
// Replace your view ids comma separated with folloing array
$view_ids = array(999,222);

if (in_array($id, $view_ids)) {
        $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;
}

I hope above solution will help you to resolve your issue.

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