What is the action or filter for changing permalink in Edit Post/Page?

You can use the the_permalink filter to modify permalinks. Take a look at the function reference for the same. Code sample from the docs: Append the query string for the current page to permalink URLs function append_query_string($url) { return add_query_arg($_GET, $url); } add_filter(‘the_permalink’, ‘append_query_string’); More information on permalinks: Here (StackOverflow) Here (Elegant Themes) And here … Read more

Automatically set page order on create page

You could use ajax and the admin_footer-post-new.php hook. The sql would vary depending on whether you want the highest or most recently published order number. The following returns the highest published order number + 1: function wpse155926_set_menu_order() { $ret = array(); if ( check_ajax_referer( ‘wpse155926_set_menu_order_post’, ‘nonce’, false /*die*/ ) ) { global $wpdb; //last published … Read more

How to replace default icon on “Add Media” button?

CSS is the way to go here. Add a new CSS for admin using the admin_enqueue_scripts hook in your child theme functions.php (if you don’t have one, you’re doing something wrong) function my_admin_enqueue_style() { wp_enqueue_style(‘my-css’, get_stylesheet_directory_uri().’/css/my-admin.css’, array(), ‘1.0.0’); } add_action(‘admin_enqueue_scripts’, ‘my_admin_enqueue_style’); In your my-admin.css file /* change the content to another Dashicon */ #wp-content-editor-tools .wp-media-buttons … Read more

WordPress MultiSite Paste from Word Tool Does not work

Problem was the page encoding. The wordpress database is UTF-8, i had switched the default to ISO-[something] to match the database we’re using to populate additional content and had not noticed any issue for over a month- until we started populating the blogs section of this page. We discovered the problem by following the code … Read more

Publish post when edit post form submitted with enter/return pressed on keyboard

you may add a filter on wp_insert_post_data: add_filter( ‘wp_insert_post_data’, ‘my_force_publish_post’, 10, 2 ); function my_force_publish_post( $data, $postarr ) { if ( ! isset($postarr[‘ID’]) || ! $postarr[‘ID’] ) return $data; if ( $postarr[‘post_type’] !== ‘inventory’ ) return $data; $old = get_post( $postarr[‘ID’] ); // the post before update if( $old->post_status !== ‘draft’ ) { // force … Read more

Restrict acceess of a page in backend

This can be done in two steps. First, add a hook to the page /wp-admin/edit.php?post_type=page to remove the desired page from appearing to other users. And another hook to redirect non-authorized users from trying to access the page directly /wp-admin/post.php?post=ID&action=edit. Here, the post type is page, but it can be changed to any other. Make … Read more

How can I hook into the post editor title field in order to change the HTML?

There is no hook to change the HTML of the input (only the enter_title_here filter to change the placeholder text). You could pull this off easily with jQuery, though. Try this in your functionality plugin or theme’s functions.php file: // Add to the new post screen for any post type add_action( ‘admin_footer-post-new.php’, ‘wpse_add_required_attr_to_title_field’ ); // … Read more