Provide zblog template_zblog them_wordpress template download and customization

Operation method of title, keyword and description of zblogphp homepage, list page and content page

Tianxing Studio 2014-11-26 20:55 course thirteen thousand three hundred and forty-three 8 Comments


There are several plug-ins for zblogphp to set the title, keywords, and descriptions of web pages, some of which are free of charge. You can go to the application center of zblog to find them.

This article is shared with you to solve this problem directly from the code level, and friends with certain foundation can operate it.

The template to be modified is“ header . php ", open this template, and find:

 <title>{$title}-{$name}</title>

Replace with the following code:

 {if $type=='article'}  <title>{$title}_{$article.Category.Name}_{$name}</title>  <meta name="keywords" content="{foreach $article.Tags as $tag}{$tag.Name}{/foreach}" /> <meta name="description" content="{$article. Title} is an article about {foreach $article. Tags as $tag} {$tag. Name} {/foreach} in {$name}. Welcome to read and comment, {$name}"/> {elseif $type=='page'}   <title>{$title}_{$name}</title>   <meta name="keywords" content="{$title},{$name}"/>   {php}     $description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');   {/php}   <meta name="description" content="{$description}"/>   <meta name="author" content="{$article.Author.StaticName}"> {elseif $type=='index'} <title>{$name} {if $page>'1 '}_Page {$pagebar. PageNow} {/if} _ {$subnet}</title> <meta name="Keywords" content="The keywords on the homepage of the website can be modified by yourself"> <meta name="description" content="Modify the description of the homepage of the website"> {elseif $type=='category'} <title>{$title} _ {$name}_Page {$pagebar. PageNow}</title>   <meta name="Keywords" content="{$title},{$name}"> <meta name="description" content="{$title} _ {$name} _ is currently the {$pagebar. PageNow} page"> {else}   <title>{$title}_{$name}</title> {/if}

The above code uses four judgments, respectively corresponding to the content page, single page, list page and home page. You can also modify it according to your own needs, as shown below:

Article: This is the content page;

Page: This is a single page (message book);

Index: This is the home page,

Category: This is the list page

The remaining pages are all behind else.

The effect of this code can be seen in my personal blog: http://www.fengxiaoxi.net/

The disadvantage of this code is that the keywords and descriptions of the list page cannot be defined separately. It is recommended to use it together with plug-ins for better results.


Can't find a tutorial that can solve your problem?

You can try to search or ask questions directly online. We also provide charging technical support. If you need it, you can contact us online.

Online questions Online Service

yes eight Comments from netizens:

  •  PHP Technology Blog

    PHP Technology Blog 8 years ago (2016-10-29) reply

    So your blog is here. ha-ha.

  •  Netizens of Tianxing Studio

    Netizens of Tianxing Studio 8 years ago (2016-05-08) reply

    Yes, I learned.

  •  Sunny Blog

    Sunny Blog Nine years ago (2015-08-22) reply

    Finally, there is a number. What about the number?

  •  Sunny Blog

    Sunny Blog Nine years ago (2015-08-21) reply

    Why is there no TAGS number in my KEY?

    •  Tianxing Studio

      Tianxing Studio Nine years ago (2015-08-21) reply

      Just add a comma after {$tag. Name}, (- __ -)

      •  Little brother

        Little brother Seven years ago (2017-08-04) reply

        After adding a comma, there will be one more comma. For example, if three keywords are cycled three times and one more comma is added each time, it becomes

  •  A rainy night

    A rainy night 10 years ago (2014-11-30) reply

    If you have nothing to do, isn't it good to use custom fields to realize the keywords and other information of each article? But I'm lazy, not every article writes this way, hehe.

    •  Tianxing Studio

      Tianxing Studio 10 years ago (2014-12-01) reply

      It's really easy to be lazy and useless, but you can write a tutorial about it. If you are diligent

welcome you Comment: Cancel Reply

 Please fill in the verification code
  • Latest articles
  • Hot article ranking
  • Most Comments
Label aggregation