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?
- Show only taxonomy types terms associated with a custom post type in WordPress PHP
- How to Filter the Custom term loop based on dropdown
- Can I display custom post types in home.php or need page template?
- categories should be available across all custom post types
- Set featured image to archive.php
- how to echo meta tag in header using php
- Get term name without a foreach loop
- Unable to link categories to custom post type using standard function
- Cant get paginations on single.php to work with my custom post types
- How to Set Taxonomy Object Description?
- Categories and tags for custom post types
- Including all post id’s of a custom post type into an array
- Create new custom post and post category of same name
- wordpress remove views from action links in a custom post
- Understanding Post Formats/Custom Post types Etc
- Custom post type causes php-error in php version 5.2.17
- Custom select query for taxonomies that have posts categorized in another taxonomy
- Enable taxonomies by post type in an array of CPTs
- How to assign tag to custom post type in wordpress?
- Trying to get custom post of a custom taxonomy
- Custom Taxonomy Is Being Pulled into a Page, But It Doesn’t Have A Hyperlink
- Querying two taxonomies with tax_query not woking
- How can I group posts by months and years?
- Rename a slug label
- PHP question: how to combine syntax?
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- Add first letter of titles to array, then compare arrays
- Custom Taxonomy Category link
- wp_insert_post wrong post type [closed]
- Get Post Terms of Current Post (selected taxonomy term) – How to get only the taxonomy value and not “Array ( [0] => taxonomy term )” in the frontend?
- Loop increase number
- custom post for slider
- How to get all Custom Post Type Filtered by one Specific Taxonomy Term
- Using wp_query to modify the loop in index.php for a CPT
- WP_Query Custom Post Type if Category ID Equals
- Hide specific taxonomies from a taxonomy list using ‘get_object_taxonomies’
- How does the ‘the_post_navigation()’ work for CPT’s?
- Custom post type – list posts based on meta_key and display them divided by CPT taxonomy category
- Assign category a default post type
- Custom taxonomy (categories) on custom post type return no results
- Filter second dropdown (tax) based on first dropdown (cpt)
- Variable not working in WP_Query
- Hide meta box for everything BUT a certain custom post type
- Not sure why this template for custom post type posts isn’t displaying anything. What’s missing?
- Filter posts by tax (dropdown) and meta value
- Archive-posttype.php isn’t loaded
- Is This Code Efficient – Or is there a better way?
- get_category_link() for custom post type does not include custom slug rewrite?
- Add tags to custom post type without menu link
- Control content before and after custom post type loop
- Custom Post not working as expected
- How to use a variable as a function name?
- Targeting categories in custom fields
- Check IF single OR multiple custom data has been entered
- Get custom post type categories to show up in menus
- How can I create an automatic drop down menu with my tags?
- Associate all Custom Post Types with Taxonomy
- How to define a term for custom taxonomy
- Saving fields in a drop-down in WordPress
- Invalid Taxonomy
- List custom taxonomy as navigation – taxonomy pages with all it’s posts?
- Need help deciding on a taxonomy