Home Forums WTI Like Post PRO Exclude Custom Post Types

This topic contains 1 reply, has 2 voices, and was last updated by  Webtechideas 3 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #117

    seamtv
    Participant

    Hi there, love the plugin.

    Just have some nigglies…

    There’s no way to exclude custom post types and this creates a lot of problems when I use them. For instance, I use Templetera, which allows me to create site elements that can be reused in many places (in effect, templates). To do this, it uses a custom post type. However, this means that multiple WTI Like voting images sometimes appear all over my pages!
    I have tried to exclude the post ids of those templates, but, as you can imagine it can become a losing battle over time.
    It would be great if you had a checkbox to enable me to exclude custom post types as a whole!
    Thanks.

    #118

    Webtechideas
    Keymaster

    As a quick fix, you can possibly add a line of code which will prevent the like/unlike buttons being rendered. Let’s say you want to exclude type1 post type.

    – Open the file wti_like_post_site.php in a text editor.
    – Search for the function GetWtiLikePost.
    – Just before this line $ip = WtiGetRealIpAddress();, add the following code

    // Exclude depending on post type
    $post_type = get_post_type( $post_id );
    $excluded_types = array('type1');
    
    if ( in_array( $post_type, $excluded_types ) ) {
    	return;
    }

    Note:
    – If you want to exclude more than 1 post type such as type1 and type2, you need to use $excluded_types = array('type1', 'type2'); in the above code.

    Do let us know if this worked or not.

    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.