How to customize a theme to display adverts based on a category or else PHP logic?


(Madushan) #1

Hi,

I’m using Newspaper 9 theme and polylang plugin to create a magazine.

The website should display adverts based on the language or else category. Is it possible to customize the theme to display adverts based on a category or else using a PHP logic?

Could you please help me out here. I’m familiar with a few MVC frameworks but new to WordPress. And this is really confusing me.

Thank You


(Leland Fiegel) #2

See here, specifically the pll_current_language function: https://polylang.pro/doc/function-reference/

Then here, specifically for the in_category function: https://codex.wordpress.org/Conditional_Tags

So for example, something like:

if ( 'english' === pll_current_language() && in_category( 4 ) ) {

	// Show an ad for English in category ID 4
}

Does that help?