Skip Navigation

[Resolved] Class 'WPV_wpcf_switch_post_from_attr_id' not found

This support ticket is created 3 years, 11 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
- 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 4 replies, has 3 voices.

Last updated by fabienM-2 3 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1938933

Link to a page where the issue can be seen: hidden link
I update Toolset Types and Views to the latest version today, then now i've got the error when i try to display the page build with Views. : "Class 'WPV_wpcf_switch_post_from_attr_id' not found"
I create a custom function (in my functions.php) to display taxonomies link to a post, here my function :

function wpv_post_taxonomies_alisea_member_shortcode_render($atts) {
    $post_id_atts = new WPV_wpcf_switch_post_from_attr_id($atts);
 
    extract(
        shortcode_atts( array('format' => 'link',
                              'show' => 'name',
                              'page_id' => 0,
                              'order' => 'asc'),
                       $atts )
    );
 
    global $wplogger;
     
    $out = '';
    if (empty($atts['type'])) {
        return $out;
    }
    $types = explode(',', @strval($atts['type']));
    if (empty($types)) {
        return $out;
    }
     
    global $post;
    $separator = !empty($atts['separator']) ? @strval($atts['separator']) : ', ';
    $out_terms = array();
    foreach ($types as $taxonomy_slug) {
        $terms = get_the_terms($post->ID, $taxonomy_slug);
        if ( $terms && !is_wp_error( $terms )) {
            foreach ($terms as $term) {
                $text = $term->name;
                switch ($show) {
                    case 'description':
                        if ($term->description != '') {
                            $text = $term->description;
                        }
                        break;
                     
                    case 'count':
                        $text = $term->count;
                        break;
                     
                    case 'slug':
                        $text = $term->slug;
                        break;
                }
                
                switch ($taxonomy_slug) {
                    case 'country':
                    	$queryparam = 'wpv-country';
                        break;
                     
                    case 'sector':
                    	$queryparam = 'wpv-sector';
                        break;
                     
                    case 'alisea-keyword':
                    	$queryparam = 'wpv-keyword';
                        break;
                }                
                
                //$term_link = get_term_link($term->slug, $taxonomy_slug);
        	$term_link = add_query_arg( array($queryparam => $term->slug), '/alisea-member/' );
                 
                if (is_wp_error($term_link)) {
                    $wplogger->log('Term invalid - term_slug = ' . $term->slug . ' - taxonomy_slug = ' . $taxonomy_slug, WPLOG_DEBUG);
                }
                 
                if ($format == 'text') {
                    $out_terms[$term->name] = $text;
                } else if ($format == 'url') {
                    $out_terms[$term->name] = $term_link;
                } else {
                    $out_terms[$term->name] = '<a href="' . $term_link . '">' . $text . '</a>';
                }
            }
        }
    }
    if (!empty($out_terms)) {
        if ($order == 'asc') {
            ksort($out_terms);
        } elseif ($order == 'desc') {
            ksort($out_terms);
            $out_terms = array_reverse($out_terms);
        }
        $out = implode($separator, $out_terms);
    }
 
    return $out;
}
add_shortcode( 'wpv-post-taxonomy-alisea-member', 'wpv_post_taxonomies_alisea_member_shortcode_render' );

I check in the files, it looks the WPV_wpcf_switch_post_from_attr_id class is still available, how can i fix that ?

#1939063

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm sorry, but this is custom code using the internal workings of the plugins rather than the official APIs, we can't support it.

If you describe what the purpose of the code is, we might be able to help you create code that achieves the same using the official APIs.

#1940279

Hello, i wrote this code based on what i found onn this forum long time ago.
This function is a shorcode to get the value of the taxonomy of a specific post.

i have a custom post create with type called "alisea-member"
link to this custom post i've got taxonomies "country", "sector" and "alisea-keyword".
On my view, in the loop, i call the shortcode wpv-post-taxonomy-alisea-member with the taxonomy in parameter : [wpv-post-taxonomy-alisea-member type="country"] this function should give me the good country fr the post.
Thanks

#1940405

Minesh
Supporter

Languages: English (English )

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

With the code you shared , as you shared the problematic line of code is the following:

$post_id_atts = new WPV_wpcf_switch_post_from_attr_id($atts);

After checking the full code, I do not see the variable $post_id_atts is used anywhere within the code.

I suggest you should comment out or delete the above line of code and it should work fine. Can you please give a shot and let me know how it goes. It should work without any issues.

#1940411

My issue is resolved now. Thank you!