• Hello!
    I tried to add this code

    backticks[php]
    add_filter(‘wp_nav_menu_items’, ‘wps_add_login_logout_link’, 10, 2);
    function wps_add_login_logout_link($items, $args) {
    $login = __(‘Sign in’);
    $logout = __(‘Sign out’);
    
    //use one of the following methods of identification
    $menu_id = ’34’;
    $menu_name = ”; //name you gave to the menu
    $menu_slug = ”; //slug of the menu, generally menu_name reduced to lowercase
    
    if ( ! is_user_logged_in() )
    $link = ‘<a href="’ . esc_url( wp_login_url($redirect) ) . ‘">’ . $login . ‘</a>’;
    else
    $link = ‘<a href="’ . esc_url( wp_logout_url($redirect) ) . ‘">’ . $logout . ‘</a>’;
    
    if ( ($menu_id) && ($args->menu->term_id == $menu_id) )
    $items .= ‘
    <li>’. $link .'</li>
    ’;
    elseif ( ($menu_name) && ($args->menu->name == $menu_name) )
    $items .= ‘
    <li>’. $link .'</li>
    ’;
    elseif ( ($menu_slug) && ($args->menu->slug == $menu_slug) )
    $items .= ‘
    <li>’. $link .'</li>
    ’;
    
    return $items;
    }
    [/php]

    to my functions.php file and I received this message

    Parse error: syntax error, unexpected ‘add_filter’ (T_STRING) in /home1/wabhh40aayb4/public_html/wp-content/themes/child-theme/functions.php on line 4

    and now I’m stuck with that message I can’t do anything.
    I deleted the code and left the file looking like that
    <?php
    /* Write your awesome functions below */
    but the message remains.
    my website is myecoways.com

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Parse error: syntax error, unexpected 'add_filter' (T_STRING)’ is closed to new replies.