WordPress.org

Ready to get started?Download WordPress

Forums

the_content and post_type problem (4 posts)

  1. leisegang
    Member
    Posted 1 year ago #

    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');
    ?>
  2. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  3. leisegang
    Member
    Posted 1 year ago #

    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...

  4. vtxyzzy
    Member
    Posted 1 year ago #

    Did declaring $post as global not help?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.