Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-14-2009, 08:19 PM Wordpress Question
Super Talker

Posts: 133
Trades: 0
On the sidebar of my wordpress blog, I only want some advertisements to appear on the main page of my blog (it becomes too long when viewing individual posts. How would I do this?

I'm talking about the ads under the Sponsors tab at http://nkingdom.com
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
smashking is offline
Reply With Quote
View Public Profile Visit smashking's homepage!
 
 
Register now for full access!
Old 03-14-2009, 10:49 PM Re: Wordpress Question
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
All wordpress pages use a shared sidebar, so you'll have to edit the code in sidebar.php to do this.

Wordpress has a built in way of handling this sort of thing:
PHP Code:
<?php 
/* If this is the frontpage */ 
if ( is_home() || is_page() )
{
     
//echo advertisement
}
I think that should work. Just find the position in the sidebar where you want your ads to appear and use that code.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-15-2009, 12:26 AM Re: Wordpress Question
Skilled Talker

Posts: 59
Location: Random places
Trades: 0
You also have to use !is_paged() if you only want it to appear on the main page, and not the main page's archives. ["previous entries" at the bottom]
__________________

Please login or register to view this content. Registration is FREE
- Ugly website, great ideas
Try:
Please login or register to view this content. Registration is FREE
.
Please login or register to view this content. Registration is FREE
.
Please login or register to view this content. Registration is FREE

Last edited by Generator; 03-15-2009 at 12:21 PM.. Reason: checked my WP code :)
Generator is offline
Reply With Quote
View Public Profile Visit Generator's homepage!
 
Old 03-15-2009, 12:34 AM Re: Wordpress Question
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by Generator View Post
You also have to use !is_page() (I think that's correct) if you only want it to appear on the main page, and not the main page's archives. ["previous entries" at the bottom]

That's assuming || is_page() doesn't do that for ya - not too familiar with php conditionals
Are you sure? I pulled that code off of my own WP and it was for the links and meta sections, which only appear on the main page. I could be wrong, but from looking at my own blog that's how it appears.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-15-2009, 01:43 AM Re: Wordpress Question
Super Talker

Posts: 133
Trades: 0
Quote:
Originally Posted by smashking View Post
On the sidebar of my wordpress blog, I only want some advertisements to appear on the main page of my blog (it becomes too long when viewing individual posts. How would I do this?

I'm talking about the ads under the Sponsors tab at http://nkingdom.com
Hmm...it didn't work, but maybe I didn't do it right. Where do I put my ad code at? Sorry, I'm not great at php. I only really know enough to figure out what something is so I know how to move things around to get the design I want.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Last edited by smashking; 03-15-2009 at 01:45 AM..
smashking is offline
Reply With Quote
View Public Profile Visit smashking's homepage!
 
Old 03-15-2009, 01:50 AM Re: Wordpress Question
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
In your dashboard go to your theme editor and locate sidebar.php. Different themes have different sidebar code so where it goes is really going to depend on your theme. I think the code should be something like:
PHP Code:
if ( is_home() || is_page() ) 

     echo 
'Advertisement code goes here';

If that doesn't work you can post your sidebar.php code and I'll see what I can do.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-15-2009, 02:12 AM Re: Wordpress Question
Super Talker

Posts: 133
Trades: 0
Ok, that is what I did but I get a syntax error. Here is my code. Some of it has been edited by me so it might not be the most efficient code, but it gets me what I need.

PHP Code:
<div id="dynamic_sidebars">
<div class="dynamic_widget">
<?php if ( !function_exists('dynamic_sidebar')
        || !
dynamic_sidebar(1) ) : ?>
<h2>Categories</h2>
<ul class="arrow">
<?php wp_list_cats('sort_column=name&optioncount=0'); ?>
</ul>
<h2>Recent Entries</h2>
<ul class="arrow">
<?php get_archives('postbypost'5); ?>
</ul>
<h2>Featured Sponsor</h2>
<center><a href="http://click.linksynergy.com/fs-bin/click?id=PWeI268eJl8&offerid=148499.10000086&type=4&subid=0"><IMG alt="Gameduell Inc." border="0" src="http://us-m1.gameduell.com/res/Affiliate/US/180x150/gif/prt/180x150_prt_us.gif"></a><IMG border="0" width="1" height="1" src="http://ad.linksynergy.com/fs-bin/show?id=PWeI268eJl8&bids=148499.10000086&type=4&subid=0"></center>
<h2>Recent Comments</h2>
<ul class="arrow">
<?php if(function_exists("get_recent_comments")) : ?>
<?php get_recent_comments
(); ?>
<?php 
else : ?>
<?php mw_recent_comments
(5false505035'all''<li><a href="%permalink%" title="%title%"><font color="#AB3622">%date%</font> | %author_name% in %title%</a></li>','d.m'); ?>
<?php 
endif; ?>
</ul>
<h2>Links</h2>
<ul class="arrow">
<?php get_links(-1'<li>''</li>'' - '); ?>
</ul>
<?php endif; ?>
<h2>Rss</h2>
<ul class="arrow">
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>">Main Entries RSS</a></li>
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>">
<?php _e('Comments RSS'); ?>
</a></li>
</ul>
<h2>Archives</h2>
<ul class="arrow">
<?php wp_get_archives('type=monthly'); ?>
</ul>
<!--<h2>Meta</h2>
<ul class="arrow">
<?php wp_register(); ?>
<li>
<?php wp_loginout(); ?>
</li>
<li><a href="http://validator.w3.org/check?uri=referer">Valid XHTML</a></li>
<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
<?php wp_meta(); ?>
</ul>-->
<h2>Sponsors</h2><br />
<center><script src="http://tag.contextweb.com/TagPublish/getjs.aspx?action=VIEWAD&cwrun=200&cwadformat=160X600&cwpid=506087&cwwidth=160&cwheight=600&cwpnet=1&cwtagid=52101"></script><br /><br /><script src="http://entrecard.s3.amazonaws.com/widget.js?user_id=44205&type=standard_127" type="text/javascript" id="ecard_widget"></script></center><br />
</div>
</div>
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
smashking is offline
Reply With Quote
View Public Profile Visit smashking's homepage!
 
Old 03-15-2009, 02:49 AM Re: Wordpress Question
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
This should work:
PHP Code:
<div id="dynamic_sidebars"> 
<div class="dynamic_widget"> 
<?php if ( !function_exists('dynamic_sidebar'
        || !
dynamic_sidebar(1) ) : ?> 
<h2>Categories</h2> 
<ul class="arrow"> 
<?php wp_list_cats('sort_column=name&optioncount=0'); ?> 
</ul> 
<h2>Recent Entries</h2> 
<ul class="arrow"> 
<?php get_archives('postbypost'5); ?> 
</ul> 
<h2>Featured Sponsor</h2> 
<center><a href="http://click.linksynergy.com/fs-bin/click?id=PWeI268eJl8&offerid=148499.10000086&type=4&subid=0"><IMG alt="Gameduell Inc." border="0" src="http://us-m1.gameduell.com/res/Affiliate/US/180x150/gif/prt/180x150_prt_us.gif"></a><IMG border="0" width="1" height="1" src="http://ad.linksynergy.com/fs-bin/show?id=PWeI268eJl8&bids=148499.10000086&type=4&subid=0"></center> 
<h2>Recent Comments</h2> 
<ul class="arrow"> 
<?php if(function_exists("get_recent_comments")) : ?> 
<?php get_recent_comments(); ?> 
<?php else : ?> 
<?php mw_recent_comments(5false505035'all''<li><a href="%permalink%" title="%title%"><font color="#AB3622">%date%</font> | %author_name% in %title%</a></li>','d.m'); ?> 
<?php endif; ?> 
</ul> 
<h2>Links</h2> 
<ul class="arrow"> 
<?php get_links(-1'<li>''</li>'' - '); ?> 
</ul> 
<?php endif; ?> 
<h2>Rss</h2> 
<ul class="arrow"> 
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>">Main Entries RSS</a></li> 
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"> 
<?php _e('Comments RSS'); ?> 
</a></li> 
</ul> 
<h2>Archives</h2> 
<ul class="arrow"> 
<?php wp_get_archives('type=monthly'); ?> 
</ul> 
<!--<h2>Meta</h2> 
<ul class="arrow"> 
<?php wp_register(); ?> 
<li> 
<?php wp_loginout(); ?> 
</li> 
<li><a href="http://validator.w3.org/check?uri=referer">Valid XHTML</a></li> 
<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li> 
<?php wp_meta(); ?> 
</ul>--> 
<?php if(is_home()) { ?>
<h2>Sponsors</h2><br /> 
<center><script src="http://tag.contextweb.com/TagPublish/getjs.aspx?action=VIEWAD&cwrun=200&cwadformat=160X600&cwpid=506087&cwwidth=160&cwheight=600&cwpnet=1&cwtagid=52101"></script><br /><br /><script src="http://entrecard.s3.amazonaws.com/widget.js?user_id=44205&type=standard_127" type="text/javascript" id="ecard_widget"></script></center><br /> 
<?php ?>
<?php 
endif; ?>
</div> 
</div>
In this case I set it so that your sponsors section would only be visible on your home page.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 03-15-2009 at 02:52 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-15-2009, 09:21 AM Re: Wordpress Question
Super Talker

Posts: 133
Trades: 0
I get this:

Code:
Parse error: syntax error, unexpected T_ENDIF in /home/supersma/public_html/wp-content/themes/red-star-version-2/sidebar.php on line 53
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
smashking is offline
Reply With Quote
View Public Profile Visit smashking's homepage!
 
Old 03-15-2009, 12:20 PM Re: Wordpress Question
Skilled Talker

Posts: 59
Location: Random places
Trades: 0
Quote:
Originally Posted by NullPointer View Post
Are you sure? I pulled that code off of my own WP and it was for the links and meta sections, which only appear on the main page. I could be wrong, but from looking at my own blog that's how it appears.
Yup, check http://tinsology.net/page/2/

You can see how it works with the !is_paged type code over on my graphics blog. The previous pages don't have some of the contents I don't want duplicated

Just checked my code and it's this I use for that:
Code:
<?php if (is_home() && !is_paged()) { } ?>
__________________

Please login or register to view this content. Registration is FREE
- Ugly website, great ideas
Try:
Please login or register to view this content. Registration is FREE
.
Please login or register to view this content. Registration is FREE
.
Please login or register to view this content. Registration is FREE
Generator is offline
Reply With Quote
View Public Profile Visit Generator's homepage!
 
Old 03-15-2009, 05:59 PM Re: Wordpress Question
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by Generator View Post
Yup, check http://tinsology.net/page/2/

You can see how it works with the !is_paged type code over on my graphics blog. The previous pages don't have some of the contents I don't want duplicated

Just checked my code and it's this I use for that:
Code:
<?php if (is_home() && !is_paged()) { } ?>
My mistake. Turns out (after looking up the documentation) that is_home() refers to the main page and is_page() refers to any page (which may include the home page). So I think using just is_home() is correct.

This should fix that bug smashking:
PHP Code:
<div id="dynamic_sidebars">  
<div class="dynamic_widget">  
<?php if ( !function_exists('dynamic_sidebar')  
        || !
dynamic_sidebar(1) ) : ?>  
<h2>Categories</h2>  
<ul class="arrow">  
<?php wp_list_cats('sort_column=name&optioncount=0'); ?>  
</ul>  
<h2>Recent Entries</h2>  
<ul class="arrow">  
<?php get_archives('postbypost'5); ?>  
</ul>  
<h2>Featured Sponsor</h2>  
<center><a href="http://click.linksynergy.com/fs-bin/click?id=PWeI268eJl8&offerid=148499.10000086&type=4&subid=0"><IMG alt="Gameduell Inc." border="0" src="http://us-m1.gameduell.com/res/Affiliate/US/180x150/gif/prt/180x150_prt_us.gif"></a><IMG border="0" width="1" height="1" src="http://ad.linksynergy.com/fs-bin/show?id=PWeI268eJl8&bids=148499.10000086&type=4&subid=0"></center>  
<h2>Recent Comments</h2>  
<ul class="arrow">  
<?php if(function_exists("get_recent_comments")) : ?>  
<?php get_recent_comments(); ?>  
<?php else : ?>  
<?php mw_recent_comments(5false505035'all''<li><a href="%permalink%" title="%title%"><font color="#AB3622">%date%</font> | %author_name% in %title%</a></li>','d.m'); ?>  
<?php endif; ?>  
</ul>  
<h2>Links</h2>  
<ul class="arrow">  
<?php get_links(-1'<li>''</li>'' - '); ?>  
</ul>  
<?php endif; ?>  
<h2>Rss</h2>  
<ul class="arrow">  
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>">Main Entries RSS</a></li>  
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>">  
<?php _e('Comments RSS'); ?>  
</a></li>  
</ul>  
<h2>Archives</h2>  
<ul class="arrow">  
<?php wp_get_archives('type=monthly'); ?>  
</ul>  
<!--<h2>Meta</h2>  
<ul class="arrow">  
<?php wp_register(); ?>  
<li>  
<?php wp_loginout(); ?>  
</li>  
<li><a href="http://validator.w3.org/check?uri=referer">Valid XHTML</a></li>  
<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>  
<?php wp_meta(); ?>  
</ul>-->  
<?php if(is_home()) : ?> 
<h2>Sponsors</h2><br />  
<center><script src="http://tag.contextweb.com/TagPublish/getjs.aspx?action=VIEWAD&cwrun=200&cwadformat=160X600&cwpid=506087&cwwidth=160&cwheight=600&cwpnet=1&cwtagid=52101"></script><br /><br /><script src="http://entrecard.s3.amazonaws.com/widget.js?user_id=44205&type=standard_127" type="text/javascript" id="ecard_widget"></script></center><br />  
<?php endif; ?> 
</div>  
</div>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 03-15-2009 at 06:03 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-16-2009, 05:27 PM Re: Wordpress Question
Super Talker

Posts: 133
Trades: 0
awesome, that works. Thanks a ton for your help.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
smashking is offline
Reply With Quote
View Public Profile Visit smashking's homepage!
 
Old 03-18-2009, 07:44 PM Re: Wordpress Question
nascar59's Avatar
Ultra Talker

Posts: 299
Location: north central,florida
Trades: 0
thanks for the visable codes nullpointer Iam dealing with the same issue Iam a newbie at this so is info was indeed appreciated
nascar59 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Wordpress Question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.78866 seconds with 12 queries