You can add an action to wp_insert_post()
. The cool thing about it is the third parameter – $update
, because it allows you to only set the post_format
once, and you can change it later. This is necessary because the function wp_insert_post()
is not only called on the creation, but also on update etc.
add_action( 'wp_insert_post', 'f711_set_default_format', 10, 3 );
function f711_set_default_format( $post_ID, $post, $update ) {
// execute only on creation, not on update, and only if the post type is post
if ( $update !== true && $post->post_type == 'post' ) {
set_post_format( $post_ID, 'audio' );
}
}
If you need this done for all of your existing posts, just create a loop and call the set_post_format()
for every single one.
Related Posts:
- Only get_posts of certain post formats
- static variable loop not working in WordPress
- How does WP detect format type (and can I make use of this)?
- How to filter posts by post format “standard” from wp-json api?
- Get first URL from post content
- How do I use this PHP library to access OpenGraph data in a child theme?
- WordPress add post format support not working
- trigger html cleanup for all posts
- Almost Done… Post Format Code
- Display the video of a post_format Video
- Wrap posts p tags in div
- Conditional for Post Format
- How can I add WordPress Audio Player as featured audio in Audio Blog Posts?
- Custom single.php files for different post formats
- Can i use php sql functions instead of $wpdb?
- Getting paginate_links() ‘end_size’ to display none
- What is the best practice for escaping data URIs?
- WordPress Template Engine?
- Display only text to WordPress loop without loosing the text formatting
- Making a follow button, Ajax not talking to php
- Replace existing content from specific WooCommerce admin orders list column
- How do I get images (with a thumbnail preview) to show in search results?
- How to display blog images using wordpress in existing project
- How do I translate this string – PHP syntax question
- PHPCS: Strings should have translatable content
- mysqli_real_connect() – authentication method unknown to the client Warnings
- php syntax – how to concatenate properly – echo bloginfo(‘stylesheet_directory)
- how to increase custom post value by one most efficiently?
- multiple if statements [closed]
- Escape post image attachments added to template
- Woocommerce product download URL
- Multiple choice in a custom taxonomy
- Calculations in functions.php [closed]
- Get_avatar filter?
- WordPress custom login form using Ajax
- WP dynamic featured image – Can’t get second featured image url
- Why is my cookie not unsetting upon logout? [closed]
- How to remove role=”navigation” from all nav elements?
- How to use $_GET function WordPress backend
- How to set variable, pass it to a partial file and remove it after?
- Dynamic content in template
- wp_dropdown_pages auto submit
- WooCommerce Tabs [closed]
- Limit checklist by the current user
- Adding Meta Tags to a Post using its Tags, Excerpt and content
- Use Tags to initiate Search
- Show About and Contact Us page when they’re clicked in the top menu.
- single.php with different look by category
- Displaying posts based on category
- Changing the color scheme based on the url visited
- How to send form data from WordPress (Meta Box) to an OData service?
- Issue with custom loop in Archive page
- WooCommerce pages looks unstyled
- class ‘wphpc_PAnD’ not found
- Accessing values from ACF sub field (flexible content area) in PHP
- Creating an image from a custom field
- home.php show blog posts as grid view
- Custom post type permalinks do not appear using the link functions
- Loading Posts & Category with Ajax
- How to organize functions.php content
- List all anchor links on a page
- Assign Custom classes to every Excerpt
- Adding a ‘style=’ bit to image_send_to_editor output
- Auto create Nextgen Gallery on post creation [closed]
- Adding a navigation page state to individual blog and portfolio pages
- Inline CSS header style priority function.php Child (no enqueing I think)
- Display Post Title From Select Choice Loop in Advanced Custom Fields (ACF) – WordPress
- Jetengine Forms – Media upload path
- excep tonly one css, don’t load any css
- is_front_page is not working in my functions.php
- Is it possible to update the dataset using update_post_meta
- Change ajax live search results
- Hide payment method based on user role AND minimum cart value
- Checkbox is not being set
- Install functionality for push notifications but WP-Theme has oddly-named, hidden source files [closed]
- Update $wpdb query with AJAX
- How to get this .php code from my theme into my plugin?
- Send Notification to all users that followed some author
- Search function not working
- loop to return tags in woocommerce in alphabetical order?
- Embedded pages by ID are not respecting Private and Draft status
- Adding a sidebar to wp-login.php
- rewrite_rule – working fine but broken for pagination
- AdWords API with WP
- Add title and caption to thumbnail image on mouseover
- Postmeta not saving
- WordPress wp_remote_post() sending informaiton to Redmine REST API
- Missing items on page
- WordPress rewrite question
- WordPress blog set up
- Cannot get custom javascript to execute on page
- How to declare a variable at the bottom of the page and use its value at the top?
- How can a ‘scripts’ directory be hooked into wp_head();?
- Display Current Time using shortcode
- WP and Laravel integration (Updated) [closed]
- SQL – How to echo out inside of where statement
- How to create different templates for woocommerce single-product.php?
- How can I update a value of a field depending on outside source?
- Restricting access to a file for everyone except logged in users
- WordPress Block Editor Gutenberg running code inside ! is_admin()