WordPress.org

Support

Support » How-To and Troubleshooting » the_content and post_type problem

the_content and post_type problem

  • leisegang

    @leisegang

    Trying to add something here. But NOT when the post type is static_block

    I really cant figure out how to show something when the post is NOT static_block,

    The theme i am using is inputting the_content other places and i dont want the image i am trying to add. like 5 places.

    Anyone?

    <?php
     function reklame_under($content) {
     	if (is_singular() && $post->post_type != "static_block" ){
    			   $reklame = '
    				<div style="width:468px; margin:5px auto;">
                                     Trying to add something here. But NOT when the post type is static_block
    				</div>
    				<br/>
    			';
    			   return $content.$reklame;
     	}
    
     	else {
     		return $content;
     		}
     }
     add_filter('the_content', 'reklame_under', '100');
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • vtxyzzy

    @vtxyzzy

    So what is happening with the code you showed?

    Is it always showing the extra content? If so, you might need to declare $post as global.

    leisegang

    @leisegang

    if (is_singular(array( ‘post’, ‘page’,’attachment’, ))){

    is there any way of excluding a post_type in the above line?

    i HAVE to hide static_block post types…

    vtxyzzy

    @vtxyzzy

    Did declaring $post as global not help?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘the_content and post_type problem’ is closed to new replies.