Support » Fixing WordPress » All links have _blank target

  • Resolved jakubmudra123

    (@jakubmudra123)


    [ Moderator note: moved to Fixing WordPress. Please do not use Developing with WordPress for these topics. ]

    Hi,

    i have a problem. Im developing a theme for wordpress, but i have problem.I dont know why, but all link have atribute target=”blank” on end of the a tag. If i check checkbox in menu options to open link in new tab, atribute only move to the start of the a tag.

    I dont know why its doint this.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    Are you using any plugins? If yes try disabling them to see if anything changes, some plugins ( like SEO ones ) have options to force the target’s on all links etc.

    If you are not developing a theme from scratch there might even be a Theme Setting somewhere doing it as well.

    Best regards,
    Konstantinos

    Thread Starter jakubmudra123

    (@jakubmudra123)

    Thanks for answer.

    Yes, im using some plugins. I disabled all of them, but nothing changed. Heres my functions.php.

    <?php
    /**
     * Migration functions and definitions.
     *
     * Sets up the theme and provides some helper functions, which are used
     * in the theme as custom template tags. Others are attached to action and
     * filter hooks in WordPress to change core functionality.
     *
     * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
     * to a filter or action hook.
     *
     * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
     *
     */
    
    /**
     * Sets up theme defaults and registers the various WordPress features that
     * the Migration theme supports.
     *
     * @uses add_editor_style() To add a Visual Editor stylesheet.
     * @uses add_theme_support() To add support for post thumbnails
     * @uses register_nav_menu() To add support for navigation menus.
     * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
     *
     */
    function migration_setup() {
    
    	// This theme styles the visual editor with editor-style.css to give it some niceties.
    	add_editor_style();
    
    	// This theme uses wp_nav_menu() in one location.
    	register_nav_menu( 'o_stitne_zlaze', __( 'O štítné žláze', 'o_stitne_zlaze' ) );
    	register_nav_menu( 'nemoci_stitne_zlazy', __( 'Nemoci štítné žlázy', 'nemoci_stitne_zlazy' ) );
    	register_nav_menu( 'karcinom_stitne_zlazy', __( 'Karcinom štítné žlázy', 'karcinom_stitne_zlazy' ) );
    	register_nav_menu( 'lecba_karcinomu', __( 'Léčba karcinomu', 'lecba_karcinomu' ) );
    	register_nav_menu( 'kontakt', __( 'Kontakt', 'kontakt' ) );
    	register_nav_menu( 'mohlo_by_vas_zajimat', __( 'Mohlo by vás zajímat', 'mohlo_by_vas_zajimat' ) );
    	register_nav_menu( 'casto_hledate', __( 'Často hledáte', 'casto_hledate' ) );
    	register_nav_menu( 'videa', __( 'Videa', 'videa' ) );
    	register_nav_menu( 'footer', __( 'Patička', 'footer' ) );
    
    	// This theme uses a custom image size for featured images, displayed on "standard" posts.
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 500, 9999 ); // Unlimited height, soft crop
    }
    
    add_action( 'after_setup_theme', 'migration_setup' );
    
    if (function_exists('acf_add_options_page')) {
     
        acf_add_options_page(array(
            'page_title'    => 'Obecné nastavení',
            'menu_title'    => 'Nastavení šabl.',
            'menu_slug'     => 'nastaveni',
            'capability'    => 'edit_posts',
            'redirect'      => false
        ));
     
        acf_add_options_sub_page(array(
            'page_title'    => 'Nastavení hlavičky',
            'menu_title'    => 'Hlavička',
            'parent_slug'   => 'nastaveni',
        ));
     
        acf_add_options_sub_page(array(
            'page_title'    => 'Nastavení patičky',
            'menu_title'    => 'Patička',
            'parent_slug'   => 'nastaveni',
        ));
         acf_add_options_sub_page(array(
            'page_title'    => 'Nastavení 404',
            'menu_title'    => '404',
            'parent_slug'   => 'nastaveni',
        ));
     
    }
    
    // ====== option 2, used ====== //
    
    // This does the same actually, taken from http://css.dzone.com/news/wordpress-wpnavmenu-separator
    function nav_menu_first_last( $items,$args ) {
    
    	 if( $args->theme_location == 'o_stitne_zlaze' OR $args->theme_location == 'nemoci_stitne_zlazy' OR $args->theme_location == 'karcinom_stitne_zlazy' OR $args->theme_location == 'lecba_karcinomu' OR $args->theme_location == 'kontakt' ){
    		 $pos = strrpos($items, 'class="menu-item', -1);
    		 $items=substr_replace($items, 'menu-item-last ', $pos+7, 0);
    		 $pos = strpos($items, 'class="menu-item');
    		 $items=substr_replace($items, 'vetsi  ', $pos+7, 0);
    	}
    	return $items;
    }
    add_filter( 'wp_nav_menu_items', 'nav_menu_first_last', 10, 2);
    /**
     * Enqueues scripts and styles for front-end.
     */
    function migration_scripts_styles() {
    	global $wp_styles;
    
    	/*
    	 * Loads our main stylesheet.
    	 */
    	wp_enqueue_style( 'migration-style', get_stylesheet_uri() );
    
    	/*
    	 * Optional: Loads the Internet Explorer specific stylesheet.
    	 */
    	//wp_enqueue_style( 'migration-ie', get_template_directory_uri() . '/css/ie.css', array( 'migration-style' ), '20121010' );
    	//$wp_styles->add_data( 'migration-ie', 'conditional', 'lt IE 9' );
    }
    add_action( 'wp_enqueue_scripts', 'migration_scripts_styles' );
    
    • This reply was modified 3 years, 10 months ago by jakubmudra123.
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you show us a page with the problem?

    Thread Starter jakubmudra123

    (@jakubmudra123)

    You have this in your /themes/stitnazlaza/js/default.js

    Line 10:

     $("a[href^='http://']").each(function() {
        if(!$(this).attr('href').match("stitnazlaza.info")){
          $(this).attr('target', '_blank');      
        }
      })

    Remove that and there won’t be any target blank I bet.

    Best regards,
    Konstantinos

    Thread Starter jakubmudra123

    (@jakubmudra123)

    Thank you very much! 🙂

    No problem, I’m happy to help!

    Best regards,
    Konstantinos

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘All links have _blank target’ is closed to new replies.