Jump to content

Need To Pull Content From Specific Category In Wordpress


biggupp

Recommended Posts

This is a humble request for help, as I am stumped.

 

http://www.ahy4life.com/update_20121008/

 

The above is a testing site. I need to add additional categories but cannot seem to fathom precisely the proper code for a specific section on each page. An rtfm has been unsuccessful. I tried using query, also without success.

For example, if I wish to display the title and then the content from a post from 'events', which is ID=4, in the code below:

 

'

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

 

<h2><center><?php the_title(); ?></center></h2>

 

<!-- Display the Post's Content in a div box. -->

 

<?php the_content(); ?>

 

<?php endwhile; else: ?>

<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>

<?php endif; ?>

'

 

what is the proper code?

Link to comment
Share on other sites

OK, I am trying to set up query using the code below for

<http://www.ahy4life.com/update_20121008/events.php>

for the category 'new_event' cat=5, but still not working.

'

<?php

$featuredPosts = new WP_Query();

$featuredPosts->query('showposts=5&cat=5');

while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>

<h2><center><a href="<?php the_permalink() ?>"><?php the_title(); ?></center></a></h2>

 

 

<?php the_content(); ?>

 

<?php endwhile; ?>

'

Link to comment
Share on other sites

Sorry. Doesn't seem to work. Opening the page reveals nothing being posted to the targeted area, Where I added "Post for new_event ID=5 to appear here."

 

I don't need to know, nor do I care, about the location of where the posts are to be displayed. Have you checked your errors logs? Do you have error reporting turned on? Can you post your most recent code. Have you verified you have a category #5 in the table you are querying?

Link to comment
Share on other sites

Most recent code:

'

<?php

$featuredPosts = new WP_Query();

$featuredPosts->query('showposts=5&cat=5');

while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>

<h2><center><a href="<?php the_permalink() ?>"><?php the_title(); ?></center></a></h2>

 

 

<?php the_content(); ?>

 

<?php endwhile; ?>

'

 

Error reporting, which I did enable, does not show anything. Category ID = 5 does exist in the sql table.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.