This topic has 2 replies, 2 voices, and was last updated 10 years by sharmstr.

  • Author
  • #26323
     sharmstr
    Moderator

    What’s the best way to add your item likes to custom post types? I can easily do it by adding the custom post type to the $post_types array in the show_likes function in item-likes.php, but the obvious problem is that it will be overwritten during a Kleo upgrade.

    Specially I’m working on adding it to the posts footer. I tried changing do_action(‘kleo_post_footer’) to do_action(‘story_post_footer’), then adding the following to my functions.php file. (btw – fiction is the custom post type below)

    COPY CODE
    
    
    add_action('story_post_footer', array(&$this, 'show_story_likes'));
    function show_story_likes()
    {
    	$ids = str_replace(' ', '', trim(strip_tags(sq_option('likes_exclude'))));
    	$ids = explode(',', $ids);
    	if(in_array(get_the_ID(), $ids)) return;
    	
    	$post_types = array( 'post', 'attachment','fiction' );
    	$post_types = apply_filters( 'kleo_likes_post_types', $post_types );
    	$current_post_type = get_post_type();
    	
    	if( in_array( $current_post_type, $post_types ) ) {
    		echo $this->do_likes();
    	}
    }
    

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #28047
     Abe
    Keymaster

    Hi, I think all you need to do is add this in your child theme in functions.php

    COPY CODE
    
    add_filter('kleo_likes_post_types', 'kleo_my_custom_like');
    function kleo_my_custom_like( $post_types ) {
      $post_types[] = 'fiction';
    
      return $post_types;
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #28051
     sharmstr
    Moderator

    It works perfectly. Thank you, Abe.

    I just learned something too. This is awesome. Thank you again.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

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

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?