Custom Post Types and independent Categories – complex Taxonomy

In wordpress, the slug (post name) is unique per post type. So, an url like /company-1/items/item-type-1/product-1 and one like /company-2/items/item-type-1/product-1 where product-1 is the post name, cannot address to 2 different products. If you create 2 products with same title WordPress on saving will set an unique slug. Same thing is for articles. For this … Read more

How to link to “most recent” document in the Media Library?

You could search the latest attachments like my example below. I searches for the string “newsletter”, and the first time it pops up in a filename, it writes a link. I’ve tried to make it easy to understand. $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => 20, ‘post_status’ => null, ‘post_mime_type’ => ‘application/pdf,application/msword’ ) … Read more

Trailing slash at the end of permalink loads faster / better SEO?

If the permalink is to a file with an extension, no trailing slash is needed. http://www.domain.com/afile.html If the permalink is to a directory, a trailing slash is preferred. Otherwise, the server will respond with a redirect and the browser will have to add the trailing slash and make a second request automatically. http://www.domain.com/adirectory/ is served … Read more

Remove permalink settings in post for users

The default post types are post, page, attachment, revision, and nav_menu_item. Replace ‘post_type’ with ‘post’: add_action(‘admin_head’, ‘wpds_custom_admin_post_css’); function wpds_custom_admin_post_css() { global $post_type; if ($post_type == ‘post’) { echo “<style>#edit-slug-box {display:none;}</style>”; } } If you want to remove it for multiple post types (i.e. post, page, or any custom post types you might have), change line … Read more

Bulk update post slugs through database

Try this query, remembering to change out your_posts_table with the proper name in your database. Using CONCAT, you can add any number of strings, just pass post_name to add your changes before/after. update your_posts_table set post_name = CONCAT(‘pre-‘, post_name) More info on MySQL CONCAT Note: Use a WHERE clause if you only want to update … Read more

MultiSite Move conjures duplicate URL

I would suggest to use Search and Replace utility when you move your WordPress Network. it seamlessly update all the fields of the database from old domain to new domain. After that, you only need to update the domain name in wp-config.php. (Tip: do not include http:// and trailing slash while replacing the domain rather … Read more

Dynamically generate child-URLs for posts or custom posts

I just completed something like this (with great help from folks on this site). First, you need to add the rewrite endpoint to your functions: function wpa_read_endpoint(){ add_rewrite_endpoint( ‘sub-url’, EP_PERMALINK); } add_action( ‘init’, ‘wpa_read_endpoint’ ); Make sure to then go to the permalinks section of admin and save to refresh permalink settings. Then add some … Read more