Link to home
Start Free TrialLog in
Avatar of jameshuckabonetech
jameshuckabonetech

asked on

Wordpress Page of Posts Problem

I have been having some trouble (i don't know any PHP) setting up wordpress to display posts from a specific category, based on what page is currently displayed (page.php below). I was pointed to this page (look at page of posts) for help but now I'm stuck. Can someone help me figure out the last details of this? Thanks a lot!

http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates


<?php
/**
 * @package WordPress
 * @subpackage Default_Theme
 */
 
get_header(); ?>
 
 
	<div id="content" class="narrowcolumn">
<?php
// page id 21 will get category ID 12 posts, page 16 will get category 32 posts, page 28 will get category 17 posts
if (is_page('Healthy Food') ) {
$cat = array('healthy-food');
} elseif ( is_page('How You Clean') ) {
$cat = array('how-you-clean');
} elseif ( is_page('You and Your Baby') ) {
$cat = array('you-and-your-baby');
} else {
$cat = '';
}
 
$showposts = -1; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
   'category__in' => $cat,
   'showposts' => $showposts,
   'caller_get_posts' => $do_not_show_stickies
   );
$my_query = new WP_Query($args); 
 
?>
 
 
<?php if( $my_query->have_posts() ) : ?>
 
		<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
			<?php
			//necessary to show the tags 
			global $wp_query;
			$wp_query->in_the_loop = true;
			?>
			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
 
				<div class="entry">
					<?php the_content('Read the rest of this entry »'); ?>
				</div>
 
				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
			</div>
 
		<?php endwhile; ?>
 
	<?php else : ?>
 
		<h2 class="center">Not Found</h2>
		<p class="center">Sorry, but you are looking for something that isn't here.</p>
		<?php get_search_form(); ?>
 
	<?php endif; ?>
 
 
</div>
 
<?php
 
if(is_page('1')) {
 
     echo 'Hi There!';
 
} elseif (is_page('Healthy Food')) {
 
     echo '<div id=sidebar>
<h1>Featured Product</h1><p class="centered">DERMAdoctor<br /><a href=http://click.linksynergy.com/fs-bin/click?id=mir9zur4eS8&offerid=30329.10000043&type=4&subid=0><img width=120 height=60 alt=Banner 10000043 border=0 src=http://www.dermadoctoraffiliates.com/graphics/images/alwaysin120x60.gif></a><img border=0 width=1 height=1 src=http://ad.linksynergy.com/fs-bin/show?id=offJEA3lmBg&bids=mir9zur4eS8&type=4&subid=0></p>
 
<p>For sheer information, it\'s tough to beat DERMAdoctor\'s feature articles and newsletters where Dr. Kunin shares the most current developments in skin care technology and research. This is what separates DERMAdoctor.com from other retailers on the web.</p>
<p>Accurate information gives you the power to make the right skin care choices from our wide array of products. And for the shopper in a hurry, some guests prefer to browse the extensive listings of products and descriptions.</a></p></div>';
 
} elseif (is_page('How You Clean')) {
 
     echo '<div id="sidebar">
<h1>Featured Product</h1><p class="centered">Aquasana.com<br /><a href=http://www.aquasanaaffiliates.com/b.asp?id=4270>
<img src=http://www.aquasanaaffiliates.com/showban.asp?id=4270&img=banner7.jpg border=0></a></p><p>This water filter is perfect for your home. We have done our research and have found this to be the most economical solution available. We give it our full endorsement and know youll just love the system.</p></div>';
     
} elseif (is_page('Around the House')) {
 
     echo '<div id=sidebar><p><a href="http://www.greensuperfood.com/?Click=4578">Click here to visit greensuperfood.com</a></p></div>';
     
} elseif (is_page('Out and About')) {
 
     echo '<div id=sidebar>Out and Aboot</div>';
     
} elseif (is_page('You and Your Baby')) {
     
     echo '<div id=sidebar>You & Bebeh</div>';
 
} elseif (is_page('Healthy Pets')) {
     
     echo '<div id=sidebar>Smetz</div>';
 
}
 
else {
 
     echo '<div id="sidebar"><h1>Featured Product</h1><p class="centered">Bulk Herbs - Great Value!<br /><br />
If you&#39;re looking to buy in quantity and want a great low price, then check out these guys:<br /><br /> 
<a href="http://www.morethanalive.com/?a_aid=e970b042&amp;a_bid=75abec25"><img src="http://join.morethanalive.com/scripts/sb.php?a_aid=e970b042&amp;a_bid=75abec25" alt="www.morethanalive.com" border="0" title="www.morethanalive.com"></a></p></div>';
 
}
 
?>
 
<?php get_footer(); ?>

Open in new window

Avatar of rondelrosario
rondelrosario
Flag of Japan image

What exactly do you want to achieve?
Avatar of jameshuckabonetech
jameshuckabonetech

ASKER

"setting up wordpress to display posts from a specific category, based on what page is currently displayed (page.php below)"
ASKER CERTIFIED SOLUTION
Avatar of jameshuckabonetech
jameshuckabonetech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial