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 want to use tabs plugin and load tab contents using ajax. The problem is: the plugin requires a solid .php file to be specified in href e.g.

<li><a href="ajax/content3-slow.php">Tab 3 (slow)</a></li>

You know this does not work well with WordPress. A callback here would have worked. Is there such fork available Or any other plugin?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can always use the proper WordPress Ajax API (well not really an api) for example:

<li><a href="url to wp-admin/admin-ajax.php?action=my_ajax_tabs&tab=tab1">Tab 1</a></li>
<li><a href="url to wp-admin/admin-ajax.php?action=my_ajax_tabs&tab=tab2">Tab 2</a></li>

then you create a function that will respond to the ajax calls:

function do_my_tabs(){
    $tab = $_GET['tab'];
    switch ($tab){
    case "tab1":
        echo 'tab1 content';
        break;
    case "tab2":
        echo 'tab2 content';
        break;
    }
    die();
}

and last just hook this function :

//if you want only logged in users to access this function use this hook
add_action('wp_ajax_my_ajax_tabs', 'do_my_tabs');

//if you want none logged in users to access this function use this hook
add_action('wp_ajax_nopriv_my_ajax_tabs', 'do_my_tabs');

//if you want both logged in users and guests to access this function then add both
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.