jcaudill
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Yoast SEO] ?s={search_term_string} when “s” changed to a different parameterThank you! That did it.
Forum: Plugins
In reply to: Category Posts PluginI’ve updated the code for WP 2.0+ and to support limiting, and CSS class.
Put the following in a file, name it wp_category_posts.php and put it in your plugins folder. Activate and all should be right in the world.
<?php /* Plugin Name: WP Category Posts Plugin URI: https://www.itsensellc.com Description: List the posts in a specific category - for version 2.0+ only - support optional arguments of limit and css class Author: JP Caudill Version: 1.0 Author URI: https://www.itsensellc.com */ function wp_cat_posts( $catID, $limit=null, $class=null ) { global $wpdb; $get_posts_in_cat = "SELECT ID,post_title "; $get_posts_in_cat .= "FROM $wpdb->posts "; $get_posts_in_cat .= "WHERE ID IN (SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$catID') "; $get_posts_in_cat .= "AND post_type = 'post' "; $get_posts_in_cat .= "ORDER BY post_date DESC "; if($limit) $get_posts_in_cat .= "LIMIT 0, $limit "; $get_posts_in_cat_result = mysql_query($get_posts_in_cat); while ($posts_in_cat_row = mysql_fetch_assoc($get_posts_in_cat_result)) { $post_title = $posts_in_cat_row['post_title']; $postID = $posts_in_cat_row['ID']; echo '<a href="' . get_permalink($postID) . '" class="' . $class . '">' . $post_title . '</a><br />'; } } ?>
Use it like:
<?php wp_cat_posts(3); ?> – straight links, no styling and no limit
<?php wp_cat_posts(3,10); ?> – straight links, no styling limited to 10
<?php wp_cat_posts(3,10,’leftmenu’); ?> – links with a css class of leftmenu appled and limited to 10
Viewing 2 replies - 1 through 2 (of 2 total)