I have a WordPress blog which is using a 3rd party theme called Alphabet (it's no longer available and seems to have been taken down by the creator: https://themeforest.net/item/alphabet-a-responsive-wordpress-blog-theme/14258651)

There are no pages on this site--just blog posts. The search bar works unless you use it on an actual post page. If you use it there, you get a 404 error no matter your search query. Something seems incorrect with how the search result query is appended to the url.

For example, if you use the search on the home page, the url is set up like this: http://[my-site.com]/?s=test

If you go to a post and use the search there, the url is setup like this: https://[my-site.com]/[sample-post-title]/?s=Culturalism

If I change the url to exclude the post title, then the search query works. I wouldn't be surprised if something is wrong with how this 3rd party theme setup the search as it isn't setup properly by WordPress standards.

Here is the search.php file:

<!-- Start main_content -->
<div class="main_content container">
    <!-- Start posts_sidebar -->
    <div class="posts_sidebar clearfix <?php echo esc_attr($sidebar_position); ?>">

        <!-- Start Sidebar -->
        <?php if (alphabet_get_option('blog_archive_sidebar') == 'Left') {
        } ?>
        <!-- End Sidebar -->

        <!--Start Posts Areaa -->
        <div class="archive_areaa <?php echo esc_attr($fullwidth_position); ?>">
            <div class="row">
                <!-- post_header -->
                <div class="post_header">
                    <h1><?php the_search_query(); ?></h1>
                    <span class="title_divider"></span>
                <!-- // post_header -->

                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <!-- Start as_post -->
                    <article class="as_post">
                        <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
                            <?php $format = get_post_format();
                            if (false === $format) {
                                $format = 'standard';
                            } ?>
                            <?php get_template_part('includes/content', $format); ?>
                    <!-- End as_post -->
                <?php endwhile; ?>

                    <!-- Start pagination_post -->
                    <nav class="pagination_post">
                        <ul class="pager">
                            <li><?php previous_posts_link(); ?></li>
                            <li><?php next_posts_link(); ?></li>
                <?php else : ?>
                    <p><?php esc_html_e('Sorry, no posts matched your criteria.', 'alphabet'); ?></p>
                <?php endif; ?>
                <!-- End pagination_post -->
        <!--End Posts Areaa -->

        <!-- Start Sidebar -->
        <?php if (alphabet_get_option('blog_archive_sidebar') == 'Right') {
        } ?>
        <!-- End Sidebar -->

    <!-- posts_sidebar -->
<!-- main_content -->

And here is the search form's code (located in header1.php -- this theme has multiple header.php files, but this is the one the blog is using):

 <!-- Start top_search_ico -->
   <div id="top_search_ico">
      <!-- Start top_search -->
      <div class="top_search">
        <form method="get"><input type="text" placeholder="<?php esc_html_e( 'Search and hit enter...', 'alphabet' );?>" name="s" id="s"></form>
        <i class="fa fa-search search-desktop"></i>
      <!-- End top_search -->
      <!-- Start top_search_toggle -->
      <div id="top_search_toggle">
        <div id="search_toggle_top">
        <form method="get"><input type="text" placeholder="<?php esc_html_e( 'Search and hit enter...', 'alphabet' );?>" name="s" id="s"></form>
        <i class="fa fa-search search-desktop"></i>
      <!-- End top_search_toggle -->

In case it may be useful, I have the permalinks formatted on the blog as such: https://[my-site.com]/sample-post/

1 Answer 1


Your form doesn't have an action, so it submits to whatever the current URL is. You can point it to home_url() so it will submit there regardless of what page you search from.

<form method="get" action="<?php echo esc_url( home_url() ); ?>">
  • Thanks! I didn't make the form, though -- someone else did. Not surprised it's incorrectly set up, though. This theme has a lot of issues, and unfortunately, it can be changed to something better. Commented May 25, 2017 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.