Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1277950
    JfantasyBooks
    Participant

    Hey there, Themeco Team!

    Name: JFantasyBooks
    Site: Fantasy-Books
    Site Url: https://fantasy-books.live
    WordPress Version: 4.6.1
    X Version: 4.6.4
    Cornerstone Plugin Version: 1.3.3

    Problem:

    Ok! So, I have a shortcode that appears on everypage as I used the php do shortcode.

    Is there a way to make it selective to only posts under a particular category?

    #1278195
    Friech
    Moderator

    Hi There,

    Thanks for writing in! You can use the is_category function.

    e.g.

    <?php if(is_category( 'category-slug' )): ?>
    /*your do_shortcode here*/
    <?php endif; ?>

    Where category-slug is the actual slug of your category or the category ID.

    Hope it helps, Cheers!

    #1278283
    JfantasyBooks
    Participant

    So I have this:

    
    function somefu
    <?php if(is_category( 'category-slug' )): ?>
    
     <div class="x-nav-1">
    	
    	<?php echo do_shortcode('[shortcode]');?> 
    
    </div>
    <?php endif; ?>
    
    }

    But it’s still not appearing. Did I do something wrong? It appears without it the category function, but not with it.

    #1278379
    Rupok
    Member

    Hi there,

    Make sure to replace category-slug with your real category slug, it should work. Make sure other code is also correct; like I am not sure about function somefu

    Thanks!

  • <script> jQuery(function($){ $("#no-reply-1277950 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>