• Resolved Chigolo

    (@fitnsexy)


    Hello,

    I have created snippets to supplement my posts with certain information. Is it possible to disable these snippets for individual posts?

    The code looks like this:

    add_action('generate_after_entry_title', function(){
    if(is_single()){
    // Nur in Beitr?gen zu sehen
    echo do_shortcode('Anzeige/Werbung');
    }
    });
    
    add_action('generate_after_entry_title', function(){
    if(is_front_page()){
    // Nur auf übersichtsseiten zu sehen
    echo do_shortcode('Anzeige/Werbung');
    }
    });
    
    add_action('generate_after_entry_title', function(){
    if(is_category()){
    // Nur auf Kategorieseiten
    echo do_shortcode('Anzeige/Werbung');
    }
    });
    
    add_action('generate_after_entry_title', function(){
    if(is_search()){
    // Nur auf Suchseite (Seiten über Editor ausgeschlossen)
    echo do_shortcode('Anzeige/Werbung');
    }
    });

    I would simply like to exclude individual targeted contributions.
    Thx in advance.

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi @fitnsexy,

    You can add an additional check to your if statements that uses is_single to exclude specific posts:

    
    add_action( 'generate_after_entry_title', function () {
    	if ( is_single() && ! is_single( [ 32, 41, 12, 'some-post-name' ] ) ) {
    		// Nur in Beitr?gen zu sehen
    		echo do_shortcode( 'Anzeige/Werbung' );
    	}
    } );
    
    add_action( 'generate_after_entry_title', function () {
    	if ( is_front_page() && ! is_single( [ 32, 41, 12, 'some-post-name' ] ) ) {
    		// Nur auf übersichtsseiten zu sehen
    		echo do_shortcode( 'Anzeige/Werbung' );
    	}
    } );

    Just replace 32, 41, 12, 'some-post-name' in the above snippet with the list of post IDs, names or slugs you want to exclude.

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude snippets from individual posts’ is closed to new replies.