TransWikia.com

How to add custom label or texts in featured image

WordPress Development Asked on December 21, 2021

I have tried to add custom title or hint text inside the featured image box in Worpress custom taxonomy. but didn’t get the solution. how to add a custom text underneath of the Click the image to edit or update in featured image.

Please check the screenshot for better understanding.

https://www.screencast.com/t/VafpoWvxw

Thanks

One Answer

You can do this by calling a javascript file for admin.

Create a javascript file in js folder in you current theme called admin.js. inside the file add this code:

jQuery(document).ready(function($) {
    $('#postimagediv .inside').prepend('<p>Recommended image size 300*300px</p>');
});

Now in functions.php in your current theme folder add this code to call the javascript file exclusive for admin backend.

add_action('admin_init', 'custom_admin_js');
function custom_admin_js() {
    wp_register_script( 'admin-js', get_stylesheet_directory_uri() . '/js/admin.js' );
    wp_enqueue_script( 'admin-js' );
}

For different taxonomy blocks/sections you can use their identifier and in html their ID will end with div. For example if the taxonomy identifier is "some_taxonomy_identifier" the html ID will be "some_taxonomy_identifierdiv". so in js will be like this:

$('#some_taxonomy_identifierdiv .inside').prepend('<p>Some recommended text</p>');

Answered by mysticalghoul on December 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP