WordPress wp_loaded action hook

wp_loaded is called long, long before the post content is fetched. Put that code into a plugin. Also, you shouldn’t echo anything that early. The HTTP headers aren’t sent yet on wp_loaded, so you will get the Headers already sent error, and your user authentication will not work: you cannot log in anymore.

Show excerpt if no title in admin view

You can try the following approach using the the_title filter in the edit.php screen: /** * Modify post titles in the edit.php screen. * If the post title is empty, then show max 10 words from the post content instead. */ add_action( ‘load-edit.php’, function() { add_filter( ‘the_title’, function( $title ) { $post = get_post(); if( … Read more

Remove Permalink From Admin Edit Post

I’m running the most up to date version of WordPress which has made changes to how permalinks are displayed and handled. There’s no longer a View Post button. I was able to remove the whole area using the get_sample_permalink_html hook. Just return an empty string: function hide_permalink() { return ”; } add_filter( ‘get_sample_permalink_html’, ‘hide_permalink’ );

Where Are Hooks?

Hooks/actions are better thought of as events. When you run this code: add_action( ‘post_footer’, ‘toms_footer_stuff’ ); You’re saying that when the post_footer event happens, run the toms_footer_stuff function. These functions take the form of: add_action( name_of_action, php_callable ); A PHP callable is something that can be called represented as an object. It can be any … Read more