0

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?

1 Answer 1

1

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();
         }
    }
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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