R
R
Ruslan Makarov2016-02-28 13:23:54
WordPress
Ruslan Makarov, 2016-02-28 13:23:54

If there are posts with this ID, then... and if not, then... WordPress, how?

Good day!
Please tell me how to make such a filter in WordPress posts:
if there are posts with such IDs, then show this ad unit, if not, then another one.
In simple words:
In some posts, the place of the adsense block is to show another ad...
Thank you very much in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2016-02-28
@HeadOnFire

Conditional Tags
For example, in single.php where you show ads:

<?php
$page_ids = array( 11, 34, 76, 237 ); // ID постов
if( is_single( $page_ids ) ) {
    // тут показываем рекламу которая нужна на страницах этих постов
} else {
    // тут показываем рекламу для всех остальных постов
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question