Forums

[resolved] localization in dynamic menu (4 posts)

  1. lightblack
    Member
    Posted 2 months ago #

    Hi ,

    I want to make my menu use localization terms the links work but I cannot make it set the class 'current'

    <?php
     if (is_single() && in_category('_e("mycat")')is_child(110))  {
    { echo ' class="current"';  }?>
    <?php } ?>>
    <a>/<?php _e('mycat'); ?>" title="<?php _e('mycat'); ?>"><?php _e('mycat'); ?></a>

    How do I use the if-conditional in wordpress with the _e() function?
    Thanks and best regards

  2. fldtrace
    Member
    Posted 2 months ago #

    Check this tutorial for dynamic menu.

  3. lightblack
    Member
    Posted 2 months ago #

    hi and thanks for your reply.
    My actual problem is not the highlighting of the menu but how to make the term _e("mycat") translatable(localization).

    I would like to have the category term e.g. about translated depending on the language <?php if (is_page('about') ) so in German it looks for the catgory name 'ueber' by using the _e() function.
    I'm not sure what I'm missing syntax error this does not work.

    in_category('_e("mycat")')

    Thanks

  4. lightblack
    Member
    Posted 2 months ago #

    I found the solution.

    You cannot use the e() function you need to use the __() function to return the string.
    
    <li<?php
     if (is_single()  && in_category(__('about', 'themeName')) || is_child(123))  {
    { echo ' class="current"';  }?>
    <?php } ?>>
    <a id="nav1" href="<?php bloginfo('url'); ?>/<?php _e('about','themeName'); ?>" title="<?php _e('About','themeName'); ?>"><?php _e('About','themeName'); ?></a></li>

Reply

You must log in to post.

About this Topic