Auto-Tagging a Custom Post Type

Referenced from https://codex.wordpress.org/Post_Status_Transitions#.7Bstatus.7D_.7Bpost_type.7D_Hook the hook named “{status}_{post_type} Hook”. This hooks is fired, when custom post type “community” is giving the status “publish” = is published. Hook will give post_id and post object as parameters to the callback function. And wp_set_post_terms, requires first parameter as post ID. This should work: add_action(‘publish_community’, ‘community_post_type_tagging’, 10, 2); function community_post_type_tagging($post_id, … Read more

showing tag beside catagory

Paste this code along side the code given by you I have not tested the code but it should do the trick… where you used this [blog1 items=1 cat=op-ed] replace this with this [blogtag items=1 tag=china] <?php $queried_object = get_queried_object(); $term = $queried_object->name; add_shortcode(“blogtag”, “blog_tag”); function blog_tag($atts, $content) { extract(shortcode_atts(array( “items” => 4, “tag” => … Read more

Prevent tag creation on the post edition page

This will disable the Tags suggesstion: function wpse207107_dequeue_suggest() { global $post_type; if ( is_admin() && $post_type == ‘post’ ) { wp_dequeue_script( ‘suggest’ ); wp_deregister_script( ‘suggest’ ); } } add_action( ‘admin_enqueue_scripts’, ‘wpse207107_dequeue_suggest’, 5 ); However, that might disable some other suggest functionalities if other plugins uses the script. Alternatively, you can entirely remove the Tags metag … Read more

Only display posts with a specific tag

Take a look at the tag parameters of the WP_Query class. You’ll most likely need to create three separate queries. <?php $query = new WP_Query( array( ‘posts_per_page’ => -1, ‘no_found_rows’ => true, ‘tag’ => ‘tag1’ ) ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); // the_title(); endwhile; wp_reset_postdata(); endif; ?>

Show all tags NOT applied to post

if i have understood your question, you want all tags from a taxonomy not applied to your post? maybe you can use get_terms(‘your_custom_taxonomy’) to get all of your tags, and parse/diff to your current post tags to get all tags not applied to your post https://developer.wordpress.org/reference/functions/get_terms/ or maybe try to use a filter like list_term_exclusions … Read more

Conditional inside search result excerpt

You are making typical mistake between conditional tags which tell you which kind of page are you on (search in your case) and functions which tell you data of the current post in the loop. What you want in this case is probably get_post_type() and make your output conditional on result of it.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)