New answers tagged

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

Here is what I did to implement this: function slug_save_post_callback( $post_ID, $post, $update ) { // allow 'publish', 'draft', 'future' if ($post->post_type != 'post' || $post->post_status == 'auto-draft') return; // only change slug when the post is created (both dates are equal) if ($post->post_date_gmt != ...


-1

in your functions.php file, you should be able to accomplish your desired functionality with something like this: function adjust_permalinks() { global $wp_rewrite; $title = get_field( 'title_field' ); $subtitle = get_field( 'sub_title_field' ); $wp_rewrite->set_permalink_structure( $title . '-' . $subtitle ); ...


0

After a long time I found a solution for this issue (thanks to franzblog). If you are using version 4.2 or higher, you need to add the following lines in your functions.php file: add_filter( 'redirect_canonical', 'custom_disable_redirect_canonical' ); function custom_disable_redirect_canonical( $redirect_url ) { if ( is_paged() && is_singular() ...


0

You could force the redirect this way by checking for the get_var query value: add_action('init','my_redirect_check'); function my_redirect_check() { if (isset($_GET['my_var'])) { if ($_GET['my_var'] != '') { if ($_SERVER["HTTPS"]) {$location = 'https://';} else {$location = 'http://';} $location .= ...


-1

UltimateMember pages are based on [shortcodes] which will be entered into normal Wordpress pages. By this means the user-profile page, which you are referring to, should be listed under your WordPress pages, the default name generated by Ultimate-Member is "User page". Search this page and edit it, you will see some content like this [ultimatemember ...


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

Here's the why part: This part of the redirect_canonical() is removing the leading & in the redirect query part: // tack on any additional query vars $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] ); Example: example.tld/?&a=1&b=2&c=3 is redirected to example.tld/?a=1&b=2&c=3 If you must have ...


0

You can use here rawurlencode() function. First pass "?&mkwid=smWfvaLGf_dm" this url into the function then you will get "%3F%26mkwid%3DsmWfvaLGf_dm" encoded value. Now go on the functions.php and put this code there (But this code will run on every call of you site) //for accessing current url $accessUrl = get_site_url() .$_SERVER['REQUEST_URI']; ...


0

I had the same issue not being able to change the permalink, in my case: http://mysite/action-2. Whatever I did trying to change this to http://mysite/action, nothing worked. I had no pages or posts in trash so that was not causing the problem. There had to be a page occupying the permalink so i just typed in: http://mysite/action and there it was, a page ...


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

SOLVED with usage of $wp_rewrite you can add a new permalink structure add_action('init', 'my_custom_rewrite'); function my_custom_rewrite() { global $wp_rewrite; $wp_rewrite->add_permastruct('hardware', '/%customname%/', false); $wp_rewrite->add_permastruct('produkt', '/%customname%/', false); $wp_rewrite->flush_rules(); } then ...


1

You can always use the post ID to link to a page, like this: http://yourdomain.tld/?p=1234 You can find out the Post ID right from the post overview screen. If you hover over the "Edit" or "Delete" link, you can see that the URL has a parameter post=. The number behind that is your page ID. It could happen, that WordPress redirects your "post ID ...


0

It's not a good idea to have two links pointing to the same Page or Post.there are two approaches: Install SEO for Yoast plugin and use its Canonical url ability choose page/post slug to a short elegant one (recommended)


-1

See if this blog post gives you any help. https://premium.wpmudev.org/blog/removing-category-base-urls-wordpress/


0

Go to "Settings" > Permalinks > [click] Save Changes You don't need to change anything in the Permalinks page, it just resets everything to correctly link up.


0

Your htaccess do not have the default wordpress related rules, go to the permalink page and save, if it it doesn't help turn off plugins.


0

This is a dirty trick and I don't have a choice but to use it. Add .php at the end: /%category%/%postname%.php Some people add .html instead. Either way, it's pretty annoying though and I don't know if it's safe.


5

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

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

This is solution of your 404 links problem, Got to Settings -> Permalinks -> In 'Product permalink base' select the 'Shop base with category' option. For more you can visit, https://wordpress.org/support/topic/permalinks-404-with-custom-post-type


0

=> Create a Custom Taxonomy First, we create a custom taxonomy object called rating with the register_taxonomy WordPress function. add_action( 'init', 'my_rating_init' ); function my_rating_init() { if ( ! is_taxonomy( 'rating' ) ) { register_taxonomy( 'rating', 'post', array( ...


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

Here are some additional details that step you through transfering a LAN-based wordpress site into an externally accessible site as well enabling editing the wordpress site from inside the LAN. Two important keys are router/firewall modifications and the "wait 10+ minutes" after making the changes at the end. -using ssh to log into your server (nano is a ...


0

When inserting images into posts and pages in WP 4.4, change the Link To under ATTTACHMENT DISPLAY SETTINGS to None.


0

I've tried a few things I saw on codex.wordpress.org... Such as...? Have you tried: href='. get_permalink() .'>


0

My head like wanna explode because of this problem. However I just solved the problem. the problem is here $content = ...


0

When you use the graphical interface, post_name is stored in the wp_posts table even for draft posts as soon as you modify the default value. I tried your code (case 2) and I actually see the new entry in the database, with the correct post_name. Perhaps your check to post_name is not correct ?


1

It may seem like WordPress is intelligently redirecting old URLs, but what it's doing is just guessing, and mostly getting it right due to the nature of your posts and URL structure being unique enough for it to guess correctly. There are cases where it'll get this guess wrong. You can see where it does this in WordPress source, the function is aptly named ...


0

You need to modify the rewrite argument when you register your post type: $args = array( // [...] 'rewrite' => array( 'slug' => "Tours" ), ); register_post_type( mc_tours, $args );


0

As far as I know, this is standard behavior for drafts. I've used pretty permalinks on every page I've built, and drafts are always directed to the "ugly" URL. If you publish the post, the actual permalink will be set as expected. Side note: When you edit the draft, you should see the actual permalink listed at the top of the page (small print, just above ...


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


0

The above helped a bit but I actually had to dig deeper into the code and found the page ID in the Body Class: body class="page page-id-4264



Top 50 recent answers are included