wordpress怎么搜 wordpress怎么搜索作者

wordpress 怎么搜索代碼

親,你好,很高興為你回答。

成都創(chuàng)新互聯(lián)公司自2013年起,先為臨沂等服務(wù)建站,臨沂等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為臨沂企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。

首先你要準(zhǔn)備2個(gè)文件

1個(gè)是在wordpress主題下的search.php文件

1個(gè)是檢索頁(yè)面需要放入html代碼。

form action="/" method="get" input name="s" type="text" placeholder="網(wǎng)站檢索" id="s" value="? the_search_query(); ?" / input name="sa" value="檢索" type="image" src="?php bloginfo('template_url'); ?/images/search_icon.gif" align="top" class="btn" / /form

上面這些是放在頁(yè)面的form表單

========================================================================

下面這些是放在search.php里的代碼

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

?php

/**

* The template for displaying all pages.

*

* This is the template that displays all pages by default.

* Please note that this is the WordPress construct of pages

* and that other 'pages' on your WordPress site will use a

* different template.

*

* @package Hotlink

* @subpackage Hotlink Theme

*/

// 検索結(jié)果用

$search_query = new WP_Query("s=$s showposts=-1");

get_header(); ?

section class="main clearfix"

?php if (have_posts()) : while (have_posts()) : the_post(); ?

div id="post-?php the_ID(); ?" class="search_post"

div class="search_title"

a href="?php the_permalink(); ?" title="?php the_title_attribute(); ?" rel="bookmark"

?php the_title(); ?

span class="search_text"?php the_excerpt(); ?/span

/a/div

?php the_date() ? ?php the_time() ?

/div

?php endwhile; else: ?

p class="search_text"

?php _e('您要搜索的內(nèi)容不存在'); ?

/p

?php endif; ?

div class="nav-previous"

?php previous_posts_link(__('? Older Entries', 'kubrick')); ?

/div

div class="nav-next"

?php next_posts_link(__('Newer Entries ?', 'kubrick')); ?

/div

/section

?php get_footer(); ?

如果可以使用,記得采納呦。。有問(wèn)題繼續(xù)追問(wèn)我。

如何搜索 wordpress文章

WordPress 默認(rèn)的搜索功能還真挺弱的,搜索出來(lái)的結(jié)果很不符合人意,如果你想讓它檢索出來(lái)的結(jié)果更加相關(guān),可以限定只搜索文章的標(biāo)題,將下面的代碼添加到主題的 functions.php 文件即可:

/**

* 讓 WordPress 只搜索文章的標(biāo)題

*

*/

function __search_by_title_only( $search, $wp_query )

{

global $wpdb;

if ( empty( $search ) )

return $search; // skip processing - no search term in query

$q = $wp_query-query_vars;

$n = ! empty( $q['exact'] ) ? '' : '%';

$search =

$searchand = '';

foreach ( (array) $q['search_terms'] as $term ) {

$term = esc_sql( like_escape( $term ) );

$search .= "{$searchand}($wpdb-posts.post_title LIKE '{$n}{$term}{$n}')";

$searchand = ' AND ';

}

if ( ! empty( $search ) ) {

$search = " AND ({$search}) ";

if ( ! is_user_logged_in() )

$search .= " AND ($wpdb-posts.post_password = '') ";

}

return $search;

}

add_filter( 'posts_search', '__search_by_title_only', 500, 2 );

wordpress怎么設(shè)置搜索功能

wordpress系統(tǒng)本身是對(duì)搜索引擎友好的,如果網(wǎng)站的內(nèi)容比較私密不希望蜘蛛爬取,可以能過(guò)以下方法實(shí)現(xiàn):

1、進(jìn)入wordpress "設(shè)置" - "閱讀" - 然后勾選“建議搜索引擎不索引本站點(diǎn)”,再點(diǎn)擊 “保存更改”。這樣搜索引擎就不會(huì)收錄和索引網(wǎng)站了。

2、還可以通過(guò)配置“robots.txt”來(lái)告訴搜索引擎,不要收錄/索引網(wǎng)站的內(nèi)容;

步驟:

1),新建一個(gè)文本文檔,重命名為“robots.txt”;

2),在文本文件貼入以下內(nèi)容并保存:

User-agent: * Disallow: / 3),將設(shè)置好的“robots.txt”上傳至網(wǎng)站的根目錄。

網(wǎng)站名稱:wordpress怎么搜 wordpress怎么搜索作者
本文路徑:http://www.bm7419.com/article48/ddoochp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、企業(yè)網(wǎng)站制作、網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、做網(wǎng)站面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化