Forums

[resolved] [Plugin: Popularity Contest] Show popular category posts on single (5 posts)

  1. ma2t
    Member
    Posted 1 year ago #

    Hey there,

    I'm using the great popularity contest plugin, and want it to show (in single) the popular posts from the same category.

    The plugin can show this on the category page, but I want it to show on the single page also.

    <?php akpc_most_popular_in_cat(5,'<li>','</li>','X'); ?>

    If I manually replace X with the category ID it works great.

    <?php the_category_ID(); ?> works to get the cat ID for me fine, but if I combine them to do it automatically as below, it doesn't work.

    <?php akpc_most_popular_in_cat(5,'<li>','</li>','<?php the_category_ID(); ?>'); ?>

    Any ideas people? I have spent too many hours on this already.

    Any help would be much appreciated!
    Many thanks,
    Matt

    Note: I only post my posts into one category.

  2. kReEsTaL
    Member
    Posted 1 year ago #

    I have exactly the same problem! I'm trying to find out what's wrong.

    Edit: It seems that

    <?php akpc_most_popular_in_cat('7','<li>','</li>', the_category_ID()); ?>

    ...does approximately work. HOWEVER, it prints the category ID in the HTML just before the list!

    How do you tell the plugin "display popular posts in the same category as the single post"?

    Any help welcome!

  3. ma2t
    Member
    Posted 1 year ago #

    Well I'm very glad you were having the same problem as me!, I thought I would never fix it.

    Thanks for posting your modified code, with it I was able to get it working perfectly :)

    By using:

    <?php akpc_most_popular_in_cat('5','<li>','</li>', the_category_ID(FALSE)); ?>

    and adding FALSE, it renders it for PHP and stops the category ID showing.

    Many thanks kReEsTaL, I'm glad we could help each other!

  4. kReEsTaL
    Member
    Posted 1 year ago #

    Wow, perfect! Thank you so much for solving this! :))

  5. bhupendra02
    Member
    Posted 9 months ago #

    I want to show only 5 most popular posts...how do i do that. by default it shows 10 most popular posts..

Topic Closed

This topic has been closed to new replies.

About this Topic