Articles of url rewriting

Using category slug in add_rewrite rule

I’m using this function ro rewrite URLs: function archive_rewrite_rules(){ add_rewrite_rule( ‘inspiracao/([^/]*)/([0-9]{4})/?$’, ‘index.php?post_type=post&cat=$matches[1]&year=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘archive_rewrite_rules’ ); But is possible to use category slug instead category id?

configuration of .htaccess for add_rewrite_rule to make sense

I am trying this code from codex wordpress site function custom_rewrite_basic() { add_rewrite_rule(‘^leaf/([0-9]+)/?’, ‘index.php?page_id=$matches[1]’, ‘top’); } add_action(‘init’, ‘custom_rewrite_basic’); How must by .htaccess file must be configured for above code to make sense? If I put the basic wordpress .htaccess configuration file then I get redirected to same page. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule […]

Using page as front page, why does /page/### work?

So I’ve experimented with different themes and have determined this is a WordPress thing and not a theme thing. Say I create a page titled “The Front Page”, then set it as the front page on reading settings under Front page displays. After doing so the following URLs will all display the front page: […]

Proper way to set up rewrite with Wp

This seems to be modding my .htaccess with every page view. What is the standard way of setting up a rewrite? This is what I have so far: if(!function_exists(‘some_rewrite’)){ add_action( ‘init’, ‘replacement_rewrite’ ); function replacement_rewrite( ) { global $wp_rewrite; $wp_rewrite->add_permastruct(‘typename’,’typename/%year%%postname%/’ , true , 1); add_rewrite_rule(‘typename/([0-9]{4})/(.+)/?$’,’index.php?typename=$matches[2]’, ‘top’); $wp_rewrite->flush_rules(); } }

optional parameter in permalink structure

Im currently facing an issue with the relationship between pretty permalink and my themes templates. I have a post type called ‘performance’, and with pretty permalinks enabled the URLs for the template at single-performance.php looks like this: In the sidebar of that template, I am listing 5 other performances. This all works fine so […]

Change permalink to attachment

Hello i found this code and I modified a litle, but i have a problem with it. I want the link of the attachment page to be something like this [post-permalink]//[postid] 1234/ .. /1253/ I tried this, the URL is like I want to be but gives me a 404 error: function wpd_attachment_link( $link, $post_id […]

How to customize sub-URLs in a wordpress website (.htaccess)

I have a regular business website that I built on WordPress – I have a blog page in my website under – When viewing a blog post it looks like this:[category]/[posts-name] How can I add “/blog” to this URL before the category? like this:[category]/[posts-name] This is my current .htaccess: # BEGIN […]

WordPress rewrite rules not working

I have created a plugin and i have gotten rewrite rules to work using my .htaccess file. I would like to make this work from my plugin instead to keep everything contained from within there. Im trying to do this via the wordpress rewrite but nothing i do it working with this. I have even […]

Pagination for custom post types – url rewriting

I’m working with custom post type, that I want to paginate, here’s part of code, initializing custom post type: $args = array( ‘labels’ => $labels, ‘public’ => false, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘show_in_menu’ => true, ‘query_var’ => true, ‘capability_type’ => ‘post’, ‘has_archive’ => true, ‘hierarchical’ => false, ‘menu_position’ => null, ‘supports’ => array(‘title’, […]

URL rewriting taxonomy term

I’m trying to find solution for the following hours now and i don’t know if this is applicable. I have 1 Custom Taxonomy “Years” for Post Type “Post (default)”. The taxonomy has 2 Terms: “2014” and “2015”. I have select some posts from category “news” to use the 2 different Taxonomy terms. This shows me […]