ThemeShaper Forums » Thematic

[closed]

adding search to menu above header

(8 posts)
  • Started 11 years ago by cookieandkate
  • Latest reply from cookieandkate
  • This topic is resolved
  1. Hi all,

    I have tried several methods of adding a search field to my menu, which appears above my header image. I had the best luck with the code posted here: http://forums.themeshaper.com/topic/cant-get-search-to-appear-next-to-menu-please-help-5#post-15730

    However, if you visit my blog, http://cookieandkate.com, you'll see that I have somehow created an additional access div. I used his code to remove the original, so I don't know why it happened. I'm not savvy enough with hooks to figure it out myself, so any help would be much appreciated. I hope it is an easy fix.

    I copied and pasted all the code from my functions.php that may be relevant to the issue. Thank you for your help!

    // Remove the standard Thematic menu

    function remove_menu() {

    remove_action('thematic_header','thematic_access',9);

    }

    add_action('init', 'remove_menu');

    // Moving the thematic menu above the header

    add_action('thematic_aboveheader','thematic_access');

    // Add search bar to top menu

    // Remove default Thematic actions
    function remove_thematic_actions() {
    remove_action('thematic_header','thematic_access',9);
    }
    add_action('init','remove_thematic_actions');

    // Create a custom access div with the menu and search box
    function search_access() { ?>
    <div id="access">
    <div class="skip-link">"><?php _e('Skip to content', 'thematic'); ?></div>
    <?php wp_page_menu('sort_column=menu_order') ?>

    <div id="access-search">
    <form id="searchform" method="get" action="<?php bloginfo('home') ?>">
    <div>
    <input id="s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="20" tabindex="1" />
    <input id="searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Search', 'thematic') ?>" tabindex="2" />
    </div>
    </form>
    </div>

    </div><!-- #access -->
    <?php }
    add_action('thematic_aboveheader','search_access',9);

    // Filter away the default scripts loaded with Thematic

    function childtheme_head_scripts() {

    // Abscence makes the heart grow fonder

    }

    add_filter('thematic_head_scripts','childtheme_head_scripts');

    function remove_description($display) {

    $display = FALSE;

    return $display;

    }

    add_filter('thematic_show_description', 'remove_description');

    Posted 11 years ago #
  2. you have 2 #access divs b/c you added thematic_access twice to the same hook (thematic_aboveheader)

    add_action('thematic_aboveheader','thematic_access');
    add_action('thematic_aboveheader','search_access',9);

    function childtheme_override_access() { ?>
    <div id="access">
    <div class="skip-link">"><?php _e('Skip to content', 'thematic'); ?></div>
    <?php wp_page_menu('sort_column=menu_order') ?>
    
    <div id="access-search">
    <form id="searchform" method="get" action="<?php bloginfo('home') ?>">
    <div>
    <input id="s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="20" tabindex="1" />
    <input id="searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Search', 'thematic') ?>" tabindex="2" />
    </div>
    </form>
    </div>
    
    </div><!-- #access -->
    <?php }
    
    // Filter away the default scripts loaded with Thematic
    
    function childtheme_head_scripts() {
    
    // Abscence makes the heart grow fonder
    
    }
    
    add_filter('thematic_head_scripts','childtheme_head_scripts');
    
    function remove_description($display) {
    
    $display = FALSE;
    
    return $display;
    
    }
    
    add_filter('thematic_show_description', 'remove_description');

    if you are using thematic 0.9.8 then you can simply use the override functions. replace your code w/ above. sidenote: when pasting code samples, please enclose between two backtick marks `

    Posted 11 years ago #
  3. Thank you for your help, Helga! I did my best to follow your instructions, and the search box now seems to be in the correct position. However, I lost my menu! Here's what I have in my functions.php file now:


    // Remove the standard Thematic menu

    function remove_menu() {

    remove_action('thematic_header','thematic_access',9);

    }

    add_action('init', 'remove_menu');

    // Moving the thematic menu above the header

    add_action('thematic_aboveheader','thematic_access');

    // Add search bar to top menu

    function childtheme_override_access() { ?>
    <div id="access">
    <div class="skip-link">"><?php _e('Skip to content', 'thematic'); ?></div>
    <?php wp_page_menu('sort_column=menu_order') ?>

    <div id="access-search">
    <form id="searchform" method="get" action="<?php bloginfo('home') ?>">
    <div>
    <input id="s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="20" tabindex="1" />
    <input id="searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Search', 'thematic') ?>" tabindex="2" />
    </div>
    </form>
    </div>

    </div><!-- #access -->
    <?php }

    // Filter away the default scripts loaded with Thematic

    function childtheme_head_scripts() {

    // Abscence makes the heart grow fonder

    }

    add_filter('thematic_head_scripts','childtheme_head_scripts');

    function remove_description($display) {

    $display = FALSE;

    return $display;

    }

    add_filter('thematic_show_description', 'remove_description');

    Where did I go wrong?

    Posted 11 years ago #
  4. P.s. I did try to enclose the code in backticks but it didn't seem to work. Sorry!

    Posted 11 years ago #
  5. Try this, something similar worked for me:

    // Remove the standard Thematic menu
    	function remove_menu() {
       remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_menu');
    
    // Moving the thematic menu above the header
    add_action('template_redirect','header_menu');
    
    // Create a custom div for a search box and stick it in the header
    	function search_access() {?>
                <div id="access-search">
                    <?php thematic_search_form() ?>
                </div><!-- #access-search-->
    <?php }
    }
    add_action('thematic_header','search_access',99);

    You may need to may some adjustment in your stylesheet though...

    Posted 11 years ago #
  6. Sorry, I'm still stuck. This issue is making me crazy. Psflannery, I tried using your code, but received an error message. It added a search box on top of my first widget in the sidebar, and the top menu still wasn't showing up.

    Helga, I thought maybe I had removed too much code when I added yours, so I added this:
    add_action('thematic_aboveheader','search_access',9);

    After this: </div><!-- #access -->
    <?php }

    All I got after doing that was an error message at the top of the page:
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'search_access' was given in /home/content/48/6128548/html/wp-includes/plugin.php on line 405

    Here's what I have in my functions.php now, which doesn't produce a warning message but still does not show my top menu:

    // Remove the standard Thematic menu

    function remove_menu() {

    remove_action('thematic_header','thematic_access',9);

    }

    add_action('init', 'remove_menu');

    // Moving the thematic menu above the header

    add_action('thematic_aboveheader','thematic_access');

    // Add search bar to top menu

    // Remove default Thematic actions
    function remove_thematic_actions() {
    remove_action('thematic_header','thematic_access',9);
    }
    add_action('init','remove_thematic_actions');

    function childtheme_override_access() { ?>
    <div id="access">
    <div class="skip-link">"><?php _e('Skip to content', 'thematic'); ?></div>
    <?php wp_page_menu('sort_column=menu_order') ?>

    <div id="access-search">
    <form id="searchform" method="get" action="<?php bloginfo('home') ?>">
    <div>
    <input id="s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="20" tabindex="1" />
    <input id="searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Search', 'thematic') ?>" tabindex="2" />
    </div>
    </form>
    </div>

    </div><!-- #access -->
    <?php }
    add_action('thematic_aboveheader','search_access',9);

    // Filter away the default scripts loaded with Thematic

    function childtheme_head_scripts() {

    // Abscence makes the heart grow fonder

    }

    add_filter('thematic_head_scripts','childtheme_head_scripts');

    function remove_description($display) {

    $display = FALSE;

    return $display;

    }

    add_filter('thematic_show_description', 'remove_description');

    add_theme_support('post-thumbnails');''

    Posted 11 years ago #
  7. did you try using my code in place of your code? it wasn't meant to be an "in addition to"

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'search_access' was given in /home/content/48/6128548/html/wp-includes/plugin.php on line 405

    that error just means that you have written add the "search_access" function, but there isn't a "search_access" function defined.

    what happens if you just use this? (w/ the version of thematic found here:
    http://developing.thematic4you.com/thematic-development-release/
    )

    function childtheme_override_access() { ?>
    
    	<div id="access">
    
    	   	<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div><!-- .skip-link -->
    
    	   	<?php 
    
    	   	if ((function_exists("has_nav_menu")) && (has_nav_menu(apply_filters('thematic_primary_menu_id', 'primary-menu')))) {
    	   		echo  wp_nav_menu(thematic_nav_menu_args());
        	} else {
        		echo  thematic_add_menuclass(wp_page_menu(thematic_page_menu_args()));
        	}
    
    	?>
    
    	<div id="access-search">
    	<form id="searchform" method="get" action="<?php bloginfo('home') ?>">
    	<div>
    	<input id="s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="20" tabindex="1" />
    	<input id="searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Search', 'thematic') ?>" tabindex="2" />
    	</div>
    	</form>
    	</div>
    
    	</div><!-- #access -->
    
    <?php }
    Posted 11 years ago #
  8. It worked! Thank you so, so much. I really appreciate your help.

    In case anyone else needs it, here's the first chunk of code in my functions.php file. It moves the menu above the header and adds a search field to the right of the menu.


    <?php

    //

    // Custom Child Theme Functions

    //

    // More ideas can be found on "A Guide To Customizing The Thematic Theme Framework"

    // http://themeshaper.com/thematic-for-wordpress/guide-customizing-thematic-theme-framework/

    // Remove the standard Thematic menu

    function remove_menu() {

    remove_action('thematic_header','thematic_access',9);

    }

    add_action('init', 'remove_menu');

    // Moving the thematic menu above the header

    add_action('thematic_aboveheader','thematic_access');

    function childtheme_override_access() { ?>

    <div id="access">

    <div class="skip-link">"><?php _e('Skip to content', 'thematic'); ?></div><!-- .skip-link -->

    <?php

    if ((function_exists("has_nav_menu")) && (has_nav_menu(apply_filters('thematic_primary_menu_id', 'primary-menu')))) {
    echo wp_nav_menu(thematic_nav_menu_args());
    } else {
    echo thematic_add_menuclass(wp_page_menu(thematic_page_menu_args()));
    }

    ?>

    <div id="access-search">
    <form id="searchform" method="get" action="<?php bloginfo('home') ?>">
    <div>
    <input id="s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="30" tabindex="1" />
    <input id="searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Search', 'thematic') ?>" tabindex="2" />
    </div>
    </form>
    </div>

    </div><!-- #access -->

    <?php }

    Here's the CSS, which I had to adjust for my site:

    /* format search box */
    #access-search{
    position:absolute;
    left:50%;
    width:225px;
    margin-left:210px;
    height:29px;
    border-top:0px solid #ccc;
    border-left:0px solid #ccc;
    border-right:0px solid #ccc;
    padding:13px 0 0 0px;
    }

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.