How to Separate CPT From Regular Posts?

The issue was that the get_previous/next nav filters were “out in the open” in the plugin; so they were executed every time the plugin was loaded. I put them in a function called myplugin_set_nav_filters(), which I invoked before the loop in the CPT single template, and everything worked as advertised. Now the nav on regular … Read more

CPT: if more than X images are in post, use pagination

Try $u = 0; foreach($photos as $photo) { $u++; … if( ($params[‘next’] > 0 && $u == $params[‘next’]) ) { $retVal[‘content’] .= “<!–nextpage–>\n\n”; $u = 0; } EDIT (explaination) in the code posted by OP $params[‘next’] > 0 && $i == $params[‘next’] assuming $i is incremented every foreach cycle (this is not visible in the … Read more

Notice: Undefined index: suppress_filters

If $query->query_vars[‘suppress_filters’] is not set you will get that message. Use empty($query->query_vars[‘suppress_filters’]) instead of false == $query->query_vars[‘suppress_filters’] ) or use $query->get(‘suppress_filters’) like this false == $query->get(‘suppress_filters’). Untested (minimally tested) but I believe either of those should give you the same results minus the notice.

Detect where custom post type is declared

Hook into registered_post_type and store the data from debug_backtrace(). The third entry should be the calling plugin. Sample code add_action( ‘registered_post_type’, ‘track_post_types’, 10, 2); function track_post_types( $post_type = NULL, $args = array() ) { static $tracked = array(); if ( ‘shutdown’ === current_filter() ) { print ‘<pre>$tracked = ‘ . esc_html( var_export( $tracked, TRUE ) … Read more

Add category attribute to custom shortcode

add_shortcode( ‘faq’, ‘wpse105856_shortcode_callback’ ); function wpse105856_shortcode_callback( $atts ) { extract( shortcode_atts( array( ‘category’ => ” ), $atts ) ); $args = array( ‘numberposts’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘post_type’ => ‘faq’ )); if ( ! empty( $category ) ) { $args[‘category_name’] = $category; } $posts = get_posts( $args ); $faq = ‘<div … Read more

Call custom post type by category

Most likely, your Custom Post Types are using custom taxonomies that happen to be named “Category”. Try something like this: $args = array( ‘post_type’ => $cpt, ‘tax_query’ => array( array( ‘taxonomy’ => ‘[whatever your taxonomy is named], ‘field’ => ‘slug’, ‘terms’ => ‘upcoming-meetings’, ) ) ); $query = new WP_Query( $args ); You may be … Read more