New answers tagged

0

If you want the short version with "-" between the words use the slug. If you don't want to use the slug use the function bellow: <?php $new_url = sanitize_title(get_the_title()); echo $new_url; ?> https://codex.wordpress.org/Function_Reference/sanitize_title


4

I want ot give you an "alternate" approach. I'm pretty sure you're not going to follow this, but I thinks is interesting to read. OOP "routing" approach In WordPress, "pretty" urls are mathed to "ugly" urls. But most web frameworks (not only PHP) uses the concept of "routing": to match an url to an "action" (or a controller). I want to give you an idea ...


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 ...


5

I am not sure if this is the best solution or not, but it works: function movie_review_permalink( $url, $post, $leavename ) { $category = get_the_category($post->ID); if ( !empty($category) && $category[0]->slug == "test" ) { //change 'test' to your category slug $date=date_create($post->post_date); $my_date = ...


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

You should just need to change the permalink of the page in the back end of WordPress. You may also need to add the short code [woocommerce_my_account] to the page content depending on your version of WooCommerce. This would however also change the account page from my-account to just account aswell.


0

Okay, currently using this craziness. A combination of the "page" rewrite and modified WP No Category Base plugin. Seems to be working perfectly. /*=========================================================== = REMOVE CATEGORY / CUSTOM PAGINATION = ===========================================================*/ ...


2

Hm. Have you thought about doing some URL rewrites in .htaccess? RewriteRule ^category/bar-talk/page/([0-9]+)$ /bar-talk/drink-number/$1 [L,R=301] RewriteRule ^bar-talk/drink-number/([0-9]+)$ /index.php?category_name=bar-talk&page=$1 [L] // @drizzlyowl


1

i'd the same problem as you. My fix was that one, but for my case i'm using Visual Composer in page creation. That's important 'cause my method will port only the content part of the page. Instead of changing the priority, i changed the category template for that category! So.. create the page that you want to set as the category and take note of the ID ...


0

I think you wanna do something like this: add_action('init', 'my_rewrite'); function my_rewrite() { global $wp_rewrite; // Your desired structure $permalink_structure = '/prodotti/%my_custom_variable%/%postname%/' // add the custom variable to wp_rewrite tags $wp_rewrite->add_rewrite_tag("%my_custom_variable%", '([^/]+)', ...


3

Do you have mod_rewrite enabled? This sort of thing tends to happen when it's not. At which point, you only have access to ugly permalinks (?p=N) or "almost pretty" permalinks (/index.php/slug). The latter uses pathinfo to get you the page you're requesting instead. So I'd suggest double checking whether mod_rewrite is installed and enabled. If it turns ...


0

This problem is .htaccess file's. Before doing anything first take backup your files and database. Then rename the .htaccess file in your root of WordPress installation. and then change the permalink setting you want in WordPress Dashboard. I hope this will work for you.


0

I solved my problem. All I needed was the WordPress Rewrite API. if( ! function_exists('theme_add_rewrite_rules') ){ function theme_add_rewrite_rules(){ add_rewrite_rule( '^blog/([^/]+)/?$', 'index.php?name=$matches[1]', 'top' ); } } add_action( 'init', 'theme_add_rewrite_rules'); This solves how ...



Top 50 recent answers are included