Using a variable will make your code a little less repetitive:
$case_history_code = get_field( 'case-history-code' );
if ( $case_history_code ) {
// make the code lowercase
$case_history_code_lower = strtolower( $case_history_code );
// use the lowercase inside of `get_posts`
$myposts = get_posts( 'numberposts=3&offset=0&category_name=" . $case_history_code_lower );
foreach ($myposts as $post) :
setup_postdata($post);
?>
<a href="https://wordpress.stackexchange.com/questions/220489/<?php the_permalink(); ?>"> </a> <?php the_excerpt(); ?><br />
<a href="<?php echo get_permalink(); ?>"> Read More...</a><br />
<?php
endforeach;
wp_reset_query();
}
Related Posts:
- Loop through two different sets of custom fields
- Loop through incrementing custom fields
- Query Posts or Get Posts by custom fields, possible?
- Best way to programmatically remove a category/term from a post
- Attaching Metadata to a Taxonomy Item
- Using get_posts with arguments found in meta keys
- How to add upload field in a custom taxonomy?
- Order posts by custom field and if custom field is empty return remaining posts
- Calling Specific Pages with wp query Part II
- use get_posts to get custom field data, but in one array
- Get posts that matches specific terms of multiple custom taxonomies
- Order posts according to user defined order for meta values?
- How to save taxonomy term meta?
- Default WordPress taxonomy (Tag) – How to add a custom field to form and save it to the database
- How do I exclude posts by custom field value?
- Echo values from custom field outside loop php
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Calling custom fields for pages (not posts)
- Duplicate posts being displayed when querying Custom Fields
- Loop to display random posts only if a custom field matches category
- How can I show custom fields in the loop only to specific user roles?
- Accessing loop functions (e.g the_title or the_content) from post ID
- get_terms that have custom sticky field checked
- If meta key exists in get posts function otherwise create it
- List taxonomy term “Last Name” + “First Name” (taxonomy custom field) in a post loop
- get_posts that haven’t been assigned a specific custom field
- Limit the number of acf content when displaying in post loop [closed]
- Is there a better way to list all database terms alphabetically?
- Change the main loop WordPress impact on the server?
- Meta Query returns wrong number of posts
- custom-meta-box checkboxes from loop won’t save
- How to find a post using XML-RPC without knowing ID
- How to show a post if was published less than two hours ago?
- List users by sum of all their posts’ custom field values
- get_posts in meta box dropdown not showing latest posts
- get post id using custom filed value
- Custom Fields – How to create a list from multi-line entries of a single value
- how to make nsfw post with thumbanil
- Custom Query based on custom field of a single post
- Delist entries in the_loop
- Efficiently sort only certain categories by custom field
- Can I access a post meta field before the loop?
- Displaying page image in the footer automatically
- Show image if author meta (profile fields) exists outside loop
- Can’t query by meta_key
- List custom queried terms in the edit-tags.php?taxonomy page
- ul list with only as many li’s as filled custom fields
- Loop through custom taxanomy in post and display custom fields from posts
- do_shortcode close
- Search Results Page – Displaying Custom Meta Fields
- tax query between operator like
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- Collect Data from NEXT item while in loop
- Get post-meta value of all custom-posts – lowest to highest year-count?
- Custom field to array?
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- How to show content of custom fields in search results?
- Custom field outside the loop and inside an array
- Display metabox title for custom fields with values
- use custom field value as post category in loop
- Filter or order based on custom field
- Compare ACF date field (if exists) and post date and order DESC
- What am I missing in this Code Block?
- get_field values for each post on home page using wp_add_inline_style
- Save Taxonomy of Post via custom Taxonomy Select Dropdown
- How do I display an article using a WordPress custom field?
- User Filter Options on Archive Page
- Custom meta boxes – add php code inside?
- get wordpress post loop by meta box date
- Outputting custom field on home.php not outside of blog list
- Why can’t I get the correct post permalink
- Counting number of images from loop
- Metabox value for post loop?
- Get meta value when the page is a blog archive
- Term specific featured post on taxonomy archive pages
- WordPress taxonomy child image
- WP_query returns error when used for custom widget
- I want my post to republish again after adding a custom field
- get_post_custom_values not working
- Display posts where date field matches current month?
- Filtering posts by WORD in custom field
- Retrieve IDs from custom field, count and display results differently according to count
- Pagination not displaying correct number of pages
- Display custom field outside the loop
- tax_query not working properly with get_posts
- Custom field not showing
- Order by a meta field in query loop
- How do I create a term for every value of a post meta?
- Create taxonomy terms from custom field values
- How to add an ACF only for parent term?
- Move posts to top of WP_Query if in certain Taxonomy?
- Title and post URL based on custom fields?
- Multiple relationships in a query
- Get content from pages with same meta_key from Database
- Loop posts based on permalink term
- how to turn a link field into a button or link text
- Why does my numeric meta query work only on one meta key and not the other?
- Post rating using Custom Field
- Inserting custom fields into new-post.php without using the Custom Fields Template plugin?
- Shortcode not picking up custom field