Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #854514

    Hi there,

    need your urgent help since I cannot publish my website until this is not solved due to incomplete permalinks:

    In the thread https://kriesi.at/support/topic/menu-and-category-menu-items-issues/ you gave me some code that excludes my recipe and lifestyle posts from the default blog posts. Now I saw that this also changes the permalinks structure! In blog posts it’s still mywebsite.com/parentcategory/subcategory/postname, but in recipe and lifestyle posts it is mywebsite.com/parentcategory/postname. Means in the URL your code removes the subcategory and in some cases the subsubcategory as well!

    Can you please urgently help? Thanks a lot in advance.

    Kind regards
    Sophie

    #855197

    Hey Sophie,

    Thank you for using Enfold

    The modification in the previous thread will not affect the breadcrumbs. Did you add any other filter for the breadcrumb? Please check the functions.php file.

    Best regards,
    Ismael

    #855367

    Hi Ismael,

    no, I did not mean the breadcrumbs, I mean the permalink structure. And after some playing around, I think I found the bug:

    To use the modification from the previous thread for excluding my recipe posts “recipes” and “lifystyle” from the default blog posts, I need to select the main category AND the subcategory in the backend. And that changes the permalink of each post (but not for the default blog posts, they are working properly, because they have no modification).

    So, if I deselect for example the main category “recipe” and just select the subcategory “icecream”, the permalink is displaying properly: mywebsite.com/recipes/icecream/postname, same with sub-subcategories: mywebsite.com/recipes/drinks/colddrinks/postname. But if I deselect the main category, it shows mywebsite.com/recipes/postname without subcategory/sub-subcategory. But then I cannot use the modification you gave me for excluding my recipe posts “recipes” and “lifystyle” from the default blog posts :-( .

    Feel a little helpless right now, because it is important to me to have my permalinks displayed with subcategories/sub-subcategories. Do you have any idea what to do that both the permalinks and your modifcation are working properly for my “recipes” and “lifestyle” posts?

    Thank you for all your efforts in this issue. Really do appreciate.

    Kind regards
    Sophie

    #856292

    Hi,

    I see. Select both the main and sub category then add the subcategory name in the “has_category” function.

    if( is_single() && has_category( 'rezepte' ) ) {
    

    Replace it with:

    if( is_single() && has_category( array('rezepte', 'another_category_slug_here') ) ) {
    

    Best regards,
    Ismael

    #856472

    Hi Ismael,

    thank you, Ismael. I did as per your advice:

    1. I selected both the main and sub category.

    2. Then added your code as follows to the functions.php:

    add_filter( 'body_class', function( $classes ) {
    	if( is_single() && has_category( array('rezepte', 'konfitueren') ) ) {
    		$classes = array_merge( $classes, array( 'single-recipe' ) );
    	}
    
    	if( is_single() && has_category( array('rezepte', 'getraenke', ) ) ) {
    		$classes = array_merge( $classes, array( 'single-lebensart' ) );
    	}
    
      return $classes;
    });

    But nothing changed. Only for category icecreams it works, even though I did NOT put its subcategory to the functions.php.

    3. When choosing a recipe post from menu item “Recipes”, the green active menu indicator is showing up below menu item “Recipes” AND “Lifestyle”, but it should only show up below “Recipes” (screenshot in private content).

    4. When choosing a lifestyle post from menu item “Lifestyle”, the green active menu indicator is jumping back to menu item “Blog”.

    5. I do have lots of categories and subcategories. How to put them in the functions.php as well?

    6. Shall I still use the custom CSS you gave me:

    .single-recipe #menu-item-450 .avia-menu-fx {
        display: none !important;
    }
    
    .single-recipe #menu-item-480 .avia-menu-fx {
        display: block;
        opacity: 1;
        visibility: visible;
    }
    
    .single-lebensart #menu-item-450 .avia-menu-fx {
        display: none !important;
    }
    
    .single-lebensart #menu-item-481 .avia-menu-fx {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    Really hope you can help, since I cannot figure out what’s wrong here. Thank you for all your efforts in this issue, Ismael.

    Best regards
    Sophie

    #857232

    Hi,

    There’s an extra comma in the following line.

     array('rezepte', 'getraenke', )
    

    Please post the url to one of the posts and the login details so that we can test it.

    Best regards,
    Ismael

    #857642

    Hi Ismael,

    please kindly find the login credentials and the URL to one of the posts in the private content box. Really hope you can help and fix this issue. That would mean a lot to me. Thanks so much in advance, Ismael.

    Kind regards
    Sophie

    #857864

    Hi,

    Thank you for the update. For clarification, the modification that we added previously didn’t affect the permalink. If you need to display the sub category in the url, just select the child category, not the parent category. We selected the “molkereiersatzprodukte” for the following post.

    EDITED

    In the functions.php file, include the child category name.

    if( is_single() && has_category( array('lebensart', 'lebensmittel', 'molkereiersatzprodukte' ) ) ) {
    

    Best regards,
    Ismael

    #858057

    Hi Ismael,

    okay, I got it ! Yes, that was what I wanted to achieve: Displaying the subcategories and sub-subcategories in the URL. So, I added some more categories and subcatgeories to the functions.php and it seems to work when deselecting the parent category! Thank you so much for all your patience and efforts resolving this issue :-) ! But, please give me some more time, I will check with some more subcategories and sub-subcatgeories and will let you know the outcome if we can close this topic finally ;-) .

    Oh, by the way: Can you please remove the URL showing my website in your a/m post? Thanks a lot!

    Have a great day!

    Kind regards
    Sophie

    #858402

    Hi,

    Alright. Let us know if you encounter any issue. The link has been removed.

    Best regards,
    Ismael

    #866189

    Hello,

    so meanwhile I added some more categories to the code in functions.php and it seems to work :-) . So you can close this topic out. Thanks so much for all your efforts.

    Have a great day!

    Kind regards,
    Sophie

    #866937

    Hi,

    Great! Please feel free to open a new thread if you need anything else. :)

    Best regards,
    Ismael

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Your code for excluding my custom posts are removing subcategory in permalinks’ is closed to new replies.