Calling related posts to a custom post type, taxonomy & Tag id

get_the_term_list() returns HTML but you are trying to use it as if it returned a term ID — ‘blog_cats’ => $blogcats,. That is not going to work. You will need to use get_the_terms() and a tax_query (I think. I am not 100% sure). Something like: $blogcats = get_the_terms($post->ID,’category’); // var_dump($blogcats); $blogcats = wp_list_pluck($blogcats,’term_id’); // var_dump($blogcats); … Read more

Non-permalink custom taxonomy not found

The problem was ‘exclude_from_search’ => true in the register_post_type options. Given that setting ‘public’ => true defaults to exluding from search by default I assumed that this was the correct setting. However this is in the WordPress codex for register_post_type exclude_from_search: Note: If you want to show the posts’s list that are associated to taxonomy’s … Read more

Filtering custom posts by custom fields (ACF) [closed]

Ok, so after deeper research I’ve found out that values of some custom fields created by ACF are stored in MySQL database with some additional information like a:5:{i:0;s:6:”Aerial”;i:1;s:6:”Nature”;i:2;s:4:”Nude”;i:3;s:6:”People”;i:4;s:8:‌​”Wildlife”;}. This happens when a custom field can store multiple values (like chechboxes). So I’ve edited part of my query from this: if( !empty($_GET[‘theme’]) ) { $contestTheme = … Read more

Adding custom post formatting options in custom post types

maybe it’s too late, but I found out how to solve this so I think I could share my solution. You have to access the global $post variable to find out the post type: function haet_custom_toolbar( $initArray ) { global $post; $post_type = get_post_type( $post->ID ); if( ‘page’ == $post_type ){ $initArray[‘toolbar1’] = ‘formatselect,styleselect,|,bold,italic,|,alignleft,aligncenter,alignright,|,pastetext,removeformat,|,undo,redo,|,bullist,numlist,|,link,unlink,|,spellchecker,fullscreen’; $initArray[‘toolbar2’] … Read more

Copy/Move selected taxonomy terms to another taxonomy for posts

This will get all posts with $old_tax, copy the terms from $old_tax to $new_tax, and then set the $new_tax terms for those posts. <?php function convert_tax($old_tax, $new_tax) { $pages = get_posts(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => $old_tax, ‘operator’ => ‘EXISTS’ ) ) )); foreach($pages as $post) { $terms … Read more