Categorie

Posted on in How-To and Troubleshooting | 0 Comments

How to show elements only in posts on WordPress

How to show elements only in posts on WordPress

If you want to show elements only on your WordPress posts, and not elsewhere (home, pages, categories, etc.), just use the following code:

<?php if( is_single() ) : ?>

<!– YOUR CODE HERE –>

<?php endif; ?>

Here you have the full documentation of is_single() function:

is_single()

If instead you want to show your element / content only on other page types (category, archive, page, etc.), just pick the corresponding function from the list below and use it in place of is_single() in your code:

  • is_page ()
  • is_home()
  • is_tag()
  • is_search()
  • is_archive()
  • is_category()
  • is_front_page()

Finally, if you want to show your element / code for all the page types DIFFERENT from a specific one, just place a ! before the corresponding function:

<?php if( !is_single() ) : ?>

<!– YOUR CODE HERE –>

<?php endif; ?>

0 Comments

Post a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Indica su quali commenti vuoi essere aggiornato via email.

Pin It on Pinterest

Shares

Condividi / Share: