Articles of permalinks

query_vars in plugin not working?

I have a problem writing a plugin for wordpress. First, I register a new query_var and add a new rewrite rule: function nng_users_query_vars( $vars ) { array_push( $vars, ‘nng_users’ ); return $vars; } add_filter(‘query_vars’, ‘nng_users_query_vars’); function nng_users_rewrite_rules( $rules ) { $newrules = array( ‘benutzer/([^/]+)/?$’ => ‘index.php?pagename=nng_users&nng_users=$matches[1]’ ); $finalrules = $newrules + $rules; return $finalrules; } […]

How to specify URLS for custom posts & taxonomies

I’ve read a few posts about this, but can’t find a clear answer 🙁 I have a custom post type called {ondemand} Within the custom post, I have three taxonomies {speakers} and {categories} and {season} Each taxonomy has 3-4 terms, for example under {speakers} there is one called [joebloggs] Currently I have a main URL […]

WordPress within specific sub-directories, implicitly not root

I have an existing application running at my website root now. Using .htaccess, would it be possible for a single WordPress installation to manage sub-directories? For example, /press/, /careers/, /blog/ would be served by WordPress. The problem is I don’t want WordPress to get served on the root. I suspect something tricky with permalinks and […]

Page Attachment Permalink Structure based on Menu Order?

I’ve been on a quest for the past couple of days reading up on Rewrite in WordPress but still can’t seem to figure out how to accomplish this. When using pretty links in WordPress, media attached to a page forms a URL like: http://www.domain.com/page_name/attachment_name/ http://www.domain.com/page_name/page_name/attachment_name/ http://www.domain.com/page_name/page_name/…/attachment_name/ What I would like to do is create a […]

Allow duplicate permalink slugs for posts in different categories

I have my permalink format set to /%category%/%postname%/ and I have two posts with the same permalink slug, but in different categories. Ideally, the two permalinks should look like this: http://example.com/category-1/post-title/ http://example.com/category-2/post-title/ But when I publish the second post, then its slug is changed to post-title-2, which makes the resulting URL http://example.com/category-2/post-title-2/. How can I […]

Multiple post categories – single permalink

I created a post which is assigned to multiple categories. Eg: I have a post “My Post”, and I put it in “foo” and “bar” categories. Now my article will have two permalinks, “/foo/my-post” and “/bar/my-post“. Google calls this a duplicate, which it considers to be spam, hence this is not what I want. How […]

Title and post URL based on custom fields?

I have custom fields in my custom post type. They should serve as a title and post slug for URL. Basically, whenever I change the content of the custom fields, the title field should react accordingly. E.g. if the field NAME contains ‘John’ and the SURNAME ‘Smith’, the title should transform to ‘John Smith’. The […]

How to make variables in URL look like the permalink structure?

I’ve been looking for the answer to this everywhere but with no success and that’s why I’m asking here. I don’t even know if the question is the right one. In any case, I’ll try to explain. I have a WordPress page with variables in the URL, like this: http://planeta-beisbol.com/tal-dia-como-hoy/?dia=18&mes=04 The content changes depending on […]

Changing a custom post type “has_archive” after registered

Ok, I’ve seen some similar posts on how to change a custom post type’s attributes after it has been registered (in my case, I’m trying to modify a custom post type created by a plugin without modifying the plugin files). This appears to be working for some properties: function change_wp_object() { $object = get_post_type_object(‘easy-rooms’); $object->show_in_menu […]

Regex in add_rewrite_tag not accepting OR operators?

I am trying to add a custom field to the post permalinks by using a combo of add_rewrite_tag and applying a post_link filter. What I am aiming for is something like this: http://example.com/%category%/%mycustomfield%/%postname% I can manage to get the %mycustomfield% as %psubject% working by using add_action( ‘init’, ‘register_rewrite_tag’); function register_rewrite_tag() { add_rewrite_tag( ‘%psubject%’, ‘(.*)’ ); […]