amandainjames (@amandainjames)

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • In reply to: change forum sidebar

    amandainjames
    Participant

    @amandainjames

    I think you want to add a custom widget in your theme. You can add custom widget adding this code in functions.php

    function wpblog_widget()
    {
        register_sidebar(array(
            'name' => __('Primary Sidebar', 'wpb'),
            'id' => 'primary_sidebar', // unique-sidebar-id
            'description' => '',
            'class' => '',
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
        ));
    
    }
    
    add_action('widgets_init', 'wpblog_widget');

    Reference: WordPress Custom Widgets


    amandainjames
    Participant

    @amandainjames

    I will suggest you to go through a WordPress custom taxonomy tutorial. Here are three steps to create a custom taxonomies in WordPress. To create a custom taxonomy you have to add this code in functions.php

    add_action( 'init', 'create_cw_hierarchical_taxonomy', 0 );
    //create a custom taxonomy name
    function create_cw_hierarchical_taxonomy() {
    $labels = array(
    'name' => _x( 'Topics', 'taxonomy general name' ),
    'singular_name' => _x( 'Topic', 'taxonomy singular name' ),
    'search_items' => __( 'Search Topics' ),
    'all_items' => __( 'All Topics' ),
    'parent_item' => __( 'Parent Topic' ),
    'parent_item_colon' => __( 'Parent Topic:' ),
    'edit_item' => __( 'Edit Topic' ),
    'update_item' => __( 'Update Topic' ),
    'add_new_item' => __( 'Add New Topic' ),
    'new_item_name' => __( 'New Topic Name' ),
    'menu_name' => __( 'Topics' ),
    );
    // taxonomy register
    register_taxonomy('topics',array('post'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'topic' ),
    ));
    }
Viewing 2 replies - 1 through 2 (of 2 total)