Documentation

Graphic_Data_About
in package

Register class that defines the About custom content post type as well as associated functions.

Table of Contents

Methods

check_existing_about_posts()  : int
Counts existing About posts across all post statuses.
create_about_fields()  : mixed
Create custom fields, using metaboxes, for About custom content type.
custom_about_permalink()  : string
Modifies the permalink structure for About post type.
custom_content_type_about()  : mixed
Create About custom content type.
display_about_limit_notice()  : void
Displays an admin notice when About page creation limit is reached.
handle_about_template()  : void
Handles template loading for the About page at the /about URL.
modify_about_add_new_button()  : void
Hides the "Add New" button when an About post already exists.
prevent_multiple_about_posts()  : array<string|int, mixed>
Prevents creation of multiple About posts.

Methods

check_existing_about_posts()

Counts existing About posts across all post statuses.

public check_existing_about_posts() : int

Queries the database for all About custom post type entries regardless of their status (publish, draft, pending, private, future, or trash). Used to enforce the single About page limitation.

Tags
since
1.0.0
Return values
int

The total number of existing About posts.

create_about_fields()

Create custom fields, using metaboxes, for About custom content type.

public create_about_fields([bool $return_fields_only = false ]) : mixed
Parameters
$return_fields_only : bool = false

If true, only return the custom fields array without registering the metabox (used as part of field validation).

Tags
since
1.0.0

Modifies the permalink structure for About post type.

public custom_about_permalink(string $post_link, WP_Post $post) : string

Filter callback for 'post_type_link' that changes the permalink for About posts to use a clean /about URL instead of the default custom post type permalink structure.

Parameters
$post_link : string

The post's permalink.

$post : WP_Post

The post object.

Tags
since
1.0.0
Return values
string

Modified permalink (/about) for About posts, original permalink otherwise.

custom_content_type_about()

Create About custom content type.

public custom_content_type_about() : mixed
Tags
since
1.0.0

display_about_limit_notice()

Displays an admin notice when About page creation limit is reached.

public display_about_limit_notice() : void

Shows a dismissible error notice in the WordPress admin when a user attempts to create a second About page. The notice is triggered by the 'about_limit_reached' query parameter in the URL.

Tags
since
1.0.0

handle_about_template()

Handles template loading for the About page at the /about URL.

public handle_about_template() : void

Intercepts requests to the /about URL and manually sets up the WordPress query to display the About custom post type using single-about.php template. Configures global query variables, prevents 404 status, and loads the appropriate template file before exiting.

Tags
since
1.0.0
global

WP_Query $wp_query WordPress Query object.

global

WP_Post $post Current post object.

Return values
void

Exits after loading template if on /about URL with published post.

modify_about_add_new_button()

Hides the "Add New" button when an About post already exists.

public modify_about_add_new_button() : void

Outputs inline CSS to hide the page title action button on the About post type admin screens when at least one About post exists. This provides a visual enforcement of the single About page limitation.

Tags
since
1.0.0
global

WP_Screen $current_screen WordPress current screen object.

prevent_multiple_about_posts()

Prevents creation of multiple About posts.

public prevent_multiple_about_posts(array<string|int, mixed> $data, array<string|int, mixed> $postarr) : array<string|int, mixed>

Filter callback for 'wp_insert_post_data' that enforces a single About page limitation. Allows updates to existing About posts but blocks creation of new ones if an About post already exists. Redirects to the About posts list with an error notification when blocked.

Parameters
$data : array<string|int, mixed>

An array of slashed, sanitized, and processed post data.

$postarr : array<string|int, mixed>

An array of sanitized (and slashed) but otherwise unmodified post data.

Tags
since
1.0.0
Return values
array<string|int, mixed>

The unmodified post data if allowed, or redirects and exits if blocked.


        
On this page

Search results