My index page look like this…
<div id="ad-id">google ad code goes here </div><br />
<div id="post-id">My posts are goes here</div>
I use
get_template_part('index')
in another page template. But I want index’s posts only NOT google ads.
Help me..
Thanks in advance..)
In your
index
template, you’ll want to add a conditional around your Google ad. The subject of that conditional is up to you, and will depend on your exact needs. For instance, if you want it to show on the homepage but not other pages, you can check ifis_home()
. If your needs are more abstract, you can define a global variable and set it as appropriate before yourget_template_part
call, e.g.$GLOBALS['show_ad'] = true;
and then only display the Google ad if that’s true.Edit: Examples
Say you want to show this only on your homepage. Here’s what your index page should look like…
Or, say your needs are more abstract. Here are both pages with a global variable.
index page:
Calling template:
… or…