Thursday, January 27, 2022

[FIXED] Hide content in front page using conditional wordpress

Issue

Currently I am trying to hide a script in my header in some single posts using id and it is working, but I want the script not to be shown in front page, home and pages, I have not been able to get it because the script is still shown in front page, home and pages.

I am doing something wrong?

This is my code, but my script is still displayed on front, home, pages:

<?php if( !is_home() && !is_front_page() && !is_page()  ) : ?>
    <!-- No Script -->
        <?php elseif  (is_single( array( 1, '32438', '10506'  ) ) ) : ?>
        <?php else : ?>
    <script></script>
        <?php endif; ?>

Solution

Does this work?

<?php if( is_home() || is_front_page() || is_page()  ) : ?>
<!-- No Script -->
    <?php elseif  (is_single( array( 1, '32438', '10506'  ) ) ) : ?>
    <?php else : ?>
<script></script>
    <?php endif; ?>


Answered By - CodeChuck

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.