Replace post title based on conditions

You can use the_title filter to modify the post_title prior to printing on the screen. add_filter(“the_title”, function($title, $id)){ $user = wp_get_current_user(); if((!is_user_logged_in() || in_array(“pending”, $user->roles)) && “post” === get_post_type($id)){ $title = “Custom title”; } return $title; }, 10, 2); source: https://developer.wordpress.org/reference/hooks/the_title/

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()