Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Sidebars & Widgets (http://forum.bytesforall.com/forumdisplay.php?f=14)
-   -   BFA Popular Post Widget with the "display the list on" feature not working? (http://forum.bytesforall.com/showthread.php?t=3466)

cyboc Sep 15, 2009 12:58 PM

BFA Popular Post Widget with the "display the list on" feature not working?
 
I'm running Atahualpa 3.4.1 on Wordpress 2.8.4 and I'm trying to display the BFA Popular Posts and BFA Recent Comments widgets only on the home page. For both of them, I checked the Homepage checkbox in the "display the list on" section. The BFA Recent Comments widget correctly displays only on the homepage but the BFA Popular Posts widget displays everywhere.

Comparing the code in bfa_recent_comments.php vs bfa_popular_posts.php (both files in the "functions" directory) seems to reveal the reason. bfa_recent_comments.php has an "if" statement that checks for the page you are on:

PHP Code:

if ( (is_home() && $bfa_rc_display_homepage == "on") OR 
(
is_category() && $bfa_rc_display_category == "on") OR 
(
is_single() && $bfa_rc_display_post == "on") OR 
(
is_page() && $bfa_rc_display_page == "on") OR 
(
is_date() && $bfa_rc_display_archive == "on") OR       
(
is_tag() && $bfa_rc_display_tag == "on") OR 
(
is_search() && $bfa_rc_display_search == "on") OR 
(
is_author() && $bfa_rc_display_author == "on") OR 
(
is_404() && $bfa_rc_display_404 == "on")) {
...


I think bfa_popular_posts.php needs similar code except variable names are different. For example, this seems to be what is needed:
PHP Code:

if ( (is_home() && $bfa_pp_display_homepage == "on") OR 
(
is_category() && $bfa_pp_display_category == "on") OR 
(
is_single() && $bfa_pp_display_post == "on") OR 
(
is_page() && $bfa_pp_display_page == "on") OR 
(
is_date() && $bfa_pp_display_archive == "on") OR       
(
is_tag() && $bfa_pp_display_tag == "on") OR 
(
is_search() && $bfa_pp_display_search == "on") OR 
(
is_author() && $bfa_pp_display_author == "on") OR 
(
is_404() && $bfa_pp_display_404 == "on")) {
...


While we are on the topic, it would be nice to have a "BFA Recent Posts" widget with similar "display only on" logic.

cyboc Sep 15, 2009 03:48 PM

Quote:

Originally Posted by cyboc (Post 14676)
I think bfa_popular_posts.php needs similar code except variable names are different. For example, this seems to be what is needed:
PHP Code:

if ( (is_home() && $bfa_pp_display_homepage == "on") OR 
(
is_category() && $bfa_pp_display_category == "on") OR 
(
is_single() && $bfa_pp_display_post == "on") OR 
(
is_page() && $bfa_pp_display_page == "on") OR 
(
is_date() && $bfa_pp_display_archive == "on") OR       
(
is_tag() && $bfa_pp_display_tag == "on") OR 
(
is_search() && $bfa_pp_display_search == "on") OR 
(
is_author() && $bfa_pp_display_author == "on") OR 
(
is_404() && $bfa_pp_display_404 == "on")) {
...



Yup, my little hack shown above works! I put it in function widget_mdv_most_commented, just below the line global $wpdb;. Don't forget to add the closing "}" at the bottom of that function to close the if statement.

cyboc Sep 15, 2009 03:52 PM

Quote:

Originally Posted by cyboc (Post 14676)
While we are on the topic, it would be nice to have a "BFA Recent Posts" widget with similar "display only on" logic.

Another nice to have would be "BFA Upcoming Posts" widget, again with "display only on" logic. I guess it would be similar to the Upcoming Posts plugin but with BFA's "display only on" logic. Basically, it should display the titles of future-dated posts (i.e. posts that haven't been published yet).


All times are GMT -6. The time now is 03:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.