Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-27-2012, 08:16 PM   PM User | #1
biggupp
New Coder

 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
biggupp is an unknown quantity at this point
How to Pull Content from Specific Category

This is a humble request for help, as I am stumped with this WordPress setup.

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?
biggupp is offline   Reply With Quote
Old 11-27-2012, 11:10 PM   PM User | #2
Junsee
New Coder

 
Join Date: Jun 2012
Posts: 42
Thanks: 4
Thanked 5 Times in 5 Posts
Junsee is an unknown quantity at this point
Have you code, or would like to know how?

you need connection details first
PHP Code:
$sql "SELECT * FROM `table` WHERE `ID` = '$ID' ; ";
$rs mysql_query($sql$conn);
while (
$row mysql_fetch_array ($rs)){
    
$column1 $row['column1'];
    
#more columns ... 

    
echo $column1;
    
# echo more columns    

something like this...?

Last edited by Junsee; 11-27-2012 at 11:11 PM.. Reason: spelling teach me to ctrl+p
Junsee is offline   Reply With Quote
Old 11-28-2012, 01:38 PM   PM User | #3
biggupp
New Coder

 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
biggupp is an unknown quantity at this point
My gut says the solution is a bit simpler. That is, the code I offered is what is used presently in the live site, and pulls content from a single category. Can this code be modified simply to specific a specific category is there are multiple categories?
biggupp is offline   Reply With Quote
Old 11-28-2012, 03:28 PM   PM User | #4
biggupp
New Coder

 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
biggupp is an unknown quantity at this point
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; ?>
'

What am I missing here?
biggupp is offline   Reply With Quote
Old 11-29-2012, 09:39 PM   PM User | #5
biggupp
New Coder

 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
biggupp is an unknown quantity at this point
anyone?
biggupp is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 01:38 PM.


Advertisement
Log in to turn off these ads.