Change permalink for a single post type only

This will be done when you register_post_type : $args = array( ‘rewrite’ => array( ‘slug’ => ‘book’ ), ); register_post_type( ‘book’, $args ); IMPORTANT ! Remember to go to wp-admin options > permalink and click SAVE on that page for the changes to take effect.

How to find out who handles a permalink?

I am not sure I get the question correctly. Anyway, I will try. Correct me if I’m wrong. What I understand your question is that you want to know which template is serving your URL. If that’s what you mean by resource, you should check out displaying current template path. It basically throw the template … Read more

Rewrite Page with a slug before page name

I’ve not tried external rules, but you can achieve that with an internal rewrite and pagename: function wpd_page_rewrite(){ add_rewrite_rule( ‘^anothername/([^/]*)/?’, ‘index.php?pagename=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘wpd_page_rewrite’ ); For parent/child pages you have to set pagename to the parent/child path, page/pagename, or you can also use page_id and use the page’s ID. EDIT – note … Read more

template_include not loading -instead goes to index.php

in order for the discography rule to work, I changed the rule from: add_rewrite_rule( ‘artists/([^/]+)/discography/?$’, ‘index.php?album_artist=$matches[1]&discography=yes’, ‘top’); to this : add_rewrite_rule( ‘artists/([^/]+)/discography/?$’, ‘index.php?artists=$matches[1]&discography=yes’, ‘top’); What the original rule was doing was pointing to the Artist’s Name and not the Artists custom post type, thus failing to redirect to the template. Thanks a lot to @RachelCarden … Read more

How to generate random numeric slugs for a custom post type?

function wpse_18293_get_random_string ($number_of_chars_to_use) { $upper_case_charachters = range(‘A’, ‘Z’); while($cnt < $number_of_chars_to_use) { $random_string.= $upper_case_charachters[mt_rand(0, count($upper_case_charachters)-1)]; $cnt++; } return $random_string } $random_string = wpse_18293_get_random_string(’10’); The ’10’ can be any number, and the function will pass back a string of random charachters that many charachters long. Note, the function name can be anything you want, I named … Read more

How to hook into permalink when publishing-saving post?

Finally, I found my answer on my own. //add our action add_action( ‘save_post’, ‘my_save_post’, 11, 2 ); function my_save_post($post_id, $post){ //if it is just a revision don’t worry about it if (wp_is_post_revision($post_id)) return false; //if the post is an auto-draft we don’t want to do anything either if($post->post_status != ‘auto-draft’ ){ // unhook this function … Read more

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