Display post titles that match string in post content

The problem is that you are matching the title string in the entire content as whole and not word by word. e.g. if your title is ‘blog’ and content contains the word ‘blogging’, it will still match and pull ‘blog’ from ‘blogging’. So, you can compare them word by word by exploding the content as … Read more

Adding taxonomy terms based on custom field

You should be able to just the following: Just a couple of things to note: By using get_term_by() instead of term_exists(), you hit the term cache instead of the database for every retrieval of the term object. /** * Set terms for the given post type based on a meta value. */ function wpdocs_set_terms_for_post_types() { … Read more

Is There a Difference Between Taxonomies and Categories?

Taxonomies, as previously described are a collective noun for the following category post_tag post_format link_category custom taxonomy The first four are built-in taxonomies, while custom taxonomies are taxonomies that are manually created by the user with register_taxonomy. Custom Taxonomies can be hierarchical (like the build-in taxonomy category) or not (like post tags) The categories and … Read more

How to Get Current Custom Post Type Associated Taxonomy Term

// First, get associated taxonomies of the post/object. $object_taxonomies = get_object_taxonomies( get_post() ); // Next, get associated terms of the post/object. $object_terms = wp_get_object_terms( get_the_ID(), $object_taxonomies ); $terms = array(); // returned object terms could be WP_Error, so check that first. if( ! is_wp_error($object_terms) && is_array($object_terms) ) { foreach( $object_terms as $object_term ) { // … Read more