Why would you want to avoid the_postthumbnail
? It can give you the exact html you want if you use the right attributes. Anyway, you can access the title and alt tags of an image like this:
// get the ID of the featured image
$thumbnail_id = get_post_thumbnail_id( $post_id );
// retrieve title (an image is a post, so you can access the title as if it is a post title)
$title = get_post($thumbnail_id())->post_title;
// retrieve alt (which is stored as metadata to a post)
$alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
Related Posts:
- Should I use RIPS tool to test my themes and plugins?
- Workflow and best practice for documentation [closed]
- How to get current post user id
- Redirect to another page using contact form 7? [closed]
- How do I combine a theme with a plugin
- Don’t load the theme for a page FROM a plugin EDITED
- Extending a theme: build new features as plugin or core modules?
- How do you create a re-useable HTML fragment in wordpress
- How to override any plugin file in the child theme
- when i activate my WordPress plugin cannot see customizer options or preview
- how to add custom css at top above all css file for specific url
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- How to show post attachment image
- Breadcrumb is not generating the correct post page url
- Site is setup statically – how to make it content managable?
- How to escape html code?
- How to make content as required in custom post type?
- How to create new title and its description inside a section in WP Customizer?
- how to get path to images in the uploads folder to be used in a plugin
- What is the correct way for a theme to support plugin UIs?
- How to call “page specific menu items” in template [closed]
- Update Multiple Post Meta for the Same Post In One call?
- Function to activate WordPress theme inside a plugin
- Which functions in theme or plugin load first
- How do I make my wordpress page more friendly for mobile viewers?
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to make my plugin theme-independent?
- How to load a new template page according to a particular URL?
- Check javascript file Proper way in functions.php
- How to Build a Movie Library in WordPress 3.x
- resize only height using wp_get_image_editor
- Autoload via composer in plugin interference
- Is there a quick way to inject i18n domain into theme/plugin files?
- Display future posts?
- Override the core function locate_template
- Having separate plugins and themes folder for multi-site setup
- Getting media library popup in custom plugin admin page
- How can I get full attachment url from wp_get_attachment_metadata?
- Translating plugin inside the theme [closed]
- unzip a folder on specific location and delete the zip file
- gallery option is not available in media upload box in costum theme option page
- Why are some of my thumbnails not being generated?
- Why is the Settings API is not saving my array of options
- Include Max mega menu Plugin into theme
- How to integrate plugin in WordPress theme
- add_action in functions.php, do_action in plugin?
- Adding Attachment Display Settings in custom media frame
- wordpress theme backend admin only
- How to generate video out of images via WordPress plugin
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- How to use get_theme_mod in gutenberg editor wordpress?
- Reusable functions and tools (Framework)
- Different UI in WordPress
- The problem with WordPress Importer
- Display post lists in 2nd paragraph
- Plugin-generated pages use Not Found or Pages Archive templates?
- Is there any kind of theme on WordPress to sell my own movies?
- Classified ad website : which solutions to use? [closed]
- What are the specifics of WordPress development I need to know? [closed]
- Homemade plugin while using Themify Ultra
- How to create a code editor for my plugin .?
- Finding the URL to be used to check if plugin is installed with a theme
- Can we have an ‘Update metadata’ button in Image Gallery for all image instances?
- wp_footer hook only working on homepage not in other pages
- How can I position ShareThis buttons manually when using the plug-in? [closed]
- How to use get_template part in the plugin?
- how to force tag page layout to use same as search layout?
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- woocommerce: Customize email with item total count
- Child theme modifications not showing up
- Rename a folder via HTML POST request
- what functions to use to resize images and create DB metadata for them after/during upload?
- How to get a post views count using ‘WordPress popular posts’ plugin
- How can I see $post object in frontend from functions.php?
- Link custom post type to page
- How to prevent redoing get_posts queries and make results available to other scripts?
- Showing different js file for different theme in wordpress customizer api
- Uploading images to custom table
- How to get current template file used by WordPress?
- How can I make a website with dynamic features with wordpress?
- How to generate a responsive output from plugin?
- How to work email subscribe in WordPress?
- How to create post comparison in wordpress
- How to add image for custom taxonomy
- Javascript as Jquery Function Call?
- Integrating WordPress Content into a jQuery Slider
- Editing a theme
- manage_{taxonomy}_custom_column not working
- how to make wordpress remember my choice
- How to Enfroce Domain Licensing Limits? [closed]
- Meta box not displaying on the plugin page
- add_meta_box showing blank screen in my page
- How to create an Info Box on WordPress [closed]
- What are Seeds? [closed]
- Frontend Enqueued Files in the Backend
- I have issue to retrive post thumbnail with rest api
- Custom Plugin not Displaying in the Website Production environment (Divi)
- Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1
- How can I keep a WordPress dropdown menu open when navigating to a child page?