Your 2nd foreach loop is a bug. $slug
is a string with a single value, and you cannot pass a string to a foreach loop. If you set debug to true, you will see an error message telling you just this.
You can simply just do
//Different markers for different types
$car_type = get_the_terms( $post->ID, 'car-type' );
//Apparently it don't get the slug if it's not in foreach loop
foreach ( $car_type as $type ) {
$slug = $type->slug;
$marker_image="https://www.my-site.com/media/markers/marker_" . $slug . '.png';
}
Related Posts:
- Show different Google Map markers for different post_meta values
- Jquery Slider for profile template
- Get excerpt using get_the_excerpt outside a loop
- Should I use loop in the single.php file?
- how to upload image using wp_handle_upload
- Avoiding using a loop to access a single post
- Adding ‘current_post_item’ class to current post in the loop
- wp_list_categories: get latest featured_image of category
- WordPress Alphabetical Glossary close div in loop
- How to make multiple Column in archive Page?
- Sort Popular Posts by Views for the Last Week
- get_the_foo() in the loop – does it perform another query?
- Exclude filter on front page
- category__not_in — anyway to use category name instead of id?
- Filtering posts by multiple taxonomies
- Check if date of post is yesterday
- Exclude first 2 posts with meta_key from loop
- Make a custom loop inside single.php with pagination
- Why do I get `Call to a member function have_posts() on a non-object `? [closed]
- Help with Changing loop.php?
- Adding shortcode closing tag after a loop
- Removing the_content() from the page
- Loop and Page template : my WP_query don’t take args
- How to split a loop into two columns
- Category Ajax call
- Change front-page layout after x amount of posts ( while in the same loop)
- Transient loop issue
- popular post weekly and monthly
- How can i use the same template file with a widget and category loop?
- WordPress Loop inside Loop?
- Filter the loop by categories using checkbox form
- Get single post from tags array
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- angularjs not displaying all posts
- query_posts() vs get_posts() multiple loops [duplicate]
- Latest Post Styled Different Than other Posts
- ACF custom field in [closed]
- Split wordpress loop to multiple layouts
- How do I make a variable available inside partials?
- Woocommerce: How to display product price [closed]
- Update status of all posts in a category
- is_active-sidebar loop
- Unable to change the “Read more” text inside the_excerpt
- Display Post Author Link above the loop
- Conditional: IF current user has NOT commented on current post (not including post author)
- Add “showing posts x to x of y” in custom post type paginated loop
- Change post order by meta key, per post basis
- Loop Problem: Displays same set of post for all categories
- Display a single category in blog section
- Query Nopaging action not having effect
- Getting page slug
- How to get pagination to work with 2 wordpress loops
- How do i find and restore a sidebar that i accidentally deleted? [closed]
- Posts not showing
- Exclude page from loop results
- How is WordPress changing the content markup?
- Inserting CPT and static content at every X post, is this possible?
- loop through posts and display inserted media and post title as a link
- using update_user_meta to rank users
- Can’t grab author info outside of the loop
- Exceprt not displaying
- Add File Attachment Name and URL into Javascript
- How to tell if all posts are only in one category?
- How to get post category and author name for cusmot API?
- How do I set the Stewart Search Template to return only published posts in the result
- Updating Post meta (ACF field) from Feed
- WordPress posts in the loop not stacking side by side
- How to separate post titles with a comma in the loop?
- get_posts changes main query
- Trying to get property ‘post_content’ of non-object
- WordPress loop : how to exclude some posts with their status?
- Homepage Loop Somehow Breaks Styling Of Post Grid
- Create an archive page(loop) for edd products (music files) with an audio player?
- WordPress Pages in an Array
- the_content() keeps repeating itself
- Strange problem with wp_get_attachment_image_src database (db) query count
- How to include posts from one category, into a separate category of posts?
- how do i make this loop work
- Making a specific page wordpress compatable that is not index
- Can’t print out returned value
- change the_content images for different sizes (Desktop, tablet, mobile)?
- WordPress Group By Problem
- display only parent replies count in index.php
- using the loop on a page
- Home page loop with pagination problem
- WooCommerce custom loop pagination on front page
- Eliminate duplicates in a foreach loop [closed]
- Tag custom loop show posts
- While loop inside another while loop
- I want the first post on my home page to be lengthier than the rest (example included)
- Loop with Custom Post Type Taxonomies and Interstitial Code
- Question about custom plugin
- loop mix my child-category and parent-category
- Fix html inside a for loop [closed]
- Display all posts in a page code for template
- How can you make it so the comment box shows on some pages or posts but not all?
- Insert multiple custom components after x-number of posts
- wp_mail sending only once inside foreach loop
- How to use orderby on meta_value when using Pods custom database table storage
- wp_mail function not working in user query loop