Ger posts from similar tags and categories

Below is the solution for your problem If my understanding is right! if ($tags) { $tag_ids = array(); foreach($tags as $single_tag) $tag_ids[] = $single_tag->term_id; $args=array( ‘tag__in’ => $tag_ids, ‘post__not_in’ => array($post->ID), ‘showposts’=> 5, ); if( count($args) < 5 ) { $n = 5 – count($args); //to get posts based on the category if ($categories) { … Read more

Auto create description in post

You need to use save_post_post hook and use $wpdb->update() method. The code – add_action( ‘my_save_post_post’, ‘save_post_post’ ); function my_save_post_($post_ID, $post ) { global $wpdb; $post_content=”You are viewing “. $post->post_title .’! These are great hairstyle designs in our ‘. get_the_category_list( ‘, ‘, ”, $post_ID ) .’ section. Hope you try this look and feel on your … Read more

Get post title by Alphabet

You have two problems. First need to global $wpdb;. Then you are using the_title() and the_permalink() both of which automatically echo out a value. So you need to switch them to get_the_title() and get_permalink(). function get_post_by_alphabet($the_char){ global $wpdb; $first_char = $the_char; $postids=$wpdb->get_col($wpdb->prepare(” SELECT ID FROM $wpdb->posts WHERE SUBSTR($wpdb->posts.post_title,1,1) = %s ORDER BY $wpdb->posts.post_title”,$first_char)); if ($postids) … Read more

How to display custom content in post with category XXX

yes you can do that. You can use get_category_link for it. if(): while(): the_content(); if(category == “category one”){ // Get the ID of a given category $category_id = get_cat_ID( ‘helper for category one’ ); //get_cat_ID(‘category_name’); // Get the URL of this category $category_link = get_category_link( $category_id ); // Print category link here } else{ display_nothink … Read more