Title: Exclude post using costum fields
Last modified: August 22, 2016

---

# Exclude post using costum fields

 *  Resolved [sjteef](https://wordpress.org/support/users/sjteef/)
 * (@sjteef)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/exclude-post-using-costum-fields/)
 * Hi,
 * is there a way to assign post to the widget by giving it a costum variable? or
   to exclude using this method.
 * Current situation
 *     ```
       <?php
       /**
        * Flexible Posts Widget: Default widget template
        */
   
       // Block direct requests
       if ( !defined('ABSPATH') )
       	die('-1');
   
       echo $before_widget;
   
       if ( !empty($title) )
       	echo $before_title . $title . $after_title;
   
       if( $flexible_posts->have_posts() ):
       ?>
       	<ul class="dpe-flexible-posts">
       	<?php while( $flexible_posts->have_posts() ) : $flexible_posts->the_post(); global $post; ?>
   
       <hr>
   
       <span class="entry-date"><?php echo get_the_date(); ?></span>
   
       			<a href="<?php echo the_permalink(); ?>">
       					<?php the_title(); ?></h4>
       			</a>
   
       	<?php endwhile; ?>
       	</ul><!-- .dpe-flexible-posts -->
       <?php else: // We have no posts ?>
       	<div class="dpe-flexible-posts no-posts">
       		<p><?php _e( 'Geen actuele storingen', 'flexible-posts-widget' ); ?></p>
       	</div>
       <?php
       endif; // End have_posts()
   
       echo $after_widget;
       ```
   
 * [https://wordpress.org/plugins/flexible-posts-widget/](https://wordpress.org/plugins/flexible-posts-widget/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [DaveE](https://wordpress.org/support/users/dpe415/)
 * (@dpe415)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/exclude-post-using-costum-fields/#post-5439055)
 * Hi sjteef,
 * If I understand your question correctly, you’d like to be able to adjust what
   posts are returned based on a a custom post meta key/value? If that is the case,
   there is a filter available on the FPW query: `dpe_fpw_args`. You’d need to adjust
   the query variables to use custom meta values as parameters of the query.
 * The code would look _something_ like this (only an example):
 *     ```
       add_filter( 'dpe_fpw_args', 'fpw_custom_args' );
       function fpw_custom_args( $args ) {
       		$args['meta_key'] = 'my_custom_key';
       		$args['meta_value'] = 'my_custom_value';
       	}
       	return $args;
       }
       ```
   
 * In the future, I’m planning to add another widget specifically for querying by
   custom meta values; but as it stands now, FPW doesn’t support this natively. 
   You’ll have to use the filter and write the parameters yourself.
 * Thanks for using the plugin!
 *  Plugin Author [DaveE](https://wordpress.org/support/users/dpe415/)
 * (@dpe415)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/exclude-post-using-costum-fields/#post-5439056)
 * Forgot to mention that you’d need to add this filter to your theme’s functions.
   php file. Cheers!
 *  Thread Starter [sjteef](https://wordpress.org/support/users/sjteef/)
 * (@sjteef)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/exclude-post-using-costum-fields/#post-5439057)
 * HI, Thanks for the fast responds.
    but i am not a coder. how can ik use the add
   filter?
 * do i need to replace a specific line?
 * Regards stefan from the netherlands.
 *  Plugin Author [DaveE](https://wordpress.org/support/users/dpe415/)
 * (@dpe415)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/exclude-post-using-costum-fields/#post-5439059)
 * Hi Stefan,
 * Unfortunately, it isn’t really easy to explain without some knowledge of code.
   In your situation I’d recommend finding a developer who can help you or trying
   another plugin/option for your situation.
 * Sorry I can’t be more help!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Exclude post using costum fields’ is closed to new replies.

 * ![](https://ps.w.org/flexible-posts-widget/assets/icon-256x256.jpg?rev=984592)
 * [Flexible Posts Widget](https://wordpress.org/plugins/flexible-posts-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/flexible-posts-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/flexible-posts-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/flexible-posts-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/flexible-posts-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/flexible-posts-widget/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [DaveE](https://wordpress.org/support/users/dpe415/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/exclude-post-using-costum-fields/#post-5439059)
 * Status: resolved