porterwp
  • Welcome
  • Quick Start
    • Create your first site
      • Getting started
    • FAQs
  • Config
    • porter.json
      • Theme Support
      • Admin
      • Public
      • Full porter.json example
    • posttypes.json
    • taxonomies.json
    • acf.json
    • blocks.json
  • Filters
    • porter_default_object_args
  • Custom blocks
    • Build script
    • ACF integration
    • Inner blocks
  • INC
    • Block Filters
Powered by GitBook
On this page
  • Parameters
  • Source
  • Example
  1. Filters

porter_default_object_args

apply_filters( 'porter_default_object_args', $args, $group );

Filters the default arguments for a group (e.g. posttype) before registration.

Parameters

$args array

The default arguments for this group.

$group string

The group name.

Source

includes/porter-config.php
$args = apply_filters( 'porter_default_object_args', $args, $group );

Example

Filter the default post type arguments

add_filter( 'porter_default_object_args', function( $args, $group ) {
    if ( 'posttype' === $group ) {
        // Add a new field to the 'supports' section
        $args['supports'][] = 'author';

        // Modify other properties, e.g., make the post type searchable
        $args['exclude_from_search'] = false; // Enable searching for the post type
    }
    return $args;
}, 10, 2 );
Previousblocks.jsonNextBuild script

Last updated 7 months ago