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
[Wordpress : How to add single page function?]
Old 06-11-2010, 09:21 AM [Wordpress : How to add single page function?]
asmalik12's Avatar
Extreme Talker

Posts: 173
Name: Abdullah Saleem
Trades: 0
Hi,

I wanna add <?php if ( is_single() ) { ?> so that it could appear only in Posts rather than static pages.

Here is a link to that code : Code
__________________
"Think 100 times before you take a decision, But once that decision is taken, stand by it as one man." - Quaid-e-Azam
asmalik12 is offline
Reply With Quote
View Public Profile Visit asmalik12's homepage!
 
 
Register now for full access!
Old 06-11-2010, 06:23 PM Re: [Wordpress : How to add single page function?]
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Is there a question in there somewhere? I'm really not sure what you're asking. More details might help.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 06-11-2010, 09:25 PM Re: [Wordpress : How to add single page function?]
Marik's Avatar
Skilled Talker

Posts: 99
Trades: 0
Well you actually have the answer right there in your question:
PHP Code:
<?php if (is_single()) { ?>

// Place the code that you want to execute on single posts here

<?php ?>
__________________

Please login or register to view this content. Registration is FREE
Marik is offline
Reply With Quote
View Public Profile
 
Old 06-11-2010, 11:24 PM Re: [Wordpress : How to add single page function?]
asmalik12's Avatar
Extreme Talker

Posts: 173
Name: Abdullah Saleem
Trades: 0
@ vangogh My question was that where should I add the single page function?

@ Marik That's a actual problem. Where it is displaying?
__________________
"Think 100 times before you take a decision, But once that decision is taken, stand by it as one man." - Quaid-e-Azam
asmalik12 is offline
Reply With Quote
View Public Profile Visit asmalik12's homepage!
 
Old 06-12-2010, 09:01 PM Re: [Wordpress : How to add single page function?]
Marik's Avatar
Skilled Talker

Posts: 99
Trades: 0
Quote:
Originally Posted by asmalik12 View Post
@ Marik That's a actual problem. Where it is displaying?
Where is it displaying? Well, since this is a conditional statement to show something on the single page which according to wordpress terminology refers to "Posts". Not "Page" pages, Not "Category" pages, Not "Tag" pages, but Posts.

So suppose you wanted to say "Hello this is a post" ONLY on your posts, you would use this:

PHP Code:
<?php if (is_single()) { ?>

<p>Hello this is a post page</p>

<?php ?>
Now as for where you would put this, the whole point of using a conditional statement like this is if it will be placed on a page that is shared by many other pages, so something like this will typically be placed in header.php, sidebar.php, footer.php or some other include file.

But you can actually affect single posts without conditionals by just placing the code in your post.php file.

If this still hasn't answered your question, then maybe you can explain what it is that you are trying to achieve because your initial post isn't really a clear question.
__________________

Please login or register to view this content. Registration is FREE
Marik is offline
Reply With Quote
View Public Profile
 
Old 06-14-2010, 06:48 PM Re: [Wordpress : How to add single page function?]
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Just to add a bit to what Marik said.

You can add this code where you want really. It depends on what you want to do. header.php is a common place, but I've used it in sidebar.php and footer.php. it really depends on what content you want to display. is_single() is the test to decide if that content will display or not.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to [Wordpress : How to add single page function?]
 

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.47747 seconds with 12 queries