admin管理员组文章数量:1315827
Generally,
We put <?php get_search_form(); ?>
in the header where we desire the search form, and then later we put the custom code for HTML in searchform.php.
This is the whole HTML from where I am trying to create an HTML template.
This is the Portion of an HTML
<li><input class="search" type="search" placeholder="Search"></li>
that was supposed to be converted into an working wordpress search.
However, I put this whole form modified a little bit with my CSS's classes →
<form action="/" method="get">
<li>
<input class="search" type="search" placeholder="Search" type="text" name="s" id="search" value="<?php the_search_query(); ?>">
</li>
</form>
THE PROBLEM → Misleading search URL. Suppose my search string is "ok"
The search URL anticipated to be generated is →
right but it generates →
wrong.
Live WP Site here.
Generally,
We put <?php get_search_form(); ?>
in the header where we desire the search form, and then later we put the custom code for HTML in searchform.php.
This is the whole HTML from where I am trying to create an HTML template.
This is the Portion of an HTML
<li><input class="search" type="search" placeholder="Search"></li>
that was supposed to be converted into an working wordpress search.
However, I put this whole form modified a little bit with my CSS's classes →
<form action="/" method="get">
<li>
<input class="search" type="search" placeholder="Search" type="text" name="s" id="search" value="<?php the_search_query(); ?>">
</li>
</form>
THE PROBLEM → Misleading search URL. Suppose my search string is "ok"
The search URL anticipated to be generated is →
right but it generates →
wrong.
Live WP Site here.
Share Improve this question edited Apr 19, 2017 at 10:43 WordCent asked Apr 19, 2017 at 9:39 WordCentWordCent 1,8776 gold badges34 silver badges60 bronze badges 4 |2 Answers
Reset to default 1Below you can find a template for displaying Search Results pages. Add the code to your search.php file. If you have installed the WP-PageNavi plugin then you'll see the pagination if the search result has more than 10 items.
<?php
/**
* The template for displaying Search Results pages.
*/
get_header();
?>
<h2><?php printf( __( 'Search Results for: %s', 'themedomain' ), '<strong>"' . get_search_query() . '"</strong>' ); ?></h2>
<div class="posts">
<?php
global $paged;
$s = $_GET['s'];
$post_types = array('post', 'page');
$args=array(
'post_type' => $post_types,
'post_status' => 'publish',
's' => $s,
'orderby' => 'date',
'order' => 'desc',
'posts_per_page' => 10,
'paged' => $paged
);
$wp_query = new WP_Query($args);
if ($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post();
?>
<!-- post-box -->
<article class="post-box">
<div class="meta">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php _e('Posted by','themedomain');?> <?php if (!get_the_author_meta('first_name') && !get_the_author_meta('last_name')) { the_author_posts_link(); } else { echo '<a href="'.get_author_posts_url(get_the_author_meta('ID')).'">'.get_the_author_meta('first_name').' '.get_the_author_meta('last_name').'</a>'; } ?> <?php _e('· on','themedomain');?> <?php echo get_the_time('F d, Y'); ?> <?php _e('· in','themedomain');?> <?php the_category(', ') ?> <?php _e('· with','themedomain');?> <?php comments_popup_link(__('0 Comments', 'themedomain'),__('1 Comment', 'themedomain'), __('% Comments', 'themedomain')); ?></p>
</div>
<?php the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>"><?php _e('Continue Reading →','themedomain'); ?></a></p>
</article>
<?php
endwhile;
endif;
?>
</div>
<!-- paging -->
<div class="paging">
<ul>
<?php
if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
?>
</ul>
</div>
<?php get_footer(); ?>
Try this form based on your code:
<form action="<?php echo esc_url(home_url()); ?>" method="get"> <li> <input class="search" type="text" name="s" id="s" placeholder="Search" value="<?php the_search_query(); ?>"> </li> </form>
本文标签: Wordpress Search Form IssueMisleading search URLPointing to wrong URL
版权声明:本文标题:Wordpress Search Form Issue | Misleading search URL. | Pointing to wrong URL 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741986373a2408703.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
action="/"
toaction="<?php echo esc_url( home_url( '/' ) ); ?>"
? WordPress seems to not be actually installed in site01? Make sure the settings are correct in wp-admin – Jebble Commented Apr 19, 2017 at 10:12