Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the default content in the WordPress article editor

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report