3
votes

I am looking to add (YARPP) to my custom post types pages.

The custom post type I am looking to add it to is quite complex and I am looking for where I place the provided code from YARPP.

This is the support I found for placing the code into the custom post type:

http://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-making-yarpp-caching-feature-work-for-custom-post-types

This is my code:

function property_listing() {
$args = array(
    'description' => 'Property Post Type',
    'show_ui' => true,
    'menu_position' => 4,
    'exclude_from_search' => true,
    'labels' => array(
        'name'=> 'Property Listings',
        'singular_name' => 'Property Listings',
        'add_new' => 'Add New Property', 
        'add_new_item' => 'Add New Property',
        'edit' => 'Edit Properties',
        'edit_item' => 'Edit Property',
        'new-item' => 'New Property',
        'view' => 'View Property',
        'view_item' => 'View Property',
        'search_items' => 'Search Properties',
        'not_found' => 'No Properties Found',
        'not_found_in_trash' => 'No Properties Found in Trash',
        'parent' => 'Parent Property'
    ),
    'public' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => true,
    'query_var' => true,
    'supports' => array('title', 'editor', 'thumbnail', 'author', 'comments')
);
register_post_type( 'property' , $args );
flush_rewrite_rules();

}

Any idea?

2

2 Answers

4
votes

Yes. it's easy look here at the end of the array:

I added: 'yarpp_support' => true

  function property_listing() {

        $args = array(
            'description' => 'Property Post Type',
            'show_ui' => true,
            'menu_position' => 4,
            'exclude_from_search' => true,
            'labels' => array(
                'name'=> 'Property Listings',
                'singular_name' => 'Property Listings',
                'add_new' => 'Add New Property', 
                'add_new_item' => 'Add New Property',
                'edit' => 'Edit Properties',
                'edit_item' => 'Edit Property',
                'new-item' => 'New Property',
                'view' => 'View Property',
                'view_item' => 'View Property',
                'search_items' => 'Search Properties',
                'not_found' => 'No Properties Found',
                'not_found_in_trash' => 'No Properties Found in Trash',
                'parent' => 'Parent Property'
            ),
            'public' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
            'query_var' => true,
            'supports' => array('title', 'editor', 'thumbnail', 'author', 'comments'),
            'yarpp_support' => true
    );

       register_post_type( 'property' , $args );
       flush_rewrite_rules();
    }
1
votes

Try adding the following code to your theme's functions.php file:

function wpurp_register_post_type( $args )
{
    $args['yarpp_support'] = true;
    return $args;
} 

add_filter( 'wpurp_register_post_type', 'wpurp_register_post_type' ); 

You could also add this in a child theme so you don't have to worry about updating the theme.