Changing search URL to something other than “search”

To change the search url hook in this function this will replace “search” to whatever you want. add_action( ‘init’, ‘wpse21549_init’ ); function wpse21549_init() { $GLOBALS[‘wp_rewrite’]->search_base=”results”; } place this code in your functions.php file and after saving this file. Go to permalink settings page and click on the save button to flush the rewrite rules. update … Read more

How to modify the slug for the default wp posts without affecting other posttypes?

According to the docs: https://codex.wordpress.org/Using_Permalinks Go to settings -> permalinks -> custom structure and change that to: /blog/%postname%/ But please make sure that in your custom post types definition, (register_post_type) set ‘rewrite’ => array( ‘with_front’ => false ), unless the URL of all of your custom post types will be prefixed by /blog/ UPDATE: As … Read more

Custom add_rewrite_rule & permalinks

Add this code to functions.php file: function custom_rewrite_basic() { add_rewrite_rule(‘^mp3s/mp3/([^/]+)/playlist/([0-9]+)/?’, ‘index.php?page_id={PAGE_ID}&songs=$matches[1]&playlist=$matches[2]’, ‘top’); } add_action(‘init’, ‘custom_rewrite_basic’); function custom_rewrite_tag() { add_rewrite_tag(‘%songs%’, ‘([^&]+)’); add_rewrite_tag(‘%playlist%’, ‘([^&]+)’); } add_action(‘init’, ‘custom_rewrite_basic’); Create a file named my-custom-template.php in your themes root directory as following: <?php /** * Template Name: Music */ get_header(); global $wp_query; echo ‘Songs : ‘ . $wp_query->query_vars[‘songs’]; echo ‘<br … Read more

Remove Dash/Hyphen From WordPress CustomPosttype Permalink

You need to use to hook into WordPress’s sanitize title hook. function no_dashes($title) { return str_replace(‘-‘, ”, $title); } add_filter(‘sanitize_title’, ‘no_dashes’ , 9999); for particular post type you can use these hook function no_dashes( $slug, $post_ID, $post_status, $post_type ) { if( $post_type == “page” ) { $slug = str_replace( ‘-‘, ”, $slug); } return $slug; … Read more

How can I link a file in admin with a button?

Finally, I make it, the way without losing the access to WordPress environment: add_action( ‘edit_form_after_title’, ‘custom_button’ ); function custom_button() { $button = sprintf(‘<a href=”https://wordpress.stackexchange.com/questions/273582/%1$s” class=”button button-primary button-large”>%2$s</a>’, esc_url( add_query_arg( ‘link’ , true, get_the_permalink() ) ), ‘Custom Button’ ); print_r($button); } Update: Hint: Please make a function for validation the url for ssl and wrap get_the_permalink() … Read more

Disable permalinks on all pages and posts

Since WP 4.4, there is a hook you can use to edit default arguments for registered post types: register_post_type_args (view in context on trac) If you’re wanting to remove the permalink/slug from the edit post/page screens but not remove posts from the admin menu itself, setting public => false and show_ui => true should do … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)