Viewing 30 posts - 1 through 30 (of 32 total)
  • Author
  • #792582

    How are popular posts calculated by the Enfold Combo Widget? I’m just curious because we are migrating our site, and the popular posts displayed by the widget are different than those displayed on our old site’s widget.


    Hey perfectword,

    I am not sure if I understood your question. May you explain it better?

    Best regards,
    John Torvik


    Well, I’m not really certain how to say it better, but I was wondering how the widget decides what post is “popular” and what isn’t? Like if it was based on hits or something else. But I think I figured it out: it seems to be choosing whichever posts have the most comments on them. :)
    While we’re on the subject, though, is there any way to exclude a post from the “Most Popular” list in the Enfold Combo Widget?



    Yes, that is correct. The orderby parameter is set to comment_count or which posts have the highest comment count. If you want to exclude post, you need to modify the default query in the framework > php > class-framework-widgets.php file, line 962:


    Best regards,


    Thanks for the response. I found the line, but I don’t really know how to write in the modification to the query. Could you please provide me with the modified code (and also notate where I will need to put in any post-specific info like the ID number)?
    Also, I am running my site with a child theme–can I make this change in the child theme? If so, where?
    Thanks in advance.



    The ideal solution would be to create a category, add those posts to it, then exclude the category.


    Best regards,
    Jordan Shannon


    Thanks Jordan.
    Where in that line do I specify which category to exclude? Do I replace the “4” in “cat=-4” with the category ID, or something else?
    Also, I duplicated the “framework > php > class-framework-widgets.php” file and location in my child theme, and am making my edits there. Is that correct?



    Correct duplicate the structure within your child theme, and then in the theme functions file add the following:

    include( get_stylesheet_directory() . '/framework/php/class-framework-widgets.php' );

    Also, yes replace the 4 with your specific category id.

    Best regards,
    Jordan Shannon


    I followed the instructions, but it broke the site. All I get is a blank page with this text: “No direct script access allowed”
    What could I be doing wrong?



    Were you able to recover the site? To do so just remove the last code I added from your functions file. You may have to do it within a file editor outside of the wordpress dash.

    Best regards,
    Jordan Shannon


    I did recover the site, the way you just said.



    Okay great. Do you have this line at the top of the file you are trying to modify?

    <?php  if (  ! defined( 'AVIA_FW' ) ) exit( 'No direct script access allowed' );

    Best regards,
    Jordan Shannon


    Yes, that is at the top of my class-framework-widget.php file in my child theme.



    Great. Please change that to simply:


    Then add the following line to your child themes function.php

    require( 'class-framework-widget.php' );

    Let me know the results.

    Best regards,
    Jordan Shannon


    Didn’t work. :(
    Still works fine after the first change, but once I add the snippet to function.php, it breaks the site–no text this time, just a completely blank page. (I recovered the site again.)



    If possible please post FTP and temporary admin logins here privately.

    Best regards,
    Jordan Shannon


    Before we go there, can we please try this one more time?
    I edited the actual class-framework-widgets.php file in Enfold parent, and I have verified that this works to exclude categories:
    I also know that this code correctly accesses the class-framework-widgets.php file in Enfold-child theme
    require_once( get_stylesheet_directory() . '/framework/php/class-framework-widgets.php' );
    because I edited the error “No direct script access allowed” in that file, and the error displayed as I edited it.
    So the only problem that remains is that, for some reason, the phrase
    ( ! defined('AVIA_FW'))
    is being triggered, as “AVIA_FW” is not getting defined by class-framework-widgets.php in the child theme. (I know you told me to remove that line, but it doesn’t fix the problem–it only removes the error message.)
    So my question is, how can I define “AVIA_FW” in my child theme (or is it not that simple)?



    Sure, I can continue to try and walk you through it. Paste the class-framework-widgets.php file into the root directory (enfold-child) and see if the error remains.

    Best regards,
    Jordan Shannon


    No change. Rewrote the code to reference the file at its new location
    require_once( get_stylesheet_directory() . '/class-framework-widgets.php' );
    but the error persisted. (At first we left off the leading “/” in the location and it didn’t work at all, so we added that.) It is definitely still referencing the child’s class-framework-widgets.php because we can still see the edited error message.
    (Also we tried removing
    if ( ! defined( 'AVIA_FW' ) ) exit( 'No direct script access allowed' );
    from the class-framework-widgets.php again, but it was still broken [blank–no error message].)


    We just turned on display_errors in PHP and got this error message for you:
    Fatal error: Cannot declare class avia_instagram_widget, because the name is already in use in /home/account/domain/wp-content/themes/enfold/framework/php/class-framework-widgets.php on line 0
    Hope this is helpful.



    You also have the option to copy everything in that file to your child theme functions.php file and you can edit it there. Whenever you see code surrounded by the “functions_exists” then you can copy it all to your child theme functions.php file and it will be used instead.

    Best regards,
    Jordan Shannon


    Can you please reply again? I don’t think your whole answer came through.



    Apologies, it looks like the format got messed up. Please view the updated answer above.

    Best regards,
    Jordan Shannon


    Thanks for all the help Jordan.
    I copied the entire “AVIA COMBO WIDGET” code into the functions.php (with the edits) and it’s working now! :) Seems like a simple solution after everything.


    Now that we’ve done all that….. How could the code be changed to exclude by post instead of category?


    Hi perfectword,

    Do you have ids of the posts you want to exclude or what is the criteria for exclusion?

    Best regards,



    As I mentioned before, the ideal solution would be to create a category, add those posts to it, then exclude the category.

    Best regards,
    Jordan Shannon


    Thank you. I realize that it would be simplest to just put all the posts I want to exclude from popular posts into their own category; however, I realize now that solution will not suit my needs. Please provide me with the code I need to exclude posts on a per post basis. I know the post ids I want to exclude. Thanks again.



    Please use the post__not_in parameter.

    OR replace the avia_get_post_list function with the following.

    $exclude = array(46,31,24);
    $query   = array('posts_per_page' => $posts, 'orderby' => 'comment_count', 'post__not_in' => $exclude);
    avia_get_post_list($query, false);

    Include the id of the posts in the $exclude array.

    Best regards,


    Thanks so much! I used the code you provided and it’s perfect. :)

Viewing 30 posts - 1 through 30 (of 32 total)
  • The topic ‘Enfold Combo Widget – Popular Posts’ is closed to new replies.