Okay.
I was hoping that someone else would drop in because Iām not an expert at all on PHP or WordPress templates. It looks like itās just me.
Thatās great to see the JavaScript, but I donāt think this issue goes beyond PHP and HTML/CSS.
It looks like you are approaching this by checking for the home page and adding the div there.
<?php
if (is_home()) { ?>
<div class="nk-trending"> </div>
<?php } ?>
Then, my next thought is about the class, nk-trending
. That class is not in the stylesheet and also has nothing to do with the elements you are trying to remove on everything but the homepage. It is the <ul>
with a class of sections-wrapper
that you want to inject on your home page.
<ul class="sections-wrapper"> <!-- HIDE ME, not nk-trending -->
<div><span><div style=" color:#fff; font-size: 17px; " class="kittab tablink"> <li id="tabs2""> <span class="a active"><div class="sections-wrapper">
<input id="tabs-2" class="posts-section-link trending-posts-input" type="radio" name="tabs" checked="">
<label for="tabs-2"> TRENDING POST </label></span></li></div> </span>
<div class="kittab tablink"><li id="tabs1" "> <span class="b"> <input id="tabs-1" class="posts-section-link latest-posts-input" type="radio" name="tabs">
<label for="tabs-1">LATEST POST<span class="new-label">new</span></label></span> </li></div></div>
</ul> </div> </div> </div>
It may only work to adjust the PHP to remove the sections-wrapper
by changing its class when the visitor is not on the home page:
<?php
if (!is_home()) { ?>
preg_replace('#<div class="hidden">(.*?)</div>#', ' ', $incoming_data);
<?php } ?>
(I donāt even think this is exactly right, but I do think you can use preg_replace()
to find the class and change it to a new class called hidden
.)
and add in to your CSS files:
.hidden { display:none; }
Again, nk-trending
is nowhere (unless you can show me in that confusing code where it is and what it has to do with sections-wrapper
(the real element container that you want to hide).
I wish I had a more direct answer for you, but WordPress code is nearly impossible to read.
Are you saying that if you corrected some of the validation errors (like the obvious āā typos and stuff) that the scripts would not allow it to work or something? I know nothing about WordPress, but I know why it would make sense for people to use a CMS.