Solution 1 :

If you want to remove specific divs from source code, get all the div's which has class twp-ticket and pin.slick-slide nested inside postid-30134, loop over it and remove the div.

document.querySelectorAll('.postid-30134 .twp-ticket-pin.slick-slide')
  .forEach(div => div.remove());
<div class="postid-30134">
  <div class="twp-ticket-pin slick-slide">Div One</div>
  <div class="twp-ticket-pin slick-slide">Div Two</div>
  <div>Do not remove</div>
</div>

Problem :

WordPress: Removing DIV Classes / Visibly & in code from certain pages

I am trying to limit the number of outbound links in the HTML source code on certain pages. I know I can visibly hide various elements like this:

.postid-30134 .twp-ticket-pin.slick-slide  {
  display: none;
}

But all the hidden parts are still in the source code – including say for instance theme elements with loads of outbound links.

How do I “clean the code” – and basically “remove” the div tags instead of hiding them?

Comments

Comment posted by user1533312

I tried adding: – if ( $(element).css(‘display’) == ‘none’ ){ $(element).remove(); } To the end of main.js … to no avail

Comment posted by user1533312

Thank you very much for looking at it. document.querySelectorAll(‘.postid-30134 .twp-ticket-pin.slick-slide’) .forEach(div => div.remove()); Where exactly do I insert the above? I tried randomly dumping it to the themes .js file. And do I simply reproduce it endlessly for all posts / div classes or can I “bulk” do it in one command?

Comment posted by random

In the

By