Title: Hide section with post widget
Last modified: December 21, 2020

---

# Hide section with post widget

 *  Resolved [gsibert](https://wordpress.org/support/users/gsibert/)
 * (@gsibert)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/hide-section-with-post-widget/)
 * Hello,
 * I’m trying to hide a section on a page that contains a post widget for a CPT 
   when that widget has no results for the posts it fetches.
 * I figured between this and Dynamic Conditions I’d be able to get it working but
   haven’t figured out the recipe yet.
 * The post widget gets posts from the CPT when the posts taxonomy name matches 
   the page title. For example, the page is Alabama and it pulls all the CPTs that
   have the taxonomy Alabama. However there are states (in this example) that don’t
   have any associated posts so I’d like to hide the section and display a different
   section.
 * I was thinking the NumberPostsQuery might do the trick but not sure how to set
   it and if it can have a variable. So:
 * posttype: nonprofit
    taxonomy: nonprofit_state taxonomy field: name term: get_the_title()
 * Guidance appreciated.
    -  This topic was modified 5 years, 3 months ago by [gsibert](https://wordpress.org/support/users/gsibert/).

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

 *  Plugin Author [rtowebsites](https://wordpress.org/support/users/rtowebsites/)
 * (@rtowebsites)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/hide-section-with-post-widget/#post-13871619)
 * Hello [@gsibert](https://wordpress.org/support/users/gsibert/)
 * You could use “WidgetContent” as the DynamicTag and check whether the Post widget
   contains Article.
    Like this: [https://ibb.co/482wF5D](https://ibb.co/482wF5D)
 * You can find out the widget ID using the browser’s developer tools:
    [https://ibb.co/jHmcdsv](https://ibb.co/jHmcdsv)
 *  Thread Starter [gsibert](https://wordpress.org/support/users/gsibert/)
 * (@gsibert)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/hide-section-with-post-widget/#post-13878709)
 * Thanks for the tips but I couldn’t get it to work. Ended up making 2 different
   page templates and using conditions to determine what page to show.

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

The topic ‘Hide section with post widget’ is closed to new replies.

 * ![](https://ps.w.org/dynamictags/assets/icon-256x256.jpg?rev=2360854)
 * [DynamicTags](https://wordpress.org/plugins/dynamictags/)
 * [Support Threads](https://wordpress.org/support/plugin/dynamictags/)
 * [Active Topics](https://wordpress.org/support/plugin/dynamictags/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/dynamictags/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/dynamictags/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [gsibert](https://wordpress.org/support/users/gsibert/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/hide-section-with-post-widget/#post-13878709)
 * Status: resolved