<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
title="Valid Post Type Slug"
>
<standard>
<![CDATA[
The post type slug used in register_post_type() must be between 1 and 20 characters.
]]>
</standard>
<code_comparison>
<code title="Valid: short post type slug.">
<![CDATA[
register_post_type(
<em>'my_short_slug'</em>,
array()
);
]]>
</code>
<code title="Invalid: too long post type slug.">
<![CDATA[
register_post_type(
<em>'my_own_post_type_too_long'</em>,
array()
);
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
The post type slug used in register_post_type() can only contain lowercase alphanumeric characters, dashes and underscores.
]]>
</standard>
<code_comparison>
<code title="Valid: no special characters in post type slug.">
<![CDATA[
register_post_type(
<em>'my_post_type_slug'</em>,
array()
);
]]>
</code>
<code title="Invalid: invalid characters in post type slug.">
<![CDATA[
register_post_type(
<em>'my/post/type/slug'</em>,
array()
);
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
One should be careful with passing dynamic slug names to "register_post_type()", as the slug may become too long and could contain invalid characters.
]]>
</standard>
<code_comparison>
<code title="Valid: static post type slug.">
<![CDATA[
register_post_type(
<em>'my_post_active'</em>,
array()
);
]]>
</code>
<code title="Invalid: dynamic post type slug.">
<![CDATA[
register_post_type(
<em>"my_post_{$status}"</em>,
array()
);
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
The post type slug used in register_post_type() can not use reserved keywords, such as the ones used by WordPress itself.
]]>
</standard>
<code_comparison>
<code title="Valid: prefixed post slug.">
<![CDATA[
register_post_type(
<em>'prefixed_author'</em>,
array()
);
]]>
</code>
<code title="Invalid: using a reserved keyword as slug.">
<![CDATA[
register_post_type(
<em>'author'</em>,
array()
);
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
The post type slug used in register_post_type() can not use reserved prefixes, such as 'wp_', which is used by WordPress itself.
]]>
</standard>
<code_comparison>
<code title="Valid: custom prefix post slug.">
<![CDATA[
register_post_type(
<em>'prefixed_author'</em>,
array()
);
]]>
</code>
<code title="Invalid: using a reserved prefix.">
<![CDATA[
register_post_type(
<em>'wp_author'</em>,
array()
);
]]>
</code>
</code_comparison>
</documentation>
|