Widget Interfering with Breadcrumb

  • Unknown's avatar

    I have a widget that is interfering with my breadcrumb in that it is causing my breadcrumb to show a path as if it were from a different page. An example, it should be getting the post id from the URL but instead it is hard coded to post_id=4. I noticed that when I changed post_id in my widget, the breadcrumb then reflected that change. I have pasted the code from my widget and from my breadcrumb below. Any ideas on how I can make sure the to do not interfere with one another?

    //**Widget**//
    function load_quick_search()
    {
    register_widget( ‘quick_search’ );
    }
    class quick_search extends WP_Widget
    {
    function quick_search()
    {
    $widget_ops = array( ‘classname’ => ‘quick_search’, ‘description’ => __(‘A box for searches’, ‘quick_search’) );
    $control_ops = array( ‘width’ => 300, ‘height’ => 350, ‘id_base’ => ‘quick_search’ );
    $this->WP_Widget( ‘quick_search’, __(‘Quick Search’, ‘quick_search’), $widget_ops, $control_ops );
    }
    function widget( $args, $instance )
    {
    extract( $args );
    echo $before_widget;

    echo ‘<div class=”qsearch”><p>Career Search:</p>’;
    $my_query = new WP_Query(‘post_type=page&post_parent=4’);
    echo ‘<select id=”searchchoice”><option>Search Category</option>’;

    ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <option value=”<?php the_permalink() ?>”><?php the_title() ?></option> ‘;

    <?php endwhile;
    echo ‘</select>’;
    echo ‘GO</div>’;
    ?>
    //**end widget**//

    //**breadcrumb**//

    $my_query = new WP_Query(‘post_type=page&post_parent=20’);
    $parent_title = get_the_title($post->post_parent);
    echo ‘<div class=”breadcrumb”><a href=”‘;
    echo get_option(‘home’);
    echo ‘”>Home’;

    echo ” » “;
    if(is_page() && $post->post_parent){
    echo (‘post_parent)
    . ‘” title=”‘ . $parent_title . ‘”>’ . $parent_title
    . ‘
    » ‘); }

    //**end breadcrumb**//

    Thanks in advance for any help you can offer.

  • Unknown's avatar

    You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.

    If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.

    This is an automated message.

  • The topic ‘Widget Interfering with Breadcrumb’ is closed to new replies.