Get template part using a custom taxonomy term
leanda reports that the problem has been resolved: Solved it by changing array_pop to array_shift.
leanda reports that the problem has been resolved: Solved it by changing array_pop to array_shift.
You’re pretty close. Your rewrite rule is using the wrong query var, pagename should be just name. Here’s a version that works for me on a fresh 4.4.1 install and twentysixteen theme- function bvt_product_init() { $args = array( ‘label’ => __( ‘Product’, ‘domain’ ), ‘description’ => __( ‘Company products’, ‘domain’ ), ‘supports’ => array( ‘title’, … Read more
You need to loop through your posts, and retrieve the metadata for each post. Add them to your array, and encode them to JSON. $posts = $query->get_posts(); foreach( $posts as &$thispost ) { // reference the current item $thispost->meta = get_post_meta( $thispost->ID ); } Now you got a WP_Post-Object, with all the post meta available … Read more
I am not sure how you are activating theme on Network but here I am considering a case of installing fresh theme on a existing Network. Activating theme on any single site will insert the term for every site in Network but yes of course taxonomy registration code should be there already. Consider this example … Read more
You don’t need a custom query to include CPTs in homepage posts in normal cases. Just use pre_get_posts. function wpse215208_include_all_cpt( $query ) { if ( is_home() && $query->is_main_query() ) { $query->set(‘post_type’, array( ‘post’, ‘photo’, ‘video’, ‘web’ ) ); } } add_action(‘pre_get_posts’, ‘wpse215208_include_all_cpt’);
There is no $post var local to your function, you need to use global $post first, or get_the_ID(). get_post_meta( get_the_ID(), ‘_cf_address’, true );
You most probably ran into problems with escaping code and HTML from each other. Try this (added line breaks just for better readability): <i class=” <?php echo (get_post_meta(get_the_ID(), ‘Preis’, true) != ”) ? ‘fa fa-check’ : ‘fa fa-times’; ?> “>
I’m going to post this as an answer, because it worked for me: function my_awesome_func ($post_id, $post, $update) { //update the value we need early update_post_meta($post_id, ‘my_meta_key’, $_REQUEST[‘my_meta_key’]); $newValue = get_post_meta($post_id, ‘my_meta_key’); } add_action( ‘save_post_my-custom-post-type’, ‘my_awesome_func’, 10, 3 ); You could also simply use the value of $_REQUEST[‘my_meta_key’] directly if that works, but for my … Read more
Any template file must be in the current active theme folder. If they are in a different location, they won’t be automatically loaded, instead you need to code and modify the template file location determined by WordPress template system: add_filter( ‘template_include’, ‘envento_type_templates’, 99 ); function portfolio_page_template( $template ) { if ( is_archive( ‘evento_type’ ) ) … Read more
Yes too early is probably why, the global $post variable is not populated yet. Try hooking to a later action (I think init at the very least): add_action(‘wp_enqueue_scripts’,’enqueue_product_styles’); function enqueue_product_styles() { if (get_post_type() == ‘product’){ wp_enqueue_style( ‘css_products.css’, get_stylesheet_directory_uri().’/assets/css/css_products.css’, false ); } }