WordPress.org

Ready to get started?Download WordPress

Forums

Conditional Statement to post a widget into a specific page (3 posts)

  1. camzaytie
    Member
    Posted 1 year ago #

    I'm having a trouble with my code.

    Basically, I want a specific widget (Sidebar) to appear in a specific page and a widget that will appear to the rest of the pages except home page.

    <?php if(is_page(4)):?>
    	<?php
            // A series of widgets posted in specific page.
            if ( is_active_sidebar( 'primary-widget-area','about-us','careers','news','contact-us','local' ) ) : ?>
    
                    <div class="side_navigation widget-area" id="secondary" role="complementary">
                        <ul class="parent">
    
                             <?php dynamic_sidebar( 'about-us' ); ?>
    
                             <?php /*?><?php if(is_page(6)):?>
                                <?php dynamic_sidebar( 'services' ); ?>
                             <?php endif;?>
                             <?php if(is_page(8)):?>
                                <?php dynamic_sidebar( 'careers' ); ?>
                             <?php endif;?>
                             <?php if(is_page(10)):?>
                                <?php dynamic_sidebar( 'news' ); ?>
                             <?php endif;?>
                             <?php if(is_page(12)):?>
                                <?php dynamic_sidebar( 'contact-us' ); ?>
                             <?php endif;?>
    
                             <?php if(!is_front_page()):?>
                                <?php dynamic_sidebar( 'local' ); ?>
                             <?php endif;?><?php */?>
                        </ul>
                    </div>
                    <!-- ABOUT US .widget-area -->
    
    <?php endif;?>

    It doesn't let me show :(

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    possibly reconsider the use of is_active_sidebar()

    http://codex.wordpress.org/Function_Reference/is_active_sidebar

    you might need to use:

    if ( is_active_sidebar( 'primary-widget-area' ) || is_active_sidebar( 'about-us' ) || is_active_sidebar( 'careers' ) || is_active_sidebar( 'news' ) || is_active_sidebar( 'contact-us' ) || is_active_sidebar( 'local' ) ) : ?>
  3. camzaytie
    Member
    Posted 1 year ago #

    Thanks for the reply.
    I just used widget logic plug in

Topic Closed

This topic has been closed to new replies.

About this Topic