Your “states” appear to be terms in a custom taxonomy. In the code below I’ve assumed the taxonomy’s name is my_state
; you’ll need to make sure that’s updated to match the actual taxonomy name.
add_filter( 'the_title', function( $title, $id ) {
// Gets the list of 'states' the post belongs to.
$states = wp_get_post_terms( $id, 'my_state' );
// If there's more than 1 state, prepend 'National - ' to the title.
if ( 1 < count( $states ) ) {
$title="National - " . $title;
}
return $title;
}, 10, 2 );
References
Related Posts:
- How to filter out post type meta?
- Custom query to filter posts that have current post as a taxonomy [closed]
- Saving Taxonomy Terms
- How can I remove the “Add New” button in my custom post type?
- Taxonomy terms with edit/filter link in wp-admin, in the list of custom posts
- How to get a list of term names of the custom post type im currently on in single.php
- Ajax filter with custom taxonomies
- Filter posts with ajax form and checkboxes
- Get all taxonomies for all post types
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Get Post Primary Category
- Categories of custom taxonomy don’t show any posts
- How to Filter custom post type by taxonomy?
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- creat filter with wp_query
- search suggest – filter post type
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Different Category system needed for the Custom Post Type
- Redirect to another page using contact form 7? [closed]
- How do I add custom HTML to the content of an archive page’s posts?
- Pagination hitting 404 page on /page/4
- Query custom post types & Taxonomies and list them in a table on a page
- Using page title as a link to term archive
- How to get post count of specific taxonomy that have store name & category
- Page that lists publications by classifying them by taxonomy
- Filter taxonomy by CPT
- Display category filters for custom post type when category is shared by multiple post types
- Dynamic page for nav items used as filters
- Taxonomies are not showing in the category dropdown
- Taxonomy doesn’t follow slug permalink structure
- Custom Taxonomy – fields
- tax_query not working?
- Sorting on Taxonomy in archive page
- Custom Search not working
- Exclude Custom Post Type from shared Custom Taxonomy
- using ACF datepicker to filter posts on a page
- Looping taxonomy in taxonomy?
- How do I filter a custom post type loop by a field?
- Row actions for custom post types?
- How to order posts of a custom post type by date DESC in dashboard Admin?
- How to limit the number of terms (terms acts like categories)
- Custom Post Type – Taxonomy Dropdown Menu?
- How can I list all the categories under a Custom Post Type (taxonomy)?
- How can I get next/ previous post links to order by a filter (by the last word of the title)?
- Filtering Posts by Multiple Taxonomy Terms such as in an Admin Post Listing?
- Group list of posts by taxonomy and allow for pagination
- Priority for Categories, Tags, Taxonomies, Posts, Pages and Custom Posts with same url
- Custom post type loops with different page templates
- How can I programmatically save data into custom fields that contain serialized data?
- Row actions not showing? Why?
- Displaying custom post type on front page
- Archive filter disappears on no results?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- Remove “Get Shortlink” button in admin of custom post type
- How do I display custom post types through a common taxonomy?
- Paginate_links won’t create the right links on a taxonomy filtered custom post type archive
- Make a function to run only for CPTs
- Link users to a custom post type
- Weird problem happening with custom taxonmy when creating/updating posts
- Conditional regex in add_rewrite_rule() for specific query filters & pagination
- Query Multiple Taxominies Across Multiple Post type’s
- CPT + CMB2: data not displaying for only first post in loop
- Using custom field content as expression in IF statement [closed]
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Filtering posts list table
- Make a custom_post translatable
- How to update post meta on uploaded image from a custom form?
- Linking from CPT page to taxonomy.php
- Page not found for custom post type UI plugin and taxonomy
- Loop increase number
- Is This Code Efficient – Or is there a better way?
- Get data from PHP to JavaScript to set position of each post on front page
- Get assigned post categories
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- Nested Custom Taxonomies | Incorrect posts when querying
- How do I get the index for a custom post?
- Commas not displaying in implode
- add custom tags for custom post type in wordpress
- Modify a plugin function output from another plugin
- Filter search posts by post meta?
- Modifying search results based on post_type
- Is it a connection or relationship between 2 custom post types?
- Custom front-end form for adding post – Category problem
- Store a value in global scope after init hook is fired
- How to get current post type?
- Duplicate posts in my custom loop
- Wrap an X amount of taxonomy posts in a separate Row in WordPress
- get_post_meta for Custom Post Type ( CPT )
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Meta box not saving
- add current-menu-item to multiple custom post types
- Default taxonomy ‘post_tag’ added to CPT managing by custom role : nothing in the metabox
- WordPress Set A Static Page/Template For All Sub-Pages
- Add HTML before a specific div?
- How to hide home title on pages and posts?
- Display associated taxonomy child name on single CPT page
- Is there any way of not using my_init_method in the following code (that creates a custom post type)?
- Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT
- Custom post type is_singular condtional not working when managing sidebar display
- Taxonomy Archive URL + Template