Custom permalink structure for posts in certain categories

here is a solution to search through all categories, not only the first one. add_filter(‘post_link’, ‘custom_permalink’, 10, 2); function custom_permalink( $permalink, $post ) { // Get the categories for the post $categories = get_the_terms($post->ID, ‘category’); if (!empty($categories)) { foreach ($categories as $category) { if ($category->cat_name == “ICO”) { $cat_name = strtolower($category->cat_name); $permalink = trailingslashit( home_url(“https://wordpress.stackexchange.com/” … Read more

Logging in to installation in subdirectory renders broken dashboard (no CSS, broken links)

Try disabling all plugins temporarily (you can do that quickly by renaming the wp-content/plugins folder to something else). See if that fixes the admin screen. If it does, make a new wp-content/plugins folder, then move plugin folders from the renamed folder back into the wp-content/plugins folder one at a time. Retest, and see if one … Read more

How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]

I think you have to create your own rewrite rule for that custom post type. Example creating a rewrite rule : function custom_rewrite( $wp_rewrite ) { $feed_rules = array( ‘reviews/(.+)/(.+)’ => ‘index.php?post_type=movies&taxonomy_name=”.$wp_rewrite->preg_index(1).”&post_name=” . $wp_rewrite->preg_index(2) ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } // refresh/flush permalinks in the dashboard if this is changed in any way add_filter( … Read more

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