Trim Titles Only On Some Pages
You need to trim this things for title tag or for heading of any template or in any php file? because – RC Cars Xmas Gifts is looks like site title. please share your code which you are trying.
You need to trim this things for title tag or for heading of any template or in any php file? because – RC Cars Xmas Gifts is looks like site title. please share your code which you are trying.
Display Most Recent Post Widget Title On Page
Filter the title to only affect the_title() template function
How to ignore WP_ERROR caused by “get_the_excerpt” method in an AJAX call?
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/
Are you sure you are not using a custom taxonomy in your custom post type? Taxonomies for Custom Post Types have to use get_terms instead of get_category. More information on get_terms from the WordPress Codex: http://codex.wordpress.org/Function_Reference/get_terms
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.
The second argument of the save_post action contains the post data: do_action(‘save_post’, $post_ID, $post); You can also hook post_updated which will let you easily compare the before/after data: do_action( ‘post_updated’, $post_ID, $post_after, $post_before);
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
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()