• I’m planning to use a search template for my website based on the brilliant virtue theme along with the relevanssi plugin. I’m using this css code to align the sidebar to the right:
    .kad-sidebar { float: right; }
    The sidebar isn’t static (non-moving) though i.e. it moves downward if there is text on the page. The text occupies the space of the sidebar if the text stretches up to the sidebar. I’ve attached the screenshot here:
    https://imgur.com/AZLMtiJ
    Can you please help how to make the sidebar static? Also, can you let me know of the function to call the footer to appear on the search template?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hey,
    by search template what are you adding? A search.php file in a child theme?

    The header and footer are automatically called on all templates and the sidebar can be controlled with a function. as long as your not doing some crazy redirect your should be fine already with the search.php file.

    Kadence Themes

    Thread Starter ayush1989

    (@ayush1989)

    Thanks for the response. Yes, you rightly said that I’m modifying search.php. I was trying to align the sidebar to the right and make it static so that if the text of the main para extends upto the sidebar then it doesn’t go down automatically. But I wasn’t able to figure out how to do so. I’ve tried using the css mentioned in my post above to align it to the right, however, when there is some text in the main page it automatically moves down to provide space to the main para. Can you please let me know how the sidebar can be made static like on the other pages?

    Can you post a link? The search page should automatically have a sidebar.

    Are you adding any other custom css? You shouldn’t need to float the sidebar right.

    Kadence Themes

    Thread Starter ayush1989

    (@ayush1989)

    I’m extremely sorry I can’t post a link to it. But I’ve attached the entire code I’m using as search.php below. I’m a newbie at coding so I can’t figure out how to align the sidebar properly. It moves down to accommodate the text when there are no results to show on the search page. I’m using the relevanssi plugin for search:

    <?php
    /**
    * The template for displaying Search Results pages
    *
    * @package WordPress
    */
    ?>

    <html>

    <head>
    <style type=”text/css”>

    .kad-sidebar { float: right; }

    </style>
    </head>

    <body class=”page page-id-20 page-template-default”>

    <?php if ( have_posts() ) : ?>

    <header class=”page-header”>
    <h1 class=”page-title” style=”margin-left: 20px; margin-top: -10px; padding-top: -10px;”><?php printf( __( ‘Search Results for: %s’, ‘Virtue’ ), get_search_query() ); ?></h1>
    <h6 style=”margin-left: 20px; margin-bottom: -6px; padding-bottom: -6px;”><?php echo ‘Search found ‘ . $wp_query->found_posts . ‘ results’; ?><?php if (function_exists(‘relevanssi_didyoumean’)) { relevanssi_didyoumean(get_search_query(), “. Were you searching for: “, “?”, 5); }?></h6>
    </header><!– .page-header –>

    <ul id=”post-list”>

    <?php while (have_posts()) : the_post(); ?>

    <div class=”sresults” style=”margin-bottom: 20px; display: inline;”>
    <div class=”thumbs” style=”float: left; width: 100px; height: 100px; margin: 0 10px 10px 0; “>” title=”<?php the_title(); ?>”><?php echo relevanssi_highlight_terms(get_the_title(), get_search_query()) . get_the_post_thumbnail( $post_id, array(100,100), none ); ?></div>
    </div>

    <?php endwhile; ?>

    <?php else : ?>

    <header class=”page-header”>

    <h1 class=”page-title” style=”margin-left: 20px; margin-top: -10px; padding-top: -10px;”>
    <?php _e( ‘Nothing Found’, ‘nothing’ ); ?>
    </h1>
    <h6 style=”margin-left: 20px; margin-bottom: -14px; padding-bottom: -14px;”>
    <?php if (function_exists(‘relevanssi_didyoumean’)) { relevanssi_didyoumean(get_search_query(), “<p>Did you mean: “, “?</p>”, 5); }?>
    </h6>
    </header>

    <span style=”margin-left: 20px;”>Sorry, nothing matched your search criteria. We have in store what you have in mind! Please try again with some different keywords.</span>

    <?php endif; ?>

    </body>
    </html>

    Thread Starter ayush1989

    (@ayush1989)

    I’m sorry for the direct copy-paste. Here’s the pastebin link: https://pastebin.com/z1qguen4. Thanks!

    Theme Author Ben Ritner – Kadence WP

    (@britner)

    Hey so you shouldn’t be adding things like <html> in your template. Look at the index.php file. That is the template you want to copy from.

    Kadence Themes

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Sidebar alignment in search template’ is closed to new replies.