How to temporarily set the featured image for a post when the post is loaded

The post_thumbnail_html action hook will be the one you’re looking for. This allows you to add conditional logic to change the source url depending on the page you’re looking at. function new_post_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) { $new_html = $html; if ( is_archive() ) : $new_html=”<img src=”https://your-image-source.com” alt=”Your image alt tag”>”; endif; return … Read more

Call to undefined function create_function() – PHP 8.2

You are going to want to edit this line: add_action( ‘plugins_loaded’, create_function( ”, ‘global $BBCode; $BBCode = new BBCode();’ ) ); You will want to make yourself an actual function. Probably something like this: function my_hacked_function(){ global $BBCode; $BBCode = new BBCode(); } add_action( ‘plugins_loaded’, ‘my_hacked_function’); I’ve not tested this. However, this is the general … Read more

Get generated block styles programmatically

We can look at the source of the wp_head() function: function wp_head() { /** * Prints scripts or data in the head tag on the front end. * * @since 1.5.0 */ do_action( ‘wp_head’ ); } And see that it really only calls the wp_head hook. We can then look through the WordPress core code … Read more

How to send user password reset link to their phone number instead of email

To resolve the error in your code for sending a password reset link via SMS using Twilio, here’s a refined version of your function with necessary error handling and dependencies: function send_password_reset_sms( $user_login, $user_data ) { $phone_number = get_user_meta( $user_data->ID, ‘phone_number’, true ); if ( ! empty( $phone_number ) ) { $reset_key = get_password_reset_key( $user_data … Read more

WooCommerce: Custom dropdown for variation selection

I think the condition here has_term($term_slug, $taxonomy, $variation->get_id()) won’t work for variation. If you want to check term, we need to check with parent variable product instead of checking variation because Woocommerce doesn’t store any taxonomy/term attribute to variation. Instead of using has_term, we can use your existing attributes in get_variation_attributes to get and check … Read more

Warning: Undefined variable $post_id

Try this instead: $posts_with_category = new WP_Query( $args ); if( $posts_with_category->have_posts() ) { Instead of just checking if $posts_with_category is non-empty it checks if it’s an array of WP_Post objects. We don’t have line numbers to see where the error is being thrown. Is line 47 your return statement?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)