Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1352 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming :

About Wordpress widgets?

Thread title: About Wordpress widgets?
Reply  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
01-07-2011, 05:57 AM
#1
noboss is offline noboss
Status: Member
Join date: Mar 2010
Location:
Expertise:
Software:
 
Posts: 177
iTrader: 0 / 0%
 

noboss is on a distinguished road

  Old  About Wordpress widgets?

So, I put an Adsense ad unit on the sidebar of my Wordpress blog as a widget. I want the ad unit appear only on the index page, and not on single posts. You can do it on Joomla, but I don't see such a feature on Wordpress. Any suggestion?

Reply With Quote
01-07-2011, 08:55 AM
#2
mac is offline mac
Status: Junior Member
Join date: Nov 2010
Location:
Expertise:
Software:
 
Posts: 49
iTrader: 0 / 0%
 

mac is an unknown quantity at this point

  Old

I believe I have done this before. There is a syntax in the HTML that determines whether the page to be displayed is a single page or an index page. Find the container for the portion of the page where you want the ad to appear and insert the Adsense code there; but put the code inside the conditional syntax.

Reply With Quote
01-07-2011, 02:38 PM
#3
Gaz is offline Gaz
Gaz's Avatar
Status: Request a custom title
Join date: Apr 2007
Location: UK
Expertise: Code & Programming
Software: Coda, TextMate, Sublime 2
 
Posts: 2,097
iTrader: 26 / 100%
 

Gaz will become famous soon enough Gaz will become famous soon enough

Send a message via Skype™ to Gaz

  Old

There might be a better way with widgets but I'd do the same as mac:

PHP Code:
<?php if( is_home() ): ?>
ADSENSE CODE
<?php endif; ?>
Info: http://codex.wordpress.org/Conditional_Tags

Reply With Quote
Thanked by:
KewL (01-07-2011)
01-07-2011, 03:08 PM
#4
KewL is offline KewL
Status: OG
Join date: Apr 2006
Location: California
Expertise: Design, Music, Xhtml, Css
Software: Photoshop, Coda, FL Studio
 
Posts: 2,007
iTrader: 11 / 100%
 

KewL is an unknown quantity at this point

  Old

Originally Posted by Gaz View Post
There might be a better way with widgets but I'd do the same as mac:

PHP Code:
<?php if( is_home() ): ?>
ADSENSE CODE
<?php endif; ?>
Info: http://codex.wordpress.org/Conditional_Tags
Thanks, that'll probably be use full to me one day.

Reply With Quote
01-08-2011, 05:18 PM
#5
noboss is offline noboss
Status: Member
Join date: Mar 2010
Location:
Expertise:
Software:
 
Posts: 177
iTrader: 0 / 0%
 

noboss is on a distinguished road

  Old

Wow, thanks so much Gaz and Mac. I will put the Adsense ad that way. I think it's simpler than using a widget. Do you think it will make the page load faster also?

Reply With Quote
01-08-2011, 06:54 PM
#6
Jordan is offline Jordan
Jordan's Avatar
Status: #pugs {display: block;}
Join date: Jan 2007
Location: Chicago
Expertise: CSS, HTML, PHP
Software: Sublime Text 2
 
Posts: 1,187
iTrader: 7 / 100%
 

Jordan is on a distinguished road

  Old

You really won't notice between a widget and/or hard code truth be told. It all depends on how the rest of your WordPress blog is optimized.

Reply With Quote
01-08-2011, 09:08 PM
#7
Gaz is offline Gaz
Gaz's Avatar
Status: Request a custom title
Join date: Apr 2007
Location: UK
Expertise: Code & Programming
Software: Coda, TextMate, Sublime 2
 
Posts: 2,097
iTrader: 26 / 100%
 

Gaz will become famous soon enough Gaz will become famous soon enough

Send a message via Skype™ to Gaz

  Old

Except for the fact that if you have lots of sidebars defined it is easier to move them around for the less PHP/hard code inclined..

Reply With Quote
01-09-2011, 07:07 AM
#8
Jordan is offline Jordan
Jordan's Avatar
Status: #pugs {display: block;}
Join date: Jan 2007
Location: Chicago
Expertise: CSS, HTML, PHP
Software: Sublime Text 2
 
Posts: 1,187
iTrader: 7 / 100%
 

Jordan is on a distinguished road

  Old

Originally Posted by Gaz View Post
Except for the fact that if you have lots of sidebars defined it is easier to move them around for the less PHP/hard code inclined..
That has nothing to do with load time for pages using hardcode sidebars vs widgets (specifically just the conditional sidebars.)

Of course moving/customizing a widget is going to be easier and more efficient than hardcode.

Reply With Quote
01-09-2011, 10:03 AM
#9
mac is offline mac
Status: Junior Member
Join date: Nov 2010
Location:
Expertise:
Software:
 
Posts: 49
iTrader: 0 / 0%
 

mac is an unknown quantity at this point

  Old

Right, a widget is designed to make the template more user-friendly. But for those who can at least see what the codes mean and not mean (like the conditional code above), then editing the template directly should work.

Just remember, it's one thing to know the code. It's another thing to know where to place them. That's why I mentioned "containers" in my earlier post. A little live experiment should do the trick.

Reply With Quote
01-09-2011, 06:43 PM
#10
noboss is offline noboss
Status: Member
Join date: Mar 2010
Location:
Expertise:
Software:
 
Posts: 177
iTrader: 0 / 0%
 

noboss is on a distinguished road

  Old

Yeah using widgets maybe easier but personally I prefer to hardcode than to use widgets. There are places where you can't put specific content (like ads) on using widgets.

Reply With Quote
Reply  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed