New answers tagged

1

We have to do this keeping post_name unique. Otherwise, it might cause many troubles. We can use post_title with sanitize_title. In this way, you can keep your URL nice and clean, and your post_name will remain unique as well. First we will need to write custom permalink structure. function my_awesome_permalink( $url, $post, $leavename ) { $url= ...


1

For anyone interested, this was the full solution to my problem. So far it works quite good. I use %postname% as the permalink structure and have my Custom Taxonomy working as my Brand and the Custom Post Type working as my Product. So my URL looks like this example.org/some-brand/some-product while I can display an overview on example.org/some-brand/. ...


0

If your mu-plugin has options I would put the flush right after updating them: update_option( 'my_options', $values ); // Flush rules after install flush_rewrite_rules();


0

What I understand that you want to use post ID instead of Post Title . and you have trouble because of the same titles name . If that's right , the solution will be like following : 1 - change permalink to custom structure like the following figure 2- go to phpmyadmin and change your posts name like following figure


0

Well this is silly but I figured it out. I removed the last / from the pattern and now it works as expected. Code is now... add_rewrite_rule('^coaching/apply', 'index.php?page_id=5156', 'top'); Seems weird to me that ^coaching/apply would work but not ^coaching/apply/ esp when entering example.com/coaching/apply/ as the url works.


0

I copied your code as-is above, pasted it into the twentysixteen theme, and changed just the post type rewrite slug from review/%brand% to %brand%. This resulted in both the term archive and review posts having your desired URL structure and successfully displaying. Now the bad news is that the rewrite rules generated for the taxonomy and post type stomp ...


0

Are you sure your custom post type has a separate single.php file? I was having a problem and this was the situation: I have three custom post types. I recently created the new one and its permalink redirects me to a diff custom post type's page. I have tried all rewrite flush rules etc but then I came to realize that the problem was because I don't have a ...


0

I ended up following @Kolya Korobochkin advice and added uppercase and lowercase versions of the rewrite rules that include escaped octets. $regular_page_uri = get_page_uri( $page->ID ); $uppercase_page_uri = preg_replace_callback( '/%[0-9a-zA-Z]{2}/', create_function( '$x', 'return strtoupper( $x[0] );' ), $regular_page_uri ); The Percent ...


0

You're pretty close. Your rewrite rule is using the wrong query var, pagename should be just name. Here's a version that works for me on a fresh 4.4.1 install and twentysixteen theme- function bvt_product_init() { $args = array( 'label' => __( 'Product', 'domain' ), 'description' => __( 'Company ...



Top 50 recent answers are included