You are using $post_id
, but you have passed the post ID as $postID
. As a result $a
is always empty.
Even if it weren’t empty, there is no PHP function srtpos
. It’s strpos
and you could have more straightforward logic to execute set_post_format
.
Wrapping it up:
function CambiarPostFormat( $postID ) {
$a = get_the_title( $postID );
if ( !has_post_format( 'image', $postID ) && strpos($a, 'imagenes') !== false)
set_post_format( $postID, 'image' );
}
Related Posts:
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- Using require_once in a Plugin?
- Simple form that saves to database
- How to call plugin path in JS?
- Get Current user email as a return string value
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- How can I make content disappear when a user logs in?
- Plugin.php: PHP Notice: Undefined offset: 0 in
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- Determining where fopen() is writing files when used from WordPress AJAX call [closed]
- New Plugin: Post update pushes a copy as a revision
- Overide a function that is inside a plugin
- How to install and activate a plugin via an external PHP script
- How to remove xmlns on language_attributes()?
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Add keywords meta to index.php page
- Download any file after submitting a form [closed]
- WordPress on AWS with ELB
- Executing my function once on a specific time
- Output array into one table cell
- wordpress plugin is not activating from widget
- Using meta_query to get date type values from post_meta table WordPress
- There is any way to remove post-format filter? [closed]
- Using plugin functions/methods within templates
- How can integrate zend module with wordpress admin dashbord [closed]
- Setup wp_schedule_event within a custom plugin
- Does having more than 30 Admin Ajax affects site performance (plugin)?
- execute function after one completed
- WHy custom plugin slows down the loading of the pages?
- Adding media upload button to User Profile page (following a tutorial)
- How to get specific string/value from an array? php [closed]
- WordPress Stock Update Programatically
- UTF-32be error WordPress
- Background Music WP [closed]
- Getting a ressource ID, from a WC_Order_Item_Product/Order
- Why is it important to check for isset and is_array before checking in_array in this example?
- How to delete a theme using AJAX
- ACF – How to set the menu order for the relationship field
- Custom search search does not work?
- How to call external functions from a PHP script in a WordPress plugin?
- same user role or copy the user role to be same as the other role
- Equivalent of admin.php for public pages
- Social share buttons text shows up on post excerpts
- How to add custom function to pluggable.php
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- Plugin Admin panel checkbox unchecked after submit
- Getting URL GET parameter with Code snippets and storing it in database?
- WooCommerce – new order email hook
- save_post_product action not firing
- How to get the custom field value using SQL query
- How to list datas from database in a topic?
- Editing a coupon generating plugin
- WordPress fatal error from php protocol codes
- How to hide an option from dropdown in filter module
- How use wp_insert_post and add og:custom tags?
- Display pagination in reservation Plugin and and Print table as pdf
- Changing wordpress/woocommerce notices default message to other languages (text)
- Why does my custom plugin only function correctly once per page?
- How to change “Read More” text?
- How to change a wordress plugin php code in my child’s functions.php file?
- What is the right way to populate a dropdown from MySql?
- make p tag collapsed after 3 rows
- I can’t view the orders on the woocomerce dashboard with the brainblocks plugin
- Woocommerce – Change variations output
- WordPress Plugin PHP Not Calling Function
- load plugin in code snippet
- Generate and send ICS file through WordPress
- Is admin section completely customizable in terms of styling?
- WP Plugin permissions – create new files
- Run a Change Role Cron Job on WordPress via cPanel
- How to display variables from plugin?
- How to make the first letter of a post title uppercase, in a plugin?
- Creating Admin Submenu Page via Class Method
- .htaccess file doesn’t work, with hundred tries
- How to change the product short description for each product with PHP?
- ACF Repeater Field Question [closed]
- How to create a dashboard for logged-in users with custom functionality? [closed]
- Cannot access variables within a widget
- How do I convince this button to do something when it is clicked?
- WordPress function to add text
- TheCartPress plugin – Make every item in store unique
- Postal address auto-complete on profile page
- Doing action based on input from options menu
- Insert dynamic content into posts
- WordPress Related Plugin – Adding an image
- WordPress User Frontend Editing Custom Fields
- How to delete remain data in WP database after deleting custom post via admin interface
- My wordpress site wont load, it gives header error warnings
- Can anyone see a syntax error in this? [closed]
- Populate Woocommerce order notes with custom field value
- Woocommerce Product Add-ons – Auto-select first option
- Strict Standards: Non-static method in sidebar generator
- Fast Tranfering my WordPress site to another server
- Duplicating wordpress install issue
- Can’t use updated variables in handle function
- How to get URL param for pagination in shortcode?
- Make plugin admin page visible to other roles
- Is there any WordPress Plugin that provides video editing from front end side? [closed]
- How Create LastMod and Update Date Only on Taxonomy Category and Tags