title_save_pre on post publish

The filter title_save_pre runs before the post is written to the database, and also before any of its post meta is saved to the database. So get_post_meta at this point will be blank for the first run, and always return ‘old’ data. To correct this you’ll want to hook into save_post and update the post … Read more

Disallow Same Post Title

Main Code Please check the auxiliary code after this block /* * Prevent Duplicated Titles * */ if( is_admin() ) // check if we are in the administrative area { add_action( ‘save_post’, ‘wpse_54258_check_for_duplicate_title’, 11, 2 ); add_action( ‘admin_head-post.php’, ‘wpse_54258_check_for_notice’ ); } /* * Checks for more than one post with the same title * * … Read more

How to add subscript and superscript in WordPress page titles

You can use markup in titles. H<sub>2</sub>O will work just fine. I would use H₂O with a real ₂ because markup will be stripped in title attributes and in feeds. Note that WordPress will not create a pretty permalink for the correct character. The slug for my example will look like this: h2o-h%e2%82%82o. You need … Read more

order by second word in title?

There is a filter, ‘posts_orderby’, which allows you to specify your own ORDER BY clauses. In your case, the code would look something like this: add_filter( ‘posts_orderby’, ‘order_by_surname’ ); function order_by_surname( $orderby, $query ) { // first you should check to make sure sure you’re only filtering the particular query // you want to hack. … Read more

Require title for pages

Start with downloading the plugin called Force Post Title. Here’s the plugin with one row (2 with the comment line) added to the bottom, based on our comments. What happens is that a small jQuery script is added to the page Create Post/Page. The script will check if the title field is empty when the … Read more

Problem in wordpress with “-“

Background: WordPress converts normal dash (-) to long dash (–), straight quotes to curly quotes and some other similar symbols and punctuations to their printer friendly versions using wptexturize. Generally it’s recommended to leave them up to WordPress. However, occasionally, we may want to override this behaviour. For example, in case we are writing Programming … Read more

Set Post Title to Read-only and Disable Permalink Slug Editor in Gutenberg

I used this, inline, on specific pages (using get_current_screen()). I’d hoped this would enable me to hide/show the permalink panel under certain conditions. However, removeEditorPanel() removes the permalink panel globally. This isn’t completely horrifying, since the css still works conditionally, and the permalink can still be edited via the editor (by clicking on the title) … Read more