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)
-   -   [SOLVED] Where to place the conditional if_front_page tag (http://forum.bytesforall.com/showthread.php?t=11370)

webgurl Nov 24, 2010 08:35 PM

[SOLVED] Where to place the conditional if_front_page tag
 
I've read Flynn's 2009 post about creating new widgets again and again, and I still can't decide where to put the php conditional statement to have the new widget area appear only on the first page.

I have the widget area created on my static front page, and the widget is running on every page.

I know I need the php is_front_page to stop it from running on all pages, and Flynn says to put it in index.php, but I don't see the <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(X) ) : endif; ?> statement he says should be in the template to make the widget run. It's running, so it must be somewhere, but I just can't find it!

I am running default templates for all pages; landing page is set to static in wp>general>Reading options.

Thanks for any help you can give. Site is www.greenvilleconcerts.com/blog wp3.0 ata 3.4.9

lmilesw Nov 24, 2010 08:50 PM

In the place where you are putting the new widget area code put this instead.

HTML Code:

<?php if( is_front_page() ) bfa_widget_area('name=My new widget area'); ?>

webgurl Nov 25, 2010 02:59 PM

Sorry to be such a noob regarding wordpress, but I take it you mean to replace the first line of code only, leaving the div on the following line as it is? Thx a lot.

lmilesw Nov 25, 2010 07:20 PM

I don't know what first line of code you mean. Where did you put the code to create the new widget area? Or where do you want the new widget area to appear?

webgurl Nov 26, 2010 12:23 PM

Quote:

Originally Posted by lmilesw (Post 50310)
I don't know what first line of code you mean. Where did you put the code to create the new widget area? Or where do you want the new widget area to appear?

In ATO>Center Col>Style and Edit center column>Content Above The Loop... I placed this code:

<?php bfa_widget_area('name=My new widget area'); ?>

I don't think I loaded anything else, but in the same place, (Content Above The Loop) right under that line, this code appears:

<div id="my_new_widget_area" class="bfa_widget_area"></div>
<?php /* For MULTI post pages if activated at ATO -> Next/Previous Navigation: */
bfa_next_previous_page_links('Top'); ?>

<?php /* For the plugin Page2Cat http://wordpress.org/extend/plugins/page2cat/ */
if( is_category() AND function_exists('page2cat_output')) { page2cat_output($cat); } ?>


I've been reading Codex and this forum very regularly for four weeks, but the light bulb isn't going off yet. I'm still trying to piece together the dynamically generated code, template tags, static code, etc and AWO on top of that, to see how it all relates. Sorry if I sound lost.

What I am trying to do is have a static front page with a center column widget area to run the gce widget. The widget runs ok, but I have it on all three pages. I only want it to appear on the first page. Thanks.

lmilesw Nov 26, 2010 01:16 PM

OK then... Here is what it appears you currently have in Above the Loop...

HTML Code:

<?php bfa_widget_area('name=My new widget area'); ?>

<div id="my_new_widget_area" class="bfa_widget_area"></div>

<?php /* For MULTI post pages if activated at ATO -> Next/Previous Navigation: */
bfa_next_previous_page_links('Top'); ?>

<?php /* For the plugin Page2Cat http://wordpress.org/extend/plugins/page2cat/ */
if( is_category() AND function_exists('page2cat_output')) { page2cat_output($cat); } ?>

Take out the first two lines and replace with
HTML Code:

<?php if( is_front_page() ) bfa_widget_area('name=My new widget area'); ?>
You can change the name to something else besides My new widget area. That line could for instance be.
HTML Code:

<?php if( is_front_page() ) bfa_widget_area('name=Front page widget area'); ?>
That way when you look in Appearance>Widgets you will see a widget titled Front page widget area.

The whole Above the Loop area would look like the following when you are done.
HTML Code:

<?php bfa_widget_area('name=Front page widget area'); ?>

<?php /* For MULTI post pages if activated at ATO -> Next/Previous Navigation: */
bfa_next_previous_page_links('Top'); ?>

<?php /* For the plugin Page2Cat http://wordpress.org/extend/plugins/page2cat/ */
if( is_category() AND function_exists('page2cat_output')) { page2cat_output($cat); } ?>

If you changed the name to my suggestion you will need to go to the Add new widget areas section and delete the My new widget area. Or you could take out the first two lines first then go to ATO>Add new widget areas and delete the widget area. Now go back to Style and edit Center column and add the code as described above.

I hope I haven't confused you with too many words. If I have just ask for clarification where needed.

webgurl Nov 26, 2010 01:56 PM

One question before I do what you suggested. If I take out the line
HTML Code:

<div id="my_new_widget_area" class="bfa_widget_area"></div>
Will I lose the div section or is it re-created automatically?

lmilesw Nov 26, 2010 02:08 PM

I don't even know why that div is there. You create a new widget area then you put widgets it it via Appearance>Widgets.

webgurl Nov 26, 2010 04:21 PM

Followed your instructions and I'm back on track. Thanks for all your help Larry.


All times are GMT -6. The time now is 06:18 AM.

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