亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
1. Disable article revision
2. Delete article revisions
3. Delete unnecessary attachments
4. Disable automatic saving
5. Rearrange discontinuous article IDs
Home CMS Tutorial WordPress A brief analysis of how to solve the problem of discontinuous article IDs in WordPress (perfect method)

A brief analysis of how to solve the problem of discontinuous article IDs in WordPress (perfect method)

Mar 15, 2023 pm 08:34 PM
php wordpress

How to solve the problem of discontinuous article IDs in WordPress? The following article will share with you how WordPress can perfectly solve the problem of discontinuous article IDs. I hope it will be helpful to you!

A brief analysis of how to solve the problem of discontinuous article IDs in WordPress (perfect method)

There are many WordPress blogs that use article IDs in their fixed links. However, WordPress has caused the problem of discontinuous article IDs due to various reasons. There are often bloggers in the forum. Ask questions to resolve the issue, but rarely get a satisfactory answer from them.

Today I will tell you how to solve this problem perfectly. To say it is perfect may be a bit too much. Versions after WordPress 3.0 will have an automatic draft, and each article published will occupy two IDs. No. There is currently no way to disable it. Please continue reading to see how to solve the problem of discontinuous article IDs to a certain extent.

Of course, if you do not use post ID in your fixed link, then the post ID is transparent to you and does not matter. Even if the post ID is used in the permalink, if you don't particularly care, even the discontinuity is irrelevant, and this article will not make much sense to you.

1. Disable article revision

The so-called article revision means that every time you modify an article, it will automatically save the article version before modification for you, professional The term is called version control, which ensures that the previous content can be restored in the event of mistaken modification. This is very helpful in maintaining Wiki documents, but as our small blog, it does not seem to be of much use, and this revised version It occupies an ID in the database, which is also one of the problems that causes article IDs to be discontinuous. To disable article revisions, you can add:

define('WP_POST_REVISIONS', false);

to the wp-config.php file. You can also add the following PHP code to functions.php of the current theme:

// 禁用修訂版本,2015年3月5日更新
add_filter( 'wp_revisions_to_keep', 'specs_wp_revisions_to_keep', 10, 2 );
function specs_wp_revisions_to_keep( $num, $post ) {
   if ( 'post_type' == $post->post_type )
      $num = 0;

   return $num;
}

2. Delete article revisions

After disabling article revisions, the previously created article revisions are still saved in the database. These are actually gone. How useful it is, and it occupies the ID, we can delete it. As for how to delete, you can execute the following SQL statement in phpmyadmin (it will affect the top article, use with caution! And make a backup):

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';

3. Delete unnecessary attachments

I believe that many bloggers will upload/insert some attachments at the same time when publishing articles, such as images, videos, music, etc. These attachments can be seen in the WordPress management background - media library, and different media correspond to Different articles. But you should note that these media also occupy the article ID, and they are stored in the same database table wp_posts as the article. If you particularly pursue that the IDs of the articles must be perfectly continuous, please do not upload/insert these media when publishing the article, and please delete the previously uploaded media in the WordPress management background - media library (note that this operation is not just deletion) records, and the files you uploaded will be deleted), please use FTP to re-upload these files if necessary.

4. Disable automatic saving

The advantage of automatic saving is that when you edit an article, the system will automatically save the edited article for you every short period of time. This prevents the webpage from suddenly closing, resulting in the thousands of words written previously being lost. The disadvantage is that each article will have an automatically saved record, which also occupies an article ID, which is one of the reasons why the article IDs are not consecutive. If you do not need this function, you can add the following code to the functions.php of the current theme:

// 禁用自動(dòng)保存,所以編輯長(zhǎng)文章前請(qǐng)注意手動(dòng)保存。
add_action( 'admin_print_scripts', create_function( '$a', "wp_deregister_script('autosave');" ) );

5. Rearrange discontinuous article IDs

Method 1: You can add the following PHP code to functions.php of the current theme , so if you just post an article without posting a page, adding a menu, or uploading media, basically the subsequent article IDs will be continuous, and the IDs of previously published articles will not be changed, and SEO will not be affected:

// WordPress 3.8測(cè)試有效
function keep_id_continuous(){
  global $wpdb;

  // 刪掉自動(dòng)草稿和修訂版
  $wpdb->query("DELETE FROM `$wpdb->posts` WHERE `post_status` = 'auto-draft' OR `post_type` = 'revision'");

  // 自增值小于現(xiàn)有最大ID,MySQL會(huì)自動(dòng)設(shè)置正確的自增值
  $wpdb->query("ALTER TABLE `$wpdb->posts` AUTO_INCREMENT = 1");  
}

add_filter( 'load-post-new.php', 'keep_id_continuous' );
add_filter( 'load-media-new.php', 'keep_id_continuous' );
add_filter( 'load-nav-menus.php', 'keep_id_continuous' );

If you use functions such as pinned articles, menus, and parent-child pages, the following method will not work:

Method 2: Complete the above steps to basically guarantee that articles will be published in the future. The IDs will be continuous, but the IDs of previously published articles are still in chaos. They need to be rearranged to ensure that the IDs are continuous. I wrote a PHP script. You can download it from the following URL. After downloading, open it with a text editor. Modify the database information according to the instructions at the beginning. Then upload the PHP file to your blog space. Run it and see OK. , you can go to phpmyadmin to check whether the IDs in the wp_posts table are consecutive. Again, please back up your database before starting. (If you use post id as a fixed link, it may change the URLs of all articles, which will affect search engine inclusion; if you use a plug-in to create a new database table, such as a voting plug-in, etc., problems will also occur; if A page with a parent-child relationship is created in your blog. If you run the following script, this relationship will be lost. Please use with caution!)

A brief analysis of how to solve the problem of discontinuous article IDs in WordPress (perfect method)

Recommended learning: "

WordPress Tutorial"

The above is the detailed content of A brief analysis of how to solve the problem of discontinuous article IDs in WordPress (perfect method). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
How to use PHP to build social sharing functions PHP sharing interface integration practice How to use PHP to build social sharing functions PHP sharing interface integration practice Jul 25, 2025 pm 08:51 PM

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.

How to use PHP combined with AI to achieve text error correction PHP syntax detection and optimization How to use PHP combined with AI to achieve text error correction PHP syntax detection and optimization Jul 25, 2025 pm 08:57 PM

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

PHP calls AI intelligent voice assistant PHP voice interaction system construction PHP calls AI intelligent voice assistant PHP voice interaction system construction Jul 25, 2025 pm 08:45 PM

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.

PHP creates a blog comment system to monetize PHP comment review and anti-brush strategy PHP creates a blog comment system to monetize PHP comment review and anti-brush strategy Jul 25, 2025 pm 08:27 PM

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 realizes commodity inventory management and monetization PHP inventory synchronization and alarm mechanism PHP realizes commodity inventory management and monetization PHP inventory synchronization and alarm mechanism Jul 25, 2025 pm 08:30 PM

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.

How to use PHP to combine AI to generate image. PHP automatically generates art works How to use PHP to combine AI to generate image. PHP automatically generates art works Jul 25, 2025 pm 07:21 PM

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.

Beyond the LAMP Stack: PHP's Role in Modern Enterprise Architecture Beyond the LAMP Stack: PHP's Role in Modern Enterprise Architecture Jul 27, 2025 am 04:31 AM

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

PHP integrated AI speech recognition and translator PHP meeting record automatic generation solution PHP integrated AI speech recognition and translator PHP meeting record automatic generation solution Jul 25, 2025 pm 07:06 PM

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.

See all articles