How do I show only posts from ONE SINGLE category
-
I have tried the query_posts method, using the category ID and the category name, but I can not get this to work.
If you go to my page, you will see a slideshow at the top that pulls ALL posts on the site. I have this same slideshow in the footer, as well, but I need it to only display posts from one category, “reviews”. This slideshow is under the “Begin reviews” section in the code. I have attached the footer.php below. Please show me the light!
FYI: This is the Mensa theme
I tried to use the category id, which is 7, but nothing. I tried to change the”featured1″ to “reviews”, and I even used
query_posts(‘category_name=reviews’);
But it is not showing any posts. It works fine with no values in there at all, it just pulls all posts from all categories, which is not what I want. I need this to only display ONE category’s posts.
Here is the settings.php file from the theme. I think maybe some changes in here might work, but i don’t want to make them without some guidance. Also, i do not want to change the way the main slideshow in the header works….it pulls from all categories. I only want to change the one in the footer to pull from a single category (ID=7, name=reviews). Thanks.
footer.php
<div class="break"></div> </div> <!-- END body --> </div> <!-- END wrapper --> </div> <!-- BEGIN bottom --> <div id="footer"> <!-- BEGIN wrapper --> <div class="wrapper"> <div align="center"> <img src="<?php bloginfo('template_url'); ?>/assets/images/partners.png" alt="PLEASE VISIT OUR PARTNERS"/></div> <!-- BEGIN top --> <div id="top"> <div class="box"> <div class="name"> <a href="#"><img align="center" alt="top" src="<?php bloginfo('template_url'); ?>/assets/images/comingsoon.png"/></a> <a class="title">Partner #1</a> <br/> <a class="title2">Coming Soon</a> </div> <div class="text2"> <p>This is where the partner synopsys will be located for this partner when completed.</p> <a href="#" class="more">Read More >></a> </div> <div class="break"></div> </div> <div class="box"> <div class="name"> <a href="#"><img alt="top" src="<?php bloginfo('template_url'); ?>/assets/images/comingsoon.png"/></a> <a class="title">Partner #2</a> <br/> <a class="title2">Coming Soon</a> </div> <div class="text2"> <p>This is where the partner synopsys will be located for this partner when completed.</p> <a href="#" class="more">Read More >></a> </div> <div class="break"></div> </div> <div class="box"> <div class="name"> <a href="#"><img alt="top" src="<?php bloginfo('template_url'); ?>/assets/images/comingsoon.png"/></a> <a class="title">Partner #3</a> <br/> <a class="title2">Coming Soon</a> </div> <div class="text2"> <p>This is where the partner synopsys will be located for this partner when completed.</p> <a href="#" class="more">Read More >></a> </div> <div class="break"></div> </div> </div> <!-- END top --> </div> <!-- END wrapper --> <!-- BEGIN wrapper --> <div class="wrapper"> <!-- BEGIN reviews --> <div id="reviews"> <a class="prev" href="#"><img class="l" alt="featured title" src="<?php bloginfo('template_url'); ?>/assets/images/left.gif"/></a> <div class="items"> <?php $tmp_query = $wp_query; query_posts('cat=' . get_cat_ID(dp_settings('featured1'))); if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="feat"> <a class="featuredimg" href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'full', 'alt="' . $post->post_title . '"'); ?></a> <div class="text"> <h2><a href="<?php the_permalink(); ?>"><a>Review: </a><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> </div> <div class="break"></div> </div> <?php endwhile; endif; $wp_query = $tmp_query; ?> </div> <a class="next" href="#"><img class="r" alt="featured title" src="<?php bloginfo('template_url'); ?>/assets/images/right.gif"/></a> </div> <!-- END reviews --> </div> <!-- END wrapper --> <!-- BEGIN wrapper --> <div class="wrapper"> <p id="info">? 2010 The Billboard Family<br />All Rights Reserved <br /><br /> → <a href="/?page_id=94">Submit A Review</a><br /> → <a href="/?page_id=118">Terms & Conditions</a><br /> → <a href="/?page_id=47">Partners</a><br /> → <a href="/?page_id=31">Contact Us</a></p> </div> <!-- END wrapper --> <!-- END bottom --> </body> </html>
settings.php
<?php $themename = "Personal Memo"; $shortname = "personalmemo"; $settings = array( 'featured1' => 'Featured', 'about'=>'Hi! My name is Paul and I am a Designer and Blogger from Brisbane. This is my creative outlet. <a href="#">more ?</a>', 'facebook'=>'', 'youtube' => 'H5h95s0OuEg', 'mail_url'=>'https://wpcorner.com/contact/', 'rss_url'=>'https://wpcorner.com/rss/', 'twitter_url'=>'https://www.twitter.com/', 'facebook_url'=>'https://www.facebook.com/', 'stumbleupon_url'=>'https://www.stumbleupon.com/', 'twitter'=>'<ul> <li> What is your Religion and is it making you a better person? <p><a href="#">2 days ago</a></p> </li> <li> What is your Religion and is it making you a better person? <p><a href="#">2 days ago</a></p> </li> <li> What is your Religion and is it making you a better person? <p><a href="#">2 days ago</a></p> </li> </ul>' ); # Settings function s_lang($text) { return $text; }; $options = array ( array( "name" => s_lang("Featured Content Settings"), "type" => "header" ), array( "name" => s_lang("Featured Category Name"), "id" => $shortname."_featured1", "std" => $settings['featured1'], "type" => "text"), array( "name" => s_lang("Left Sidebar Settings"), "type" => "header" ), array( "name" => s_lang("About Me"), "id" => $shortname."_about", "std" => $settings['about'], "type" => "textarea"), array( "name" => s_lang("Facebook Widget Code"), "id" => $shortname."_facebook", "std" => $settings['facebook'], "type" => "textarea"), array( "name" => s_lang("Featured Video (Youtube Video ID)"), "id" => $shortname."_youtube", "std" => $settings['youtube'], "type" => "text"), array( "name" => s_lang("Right Sidebar Settings"), "type" => "header" ), array( "name" => s_lang("Mail URL"), "id" => $shortname."_mail_url", "std" => $settings['mail_url'], "type" => "text"), array( "name" => s_lang("RSS URL"), "id" => $shortname."_rss_url", "std" => $settings['rss_url'], "type" => "text"), array( "name" => s_lang("Twitter URL"), "id" => $shortname."_twitter_url", "std" => $settings['twitter_url'], "type" => "text"), array( "name" => s_lang("Facebook URL"), "id" => $shortname."_facebook_url", "std" => $settings['facebook_url'], "type" => "text"), array( "name" => s_lang("StumbleUpon URL"), "id" => $shortname."stumbleupon_url", "std" => $settings['stumbleupon_url'], "type" => "text"), array( "name" => s_lang("Twitter Widget Code"), "id" => $shortname."_twitter", "std" => $settings['twitter'], "type" => "textarea"), ); function mytheme_add_admin() { global $themename, $shortname, $options; if ( $_GET['page'] == basename(__FILE__) ) { if ( 'save' == $_REQUEST['action'] ) { foreach ($options as $value) if ($value['type']!='header') update_option( $value['id'], $_REQUEST[ $value['id'] ] ); foreach ($options as $value) { if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } header("Location: themes.php?page=settings.php&saved=true"); die; } else if( 'reset' == $_REQUEST['action'] ) { foreach ($options as $value) delete_option( $value['id'] ); header("Location: themes.php?page=settings.php&reset=true"); die; } } add_theme_page($themename." Settings", "Theme Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin'); } function mytheme_admin() { global $themename, $shortname, $options; if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>'; if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>'; ?> <style type="text/css"> th { text-align: left; } td { padding: 1px 5px !important; } .header td { padding: 20px 0 10px !important; } .header td p { padding: 4px 5px !important; font-size: 12px !important; font-weight: bold !important; background-color: #073447 !important; color: #ffffff; margin: 0 !important; } .submit { padding-top: 40px; } </style> <div class="wrap"> <h2><?php echo $themename; ?> Settings</h2> <form method="post"> <table class="form-table"> <?php foreach ($options as $value) { if ($value['type'] == "text") { ?> <tr> <th scope="row" style="width: 30%"><?php echo $value['name']; ?>:</th> <td> <input style="width: 50%" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" /> <?php echo $value['note']; ?> </td> </tr> <?php } elseif ($value['type'] == "textarea") { ?> <tr> <th scope="row" style="width: 30%"><?php echo $value['name']; ?>:</th> <td> <textarea style="width: 80%; height: 70px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php if ( get_settings( $value['id'] ) != "") { echo htmlentities(stripslashes(get_settings( $value['id'] ))); } else { echo stripslashes($value['std']); } ?></textarea> <?php echo $value['note']; ?> </td> </tr> <?php } elseif ($value['type'] == "select") { ?> <tr> <th scope="row"><?php echo $value['name']; ?>:</th> <td> <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"> <?php foreach ($value['options'] as $option) { ?> <option value="<?php echo $option; ?>" <?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option> <?php } ?> </select> <?php echo $value['note']; ?> </td> </tr> <?php } elseif ($value['type'] == "header") {?> <tr class="header"><td colspan="2"><p><?php echo $value['name'] ?></p></td></tr> <?php } } ?> </table> <p class="submit"> <input name="save" type="submit" value="Save changes" /> <input type="hidden" name="action" value="save" /> </p> </form> <form method="post"> <p class="submit" style="border: 0;"> <!-- <input name="reset" type="submit" value="Reset" /> --> <input type="hidden" name="action" value="reset" /> </p> </form> <?php } add_action('admin_menu', 'mytheme_add_admin'); foreach ($options as $value) { if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } } # Set Values foreach ($settings as $k=>$v) { $var = $shortname.'_'.$k; if (!empty($$var)) $settings[$k] = stripslashes($$var); } ?>
- The topic ‘How do I show only posts from ONE SINGLE category’ is closed to new replies.