Rename a slug label

As SallyCJ mentioned, gettext is really the only option you have with this, because the Slug labels are hardcoded in the Core of WordPress. https://core.trac.wordpress.org/browser/tags/5.2/src/wp-admin/edit-tags.php#L439 Here is a snippet I wrote and tested that should work for you, and it will only run on the backend and only on the two pages where you will … Read more

Keep subcategory grandson in slug

The problem is not with WordPress — it does generate the proper permalink, be the post assigned to just grandson or son and father. It’s just that for the latter, the “chosen” category could be either son or father, but not both — and if it’s son (which has a parent category), then the permalink … Read more

List taxonomy term slugs within shortcode (do_shortcode)

The do_shortcode() function is currently in the foreach loop. I don’t know what are the parameters of this shortcode , but if it accepts comma separated values of term slugs: $terms = get_the_terms( $post->ID , ‘shoptype’ ); $i=1; $commaSeparatedvalues=””; foreach ( $terms as $term ) { $term_link = get_term_link( $term, ‘shoptype’ ); if( is_wp_error( $term_link … Read more

Attachment pages stealing page slugs

I’ve found a workaround if someone has the same problem: In the database, you can search for the attachment page that’s causing problem, you’ll find it in wp_posts by searching for its post_name (which is the slug you want). Then just rename that post_name (in about-img for example). It isn’t a fix but it will … Read more

Can anybody provide me with a function to generate slugs?

This post provides a function, but it cannot handle non-latin characters. That’s because URLs can’t have non-latin/ASCII characters. Browsers might show non-latin characters to you, but it’s just a user interface feature. For example, if you visit this Wiktionary URL: https://en.wiktionary.org/wiki/わかもの#Japanese, you browser URL encodes the japanese characters to get the real URL: https://en.wiktionary.org/wiki/%E3%82%8F%E3%81%8B%E3%82%82%E3%81%AE#Japanese then … Read more

Slug for custom post type

Somehow it seems WordPress sees the custom post type as posts, not pages? No, but your permalink structure (for the default post post type) that you set via the Permalink Settings admin page contains (or starts with) blog/ and by default, it will also be prepended to permalinks for custom post types, unless the post … Read more

Automatically redirect a page to a category that share the same slug

Well you can just turn the code 180 degrees from the linked question and problem solved. Just kidding. I would start with getting the current page slug, using that slug search for a category that has that slug, if found, redirect to it add_action(‘template_redirect’, ‘bt_redirect_page_to_category’); function bt_redirect_page_to_category () { // if we are not in … Read more

Get plugin download URL from slug

I forget exactly if the plugin slug is a reliable method to get the url, it might be in most cases but not all due to how plugins are named. You can query the api @wordpress.org for the plugins xml file which also contains the download link. For example: $plugin_slug = ‘akismet’; $return_plugin_info = “http://api.wordpress.org/plugins/info/1.0/$plugin_slug.xml” … Read more

How do you create %post_type%/%postname%/ permalink structure?

Beyond the fact that disabling ‘pretty’ permalinks in the Settings > Permalink page disables pretty permalinks for all post types and taxonomies, the options do not effect custom post types or taxonomies. If you set the permalinks to blog/%postname% then your posts will have the structure: www.yoursite.com/blog/hello-world. On the other hand, when a post type … Read more

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