• Resolved Qvidard

    (@qvidard)


    Hello,

    I am using this code to add my custom post type quote to toplytics list:

    add_filter( 'toplytics_allowed_post_types', 'toplytics_add_allowed_post_types' );
    function toplytics_add_allowed_post_types( $allowed_post_types ) {
    	if ( ! in_array( 'quote', $allowed_post_types ) ) {
    		$allowed_post_types[] = 'quote';
    	}
    	return $allowed_post_types;
    }

    And now I want to display only list of popular quote post type in page e.g.

    if ( function_exists( 'toplytics_get_results' ) ) {
            $toplytics_args = array(
                'period' => 'week',  // default=month (today/week/month)
                'numberposts' => 3    // default=5 (min=1/max=250)
            );
            $toplytics_results = toplytics_get_results( $toplytics_args );
            if ( $toplytics_results ) {
                $k = 0;
                foreach ( $toplytics_results as $post_id => $post_views ) {
                    echo (++$k) . ') <a href="' . get_permalink( $post_id )
                        . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">'
                        . get_the_title( $post_id ) . '</a> - ' . $post_views . ' Views<br />';
                }
            }
        }

    But can I limit display only for quote post type?

Viewing 1 replies (of 1 total)
  • Plugin Author Presslabs

    (@presslabs)

    Hello @qvidard,

    I am sorry for the delayed response to your message.

    If you want to display only the quote post type, you can try to overwrite the $allowed_post_types var all together instead of appending it to the array like so:
    $allowed_post_types = ['quote'];

    Please let us know if this works for you.

    Best regards,
    ~Presslabs

Viewing 1 replies (of 1 total)
  • The topic ‘Display custom post type’ is closed to new replies.