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?

1 Answer 1


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';
    case "tab2":
        echo 'tab2 content';

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

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.