WordPress建站技巧:搜索结果页面中不同分类里的文章做不同处理

前端之家收集整理的这篇文章主要介绍了WordPress建站技巧:搜索结果页面中不同分类里的文章做不同处理前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

站长朋友们在使用wordpress建站的过程中,往往会在网站中加入搜索功能wordpress默认的搜索结果页面中,是将所有搜索的结果以列表的形式展现出来。当我们想对不同分类下的文章做不同处理时,需要对的搜索结果页面做相应的修改。这篇文章中我们就来介绍一下修改方法

切换到主题目录,打开search.PHP文件,在循环体中加入以下代码

Crayon-5c891cf81c5bb841957500" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">search.PHP
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-mixed-highlight" title="Contains Mixed Languages">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-language">PHP
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-1">1
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-2">2
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-3">3
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-4">4
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-5">5
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-6">6
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-7">7
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-8">8
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-9">9
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-10">10
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-11">11
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-12">12
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-13">13
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-14">14
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-15">15
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-16">16
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-17">17
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-18">18
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-19">19
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-20">20
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-21">21
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-22">22
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-23">23
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-24">24
Crayon-num" data-line="Crayon-5c891cf81c5bb841957500-25">25
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cf81c5bb841957500-26">26
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891cf81c5bb841957500-1">Crayon-o"><Crayon-e">div Crayon-t">classCrayon-o">=Crayon-s">"list-searches"
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-2">Crayon-h"> Crayon-ta">PHPCrayon-h">
Crayon-line" id="Crayon-5c891cf81c5bb841957500-3">Crayon-h"> Crayon-st">ifCrayon-h"> Crayon-sy">(Crayon-e">have_postsCrayon-sy">(Crayon-sy">)Crayon-sy">)Crayon-h"> Crayon-o">:Crayon-h">
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-4">Crayon-h"> Crayon-st">whileCrayon-h"> Crayon-sy">(Crayon-e">have_postsCrayon-sy">(Crayon-sy">)Crayon-sy">)Crayon-h"> Crayon-o">:Crayon-h"> Crayon-e">the_postCrayon-sy">(Crayon-sy">)Crayon-sy">;
Crayon-line" id="Crayon-5c891cf81c5bb841957500-5">Crayon-h">
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-6">Crayon-h"> Crayon-o"><Crayon-e">div Crayon-t">classCrayon-o">=Crayon-s">"one-search"
Crayon-line" id="Crayon-5c891cf81c5bb841957500-7">Crayon-h"> Crayon-ta">PHPCrayon-h">
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-8">Crayon-h"> Crayon-st">ifCrayon-sy">(Crayon-e">in_categoryCrayon-sy">(Crayon-t">arrayCrayon-sy">(Crayon-cn">4Crayon-sy">)Crayon-sy">)Crayon-sy">)Crayon-sy">{
Crayon-line" id="Crayon-5c891cf81c5bb841957500-9">Crayon-h"> Crayon-st">DOCrayon-sy">.Crayon-cn">SOMETINGCrayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-10">Crayon-h"> Crayon-sy">}Crayon-st">elseCrayon-sy">{
Crayon-line" id="Crayon-5c891cf81c5bb841957500-11">Crayon-h"> Crayon-st">DOCrayon-sy">.Crayon-cn">SOMETINGCrayon-sy">.Crayon-st">ELSECrayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-12">Crayon-h"> Crayon-sy">}
Crayon-line" id="Crayon-5c891cf81c5bb841957500-13">Crayon-h"> Crayon-h">
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-14">Crayon-h"> Crayon-o"><Crayon-o">/Crayon-i">divCrayon-o"><Crayon-o">!Crayon-o">--Crayon-sy">.Crayon-i">oneCrayon-o">-Crayon-e">searchCrayon-o">--
Crayon-line" id="Crayon-5c891cf81c5bb841957500-15">Crayon-h"> Crayon-ta">PHPCrayon-h"> Crayon-st">endwhileCrayon-sy">;Crayon-h"> Crayon-st">elseCrayon-o">:Crayon-h">
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-16">Crayon-h"> Crayon-o"><Crayon-e">div Crayon-t">classCrayon-o">=Crayon-s">"no-results"
Crayon-line" id="Crayon-5c891cf81c5bb841957500-17">Crayon-h"> Crayon-o"><Crayon-e">pCrayon-o"><Crayon-e">strongCrayon-ta">PHPCrayon-h"> Crayon-e">_eCrayon-sy">(Crayon-s">'Error!'Crayon-sy">)Crayon-sy">;Crayon-h"> Crayon-o"><Crayon-o">/Crayon-e">strongCrayon-o"><Crayon-o">/Crayon-e">p
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-18">Crayon-h"> Crayon-o"><Crayon-e">p
Crayon-line" id="Crayon-5c891cf81c5bb841957500-19">Crayon-h"> Crayon-ta">PHPCrayon-h">
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-20">Crayon-h"> Crayon-e">_eCrayon-sy">(Crayon-s">'很抱歉,没找到您想要的内容。'Crayon-sy">)Crayon-sy">;Crayon-h">
Crayon-line" id="Crayon-5c891cf81c5bb841957500-21">Crayon-h">
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-22">Crayon-h"> Crayon-o"><Crayon-o">/Crayon-i">p
Crayon-line" id="Crayon-5c891cf81c5bb841957500-23">Crayon-h"> Crayon-o"><Crayon-o">/Crayon-i">divCrayon-o"><Crayon-o">!Crayon-o">--Crayon-sy">.Crayon-i">noCrayon-o">-Crayon-e">resultsCrayon-o">--
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-24">Crayon-h"> Crayon-ta">PHPCrayon-h"> Crayon-st">endifCrayon-sy">;Crayon-h">
Crayon-line" id="Crayon-5c891cf81c5bb841957500-25">Crayon-h"> Crayon-o"><Crayon-e">div Crayon-t">classCrayon-o">=Crayon-s">"clr"Crayon-o"><Crayon-o">/Crayon-i">div
Crayon-line Crayon-striped-line" id="Crayon-5c891cf81c5bb841957500-26">Crayon-o"><Crayon-o">/Crayon-i">divCrayon-o"><Crayon-o">!Crayon-o">--Crayon-sy">.Crayon-k ">listCrayon-o">-Crayon-i">searchesCrayon-o">--

猜你在找的wordpress相关文章