Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Bytelab

    (@bytelab)

    Success! I have found a solution using get_the_ID() …

    add_action('pre_get_posts','exclude_cat');
    function exclude_cat( $query ) {
            if ( get_the_ID() == '113' ) {
    		$tax_query = $query->get( 'tax_query' ) ?: array();
    		$tax_query[] = array(
    			'taxonomy' => 'st_category',
    			'field'    => 'id',
    			'terms'    => array( 115 ),
    			'operator' => 'NOT IN',
    		);
    		$query->set( 'tax_query', $tax_query );
    	}
    	return $query;
    }

    Thanks again 😀

    • This reply was modified 9 years, 4 months ago by Bytelab.
    • This reply was modified 9 years, 4 months ago by Bytelab.
    Thread Starter Bytelab

    (@bytelab)

    Hi buntegiraffe – thanks so much.

    I have tried the following based on your suggestion but again it just renders the function seemingly obsolete and shows all posts again rather than excluding those with the post_type category id of 115.

    add_action('pre_get_posts','exclude_cat');
    
    function exclude_cat( $query ) {
            if($query->query_vars['page_id'] == 113) {
    		$tax_query = $query->get( 'tax_query' ) ?: array();
    		$tax_query[] = array(
    			'taxonomy' => 'st_category',
    			'field'    => 'id',
    			'terms'    => array( 115 ),
    			'operator' => 'NOT IN',
    		);
    		$query->set( 'tax_query', $tax_query );
    	}
    	return $query;
    }

    I am really lost as to why this is happening… no doubt something simple though.
    If you have any further ideas I will be very grateful.

    Thanks!

    Hi there,

    This is half way to solving my problem so thank you very much for sharing.

    I can only get this code to work if I remove the <if> statements. I need them otherwise the function is applied to all pages in the site, not just the home page.

    I have a static front page configured.

    This is the code I have been trying to use:

    add_action('pre_get_posts','exclude_cat');
    function exclude_cat( $query ) {
    	if ( !is_admin() && $query->is_main_query() ) {
    		$tax_query = $query->get( 'tax_query' ) ?: array();
    		$tax_query[] = array(
    			'taxonomy' => 'st_category',
    			'field'    => 'id',
    			'terms'    => array( 115 ),
    			'operator' => 'NOT IN',
    		);
    		$query->set( 'tax_query', $tax_query );
    	}
    	return $query;
    }

    I have also tried the following <if> statements with no success:

    if( $query->is_page( array( 113, 'portfolio', 'Portfolio' ) ) ) {
    if( $query->is_home() ) {
    if( $query->is_front_page() ) {

    It works perfectly without the <if> statements! What is going on?

    Please help if you can – thank you!

    Thread Starter Bytelab

    (@bytelab)

    That’s it! Thank you, Bill. Very much appreciated.

    Thread Starter Bytelab

    (@bytelab)

    Hi Bill,

    Thanks for your reply. The short code I am using is :

    [display-posts post_type=”st_project” category=”wastelands” include_excerpt=”true” image_size=”full” wrapper=”div”]

    I have also tried :

    [display-posts post_type=”st_project” tag=”wastelands” include_excerpt=”true” image_size=”full” wrapper=”div”]

    If I remove the category / tag reference then it lists every project. But I can’t get it to selectively show only items based on the category or tag.

    Very best,
    Hannah

    Thread Starter Bytelab

    (@bytelab)

    Thread Starter Bytelab

    (@bytelab)

    I managed to fix this by deactivating it, renaming the plugin folder on the server, logging out, logging in, renaming the folder to the original name & reactivating.

    The change to the location of the scripts and styles from wp_head to the wp_footer eg:

    add_action(‘wp_footer’,’photo_galleria_scripts_head’);

    makes the HTML invalid since you should not have a <style> tag in the body.

    Is there a working update to solve this yet? I have tried this (latest version) in many themes and it breaks all of them in IE.

    Sooo frustrating as it is exactly what i need – a great little plugin!!!

    I have the same issue and have tested in a variety of themes – it breaks all of them in IE – a solution to this would be great… its so nice and simple to look at. In the mean time does anyone know of any similar styled plugins?

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