Custom Post Type Loop throws 500 error when used in widget

There are several problems in your provided code. $query -> while( have_posts() ) The WP_Query() return type is object. You are referring to a method that doesn’t exist. Instead, you should use the following: while( $query->have_posts() ) {…} wp_reset_postdata(); inside the conditional This function resets the post’s data, as it suggests. If you use it … Read more

Enqueueing scripts and styles multiple CPTS

There is a built-in function that you can use, instead of globals. The get_current_screen() function allows you to get the information associated with the current page. One of its return values is post_type. So you can check against an array of post types to see if anyone matches. function fhaac_admin_enqueue_scripts(){ $screen = get_current_screen(); if ( … Read more

Custom post type title is set by other custom post type

I found that i just have to use $post->post_name instead of $post->post_title because $post->post_name holds the slug also the autogenerated if you save as draft without defining a title. So the code would as follows global $post; $slug = $post->post_name; echo “<script>alert (‘”.$title.”)</script>”; $args = array( ‘post_type’ => ‘traener’, ‘posts_per_page’ => -1, ‘orderby’ => ‘post_title’, … Read more