- 17, Feb 2015
- #1
Проблема такая:
в поле поиска фраза на английском языке,хочу убрать.
Искала как это сделать,нашла что надо изменить : widgets.php в своей теме. который можно найти : /wp-content/themes/название темы//lib /wp-content/themes/название темы/includes/widgets Поменять: Для widgets.php строку
Сайт.
<?php
/**
* Custom Widgets for this theme.
*
* @package Preus
*/
class preus_Recent_Posts extends WP_Widget {
public function __construct() {
parent::__construct(
'preus_rp', // Base ID
__('Preus Recent Posts', 'preus'), // Name
array( 'description' => __( 'Display your recent posts, with a Thumbnail.', 'preus' ), ) // Args
);
}
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
$no_of_posts = apply_filters( 'no_of_posts', $instance['no_of_posts'] );
echo $args['before_widget'];
if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title'];
// WP_Query arguments
$qa = array (
'post_type' => 'post',
'posts_per_page' => $no_of_posts,
'offset' => 0,
'ignore_sticky_posts' => 1
);
// The Query
$recent_articles = new WP_Query( $qa );
if($recent_articles->have_posts()) : ?>
<ul class="rp">
<?php
while($recent_articles->have_posts()) :
$recent_articles->the_post();
?>
<li class='rp-item'>
<?php if( has_post_thumbnail() ) : ?>
<div class='rp-thumb'><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a></div>
<?php
else :
?>
<div class='rp-thumb'><a href="<?php the_permalink(); ?>"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/nthumb.png"></a></div>
<?php
endif; ?>
<div class='rp-title'><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div class="rp-date"><?php the_time('M j, Y'); ?></div>
</li>
<?php
endwhile;
wp_reset_postdata();
else:
?>
Oops, there are no posts.
<?php
endif;
?>
</ul>
<?php
echo $args['after_widget'];
}
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'Latest Articles', 'preus' );
}
if ( isset( $instance[ 'no_of_posts' ] ) ) {
$no_of_posts = $instance[ 'no_of_posts' ];
}
else {
$no_of_posts = __( '5', 'preus' );
}
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:','preus' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
<label for="<?php echo $this->get_field_id( 'no_of_posts' ); ?>"><?php _e( 'No. of Posts:', 'preus' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'no_of_posts' ); ?>" name="<?php echo $this->get_field_name( 'no_of_posts' ); ?>" type="text" value="<?php echo esc_attr( $no_of_posts ); ?>" />
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
$instance['no_of_posts'] = ( ! empty( $new_instance['no_of_posts'] ) ) ? strip_tags( $new_instance['no_of_posts'] ) : '5';
if ( is_numeric($new_instance['no_of_posts']) == false ) {
$instance['no_of_posts'] = $old_instance['no_of_posts'];
}
return $instance;
}
}
add_action( 'widgets_init', 'register_preus_widget' );
function register_preus_widget() {
register_widget( 'Preus_Recent_Posts' );
}
Вопрос решила. Форма поиска (searchform.php)
Но осталась одна проблемка. Результат поска пишет: Search Results for
Искала как это сделать,нашла что надо изменить : widgets.php в своей теме. который можно найти : /wp-content/themes/название темы//lib /wp-content/themes/название темы/includes/widgets Поменять: Для widgets.php строку
$field_value = apply_filters(‘thesis_search_form_value’, __(‘To search, type and hit enter’, ‘название_темы’))
нужно поменять на
$field_value = apply_filters(‘thesis_search_form_value’, __(Найти ‘название_темы’))
Для widget-search.php строку
<input type=»text» id=»s» name=»s» value=»<?php _e( ‘to search type and hit enter’ , ‘tie’ ) ?>» onfocus=»if (this.value == ‘<?php _e( ‘to search type and hit enter’ , ‘tie’ ) ?>’) {this.value = »;}» onblur=»if (this.value == ») {this.value = ‘<?php _e( ‘to search type and hit enter’ , ‘tie’ ) ?>';}» />
Меняем на
<input type=»text» id=»s» name=»s» value=»<?php _e( ‘Найти’ , ‘tie’ ) ?>» onfocus=»if (this.value == ‘<?php _e( ‘Найти’ , ‘tie’ ) ?>’) {this.value = »;}» onblur=»if (this.value == ») {this.value = ‘<?php _e( ‘to search type and hit enter’ , ‘tie’ ) ?>';}» />
Но у себя я такой фразы не нашла!
Сайт.
<?php
/**
* Custom Widgets for this theme.
*
* @package Preus
*/
class preus_Recent_Posts extends WP_Widget {
public function __construct() {
parent::__construct(
'preus_rp', // Base ID
__('Preus Recent Posts', 'preus'), // Name
array( 'description' => __( 'Display your recent posts, with a Thumbnail.', 'preus' ), ) // Args
);
}
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
$no_of_posts = apply_filters( 'no_of_posts', $instance['no_of_posts'] );
echo $args['before_widget'];
if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title'];
// WP_Query arguments
$qa = array (
'post_type' => 'post',
'posts_per_page' => $no_of_posts,
'offset' => 0,
'ignore_sticky_posts' => 1
);
// The Query
$recent_articles = new WP_Query( $qa );
if($recent_articles->have_posts()) : ?>
<ul class="rp">
<?php
while($recent_articles->have_posts()) :
$recent_articles->the_post();
?>
<li class='rp-item'>
<?php if( has_post_thumbnail() ) : ?>
<div class='rp-thumb'><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a></div>
<?php
else :
?>
<div class='rp-thumb'><a href="<?php the_permalink(); ?>"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/nthumb.png"></a></div>
<?php
endif; ?>
<div class='rp-title'><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div class="rp-date"><?php the_time('M j, Y'); ?></div>
</li>
<?php
endwhile;
wp_reset_postdata();
else:
?>
Oops, there are no posts.
<?php
endif;
?>
</ul>
<?php
echo $args['after_widget'];
}
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'Latest Articles', 'preus' );
}
if ( isset( $instance[ 'no_of_posts' ] ) ) {
$no_of_posts = $instance[ 'no_of_posts' ];
}
else {
$no_of_posts = __( '5', 'preus' );
}
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:','preus' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
<label for="<?php echo $this->get_field_id( 'no_of_posts' ); ?>"><?php _e( 'No. of Posts:', 'preus' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'no_of_posts' ); ?>" name="<?php echo $this->get_field_name( 'no_of_posts' ); ?>" type="text" value="<?php echo esc_attr( $no_of_posts ); ?>" />
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
$instance['no_of_posts'] = ( ! empty( $new_instance['no_of_posts'] ) ) ? strip_tags( $new_instance['no_of_posts'] ) : '5';
if ( is_numeric($new_instance['no_of_posts']) == false ) {
$instance['no_of_posts'] = $old_instance['no_of_posts'];
}
return $instance;
}
}
add_action( 'widgets_init', 'register_preus_widget' );
function register_preus_widget() {
register_widget( 'Preus_Recent_Posts' );
}
Вопрос решила. Форма поиска (searchform.php)
<?php
/**
* The template for displaying search forms in Preus
*
* @package Preus
*/
?>
<form role="search" method="get" class="row search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<button type="submit" class="btn btn-default search-submit"><i class="fa fa-search"> </i></button>
<label>
<span class="screen-reader-text"><?php _ex( 'Search for:', 'label', 'preus' ); ?></span>
<input type="text" class="search-field" placeholder="<?php echo esc_attr_e( 'Поиск...', 'preus' ); ?>" value="<?php echo esc_attr( get_search_query() ); ?>" name="s">
</label>
</form>
/**
* The template for displaying search forms in Preus
*
* @package Preus
*/
?>
<form role="search" method="get" class="row search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<button type="submit" class="btn btn-default search-submit"><i class="fa fa-search"> </i></button>
<label>
<span class="screen-reader-text"><?php _ex( 'Search for:', 'label', 'preus' ); ?></span>
<input type="text" class="search-field" placeholder="<?php echo esc_attr_e( 'Поиск...', 'preus' ); ?>" value="<?php echo esc_attr( get_search_query() ); ?>" name="s">
</label>
</form>
Но осталась одна проблемка. Результат поска пишет: Search Results for