Set the default content in the WordPress article editor. wordpress editor _ PHP Tutorial

Source: Internet
Author: User
Set the default content in the WordPress article editor. You can set the default content in the WordPress article editor. In most cases, you need to set the default content for the wordpress article editor, for example, you can set the default content in the WordPress article editor by setting a common start.

In many cases, we need to set the default content for the WordPress article editor. for example, we need to put the common start or article precautions. 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 'The default content to be set';} add_filter ('default _ content ', 'bing _ default_content ');

You can also set the default title:


/*** WordPress sets the default title * 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, open the publishing page, which is like this by default:

However, if a website has many custom document types, what should I do if I want to set the default content for each document type?

In fact, you only need to make a simple judgment and then return the results respectively:

/*** WordPress custom document types: set the default content for the editor * http://www.endskin.com/post-default-content-title/*/function Bing_default_content ($ content, $ post) {switch ($ post-> post_type) {case 'Post ': $ content = 'default document content'; break; case 'page': $ content = 'default page content'; break; case 'Pic ': $ content = 'default content of an image (custom article type) '; break;} return $ content;} add_filter ('default _ content', 'Bing _ default_content ', 10, 2 );

The default title is similar. you only need to replace the default_content hook with default_title.

Articles you may be interested in:
  • Tips for customizing the background management interface color scheme in WordPress
  • Implement function parsing for sending http requests in WordPress
  • PHP functions used to create and retrieve sidebar in WordPress
  • How to add and execute actions in WordPress

In most cases, we need to set the default content for the WordPress article editor, for example, to set the common beginning...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.