Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

feed_content_type

Function Description:

Returns the content type for specified feed type.

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: Setting the feed content type to application/json
add_action( 'init', 'custom_feed_content_type' );
function custom_feed_content_type() {
    feed_content_type( 'application/json' );
}
// Example 2: Checking the current feed content type and changing it if necessary
$current_content_type = get_option( 'feed_content_type' );
if ( $current_content_type !== 'application/json' ) {
    feed_content_type( 'application/json' );
}
// Example 3: Restoring the default feed content type if it has been modified
add_action( 'wp_head', 'restore_default_feed_content_type' );
function restore_default_feed_content_type() {
    if ( get_option( 'feed_content_type' ) !== get_default_feed_content_type() ) {
        feed_content_type( get_default_feed_content_type() );
    }
}