WPML Slug Conflicts
So I just started using WPML CMS on a site with a large number of custom post types. Everything was going fine, and the CMS editors were loving the ease of use.
Things were going smoothly until conflicting slugs started to happen. I’ll give you an example we had a page :
example.com/my-new-thing
which we linked to from our custom post type like so:
example.com/cpt/my-new-thing
Now a few things to note:
- The custom post type and the page are using the same slug
- Both do not have any translations
However wpml will redirect the page example.com/my-new-thing
to example.com/cpt/my-new-thing
! I traversed their redirect code and I believe the issue is when they search by name and pagename they do not distinguish between post types which seems to simple to be the problem ??♂️
I haven’t figured it out completely but for now I’ve done what most other people have suggested which is remove the action based on the posts ID. I’m thinking if this becomes a common problem I might create a disable WPML checkbox in the editor.
If you by chance are struggling with slug conflicts with WPML obviously head to their support forums. If you are interested in what I did to fix my woes it was something along these lines:
function wpml_remove_parse_query_action( &$query ) {
global $sitepress;
if ($query->queried_object_id === ID_OF_PAGE) {
remove_action( 'parse_query', array( $sitepress, 'parse_query' ) );
}
}
add_action( 'parse_query', 'wpml_remove_parse_query_action', 5 );
I hope this helps you out. Otherwise, it’s just another rant by a WordPress developer.
Chrome bugging you about insecure connections on localhost?
Sick of clicking Trust this site on your own Localhost. Like seriously chrome 🤦🏼♂️
Exclude a folder from your git diff
Need a way to show your git diff in your terminal while excluding a folder from your results? While boy do I have a trick for you!
Get Cloudflare geolocation data client side
Cloudflare provide a very handy HTTP Header called `CF-IPCountry` which you can use to detect your users geolocation but there is another way.
What y’all thought