Remove a specific category
-
I’m trying to remove a specific category (id=3 from showing up in a section of my themes home page.
I’ve been researching this for a few days and in theory I understand how this is done. But the theme is not coded the way the examples I’ve found are so I’m having trouble figuring out how to do this.
Here is the section of code that I need to remove a category from:
<h3><?php _e( 'Recent Post', 'app_post' ); ?></h3> <?php // echo $wpc_no_post_index; $recentQuery = "SELECT id, post_title,post_content,comment_count FROM {$wpdb->prefix}posts WHERE post_type='post' and post_status='publish' ORDER BY id DESC LIMIT $wpc_no_post_index"; $recent_posts = $wpdb->get_results($recentQuery, OBJECT); foreach ($recent_posts as $recent) : setup_postdata($recent); ?> <div id="post-<?php $recent->id; ?>"> <h2> <?php echo '<span class="app-index-category">'; the_category(', ', 'multiple', $recent->id); echo '</span><span class="app-category-arrow"></span>'; ?> <a class="app-index-title" href="<?php echo get_permalink($recent->id) ?> " > <?php echo substr($recent->post_title, 0, 60); ?> <!--</a>--> </h2> <?php //Display the post image $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $recent->post_content, $matches); $postImage = $matches[1][0]; // if (empty($postImage)){//$postImage = get_bloginfo('template_directory') . '/images/no-post.png'; // } $postContent = substr(strip_tags($recent->post_content), 0, 400); if (strlen($recent->post_content) > 400) { $postContent .= '...'; } if (empty($postImage)) { ?> <p class="app-recent-content"> <?php if (strlen($recent->post_content > 400)) echo " ..."; echo $postContent; ?> </p><?php } else { ?> <img alt="" src="<?php echo $postImage; ?>" width="298" height="" /> <?php } ?></a> <div class="clear"></div> <div class="readmore"> <!--<a href="<?php echo get_permalink($recent->id) ?>"><?php _e( 'Read', 'app_post' ); ?></a> |--> <a href="<?php echo get_permalink($recent->id); ?>"> <?php _e( 'Comments', 'app_post' ); ?> </a> </div> </div><?php endforeach; ?>
Can anyone help me figure this out?
Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Remove a specific category’ is closed to new replies.