Support » Plugin: Flexible Posts Widget » Custom Taxonomy & Term Posts Return "No Posts"

  • Resolved hutothebert


    Hi Dave,

    For some reason, when I select a custom taxonomy that I’ve created, it returns no posts. I’ve also tried with the custom taxonomy created by this plugin:; and nothing shows up there as well.

    I’m currently using the “widget.php” template with no changes to it. Could you please help me work out what might be the issue?

    Thank you in advance. I appreciate that you’re very active in supporting your great plugin!

    This is the functions.php portion for my custom taxonomy/post-type:

    add_action( 'init', 'create_staff_type' );
    function create_staff_type() {
    			'label' => __( 'Staff Type' ),
    			'labels' => array(
    				'edit_item' => __("Edit Staff Type")
    			'rewrite' => array( 'slug' => 'staff-type', 'with_front' => true, 'hierarchical' => true ),
    			'hierarchical' => true,
                'query_var'       => true,
                '_builtin'        => false,
                'paged'           => true,
    			'public' => true
    	register_post_type( 'staff', /* this can be seen at the URL as a parameter and a unique id for the custom post */
    			'labels' => array(
    				'name' => __( 'People','People' ), /* The Label of the custom post */
    				'singular_name' => __( "People" ), /* The Label of the custom post */
    				'name_admin_bar'  => __( "People"),
    				'add_new_item' => __("Add New People")
    			'public' => true,
    			'rewrite' => array('slug' => 'people', 'with_front' => true, 'hierarchical' => true), /* The slug of the custom post */
    			'supports' => array( 'title', 'editor','thumbnail','tags' ), /* enable basic for text editing */
    			'query_var' => true,
              'taxonomies'              => array('staff-type'),
              'can_export'              => true,
              'show_ui'                 => true,    // UI in admin panel
              '_builtin'                => false,   // It's a custom post type, not built in
              'hierarchical'            => true,
              'show_in_menu'            => true,
    		  'has_archive' => true
    	);flush_rewrite_rules( false );
    add_filter('rewrite_rules_array', 'mmp_rewrite_rules');
    function mmp_rewrite_rules($rules) {
        $newRules  = array();
        $newRules['people/%staff-type%/([^/]+)/(.+)/(.+)/?$'] = 'index.php?staff=$matches[3]';
        $newRules['people/%staff-type%/(.+)/?$'] = 'index.php?staff-type=$matches[1]'; 
        return array_merge($newRules, $rules);
    function filter_post_type_link($link, $post)
        if ($post->post_type != 'staff')
            return $link;
        if ($cats = get_the_terms($post->ID, 'staff-type'))
            $link = str_replace('%staff-type%', current( $cats )->slug, $link ); // see custom function defined below
        return $link;
    add_filter('post_type_link', 'filter_post_type_link', 10, 2);

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author DaveE


    Hi hutothebert,

    First, have you made sure to set the post type to Staff or Events (for The Events Calendar) for the widget instance? If you don’t set a post type to one that your taxonomy applies to, it will default to “Posts”.

    If you are setting the correct post type and it is still not working, have you tried getting regular old posts and a regular old category?

    I know for a fact that FPW will work with The Events Calendar. I’ve used it as such. However, it won’t work the way you might expect as the event dates are stored in postmeta values, not in the regular post dates so FPW has no way to properly order them.

    One thing I noticed in your code is that you’re flushing the rewrite rules on init. This is a very, very bad idea as every single page load of your website will flush the rewrite rules. I’m not sure if that is causing the issue or not, but regardless, you should probably adjust that code.

    let me know if any of these suggestions help. Cheers!

    Plugin Author DaveE


    Hi hutothebert,

    Since I haven’t heard back in 2 weeks, I’m going to close this ticket. Please feel free to post again if you have additional questions.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Taxonomy & Term Posts Return "No Posts"’ is closed to new replies.