Admin filter/error if post title is too long

The key thing I think you’re missing is understanding that WordPress doesn’t use a linear path for saving posts. Because posts are autosaved you’ll want to handle this in a way that defines it according to it’s publish status rather than it’s save state. Basically, instead of trying to truncate or adjust the title, do … Read more

How can I retrieve a Featured Image thumbnail using only the Post_title?

You can try the following: /** * Get the featured image by post title (Simple version) * * @see http://wordpress.stackexchange.com/a/158344/26350 * @param string $title Post title * @param mixed $size Featured image size */ function get_featured_image_by_post_title_wpse_simple( $title=””, $size=”thumbnail” ) { $obj = get_page_by_title( $title, OBJECT, ‘post’ ); return ( is_object ( $obj ) ) ? … Read more

Force changing the Site Title and add link

add_filter(‘option_blogname’, ‘filter_name’); function filter_name($string) { return str_replace(‘original’, ‘replacement’, $string); } This code should work, as well as yours. But there’s one catch, you have to use get_bloginfo like this: echo get_bloginfo(‘name’, ‘raw’); If not, bloginfo sanitizes the output, and it eliminates the <a></a>. At the same time is someting good, because if not you would … Read more

Change Image depending on page path

If you are dealing with a category page, you would simply use conditional tags, as suggested by @milo: if ( is_category( ‘cat-1’ ) ) { $url=”my-background-image-url-1.ext”; } else if ( is_category( ‘cat-2’ ) ) { $url=”my-background-image-url-2.ext”; } remember, you could pass in a category slug as well as a category name or an array containing … Read more

Set the Title of a Custom Post Type by code as Author’s Username

There’s actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name: function post_author_title( $post_title, $post ) { if( $post->post_type == ‘your_post_type’ ) { $user = wp_get_current_user(); $post_title = $user->display_name; } … Read more