• Resolved anonymized-7517021

    (@anonymized-7517021)


    I want to place a search function between the navigation “Older posts” and “Newer posts” that can be seen over the footer (my homepage is on swedish so Older posts = Äldre inlägg/Newer posts = Nyare inlägg). I also want to have it centered.

    I’m using the Twenty Ten theme (and have created a child theme). As you can see there is a search function there already which I made by adding “<?php get_search_form(); ?>” here in loop.php:

    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if (  $wp_query->max_num_pages > 1 ) : ?>
                <div id="nav-below" class="navigation">
                   <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div>
                   <?php get_search_form(); ?>
                   <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
                </div><!-- #nav-below -->

    How do I center it and how do I make the search function as small as the one in the widget area in the footer? Now the search function is as big as it’s on 404 error page.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You can try wrapping your search form call in the middle of your naviation with something along these lines:

    <span class="center-nav widget_search"><?php get_search_form(); ?></span>

    The ‘widget_search’ class should make the two search boxes appear the same, now just simply center the search form by applying the correct CSS to the ‘center-nav’ class, such as ‘margin: 0 auto;’ for example.

    Thread Starter anonymized-7517021

    (@anonymized-7517021)

    I’m not sure I did it right…

    Did you mean I was going to put
    <span class="center-nav widget_search"><?php get_search_form(); ?></span>
    So it be like this, in the loop.php

    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if (  $wp_query->max_num_pages > 1 ) : ?>
    				<div id="nav-below" class="navigation">
    					<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div>
    					<span class="center-nav widget_search"><?php get_search_form(); ?></span>
    					<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
    				</div><!-- #nav-below -->

    ?

    If so… It didn’t work. As you can see now the search function is even bigger (or longer).

    Did I misunderstood something?

    Thread Starter anonymized-7517021

    (@anonymized-7517021)

    One more thing. How do I do if I want to maintain the search function between the navigation even when there is no navigation?

    If I want a search function in center over the line in the footer. Should I maybe do this in another way than place it in between the navigation?

    Thread Starter anonymized-7517021

    (@anonymized-7517021)

    Here is a screenshot of how it looked when I used
    <span class="center-nav widget_search"><?php get_search_form(); ?></span>

    I changed back to only
    <?php get_search_form(); ?>

    Which is why I link to a screenshot so you can see how it turned out.

    Thread Starter anonymized-7517021

    (@anonymized-7517021)

    I decided to place the search function in the footer above the line instead which gave me the right size (and it’s still there even if there is no navigation). Now I only need to make it centered and “lift” it a little bit above the line.

    This is taken straight from my test site editing the Twenty Ten theme directly. The first bit is from the loop.php at the bottom of the file:

    <div id="nav-below" class="navigation">
      <span class="center-search"><?php get_search_form(); ?></span>
      <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
      <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
    </div><!-- #nav-below -->

    Notice the placement of ‘get_search_form’; this gets the function out of the floating issues that make centering an element between the nav items difficult.

    Now add this to you style sheet (at the end will work):

    div#nav-below span.center-search { position: relative; text-align: center; top: 18px; }
    div#nav-below span.center-search input { font-size: 10px; }

    Both of the above samples should be easily added/edited into your Child-Theme.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Search function between navigation in Twenty Ten’ is closed to new replies.