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
What PHP Code to Add More content on hundreds post wordpress
Old 05-28-2010, 04:31 AM What PHP Code to Add More content on hundreds post wordpress
Average Talker

Posts: 22
Name: Edwin Teguh N
Trades: 0
Hi,
I have a wordpress blog with hundreds pages.
I want to add affiliate link under my post description on these pages?
I feel I can add instantly maybe at index.php or page.php etc.
But I dont know the code or where to put.
Can you help me?
Thank you very much for your advance.
__________________

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


Please login or register to view this content. Registration is FREE
edwinteguhn is offline
Reply With Quote
View Public Profile Visit edwinteguhn's homepage!
 
 
Register now for full access!
Old 05-28-2010, 04:53 AM Re: What PHP Code to Add More content on hundreds post wordpress
Phunk Rabbit's Avatar
Ultra Talker

Posts: 255
Name: John Nerush
Location: Milton Keynes, UK
Trades: 0
I am not familar with the files or structure of wordpress but I assume you will have to add this into a template file, most likely one of the files included into your index.php or the file that is used to render your pages that feature the post description.
Phunk Rabbit is offline
Reply With Quote
View Public Profile Visit Phunk Rabbit's homepage!
 
Old 05-28-2010, 05:04 AM Re: What PHP Code to Add More content on hundreds post wordpress
Average Talker

Posts: 22
Name: Edwin Teguh N
Trades: 0
Yes, I think must any code to integrate this feature instantly on wordpress post.
More than thank you if you can help me.
__________________

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


Please login or register to view this content. Registration is FREE
edwinteguhn is offline
Reply With Quote
View Public Profile Visit edwinteguhn's homepage!
 
Old 05-28-2010, 09:02 AM Re: What PHP Code to Add More content on hundreds post wordpress
racer x's Avatar
Ultra Talker

Posts: 457
Name: Randy
Location: Northern Wisconsin
Trades: 0
It does depend on your theme structure as for where to put the content.

Your posts are generated with single.php.
Your page theme is page.php
Many sites will use index.php for multiple purposes.

You would add these affiliate links manually after you see:
PHP Code:
<?php the_content(); ?>
However, IMO, I would add that through hooking into WP because you could actually have multiple page templates, etc. Then it will be added to any content. Still a lot to manage.

Paste this code into your functions.php file.(You most likely have this file already in your theme. If not just create it.) Obviously, put your link info where I have "Affiliate links".

PHP Code:
function add_post_content($content) {
    if(!
is_feed() && !is_home()) {
        
$content .= '<p>Affiliate links here</p>';
    }
    return 
$content;
}
add_filter('the_content''add_post_content'); 
(from this source)

Last edited by racer x; 05-28-2010 at 09:05 AM..
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Old 05-28-2010, 10:29 AM Re: What PHP Code to Add More content on hundreds post wordpress
Average Talker

Posts: 22
Name: Edwin Teguh N
Trades: 0
Hi Racer X,
More than thank you. Finally...
But the code not at function.php, but at single.php.
As you said, this depends my theme.
And everything so okay.
Thank you very much
You great..!
__________________

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


Please login or register to view this content. Registration is FREE
edwinteguhn is offline
Reply With Quote
View Public Profile Visit edwinteguhn's homepage!
 
Old 05-28-2010, 07:20 PM Re: What PHP Code to Add More content on hundreds post wordpress
racer x's Avatar
Ultra Talker

Posts: 457
Name: Randy
Location: Northern Wisconsin
Trades: 0
You are welcome.

Placing that code in the actual single.php file kind of defeats the purpose of using a hook but, hey, as long as it works for you.

The beauty of using hooks in WP means you don't have to edit template files(usually) directly that make up a page view. By placing that same code in the functions.php file, it would have automatically added it in the same manner.
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Old 05-29-2010, 12:28 AM Re: What PHP Code to Add More content on hundreds post wordpress
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
This would have been done more easily with an update query via phpmyadmin.

UPDATE wp_posts SET post_content = CONCAT(post_content,'<p><a href="#">Affilliate Link</a><p>')
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 05-29-2010, 01:42 PM Re: What PHP Code to Add More content on hundreds post wordpress
racer x's Avatar
Ultra Talker

Posts: 457
Name: Randy
Location: Northern Wisconsin
Trades: 0
Quote:
This would have been done more easily with an update query via phpmyadmin.
I am not understanding how that would have affected future posts?

By using a wp content filter, it not only affects the existing posts, but will be added to all future posts and can be changed/managed in one simple file(even from the admin area) rather than going into phpmyadmin every time.

Plus, I am guessing Edwin may not want to be digging into his database like that which is not really advisable as you know unless you are very comfortable doing so.

Just my opinion however.
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Reply     « Reply to What PHP Code to Add More content on hundreds post wordpress
 

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