biggupp Posted November 27, 2012 Share Posted November 27, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/271267-need-to-pull-content-from-specific-category-in-wordpress/ Share on other sites More sharing options...
NomadicJosh Posted November 27, 2012 Share Posted November 27, 2012 Check out query_posts located in the docs: http://codex.wordpress.org/Function_Reference/query_posts Quote Link to comment https://forums.phpfreaks.com/topic/271267-need-to-pull-content-from-specific-category-in-wordpress/#findComment-1395712 Share on other sites More sharing options...
biggupp Posted November 28, 2012 Author Share Posted November 28, 2012 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; ?> ' Quote Link to comment https://forums.phpfreaks.com/topic/271267-need-to-pull-content-from-specific-category-in-wordpress/#findComment-1395948 Share on other sites More sharing options...
mrMarcus Posted November 28, 2012 Share Posted November 28, 2012 What about it "doesn't work"? Are you receiving errors? Are you receiving anything at all? Are you certain the correct category is 5? Throw us a bone. Quote Link to comment https://forums.phpfreaks.com/topic/271267-need-to-pull-content-from-specific-category-in-wordpress/#findComment-1395950 Share on other sites More sharing options...
biggupp Posted November 28, 2012 Author Share Posted November 28, 2012 (edited) 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." Edited November 28, 2012 by biggupp Quote Link to comment https://forums.phpfreaks.com/topic/271267-need-to-pull-content-from-specific-category-in-wordpress/#findComment-1395956 Share on other sites More sharing options...
mrMarcus Posted November 28, 2012 Share Posted November 28, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/271267-need-to-pull-content-from-specific-category-in-wordpress/#findComment-1395960 Share on other sites More sharing options...
biggupp Posted November 29, 2012 Author Share Posted November 29, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/271267-need-to-pull-content-from-specific-category-in-wordpress/#findComment-1396268 Share on other sites More sharing options...
Christian F. Posted December 1, 2012 Share Posted December 1, 2012 (edited) Not that I know how the custom PHP functions for Wordpress works, but have you tried with two ampersands before "cat"? PS: This should really have been in the "PHP Applications" section, methinks... Edited December 1, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/271267-need-to-pull-content-from-specific-category-in-wordpress/#findComment-1396616 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.