Change category display name function

So I wonder why don’t you just set the category title via the admin page, e.g. for the one having the slug alphabetical, you could set All Characters as a static title for the category? That way, you wouldn’t need to hook on get_the_archive_title.. But anyway, here is one way of how can you reduce … Read more

Which filter fires upon setting a featured image

A nearly identical use case for your question is found in the WordPress documentation for the filter admin_post_thumbnail_html. A filter hooked to this will receive the HTML for the admin screen as $content. Modify and return this markup as you wish. function filter_featured_image_admin_text( $content, $post_id, $thumbnail_id ){ $help_text=”<p>” . __( ‘Please use an image that … Read more

Display Script in Header When URL Variable Present

URL variables like that are stored in the $_GET variable. You can check the existence and value of one like this: add_action( ‘wp_head’, function() { if ( isset( $_GET[‘feedback’] ) && ‘yes’ === $_GET[‘feedback’] ) { ?> <script> alert( ‘Hello, world!’ ); </script> <?php } } ); The check for isset() is necessary as checking … Read more

How to change images url in function.php?

Most of the cache plugins have built-in CDN settings. If you are looking for a simple solution for the image URL only, you can use CDN Enabler. It is from KeyCDN but you don’t have to use KeyCDN for it to work. Simply Write your alternative domain to only use image extensions if you don’t … Read more

localize_script but data changes dependent on product ID

You should call wp_localize_script() in the wp_enqueue_scripts hook (or a later hook) in which you would get the correct product/post data such as ID, and that conditional tags like is_single() would also work as expected. So you should move all the $product, $product_id, $dataToBePassed and wp_localize_script() parts to inside the wp_enqueue_scripts callback, and then you’d … Read more