Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1402874

    How to sort the displayed articles by popularity when clicking on a category or tag?
    Most popular – first.

    #1402877

    What expresses “popularity”? Comments or post views?
    Do you measure your page views?

    #1402910

    Post views. We are using external counters, but it is difficult to use it with wortdpress core.

    I found a code for resolving my problem, bit i’m not sure hoe to use it correctly with Enfold. May be you can help me?

    To count the post views, the first thing you have to do is to add the following code to your WordPress Theme functions.php
    <?php
    /*
     * Set post views count using post meta//functions.php
     */
    function customSetPostViews($postID) {
        $countKey = 'post_views_count';
        $count = get_post_meta($postID, $countKey, true);
        if($count==''){
            $count = 0;
            delete_post_meta($postID, $countKey);
            add_post_meta($postID, $countKey, '1');
        }else{
            $count++;
            update_post_meta($postID, $countKey, $count);
        }
    }
    ?>
    And now we will call this function in the single.php to update the count value in the Database.
    <?php
        customSetPostViews(get_the_ID());//single.php
    ?>
    Now to show all the popular post in the descending order by post view count. use this code:
    <?php//popular post query
        query_posts('meta_key=post_views_count&posts_per_page=5&orderby=meta_value_num&
        order=DESC');
        if (have_posts()) : while (have_posts()) : the_post();
    ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php
        endwhile; endif;
        wp_reset_query();
    ?>
    #1403223

    Hi,
    Thanks for sharing the code snippet but I don’t see a way to use this with the Enfold elements, I have opened a feature request for this option, but I’m not sure when it may be available, but I will reply back when I hear from the Dev Team, Thank you for your patience.

    Best regards,
    Mike

    #1403246

    but isn’t there already a count implemented in the combo widget?
    So there must be a possibility to use that. Or is that a popularity used comment-count ?

    #1403333

    @Guenni007 What is combo widget? How to use it?

    #1403415

    Hi,

    Enfold Combo Widget is one of Enfold’s widgets. You can add it to your widget areas in Appearance > Widgets.

    If you’d like to add it to your page, you can add a new widget area (https://i.imgur.com/zdPz3Vd.png), please Enfold Combo Widget inside it, edit the page where you’d like to display your widget, and add Widget Area element to your page to display it.

    Best regards,
    Yigit

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.