搜索栏重复(wordpress / php / bootstrap) [英] Search bar in duplicate (wordpress/php/bootstrap)
本文介绍了搜索栏重复(wordpress / php / bootstrap)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怀疑我有一个双功能命令某处...但我找不到它。有人可以用新鲜的眼睛看代码,试着找到我的错误吗?
作为wordpress不断给我2个搜索栏而不是一个
我正在使用记事本++,Bootstrap v 3.0和Wordpress 4.7.8
这是代码
<?php get_header(); ?>
< div class =row>
< div class =col-xs-12 col-sm-8>
< div class =row text-center no-margin>
<?php
$ currentPage =(get_query_var('paged'))? get_query_var('paged'):1;
$ args = array('posts_per_page'=> 3,'post_type'=>'post','paged'=> $ currentPage);
new WP_Query($ args);
if(have_posts()):$ i = 0;
while(have_posts()):the_post(); ?>
<?php
if($ i == 0):$ column = 12; $ class ='';
elseif($ i> 0&& $ i< = 2):$ column = 6; $ class ='second-row-padding';
elseif($ i> 2):$ column = 4; $ class ='third-row-padding';
endif;
?>
<?php the_content(); ?>
< div class =col-xs-<?php echo $ column; echo $ class;?> blog-item>
<?php if(has_post_thumbnail()):
$ urlImg = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID()));
endif; ?>
< div class =blog-elementstyle =background-image:url(<?php echo $ urlImg;?>);>
<! - <?php the_title(sprintf('< h1 class =entry-title>< a href =%s>',esc_url(get_permalink ())),'< / a>< / h1>'); ?> - >
< h1 class =entry-title><?php the_title(); ?>< / H1>
< small><?php the_category(''); ?>< /小>
< / div>
< / div>
<?php $ i ++; ENDWHILE; ?>
< div class =col-xs-6 text-left>
<?php next_posts_link('«较旧的帖子'); ?>
< / div>
< div class =col-xs-6 text-right>
<?php previous_posts_link('较新的帖子»'); ?>
< / div>
<?php endif;
wp_reset_query();
?>
< / div>
< / div>
< div class =col-xs-12 col-sm-4>
<?php get_sidebar(); ?>
< / div>
< / div>
<?php get_footer(); ?>
解决方案
尝试此代码
我已经禁用了 // get_sidebar();
code><?php get_header(); ?>
< div class =row>
< div class =col-xs-12 col-sm-8>
< div class =row text-center no-margin>
<?php
$ currentPage =(get_query_var('paged'))? get_query_var('paged'):1;
$ args = array('posts_per_page'=> 3,'post_type'=>'post','paged'=> $ currentPage);
new WP_Query($ args);
if(have_posts()):$ i = 0;
while(have_posts()):the_post(); ?>
<?php
if($ i == 0):$ column = 12; $ class ='';
elseif($ i> 0&& $ i< = 2):$ column = 6; $ class ='second-row-padding';
elseif($ i> 2):$ column = 4; $ class ='third-row-padding';
endif;
?>
< div class =col-xs-<?php echo $ column; echo $ class;?> blog-item>
<?php if(has_post_thumbnail()):
$ urlImg = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID()));
endif; ?>
< div class =blog-elementstyle =background-image:url(<?php echo $ urlImg;?>);>
<! - <?php the_title(sprintf('< h1 class =entry-title>< a href =%s>',esc_url(get_permalink ())),'< / a>< / h1>'); ?> - >
< h1 class =entry-title><?php the_title(); ?>< / H1>
<?php the_content(); ?>
< small><?php the_category(''); ?>< /小>
< / div>
< / div>
<?php $ i ++; ENDWHILE; ?>
< div class =col-xs-6 text-left>
<?php next_posts_link('«较旧的帖子'); ?>
< / div>
< div class =col-xs-6 text-right>
<?php previous_posts_link('较新的帖子»'); ?>
< / div>
<?php endif;
wp_reset_query();
?>
< / div>
< / div>
< div class =col-xs-12 col-sm-4>
<?php // get_sidebar(); ?>
< / div>
< / div>
due to some reason I'm getting the search bar in duplicate. I suspect I have a double function command somewhere...but I can not find it. Can someone look at the code with "fresh eyes" and try to find my mistake? as wordpress keeps giving me 2 search bars instead of one I am using Notepad++, Bootstrap v 3.0 and Wordpress 4.7.8
Here is the code
<?php get_header(); ?>
<div class="row">
<div class="col-xs-12 col-sm-8">
<div class="row text-center no-margin">
<?php
$currentPage = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 3,'post_type'=>'post', 'paged' => $currentPage);
new WP_Query($args);
if( have_posts() ): $i = 0;
while( have_posts() ): the_post(); ?>
<?php
if($i==0): $column = 12; $class = '';
elseif($i > 0 && $i <= 2): $column = 6; $class = ' second-row-padding';
elseif($i > 2): $column = 4; $class = ' third-row-padding';
endif;
?>
<?php the_content(); ?>
<div class="col-xs-<?php echo $column; echo $class; ?> blog-item">
<?php if( has_post_thumbnail() ):
$urlImg = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
endif; ?>
<div class="blog-element" style="background-image: url(<?php echo $urlImg; ?>);">
<!--<?php the_title( sprintf('<h1 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ),'</a></h1>' ); ?> -->
<h1 class="entry-title"><?php the_title(); ?></h1>
<small><?php the_category(' '); ?></small>
</div>
</div>
<?php $i++; endwhile; ?>
<div class="col-xs-6 text-left">
<?php next_posts_link('« Older Posts'); ?>
</div>
<div class="col-xs-6 text-right">
<?php previous_posts_link('Newer Posts »'); ?>
</div>
<?php endif;
wp_reset_query();
?>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>
解决方案
Try this code.
I have disabled the //get_sidebar();
<?php get_header(); ?>
<div class="row">
<div class="col-xs-12 col-sm-8">
<div class="row text-center no-margin">
<?php
$currentPage = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 3,'post_type'=>'post', 'paged' => $currentPage);
new WP_Query($args);
if( have_posts() ): $i = 0;
while( have_posts() ): the_post(); ?>
<?php
if($i==0): $column = 12; $class = '';
elseif($i > 0 && $i <= 2): $column = 6; $class = ' second-row-padding';
elseif($i > 2): $column = 4; $class = ' third-row-padding';
endif;
?>
<div class="col-xs-<?php echo $column; echo $class; ?> blog-item">
<?php if( has_post_thumbnail() ):
$urlImg = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
endif; ?>
<div class="blog-element" style="background-image: url(<?php echo $urlImg; ?>);">
<!--<?php the_title( sprintf('<h1 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ),'</a></h1>' ); ?> -->
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php the_content(); ?>
<small><?php the_category(' '); ?></small>
</div>
</div>
<?php $i++; endwhile; ?>
<div class="col-xs-6 text-left">
<?php next_posts_link('« Older Posts'); ?>
</div>
<div class="col-xs-6 text-right">
<?php previous_posts_link('Newer Posts »'); ?>
</div>
<?php endif;
wp_reset_query();
?>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<?php //get_sidebar(); ?>
</div>
</div>
这篇关于搜索栏重复(wordpress / php / bootstrap)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文