Tagged: combo widget, exclude
-
AuthorPosts
-
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 #792668Hey perfectword,
I am not sure if I understood your question. May you explain it better?
Best regards,
John TorvikMay 13, 2017 at 8:12 am #792673Well, 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 #793160Hi,
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,
IsmaelMay 15, 2017 at 8:55 pm #793497Thanks 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 #793547Hi,
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 ShannonMay 15, 2017 at 10:28 pm #793563Thanks 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?May 15, 2017 at 11:11 pm #793593Hi,
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 ShannonMay 15, 2017 at 11:36 pm #793604I 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 #793608Hi,
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 ShannonMay 15, 2017 at 11:45 pm #793609I did recover the site, the way you just said.
May 15, 2017 at 11:53 pm #793614Hi,
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 ShannonMay 15, 2017 at 11:56 pm #793617Yes, that is at the top of my class-framework-widget.php file in my child theme.
May 16, 2017 at 12:10 am #793622Hi,
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 ShannonMay 16, 2017 at 12:48 am #793629Didn’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 #793631Hi,
If possible please post FTP and temporary admin logins here privately.
Best regards,
Jordan ShannonMay 16, 2017 at 2:13 am #793648Before 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)?May 16, 2017 at 2:42 am #793654Hi,
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 ShannonMay 16, 2017 at 2:55 am #793658No 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 #793660Hey,
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 #793662Hi,
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- This reply was modified 7 years, 5 months ago by Jordan Shannon.
May 16, 2017 at 3:15 am #793668Can you please reply again? I don’t think your whole answer came through.
May 16, 2017 at 3:23 am #793673Hi,
Apologies, it looks like the format got messed up. Please view the updated answer above.
Best regards,
Jordan ShannonMay 16, 2017 at 5:32 am #793711Thanks 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 #793731Now 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 #793882Hi perfectword,
Do you have ids of the posts you want to exclude or what is the criteria for exclusion?
Best regards,
VictoriaMay 16, 2017 at 3:10 pm #793977Hi,
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 ShannonMay 16, 2017 at 6:16 pm #794226Thank 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 #794694Hi,
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,
IsmaelMay 17, 2017 at 9:15 pm #795087Thanks so much! I used the code you provided and it’s perfect. :)
-
AuthorPosts
- The topic ‘Enfold Combo Widget – Popular Posts’ is closed to new replies.