The meta tags keywords and description provided by the WordPress theme you download are generally poorly made, or not provided at all, which is not conducive to SEO. This article will guide you how to add separate Description and Keywords to the homepage, categories, pages, and article pages.
Many people are using the All in One SEO plug-in to solve this problem, but many people say that this plug-in is not good. At worst, let's implement it ourselves with code.
The editor's code for setting keywords and description is provided below. Add the following code to the WordPress theme header.php between
, and finally save it as UTF-8 encoding, otherwise Chinese characters will be garbled:<?php $description = ''; $keywords = ''; if (is_home() || is_page()) { // 將以下引號中的內(nèi)容改成你的主頁description $description = "露兜博客描述"; // 將以下引號中的內(nèi)容改成你的主頁keywords $keywords = "WordPress, 博客, 編程,php,ludou"; } elseif (is_single()) { $description1 = get_post_meta($post->ID, "description", true); $description2 = str_replace("\n","",mb_strimwidth(strip_tags($post->post_content), 0, 200, "…", 'utf-8')); // 填寫自定義字段description時顯示自定義字段的內(nèi)容,否則使用文章內(nèi)容前200字作為描述 $description = $description1 ? $description1 : $description2; // 填寫自定義字段keywords時顯示自定義字段的內(nèi)容,否則使用文章tags作為關(guān)鍵詞 $keywords = get_post_meta($post->ID, "keywords", true); if($keywords == '') { $tags = wp_get_post_tags($post->ID); foreach ($tags as $tag ) { $keywords = $keywords . $tag->name . ", "; } $keywords = rtrim($keywords, ', '); } } elseif (is_category()) { // 分類的description可以到后臺 - 文章 -分類目錄,修改分類的描述 $description = category_description(); $keywords = single_cat_title('', false); } elseif (is_tag()){ // 標(biāo)簽的description可以到后臺 - 文章 - 標(biāo)簽,修改標(biāo)簽的描述 $description = tag_description(); $keywords = single_tag_title('', false); } $description = trim(strip_tags($description)); $keywords = trim(strip_tags($keywords)); ?> <meta name="description" content="<?php echo $description; ?>" /> <meta name="keywords" content="<?php echo $keywords; ?>" />
When writing blog posts in the future, you only need to add two custom columns (under the article editing page, if not, click Show Options# in the upper right corner) ##), the first custom column name is keywords, and the column value contains the keywords of this article. Then add a second custom column, the name of the custom column is description, and the subsequent column value contains the description of this log. After using a custom column once, you only need to select it in the drop-down box to write a log in the future. In this way, each article has your customized keywords and description, and you can completely abandon the All in One SEO plug-in.
The description and keywords of the home page and page are written directly using PHP code. You can change the description of the Pandan Blog above to your own. The description of the category page and tag page (tag) directly takes the description of the category or tag. This can be changed in the WordPress management background as needed, and keywords takes the name of the category or tag. If you want to manually define description and keywords for each category, you can change lines 27-28 of the code to:if (is_category('音樂')) { $description = '這里填音樂分類的描述'; $keywords = '這里填音樂分類的關(guān)鍵字,半角逗號隔開'; } elseif (is_category('電影')) { $description = '這里填電影分類的描述'; $keywords = '這里填電影分類的關(guān)鍵字,半角逗號隔開'; } elseif (is_category('戲劇')) { $description = '這里填戲劇分類的描述'; $keywords = '這里填戲劇分類的關(guān)鍵字,半角逗號隔開'; } // 多個分類,復(fù)制9-12行代碼,粘貼到13后面行,類似5-12行,改一下分類名稱即可 // 使用UTF-8編碼另存為,替換原來的文件,否則可能會亂碼-- End-- Recommended learning :《
WordPress Tutorial》
The above is the detailed content of WordPress sets independent Description and Keywords. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

The core method of building social sharing functions in PHP is to dynamically generate sharing links that meet the requirements of each platform. 1. First get the current page or specified URL and article information; 2. Use urlencode to encode the parameters; 3. Splice and generate sharing links according to the protocols of each platform; 4. Display links on the front end for users to click and share; 5. Dynamically generate OG tags on the page to optimize sharing content display; 6. Be sure to escape user input to prevent XSS attacks. This method does not require complex authentication, has low maintenance costs, and is suitable for most content sharing needs.

To realize text error correction and syntax optimization with AI, you need to follow the following steps: 1. Select a suitable AI model or API, such as Baidu, Tencent API or open source NLP library; 2. Call the API through PHP's curl or Guzzle and process the return results; 3. Display error correction information in the application and allow users to choose whether to adopt it; 4. Use php-l and PHP_CodeSniffer for syntax detection and code optimization; 5. Continuously collect feedback and update the model or rules to improve the effect. When choosing AIAPI, focus on evaluating accuracy, response speed, price and support for PHP. Code optimization should follow PSR specifications, use cache reasonably, avoid circular queries, review code regularly, and use X

User voice input is captured and sent to the PHP backend through the MediaRecorder API of the front-end JavaScript; 2. PHP saves the audio as a temporary file and calls STTAPI (such as Google or Baidu voice recognition) to convert it into text; 3. PHP sends the text to an AI service (such as OpenAIGPT) to obtain intelligent reply; 4. PHP then calls TTSAPI (such as Baidu or Google voice synthesis) to convert the reply to a voice file; 5. PHP streams the voice file back to the front-end to play, completing interaction. The entire process is dominated by PHP to ensure seamless connection between all links.

1. Maximizing the commercial value of the comment system requires combining native advertising precise delivery, user paid value-added services (such as uploading pictures, top-up comments), influence incentive mechanism based on comment quality, and compliance anonymous data insight monetization; 2. The audit strategy should adopt a combination of pre-audit dynamic keyword filtering and user reporting mechanisms, supplemented by comment quality rating to achieve content hierarchical exposure; 3. Anti-brushing requires the construction of multi-layer defense: reCAPTCHAv3 sensorless verification, Honeypot honeypot field recognition robot, IP and timestamp frequency limit prevents watering, and content pattern recognition marks suspicious comments, and continuously iterate to deal with attacks.

PHP ensures inventory deduction atomicity through database transactions and FORUPDATE row locks to prevent high concurrent overselling; 2. Multi-platform inventory consistency depends on centralized management and event-driven synchronization, combining API/Webhook notifications and message queues to ensure reliable data transmission; 3. The alarm mechanism should set low inventory, zero/negative inventory, unsalable sales, replenishment cycles and abnormal fluctuations strategies in different scenarios, and select DingTalk, SMS or Email Responsible Persons according to the urgency, and the alarm information must be complete and clear to achieve business adaptation and rapid response.

PHP does not directly perform AI image processing, but integrates through APIs, because it is good at web development rather than computing-intensive tasks. API integration can achieve professional division of labor, reduce costs, and improve efficiency; 2. Integrating key technologies include using Guzzle or cURL to send HTTP requests, JSON data encoding and decoding, API key security authentication, asynchronous queue processing time-consuming tasks, robust error handling and retry mechanism, image storage and display; 3. Common challenges include API cost out of control, uncontrollable generation results, poor user experience, security risks and difficult data management. The response strategies are setting user quotas and caches, providing propt guidance and multi-picture selection, asynchronous notifications and progress prompts, key environment variable storage and content audit, and cloud storage.

PHPisstillrelevantinmodernenterpriseenvironments.1.ModernPHP(7.xand8.x)offersperformancegains,stricttyping,JITcompilation,andmodernsyntax,makingitsuitableforlarge-scaleapplications.2.PHPintegrateseffectivelyinhybridarchitectures,servingasanAPIgateway

Select the appropriate AI voice recognition service and integrate PHPSDK; 2. Use PHP to call ffmpeg to convert recordings into API-required formats (such as wav); 3. Upload files to cloud storage and call API asynchronous recognition; 4. Analyze JSON results and organize text using NLP technology; 5. Generate Word or Markdown documents to complete the automation of meeting records. The entire process needs to ensure data encryption, access control and compliance to ensure privacy and security.
