• In my twenty twelve child theme (in development on my MAMP setup so there’s no link to show you)…

    In my navigation code in header.php I added the get_search_form code as follows:

    <nav id="site-navigation" class="main-navigation" role="navigation">
    			<h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
    			<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
    			<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
                <?php get_search_form(); ?>
    		</nav><!-- #site-navigation -->

    And in my style.css I added this code based off the css of twenty thirteen for the search box:

    /* search box in nav area */
    #search-form {
        float: right;
    }
    #site-search {
            background-color: transparent;
    	background-image: url(images/search-icon.png);
    	background-position: 5px center;
    	background-repeat: no-repeat;
    	background-size: 24px 24px;
    	border: none;
    	cursor: pointer;
    	height: 20px;
    	margin: 0;
    	padding: 0 0 0 34px;
    	-webkit-transition: width 400ms ease, background 400ms ease;
    	transition: width 400ms ease, background 400ms ease;
    	width: 0;
    }
    #site-search:focus {
    	background-image: url(images/search-icon.png);
    	background-position: 5px center;
    	background-repeat: no-repeat;
    	background-size: 24px 24px;
    	background-color: #fff;
    	cursor: text;
    	outline: 0;
    	width: 230px;
    }

    But I’m getting a search form and button which look default to WordPres and not the one used in TwentyThirteen, and it’s centered under my navigation menu instead of being to the right. So there’s no magnifying glass icon or expandable search box with animation like on TwentyThirteen.

    Is there something from the core of TwentyThirteen that I need to add to TwentyTwelve in order to make this work? I want this nice search box to be at the right of my navigation menu in Twenty Twelve.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter David Borrink

    (@davidborrink)

    I’ve investigated the functions.php files in TwentyThirteen and found a line in the setup area that pertains to search. But how do I add that to TwentyTwelve’s functions in a child theme so I don’t break the site? I tried and I got a blank screen.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Are you saying that you’re already pulling in the search form, it’s just that it’s missing the CSS?

    Thread Starter David Borrink

    (@davidborrink)

    Yes, the search form appears but it’s not looking or acting like the TwentyThirteen search box. It looks like a default WordPress search box and button. No magnifying glass icon with a clicking action that expands into a search field.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you replicate your webpage using a CSS sandbox such as in http://cssdesk.com ?

    Copy the HTML from your source code and grab all the CSS you can find and put it in the CSS section too. Then click on that “share” button at the top right and it’ll generate a URL for us

    Thread Starter David Borrink

    (@davidborrink)

    cssdesk. Neat idea. I pasted in the source code and my CSS and it created my front page pretty well. But when I clicked “share” all I get was http://www.cssdesk.com/# in the browser. That can’t be it. I’m using Firefox on a Mac. Where does the URL get generated to? ???

    Thread Starter David Borrink

    (@davidborrink)

    Oh wait. I didn’t click on the icon, but on the word. Here you go: http://www.cssdesk.com/wZdgF

    Thread Starter David Borrink

    (@davidborrink)

    So what do you see there?

    Thread Starter David Borrink

    (@davidborrink)

    If you look at a TwentyThirteen default setup, you’ll see the magnifying glass and when you click it expands to an input box. That’s what I”m trying to put on a TwentyTWelve child theme.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Edit: I’m going to have to look over this more thoroughly

    Thread Starter David Borrink

    (@davidborrink)

    I’m using a child theme off of Twenty Twelve. So I put my child theme’s CSS in there. Should I put Twenty Twelve’s CSS in there, AND my child theme’s CSS afterwards?

    Thread Starter David Borrink

    (@davidborrink)

    Well, I found a post that explains how to put the search form INSIDE the nav bar. here’s a function that puts a search box in the menu of TwentyTwelve, inline, and not above or below.

    Here’s the function:

    function menu_search($items){
        $search = '<li class="search">';
        $search .= '<form method="get" id="searchform" action="/">';
        $search .= '<label for="s" class="assistive-text">Search</label>';
        $search .= '<input type="text" class="field" name="s" id="s" placeholder="Search" />';
        $search .= '<input type="submit" class="submit" name="submit" id="searchsubmit" value="Search" />';
        $search .= '</form>';
        $search .= '</li>';
    
        return $items . $search;
    }
    add_filter('wp_nav_menu_items','menu_search');

    So the question remains, how do we call up the Twenty Thirteen style of search box? At least this gives us the in-line answer for positioning. 🙂

    dipesh1811

    (@dipesh1811)

    How to change twenty thirteen default search box to own search box

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Trying to add a TwentyThirteen search box to a Twenty Twelve child theme’ is closed to new replies.