Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set the default content in the WordPress article editor

Shulou Source: shulou.com Published: 2022-06-03 11:07:17 09月22日 Update

This article will explain in detail how to set the default content in the WordPress article editor. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Many times we need to set the default content for the WordPress article editor, such as putting the commonly used beginning or article notes into it. This article will teach you to set the default content for the WordPress editor.

/ * WordPress sets the default content for the article editor * http://www.endskin.com/default-content-title/*/function Bing_default_content () {return 'default content to be set';} add_filter ('default_content',' Bing_default_content')

You can also set the default title:

/ * WordPress sets the default title for the article editor * http://www.endskin.com/default-content-title/*/function Bing_default_title () {return 'default title to be set';} add_filter ('default_title',' Bing_default_title')

After adding the above two pieces of code to open the publish article interface, the default is like this:

But what if the site has many custom article types and each article type wants to set the default content separately?

In fact, you just need to make a simple judgment and return separately:

/ * * WordPress custom article type sets the default content for the editor respectively * http://www.endskin.com/post-default-content-title/*/function Bing_default_content ($content, $post) {switch ($post- > post_type) {case 'post': $content =' default content of the article'; break; case 'page': $content =' default content of the page'; break Case 'pic': $content =' default content for pictures (custom article type)'; break;} return $content;} add_filter ('default_content',' Bing_default_content', 10,2)

The default title is similar, just replace the default_content hook with default_title.

On "how to set the default content in the WordPress article editor" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: Article content editor title type article more good practical above item code picture that is commonly used beginning how to do time matters needing attention interface Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi Shulou Technology Shulou Tech Info Redmi