Removing custom post type name in single article URLs

Use the post_type_link hook, like this for use hash in link faq is the example custom post type add_action( ‘post_type_link’, ‘wpse70763_post_type_link’, 10, 2 ); function wpse70763_post_type_link( $link, $post ) { $post_type=”faq”; if ( $post->post_type === $post_type ) $link = get_post_type_archive_link( $post_type ) . ‘#’ . $post->post_name; return $link; } then unset($wp_rewrite->extra_permastructs[‘faq’]) On the init of … Read more

Avoid too long words in a post title, post content or comment but only if its not a url

Thank you Milo, “word-break” alone wasn’t enough as it’s css3 only and not cross-browser. But I found this: .bloc_content{ overflow:hidden; -ms-word-break: break-all; word-break: break-all; word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; } It seems to to work in all cases I tested. Hopefully it would be cross-browser enough to solve the problem. Not sure … Read more

How to avoid duplicate Url for the home page

From the comments: What are your settings under Dashboard -> Settings -> Reading. Specifically, what are your Front Page Displays, front page, and posts page settings? And your reply: exactly this is the point, the client has used a Theme called Choice and in the Theme Frontpage Settings there is this page selected :”Welcome to … Read more

custom page url slug needs illegal ?id=1 for javascript

Here’s a potential solution using the page_link filter and testing for the presence of a meta key to add a query arg: function wpa84303_page_query_arg( $permalink, $page, $sample ) { if( $query_arg = get_post_meta( $page, ‘query_arg’, true ) ) $permalink = add_query_arg( ‘id’, ‘0’, $permalink ); return $permalink; } add_filter( ‘page_link’, ‘wpa84303_page_query_arg’, 10, 3 ); Add … Read more

Append custom parameter to taxonomy/term URI

You can try this: function my_car_rewrite_rules( $rules ) { $newrules = array(); // add a rule for this kind of url: // http://myhost.com/cars/ferrari/used/123 // => http://myhost.com/index.php?post_type=cars&ferrari=used&p=123 $newrules[‘^cars/([^/]+)/([^/]+)/([^/]+)$’] = ‘index.php?post_type=cars&$matches[1]=$matches[2]&p=$matches[3]’; return $newrules + $rules; } add_filter(‘rewrite_rules_array’,’my_car_rewrite_rules’); and remember to “save the permalinks” when testing. I added /cars/ so this rewrite will not overwrite your other pages. … Read more

Function in functions.php by url

You can check for the presence of a specific query variable, so http://www.example.com?my_listener=test. You check for this on the init hook and if it isn’t there you just quit early and WP goes about it’s business. If it is there, you can then do something, just don’t forget to exit at the end or the … Read more