WordPress.org

Forums

[resolved] having a weird problem with the_category (4 posts)

  1. omniafausta
    Member
    Posted 2 years ago #

    Hai everyone,
    I hope you can help me. I have a problem with my categories.
    After some research I understand this:

    <?php the_category ( __( ', ', '' ) ) ?>

    should give me the categories the post is posted in, seperated by a comma. Most posts have only 1 category, but some have 2.
    What it does now (with the posts that have 2 categories) is show me the name of one category and then that name links to the other. So there must be something going horribly wrong.
    Any tips on what could be the problem??

    Here you can see an example:
    http://www.omniafausta.com/wordpress/dooreten/
    it shows the category 'eigen projecten' and if you click that, you go to 'boeken'.
    I want it to show 'categorie: boeken, eigen projecten'

    some extra info:
    I am making my own theme based on Tweaker3, with quite a bit of added stuff.

    Thanks for any help!

  2. omniafausta
    Member
    Posted 2 years ago #

    update:
    <?php echo get_the_category_list(); ?> gives me both categories, but in an ul
    As soon as I add the seperator, it turns out as before (showing just the one category that links to the other)

    could it maybe be something in the functions of the theme I started with?

  3. omniafausta
    Member
    Posted 2 years ago #

    finally found the culprit! It was a plugin that made it happen.
    'Remove Title Attributes'
    When i deactivated it, the problem was gone.

  4. omniafausta
    Member
    Posted 2 years ago #

    and I found a function that does what i needed the plugin to do, without the trouble the plugin gave me!!

    function my_nav_notitle( $nav ){
      return $nav = preg_replace('/ title=\"(.*?)\"/', '', $nav );
    
    }
    add_filter( 'wp_nav_menu', 'my_nav_notitle' );
    add_filter( 'wp_page_menu', 'my_nav_notitle' );
    add_filter( 'wp_list_categories', 'my_nav_notitle' );
    add_filter( 'the_category', 'my_nav_notitle' );
    
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic