$image_src
doesn’t exist yet when the “Header_Upper_Left” div appears. So, you’d need to place the code for deriving whichever image you want to have used before you actually use $image_src
.
There are a couple of ways to do this. One way that a lot of themes do it –
like ones that have a top “Featured Post” or “Posts” format, is to start the query, get only the most recent post (and its data, attachments, whtaever), then rewind the query if you’re using it as main loop and displaying the same post again.
The alternative would be just to separate the special div from the main query, and use a separate query or a wrapper like get_posts() or wp_get_recent_posts(), to get the post ID, and then use the post ID to get the attachment ID.
Related Posts:
- Woocommerce get category image full size
- Display the featured image from the last post
- Add Image Size for one Media Category Only
- Extract image url associated to a category
- Retrieve Image from Media Library by it’s category
- Show category images on single product page and product overview page
- Link Attachment Image to Category
- Change thumbnail image depending product category
- category image taxonomy
- get_post_meta not working on category.php
- Random Featured Image Based on Category
- Category images are not displaying in WordPress
- Need to echo category id in multi-dimensional array
- Category view with contents of [gallery]s shown
- How to add image for all posts associated to specified category?
- How to display WooCommerce category image in my category page banner as a background?
- How to make product image inherit from category image
- How to display categories image in loop homepage WordPress
- Change background image page header overlay for each category
- Image Upload Custom Form Field for Category and Custom Taxonomy
- Icon images across multiple categories
- Media Categories as Classes on WordPress Gallery Shortcode
- How to relocate images
- In a shared site, how to get products in a category from one site to another?
- Display one post on category.php: Wrong featured image
- Category page with gallery for each post
- Image menu showing categories in page
- Get all first images of posts in same category
- Add category image before post title on homepage
- how do i set an image for a category in admin panel
- How to link images of one WP site to another WP site?
- How to create a photo gallery that can be filtered by the image categories
- Images as Categories
- Is There a Difference Between Taxonomies and Categories?
- WooCommerce: List All Categories
- Get rid of WordPress category, tag and author archives?
- Filtering categories in the permalink structure
- wp_nav_menu not appearing for a couple pages
- Why aren’t sub-categories nested after creating post in the WP Admin?
- Preventing index.php?category_name=something from redirecting
- How to get category id of current post?
- Trash bin for categories
- Categories’ hierarchy in URL
- Display one category in one page
- How to get next previous category in same taxonomy?
- is_archive() content being shown instead of is_category()
- Check is category parent or not from its ID
- Which php file lists all the post of a category
- How to query posts from specific authors and categories using WP_query?
- Apply custom category template to subcategories
- Retrieve all posts within tag OR category?
- Include template before a loop
- How to customize tag and category post listings to show introductory content?
- List Terms in Category
- Customized landingpages for categories
- Class active for Archive link – looped out
- Get parrent category name
- Remove sub-menu item from admin menu
- Add child category to parent on post creation and save
- wp_list_categories in in nav_menu
- How to use an array of categories as a dropdown?
- ACF add custom fields to categories and display
- Custom taxonomy template for categories
- How to create a custom categories page
- Select posts from Category
- Get post related on category
- Give Children Unique ID’s
- Searching for a category returns nothing if category is empty
- Cannot filter categories by parent category
- Redirect year month day postname permalink structure to category postname structure
- Show all sub categories?
- Category nicename inside loop in wordpress
- Exclude all subcategories in the_category (post)
- How to show a featured image inside a post in only 1 single category
- Displaying another main nav menu for specific category
- Exclude categories from list (wp_list_categories)
- How to display the 5 latest post titles but allow only 1 in there of a specific category
- WordPress: Using the category slug get the category ID using mysql query
- How to add categories using mysql
- Posts made to category don’t show up (do show up on frontpage)
- wp_dropdown_categories() works correctly but the list is not filtered in admin for custom post type. What is the problem?
- Add $args to wp_list_categories
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- Restrict retrieved terms by category?
- Get category from slug list
- Re-coding category-template.php to go to custom URL
- Category removal – Portfolio Category:
- Show One Level Category id
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- Custom filters inside a specific category?
- $args Orderby The number
- Function to list posts from current post’s category fails in WP 3.8
- Multiple parent categories
- How to use Greek characters/letters in a query?
- Getting categories to change appropriately when using $cat = ‘ ‘;
- how to call the category of the post
- why is the delete option missing from just one category?
- Get all categories
- Show category post order ASC
- How to add custom prefix before category base for category page URL?