Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm building a WordPress options panel.

In my options panel I added the following, this creates a Yes/No dropdown menu asking whether or not the user wants to display breacrumbs - I want to be able to hide (or simply not call) the breadcrumbs when a user selects no:

array( "name" => "Display breadcrumbs on post pages?",
    "desc" => "Choose whether or not to display breadcrumbs, that is, the post trail.",
    "id" => $shortname."_breadcrumbs",
    "type" => "select",
    "options" => array("Yes", "No"),
    "std" => "Yes"),

Normally I would use something like this to call the above function:

<?php echo get_option('to_breadcrumbs'); ?>

But breadcrumbs have their own function, and I call them like so:

<?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?>

One possible solution that could be applied in other uses would be to add a div class with the hide property around the function I am calling when "No" is selected. Any help?

share|improve this question

migrated from stackoverflow.com Sep 29 '11 at 11:01

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

up vote 1 down vote accepted

Why not just check the options before calling dimox_breadcrumbs() like so:

<?php
    // Check if the user wants breadcrumbs, default to "Yes" if no option set
    if(strcmp(get_option("to_breadcrumbs", "Yes"), "Yes") == 0){
         if (function_exists('dimox_breadcrumbs')) {
             dimox_breadcrumbs();
         }
    }
?>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.