WordPress.org

Ready to get started?Download WordPress

Forums

WP Deals
Issue with Custom Taxonomy in WP Deals Plugin (1 post)

  1. Vijaybez
    Member
    Posted 1 year ago #

    Hi,

    I am trying to add a custom Taxonomy to this plugin code so I can use it for changing my URL structure.

    Below is the code I added to the WPDeals-Taxonomy.php file and it added a new Area for entering my values for a particular deal.

    register_taxonomy( 'citydeals', 'post',
                       array(   'hierarchical' => FALSE, 'label' => __('citydeals'),
                            'public' => TRUE, 'show_ui' => TRUE,
                            'query_var' => 'rating',
                            'rewrite' => true ) );
    add_filter('post_type_link', 'citydeals_permalink', 10, 3);
    
    function citydeals_permalink($permalink, $post_id, $leavename) {
        if (strpos($permalink, '%citydeals%') === FALSE) return $permalink;
    
            // Get post
            $post = get_post($post_id);
            if (!$post) return $permalink;
    
            // Get taxonomy terms
            $terms = wp_get_object_terms($post->ID, 'citydeals');
            if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
            else $taxonomy_slug = 'deals';
    
        return str_replace('%citydeals%', $taxonomy_slug, $permalink);
    }

    My issue here is that the value that I enter in the field to enter values for this citydeals taxonomy is not getting picked up when I change my Permalink structure to /%citydeals%/%postname%/

    Please help..This is a very important feature that I need to be working.

    http://wordpress.org/extend/plugins/wp-deals/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic