• Resolved Clivesmith

    (@clivesmith)


    Hi,
    Over a year ago you gave me a piece of code to sort both the topic itself and its replies when someone opens a topic.

    Now when I open a topic you cannot vote on the topic itself against the replies, you can only vote on the replies.
    If I turn on vote on topics the voting buttons show up on the list of topics as well which is not right for me. If you look at my site it would be voting for airports.
    Hope that makes sense
    Regards
    Clive

    /*********************/
    // Override to sort topics and replies by votes
    add_filter(‘bbp_has_replies_query’, ‘sort_bbpress_topics_and_replies_by_votes’, 11);
    function sort_bbpress_topics_and_replies_by_votes( $args = array() ) {
    if(!apply_filters(‘sort_bbpress_replies_by_votes’, false)) return $args;
    $bbPress_post_id = get_the_ID();
    $bbPress_post_type = get_post_type($bbPress_post_id);
    if( $bbPress_post_type == bbp_get_topic_post_type() ){
    $args[‘orderby’] = [
    ‘meta_value_num’ => ‘DESC’
    ];
    }
    return $args;
    }
    /* This sorts the replies by votes */
    add_filter(‘sort_bbpress_replies_by_votes’, ‘__return_true’);
    /********************************/

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author natekinkead

    (@natekinkead)

    In the recent updates I released for this plugin, I introduced a new settings area that replaces the need for any hooks. Try getting rid of that code snippet, make sure the plugin is updated, and look at the settings page.

    Thread Starter Clivesmith

    (@clivesmith)

    Hi,

    I have removed the code snippet but it is still not right.
    If you go to wateratairports.com then go to United Kingdom you will see that all the airports (topics) are listed with voting next to them, the votes are an accumulation of all the votes for the replies under that topic. That makes no sense in my context or any context as where would a vote for this airport go in relation to a reply ?
    I don’t want to see voting here. I can turn that off but….
    If you continue on to Gatwick airport you will see at the top, the topic contents which should be sorted along with the replies, it has a vote of 0 and the one under has a vote of 46.
    If I turn voting off for topics the that content does not get voting buttons.
    Also the admin bypass does not work.

    Regards
    Clive

    Plugin Author natekinkead

    (@natekinkead)

    @clivesmith,

    The votes on topics are NOT an accumulation of all the votes for the replies under that topic. Topics are voted on independent of their replies.

    When you are viewing a topic page, the very first message at the top IS the topic. All the messages below that are the replies to the topic.

    When you sort replies by votes, the topic will still remain at the top, but all the replies below that will be sorted by their votes.

    It looks to me like everything is working as I would expect it to. If you don’t want voting or sorting by votes on topics, you may disable those.

    Maybe I’m having a hard time understanding what you are wanting it to do.

    I also can’t test on your site if the admin bypass is working or not, but it still works on my test site. One troubleshooting tip for you with that issue. Press F12 to open the dev tools and then place your vote. You should see a message in the console telling you if a vote went through or if it was disallowed.

    Thread Starter Clivesmith

    (@clivesmith)

    Hi,
    Sorry I was wrong the votes on topic is not an accumulation, I miss read what I was seeing.
    The problem is I don’t want topics to be voted against each other, I only want voting inside each topic, I want votes to be cast on the topic contents and the reply so the ‘post’ with the highest vote is at the top not necessarily the topic ‘post’, which is what I had before.

    I have reverted back to a previous version that works as I want it. I understand that this may not be how others want it.
    As admin I rarely vote so I don’t need the multiple voting.

    Regards
    Clive

    Plugin Author natekinkead

    (@natekinkead)

    OK, I’m glad the old version works the way you want it. I think most people would want the topic at the top and only sort the replies below it.

    Thread Starter Clivesmith

    (@clivesmith)

    I understand that, thank you.

    Regards

    Clive

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Problem with sorting’ is closed to new replies.