Wordpress / PHP help please.

Joshk

New member
Jul 17, 2007
310
2
0
Phoenix AZ
I have basically what is a static ecommerce type site (one product) but it's on wordpress.

I've built two small image links at the bottom of the content so there is two choices "Read More" "Buy now"

Right now the "read more" button just displays next post. What I want it to do is a small sequence of pages like:


If you are on pages/posts X - Link to A
If you are on page/post A - Link to B
If you are on page/post B - Link to C
If you are on C - Only show buy now link.

Any ideas on how I can do something like that?

Currently I have this as content-nav.php

Code:
<div id="content-nav">
<?php
next_post_link("%link", "<img border=0 src='".get_bloginfo('template_url')."/path/readmore button'/>", FALSE);
?>
<a href="buy now link"><img border=0 src="<?php bloginfo("template_url")?>/path/buynow button"/></a>
</div>
Thanks for any help.
 


PHP:
<?php
// 'Page X' IDs
$pages = array(1, 3, 5, 7);

if(is_page('page-a')) {
	echo '<a href="/page-b/">Read More</a>';
}
elseif(is_page('page-b')) {
	echo '<a href="/page-c/">Read More</a>';
}
elseif(is_page('page-c')) {
	echo '<a href="/buy-now/">Buy Now</a>';
}
elseif(in_array($post->ID, $pages) {
	echo '<a href="/page-a/">Read More</a>';
}
?>

Something like that, I'm not great at writing PHP on the fly and that's untested. ^ Let me know if it spits out any errors.
Replace 'page-a' etc with your post slug, title or ID.
 
So I would have to include evey page/post on the site in the array? There are quite a few of them.

fwiw page "C" is a "Category Archive page", the other are "pages"
 
Replace:
PHP:
elseif(in_array($post->ID, $pages) {

With:
PHP:
else {

&Replace:
PHP:
elseif(is_page('page-c')) {

With:
PHP:
elseif(is_category()) {
Or:
PHP:
elseif(is_category('category-slug')) {