May 13, 2017 at 3:26 am #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.May 13, 2017 at 7:43 am #792668
I am not sure if I understood your question. May you explain it better?
John TorvikMay 13, 2017 at 8:12 am #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?May 15, 2017 at 6:09 am #793160
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:
IsmaelMay 15, 2017 at 8:55 pm #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.May 15, 2017 at 10:07 pm #793547
The ideal solution would be to create a category, add those posts to it, then exclude the category.
Jordan ShannonMay 15, 2017 at 10:28 pm #793563
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?May 15, 2017 at 11:11 pm #793593
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.
Jordan ShannonMay 15, 2017 at 11:36 pm #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?May 15, 2017 at 11:40 pm #793608
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.
Jordan ShannonMay 15, 2017 at 11:45 pm #793609May 15, 2017 at 11:53 pm #793614
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' );
Jordan ShannonMay 15, 2017 at 11:56 pm #793617
Yes, that is at the top of my class-framework-widget.php file in my child theme.May 16, 2017 at 12:10 am #793622
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.
Jordan ShannonMay 16, 2017 at 12:48 am #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.)May 16, 2017 at 12:50 am #793631
If possible please post FTP and temporary admin logins here privately.
Jordan ShannonMay 16, 2017 at 2:13 am #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:
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)?May 16, 2017 at 2:42 am #793654
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.
Jordan ShannonMay 16, 2017 at 2:55 am #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].)May 16, 2017 at 3:03 am #793660
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.May 16, 2017 at 3:08 am #793662
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.
May 16, 2017 at 3:15 am #793668May 16, 2017 at 3:23 am #793673
- This reply was modified 6 years, 6 months ago by Jordan Shannon.
Apologies, it looks like the format got messed up. Please view the updated answer above.
Jordan ShannonMay 16, 2017 at 5:32 am #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.May 16, 2017 at 6:33 am #793731
Now that we’ve done all that….. How could the code be changed to exclude by post instead of category?May 16, 2017 at 1:02 pm #793882
Do you have ids of the posts you want to exclude or what is the criteria for exclusion?
VictoriaMay 16, 2017 at 3:10 pm #793977
As I mentioned before, the ideal solution would be to create a category, add those posts to it, then exclude the category.
Jordan ShannonMay 16, 2017 at 6:16 pm #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.May 17, 2017 at 8:26 am #794694
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.
IsmaelMay 17, 2017 at 9:15 pm #795087
- The topic ‘Enfold Combo Widget – Popular Posts’ is closed to new replies.