Viewing 30 posts - 1 through 30 (of 32 total)
  • Author
    Posts
  • #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.
    Thanks.

    #792668

    Hey perfectword,

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

    Best regards,
    John Torvik

    #792673

    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?

    #793160

    Hi,

    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:

    avia_get_post_list('cat=&orderby=comment_count&posts_per_page='.$posts);
    

    Best regards,
    Ismael

    #793497

    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.

    #793547

    Hi,

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

    avia_get_post_list('cat=-4&orderby=comment_count&posts_per_page='.$posts);

    Best regards,
    Jordan Shannon

    #793563

    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?

    #793593

    Hi,

    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

    #793604

    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?

    #793608

    Hi,

    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

    #793609

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

    #793614

    Hi,

    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

    #793617

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

    #793622

    Hi,

    Great. Please change that to simply:

    <?php 

    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

    #793629

    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.)

    #793631

    Hi,

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

    Best regards,
    Jordan Shannon

    #793648

    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:
    avia_get_post_list('cat=-14,-18&orderby=comment_count&posts_per_page='.$posts);
    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)?

    #793654

    Hi,

    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

    #793658

    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].)

    #793660

    Hey,
    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.

    #793662

    Hi,

    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

    #793668

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

    #793673

    Hi,

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

    Best regards,
    Jordan Shannon

    #793711

    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.

    #793731

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

    #793882

    Hi perfectword,

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

    Best regards,
    Victoria

    #793977

    Hi,

    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

    #794226

    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.

    #794694

    Hi,

    Please use the post__not_in parameter.

    https://codex.wordpress.org/Class_Reference/WP_Query

    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,
    Ismael

    #795087

    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.