0

I have different content on static pages and post in my WP site. On pages is not desirable to view meta in search result, but in my post is important. Meta, I mean information about author, and date in search result.

I have created custom post-search.php. But i dont know, how to show meta information only for post in result. No for showing meta i using this part of code:

        <div class="postmeta-primary">

        <span class="meta_date"><?php the_time($theme->get_option('dateformat')); ?></span>
       &nbsp; <span class="meta_author"><?php the_author(); ?></span>

            <?php if(comments_open( get_the_ID() ))  {
                ?> &nbsp; <span class="meta_comments"><?php comments_popup_link( __( 'No comments', 'themater' ), __( '1 Comment', 'themater' ), __( '% Comments', 'themater' ) ); ?></span><?php
            }?> 

    </div>

I just thinking about some kind of "IF". For example If its_post then execute code (which I post above)

Thanks for your answers

0

You can use this inside the WordPress loop:

if (get_post_type() == 'post') {
 // do something
}
0

Ok i found working solution. Maybye will be helpfull for someone.

 <div class="postmeta-primary">

    <?php if(get_post_type() == 'post'): {

     ?><span class="meta_date"><?php the_time($theme->get_option('dateformat')); ?></span>
       &nbsp; <span class="meta_author"><?php the_author(); ?></span><?php
            }?> 
    <?php endif; ?>


            <?php if(comments_open( get_the_ID() ))  {
                ?> &nbsp; <span class="meta_comments"><?php comments_popup_link( __( 'No comments', 'themater' ), __( '1 Comment', 'themater' ), __( '% Comments', 'themater' ) ); ?></span><?php
            }?> 

    </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.