Random Custom Post Type Titles

WP_Query has an orderby property which can be set to rand. If you change your query string to ‘post_type=announcements&posts_per_page=5&orderby=rand’ you should be good to go. You might want to take the time to read through the whole documentation for WP_Query, just so you’re familiar with its capabilities.

Add title to image post

Sorry, but I don’t see any of those parameters in the parameter list for wp_get_recent_posts. $args = array( ‘numberposts’ => 10, ‘offset’ => 0, ‘category’ => 0, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘include’ => , ‘exclude’ => , ‘meta_key’ => , ‘meta_value’ =>, ‘post_type’ => ‘post’, ‘post_status’ => ‘draft, publish, future, pending, private’, ‘suppress_filters’ … Read more

how do I get the title in the post [closed]

If you just want to wrap the post title in a permalink, change this: echo ‘<h3 class=”entry-title media-title”>’ . get_the_title() . ‘</h3>’; …to this: echo ‘<a href=”‘ . get_permalink() . ‘”><h3 class=”entry-title media-title”>’ . get_the_title() . ‘</h3></a>’; Codex reference: get_permalink()

Show post title words one by one [closed]

Create a function in functions.php to see if your title part is in an array of ‘banned’ words: function check_word( $word ) { $blacklist = array(‘the’, ‘it’, ‘and’, …); if ( !in_array( $word, $blacklist ) && strlen( $word ) > 3 ) { return $word; } else { return ”; } } Run your title … Read more

Safe way to get the post ID in the_title()

Some filters in WordPress are just not user friendly and does not always quite do what one wants to. the_title filter will apply changes to all instances of get_the_title() (which is used by the_title()). So widget titles, related posts titles and post link titles are all changed, which is a problem when you just need … Read more

Shorten the title length

Try this. First check if the original string length is less than or equal to passed in length, and if so, we ignore the $after parameter : function the_titlesmall($before=””, $after=””, $echo = true, $length = false) { $title = get_the_title(); if( strlen($title) <= $length ) $after=””; if ( $length && is_numeric($length) ) { $title = … Read more

WordPress title as keywords (tags) with excluded stop words

Here is your updated function solving your 2 problems : // Post title as keywords, excluded stop words function title_as_keywords( $word ) { $blacklist = array(‘this’, ‘about’, ‘that’, ‘them’); // Excluded words … $whitelist = array(‘one’, ‘man’, ‘boy’/*etc..*/); // Whitelisted words … if ( (!in_array( $word, $blacklist ) && strlen( $word ) > 3 ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)