How to allow different authors to use same post slug?

I ended up adding this code that makes the default post type hierarchical and populating the wp_posts.post_parent field with the author ID. The combination of these two has achieved the desired implementation of having the same slug across multiple authors. // Set post type “post” to be hierarchical $wp_post_types[‘post’]->hierarchical = 1; Source: https://stackoverflow.com/questions/10750931/wordpress-how-to-add-hierarchy-to-posts

Link works although page was moved to another location

That is called canonical redirect. And it’s done through redirect_canonical() which basically Redirects incoming links to the proper URL based on the site url. and Will also attempt to find the correct link when a user enters a URL that does not exist based on exact WordPress query. (Those excerpts were both taken from the … Read more

Change permalink structure with post id

postID/postname should work faster. Had a similar dilema and it turned out WordPress did all the 301 redirects automatically: Changing pemalink structure to /%post_id%/%postname%/ Didn’t measure any rating or traffic drop. However, in the first week, page load time did increase because of most visits being redirected. After that, all fine. Make sure to change … Read more

Rename Custom Post Slug using taxonomy

You’re passing 3 arguments to your function ($permalink, $post, $leavename), but you’re only specifying that it has 2 when you’re adding the filter (the last parameter to add_filter). Change your add_filter call to this: add_filter( ‘post_type_link’, ‘custom_post_type_link’, 10, 3 );

Problem with get_permalink, to get page content

The answer lies in your question already… When you use get_permalink for your post 171, it gets you https://mysite/2018/11/24/152-revision-v1 So, as you can see, this post is not a published post, but a revision of a post. Revisions are not public, so you can’t see them… So how to solve that? You’ll have to check … Read more

Disable “similar permalink” redirect [duplicate]

To completely disable this feature, use this code, which I got from here. remove_action( ‘template_redirect’, ‘redirect_canonical’ ); To only disable it for URL addresses that contain the string ‘event’, use this code: add_filter( ‘redirect_canonical’, ‘disable_redirect_canonical_for_event’, 2, 10 ); function disable_redirect_canonical_for_event( $redirect_url, $requested_url ) { if ( strpos( $requested_url, ‘event’ ) !== false ) { return … Read more

In a multisite, how can I get posts from one site and display their permalinks in another site?

Let’s take a look at get_blog_permalink: get_blog_permalink( $blog_id, $post_id ) { switch_to_blog( $blog_id ); $link = get_permalink( $post_id ); restore_current_blog(); return $link; } As you can see, there’s no magic… But there are some problems, since switch_to_blog isn’t very efficient… It means that it would be way better if you’d done it this way: $tp_blog_id … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)