This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

How to exclude post_type asides from being displayed?

Resolved 11 replies feature-requestgeneral
10 years ago · Last reply by Andrew Misplon 10 years ago

I tried to figure it out via the query post link you give but its above my head.
You can see in the link below that the 2 posts that are post_type aides don’t have a title or an image so I’d like to exclude them.

URL: http://pacura.ru/photography/

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

11
  1. Andrew Misplon Staff 10 years, 10 months ago

    Hi Ovidiu

    Please see my answer here: Thread: How to add masonry to my categories?

    Thanks :)

  2. Ovidiu 10 years, 10 months ago

    Sorry Andrew I made a mistake, I didn’t mean to ask about posts and categories but rather about post formats => https://codex.wordpress.org/Post_Formats#Supported_Formats
    Say if I have a category containing psots with different post formats but I only want to show certain one or hide certain ones? i.e. there is a psot format: image and one gallery say I only want to show those two formats from a specific category?

  3. Andrew Misplon Staff 10 years, 10 months ago

    Ahh right, got you. I’m not sure that’ll be possible in the widget. In theory it should be. Here is a little on how that might be done in a conventional query argument:

    https://codex.wordpress.org/Class_Reference/WP_Query

    See: Nested Taxonomy Handling.

    A more manual way of excluding specific posts might be to use:

    p=-1,-2
    

    Where 1 and 2 are the post ID’s we are hiding. We could do the same with categories:

    cat=-1,-2
    
  4. Ovidiu 10 years, 10 months ago

    OK, I get your example above with cat=-1 for example but in a more complex example, say this one (taken from the page you linked to) which part would I copy into that line for the wp query argument, would that be the whole code I posted below?

     $args = array(
    	'post_type' => 'post',
    	'tax_query' => array(
    		'relation' => 'OR',
    		array(
    			'taxonomy' => 'category',
    			'field'    => 'slug',
    			'terms'    => array( 'quotes' ),
    		),
    		array(
    			'taxonomy' => 'post_format',
    			'field'    => 'slug',
    			'terms'    => array( 'post-format-quote' ),
    		),
    	),
    );
  5. Andrew Misplon Staff 10 years, 9 months ago

    Hi Ovidiu, so sorry about the delay. I wasn’t checking my forum priority lists properly and missed your reply. My bad!

    Our new Post Loop widget has a query builder, making this much easier. Try this.

    Add a Post Loop widget.
    Click Build Posts Query.
    In the Taxonomies field search for “image”. In this example, if you have posts saved as Post Format: Image you should see a result as follows: “post_format: image”. Choose that.
    Your query will now only display posts with the format “image”.
    Next you could use the Taxonomies field again and search for a category. You can keep adding onto on the query.
    You can also use the Additional field at the bottom to manually exclude a category.

    Hopefully this gets you going.

  6. Ovidiu 10 years, 9 months ago

    Thanks, the new query builder is ingenious, there is just one thing that could be better:

    say I select post_format: image in taxonomies field then wan to add 1 specific post by selecting it, that narrows it down because by default its an AND selection.

    say I select post_format: image in taxonomies field then add a second taxonomy again it gets narrowed town as its an AND selecttion.

    This tool would be so much more powerful if we could select between AND / OR relations between the criteria we can select via the query builder.

    i.e. add 1 specic post select OR and select a category, meaning I get the full category + the one post

    or alternatively
    select 2 categories and put OR between them so I get both

    Do you think this is doable maybe in a future version?

  7. Andrew Misplon Staff 10 years, 9 months ago

    Hi Ovidiu, thanks for the feedback, it’s how we improve things. Let me chat to Greg about this tomorrow and come back to you. I can definitely see the use case for building a query as you’ve described. In the short term I think it’ll be a limitation of the query builder. We’ll chat on our side tomorrow, look at what’s possible and come back to you with some feedback :)

  8. Ovidiu 10 years, 9 months ago

    Cool, thanks for considering, it would be quite an improvement.
    Btw. here’s a similar query builder, just to give you some ideas.

  9. Andrew Misplon Staff 10 years, 9 months ago

    Thanks again for your feedback on this. I’ve passed it onto Greg. For the moment we’ve marked this as a feature request.

    Could you perhaps let me know the name of the plugin you tried. The link unfortunately didn’t come through.

    Thanks :)

  10. Ovidiu 10 years, 9 months ago

    oh, no idea why the link is missing but its called Query Wrangler https://wordpress.org/plugins/query-wrangler/

  11. Andrew Misplon Staff 10 years, 9 months ago

    Super, thanks for sharing that with us. We’ll take a look.

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread