Function Signature:
wp_apply_typography_support
Function Description:
Adds CSS classes and inline styles for typography features such as font sizes to the incoming attributes array. This will be applied to the block markup in the front-end.
Function Examples:
⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Applying typography support to a custom post type
add_action( 'init', 'custom_post_type_typography_support' );
function custom_post_type_typography_support() {
$args = array(
'public' => true,
'label' => 'Books',
'supports' => array( 'title', 'editor' ),
);
register_post_type( 'books', $args );
wp_apply_typography_support( 'books' );
}
// Example 2: Applying typography support to a specific theme template
add_action( 'template_redirect', 'apply_typography_to_custom_template' );
function apply_typography_to_custom_template() {
if ( is_page_template( 'custom-template.php' ) ) {
wp_apply_typography_support( 'template' );
}
}
// Example 3: Applying typography support to a specific category
add_action( 'init', 'apply_typography_to_category' );
function apply_typography_to_category() {
$category_id = get_cat_ID( 'News' );
if ( $category_id ) {
wp_apply_typography_support( 'category-' . $category_id );
}
}