Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

The tag template page began displaying posts for specific tags once I replaced the argument statement with the following, which is great!!: $tags = get_the_tags(); $tag = $tags[0]->name; $args = array( 'post_type' => 'post', 'post_status'=>'publish', 'category_name' => 'NEWS', 'tag_slug__and' => $tag, 'posts_per_page' =&...


1

You can set orderby slug like : $tags = get_tags( 'order=ASC&orderby=slug' ); $html = '<div class="post_tags">'; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>"; $html .= "{$tag->name}</a>"; } $html .= '</...


0

I'm very late to the party but the error is that you are searching a multidimensional array. You have to specify for the key you are searching for $post_terms = wp_get_object_terms( $post_id, $taxonomy ); if( $post_terms ){ if(($key = array_search($term_id, array_column($post_terms, 'term_id'))) !== false) { unset($post_terms[$key]); } ...


0

OK finally found the solution. After looking in wp_term_taxonomy table, I noticed that taxonomy column describes the taxonomy term for tags - which is actually post_tag, not just 'tag'. So, this works: add_filter('rest_prepare_post_tag', 'wp_api_encode_yoast', 10, 3); Hopefully someone will be helped by this.


0

You could try using the rest_post_query action to add exclusion filters for categories and tags. Try something like the below. This adds ['filter']['exclude_categories'] and ['filter']['exclude_tags'] as options to use in the WP REST API. Each filter accepts multiple categories/tags seperated by a comma. add_action( 'rest_post_query', 'your_exclude_query',...


0

Actually I also wanted to use it now. Basically this is the only place in the internet to actually work for Tags. I have found some troubles with it, managed to edit it and it works for me now: Here you are saving also SPACE character to the value <input type="color" name="_tag_color" value=" <?php echo $color; ?>" -> deleted space <...


1

If you need to get tags by post id you could use the followng function. This will work on anywhere since the method is based on database querying. function sc_tf_get_tags_as_array($post_id){ global $wpdb; $tbl_terms = $wpdb->prefix . "terms"; $tbl_term_relationships = $wpdb->prefix . "term_relationships"; $sql = "...


0

You'll need to expose both the Custom Post Type (CPT) and the taxonomy you are attaching to that CPT that you'd like access to. This is a great article that helped me the first time I used it. https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-rest-api-support-for-custom-content-types/ If you are trying to expose the CPT and the ...


1

I believe the most direct way of customizing WordPress feeds is to hook into them directly with the following filter. Edit: as we talked about, let's just edit the content to tear out any function edit_your_feed_content($content) { $content = preg_replace("/(<figure.*?[^>]*>)(.*?)(<\/figure>)/i", "", $content); return $content; } ...


0

I found a solution!: $term_ids = $wpdb->get_col(" SELECT term_id FROM $wpdb->term_taxonomy INNER JOIN $wpdb->term_relationships ON $wpdb->term_taxonomy.term_taxonomy_id=$wpdb->term_relationships.term_taxonomy_id INNER JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->term_relationships.object_id WHERE DATE_SUB(CURDATE(), ...


0

The way you are customizing the query you are telling it to search for posts that ALSO match a custom tax_query criteria. This would never work, logically speaking. You said, "I want it to return a result if this tag is searched or if it matches the title" for which I understand ONE or ANOTHER. I'll show you a completely different approach, using basically ...


0

I think you need to remove $_GET['post_type'] Please use below code i think you might help : add_action( 'pre_get_posts', function ( $q ) { if ( !is_admin() // Only target front end, && $q->is_main_query() // Only target the main query && $q->is_search() // Only target the search page ) { ...


0

Your logic is wrong. Each time you loop through your tags and they contain ods in the name, you output all the content. Try this instead: // You can pass multiple terms to has_tags. if ( has_tag( 'ods1', 'ods2' ) ) { ?> <div id="destacat"> <div> <h2>Title</h2> </div> <?php ...


Top 50 recent answers are included