This problem has been bugging me for couple of days. After adding a new subnav, I got the following error when trying to use the drop down groups filter:
404 Not Found â mysite.com/wp-admin/admin-ajax.phpâ
Basically I wanted to add a new subnav items under a memberâs main nav âgroupsâ. Currently there are two subnav items there: âmembershipsâ and âinvitationsâ. I would like to add my own subnav item called âMy Customized Groupsâ. When this subnav is clicked, it will show groups of certain feature.
Okay the first step is to create a new subnav items. I did it by adding the following code to my functions.php
//add new subnav items
bp_core_new_subnav_item( array(
'name' => __( 'My Customized Groups', 'buddypress' ),
'slug' => 'my-custom-groups',
'parent_url' => $groups_link,
'parent_slug' => $bp->groups->slug,
'screen_function' => 'groups_screen_my_custom_groups',
'position' => 20
));
To make sure my subnav works, my screen_function âgroups_screen_my_custom_groupsâ is a exactly copy of the default âgroups_screen_my_groupsâ. Now the subnav is added, and groups loop show up correctly. But when I select the drop down filter ( âlast activeâ, âmost membersâ, ânewly createdâ, etc), the following error shows up:
404 Not Found â mysite.com/wp-admin/admin-ajax.phpâ
if I set this new subnav as the default by adding the following code in functions.php
$args = array(
'parent_slug' => $bp->groups->slug,
'screen_function' => 'groups_screen_my_custom_groups',
'subnav_slug' => 'my-custom-groups'
);
bp_core_new_nav_default($args);
Then the ajax works correctly for my-custom-groups, but it doesnât work for other subnav items anymore. It seems ajax only works for the default subnav? This is strange.
It must be something minor, but I still canât figure out whatâs been wrong after searching everywhere for two days.
Thanks in advance for the help.
WordPress version: 3.4.2
buddypress version: 1.6.1
Is i commented previously im having the same error. I dont know what it causing it but i found a workaround for it.
Im using a modified version (by me) of the plugin buddypress-groups-tags which allows me to create categories for groups. That plugin uses bp_core_new_subnav_item to be able to use slugs like : http://local.dev/groups/category/teachers/
My problem was that inside that url in the activity loop, the more link was getting a 404 responde header error on admin-ajax.php. If i check the response content all the activity data was there. So im not sure what is causing the problem.
To solve it i added a function that will return a status header of 200 when the ajax call is triggered. In my case i needed for “get_older_updates” action but i suppose you can use it for any other action defined at /bp-themes/bp-default/_inc/ajax.php:27
Hope it helps!