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/" . $cat_name . "https://wordpress.stackexchange.com/" . $post->post_name . "https://wordpress.stackexchange.com/" ) );
break; //we found ico, so exit foreach immediately
}
}
}
return $permalink;
}
Related Posts:
- Need help with friendly URL’s in WordPress
- Why does WordPress 3.0.4 keep deleting the contents of the .htaccess file?
- how to flush custom author rewrite rule
- Add filename to attachment page url
- Creating Search Engine Friendly URL’s with Word Press
- WordPress slugs and 404 handling takes preference over folders in site root?
- How to encode author ID in the author permalink
- WordPress Custom File Permalink
- How can I create a permalink with two categories, with the order based on the parent category?
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- Create a url structure for my blogs based on categories and sub-cats
- Woocommerce product permalink not working
- Create page as a file in my theme?
- Don’t change Custom Post Type slug to unique value
- Add or Create Custom Structure Tags to Permalink
- How do I change my permalink structure to a custom structure on an established blog?
- getting a 404 page for all pages except home. possibly permalinks
- Create Miltiple Category Base
- How to get Previous Visited Page Information
- Adding a custom field to a slug
- how can custom permalink structure use for specify custom post type
- URL issue after setting up Custom Structure in Settings >> Permalinks
- How to add rewrite rule for product compare page?
- How to add a static text at end of a wordpress permalink
- Combine Categories & Custom Taxonomy
- Structure of post types for TV Shows and episodes
- Smarter Document Management links between three WordPress sites sought
- permalink of word press in htacess
- For one linked image per post, override that link with a permalink when on the main page
- I need to display post related info
- How to keep the /blog slug even in single post slug
- Show post content in two different places without redirect
- Permalink Listing WordPress
- Redirection after Category Change for Custom Structure
- Is there a blank theme framework compatible with WP 3.0? [closed]
- Plugin SVN & update API – how are plugins identified?
- How to use more than 256MB of memory in the admin?
- Custom Search Query
- Removing fields from the Media Uploader/Gallery
- Managing Images for a WordPress Blog: Picasa or Flickr?
- When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?
- Selecting An image from the Media LIbrary on the frontend
- How wp_ajax_nopriv since WordPress 3.1
- Set user loggin status?
- redirect product-category to a custom page
- custom headers for static home page and posts page
- How to redirect WooCommerce shop URL?
- Best way to implement a thumbnail-based gallery in WordPress?
- Why is my mod_rewrite not working?
- Show posts on a page based on a category and tag(s)
- Any tools for quickly grabbing comments / comment count?
- Custom WP_Query with no posts to output
- Adding Page Attributes and Page Templates to Custom Post Type WP 4.7.3
- WordPress Locale Switching on Accept-Language Header
- syntax highlighting for theme-editor.php?
- adding homework to a school’s website
- How do I call in a category title on a category page in a child theme?
- Include custom JS without child theme
- Prepopulating a specific page template with HTML/CSS
- How to include term custom meta into the custom taxonomy term permalink structure
- WordPress 3.1 .htaccess contents keep dissappearing?
- How to get every custom taxonomy names and urls?
- Is there a way to by-pass the pagination function on one custom template?
- Changes in my child theme from customizer not appearing in style.css?
- Search URL parameters query [duplicate]
- Change Successful password reset message
- Changing the the_author_posts_link() hover title
- How I can directly add drop-down in my product on shop page as show in below image
- register_post_type permalink
- How do I hide an article element so only logged out users see it
- How to add custom ‘layout’ buttons to wordpress editor?
- How to request container_class from wp_nav_menu
- Replace a ‘Title’ tag with a Custom Field
- change top banner content on specific page
- Is “get_template_part” hierarchy possible?
- Custom Register Link on Backend Form
- Prevent WordPress from automatically installing a new theme each year
- Dynamic Sections
- How do I run a web app in my WordPress theme without the “wp-content/theme/…/webapp” in URL?
- How to make conditional statement in WpBakery (formarly Visual Composer)
- Use Theme CSS in custom code
- Widget recent comment filter by post meta_value
- Highly stylized pages
- Replace featured image when shortcode is present
- Post filter with multiple checkbox taxonomy terms
- Altered Media Library URLs
- generate a static copy of the website footer html
- Multi-site customization
- Show different pages on site depending on user choice
- Is there a way to limit multi upload in media upload box?
- Use another theme template in my theme
- How to loop through 1 CPT with 2 Taxonomies
- Pulling posts into static site (wordpress as subdirectory)
- Call a duplicate registration form with other url
- How to support extra color options for shortcodes?
- WP Customizer – what types of fields is it capable of supporting?
- pull custom fields values from wp-database in a nested foreach loop
- Pass query param to custom page
- responsive screen not working [closed]
- Custom Menu (only showing direct cildren) ACF not showing