WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
YARPP' problem with custom post types, tags and categories (6 posts)

  1. art23130
    Member
    Posted 9 months ago #

    I am developing a website for our community which is Geoinformation based on WordPress and I am using your plugin since 2010 and it is very great, but I face some problems when I start to match YARPP with a plugin called as WP Business Directory (http://codecanyon.net/item/wp-business-directory/2203258). This plugin uses custom post type, custom tags, custom categories. As you have mentioned in your tutorials we should add yarpp_support' => true to our register pattern which we have done (I have attached the PHP file) and after in automatically display of YARPP we have companies but still it dose not add anything for that means it says that mo related posts.
    These are the examples of the YARPP.........Working on normal posts............. http://www.geoinformation.com/tersakan-lake-and-tuz-lake-from-space/
    Not-working on custom posts while we added yarpp_support' => true..................http://www.geoinformation.com/GeoInformation-dir/dlr-german-aerospace-center/
    * REGISTER wpecbd POST TYPE
    */
    $labels = array(
    'name' => __('Companies', 'wpecbd'),
    'singular_name' => __('Company', 'wpecbd'),
    'add_new' => __('Add New', 'wpecbd'),
    'add_new_item' => __('Add New Company', 'wpecbd'),
    'edit_item' => __('Edit Company', 'wpecbd'),
    'new_item' => __('New Company', 'wpecbd'),
    'all_items' => __('All Companies', 'wpecbd'),
    'view_item' => __('View Company', 'wpecbd'),
    'search_items' => __('Search Companies', 'wpecbd'),
    'not_found' => __('No companies found', 'wpecbd'),
    'not_found_in_trash' => __('No companies found in Trash', 'wpecbd'),
    'menu_name' => __('WP Business Directory', 'wpecbd')
    );
    $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    #'exclude_from_search' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'rewrite' => array('slug' => $this->_options['dir_slug'], 'with_front' => (bool) $this->_options['dir_slug_with_front']),
    'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'menu_position' => null,
    'yarpp_support' => true,
    'supports' => array('title', 'editor', 'author', 'excerpt')
    );
    //Check comment active?
    if ($this->_options['comments'])
    $args['supports'][] = 'comments';

    register_post_type('wpecbd', $args);

    /*
    * REGISTER COMPANY CATEGORIES TAXONOMY
    */
    //Check for category activated
    if ($this->_options['category']):
    $cat_tax_labels = array(
    'name' => __('Categories', 'wpecbd'),
    'singular_name' => __('Category', 'wpecbd'),
    'search_items' => __('Search Categories', 'wpecbd'),
    'all_items' => __('All Categories', 'wpecbd'),
    'parent_item' => __('Parent Category', 'wpecbd'),
    'parent_item_colon' => __('Parent Category:', 'wpecbd'),
    'edit_item' => __('Edit Category', 'wpecbd'),
    'update_item' => __('Update Category', 'wpecbd'),
    'add_new_item' => __('Add New Category', 'wpecbd'),
    'new_item_name' => __('New Category Name', 'wpecbd'),
    'menu_name' => __('Categories', 'wpecbd'),
    );

    $cat_tax_args = array(
    'hierarchical' => true,
    'labels' => $cat_tax_labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array('slug' => $this->_options['cat_slug'], 'with_front' => (bool) $this->_options['cat_slug_with_front']));

    register_taxonomy('bd_categories', 'wpecbd', $cat_tax_args);
    endif;

    /*
    * REGISTER COMPANY TAGS TAXONOMY
    */
    //Check for tags activated
    if ($this->_options['tag']):
    $tag_tax_labels = array(
    'name' => __('Tags', 'wpecbd'),
    'singular_name' => __('Tag', 'wpecbd'),
    'search_items' => __('Search Tags', 'wpecbd'),
    'popular_items' => __('Popular Tags', 'wpecbd'),
    'all_items' => __('All Tags', 'wpecbd'),
    'parent_item' => null,
    'parent_item_colon' => null,
    'edit_item' => __('Edit Tag', 'wpecbd'),
    'update_item' => __('Update Tag', 'wpecbd'),
    'add_new_item' => __('Add New Tag', 'wpecbd'),
    'new_item_name' => __('New Tag Name', 'wpecbd'),
    'separate_items_with_commas' => __('Separate tags with commas', 'wpecbd'),
    'add_or_remove_items' => __('Add or remove tags', 'wpecbd'),
    'choose_from_most_used' => __('Choose from the most used tags', 'wpecbd'),
    'menu_name' => __('Tags', 'wpecbd'),
    );

    $tag_tax_args = array(
    'hierarchical' => false,
    'labels' => $tag_tax_labels,
    'show_ui' => true,
    'update_count_callback' => '_update_post_term_count',
    'query_var' => true,
    'rewrite' => array('slug' => $this->_options['tag_slug'], 'with_front' => (bool) $this->_options['tag_slug_with_front']));

    register_taxonomy('bd_tags', 'wpecbd', $tag_tax_args);
    endif;

    /*

    http://wordpress.org/plugins/yet-another-related-posts-plugin/

  2. stoi2m1
    Member
    Posted 9 months ago #

    Did you ever get this working? I was having troubles too, I added the yarpp support for the CPT and then I started adding in custom taxonomies. I think I almost have it working.

    you mentioned you were following some tutorials. where are those?

    Jesse

  3. art23130
    Member
    Posted 9 months ago #

    I am working on it but still no result :( the post registeres BUT it dose not retrive the posts because the tags are different too. About the tutorial, there is a very good one in the plugin website. Can you share the custom taxonomies plz which you have used ?

  4. stoi2m1
    Member
    Posted 9 months ago #

    Most of the notes were already there. I added a few to try and help.

    yarpp_related(
    	array(
    		// Pool options: these determine the "pool" of entities which are considered
    		'post_type' => array('movies'), // my cpt
    		'show_pass_post' => false, // show password-protected posts
    		'past_only' => false, // show only posts which were published before the reference post
    		'recent' => false, // to limit to entries published recently, set to something like '15 day', '20 week', or '12 month'.
    
    		// Relatedness options: these determine how "relatedness" is computed
    		// Weights are used to construct the "match score" between candidates and the reference post
    		'weight' => array(
    			'body' => 2,
    			'title' => 5, // larger weights mean this criteria will be weighted more heavily
    			'tax' => array(
    				'exploitation-type' => 10, // my custom taxonomy
    				// put any taxonomies you want to consider here with their weights
    			)
    		),
    		// Specify taxonomies and a number here to require that a certain number be shared:
    		'require_tax' => array(
    			'exploitation-type' => 1 // for example, this requires all results to have at least one 'post_tag' in common.
    		),
    		// The threshold which must be met by the "match score"
    		'threshold' => 2, //this is minimum score required to show a related post, i used two to make sure something would show
    
    		// Display options:
    		'template' => false, // either the name of a file in your active theme or the boolean false to use the builtin template, thumbnails is an option too
    		'limit' => 5, // maximum number of results
    		'order' => 'score DESC'
    	),
    	$post->ID, // second argument: (optional) the post ID. If not included, it will use the current post.
    	true // third argument: (optional) true to echo the HTML block; false to return it
    );

    Whats the URL to the tutorial?

    I hope that helps you get related cpt's by custom tax

    Jesse

  5. art23130
    Member
    Posted 8 months ago #

    Dear Jesse,

    I have searched for the URL but unfortunately I could not find that. I have tried the code you have attached but it dose not work.

  6. stoi2m1
    Member
    Posted 8 months ago #

    Make sure to change the above code to your CPT and your custom taxonomy.

    I removed all of the things I didnt need from the above code to start getting some basic results and then I added stuff back in. Best thing is just to comment some of the lines of code out and test it.

    Jesse

Reply

You must log in to post.

About this Plugin

About this Topic