Skip to:

the_ID = 0

  • haluhe


    Hello everybody,

    I am contributing to Advanced Ads, an ad management plugin, and we recently had a customer who wanted to inject an ad only into the group page. We already did have a solution implemented for displaying ads only on certain pages, however, it did not work for BuddyPress generated pages. When we had a closer look at it, we realized that it did not work simply because of the fact that the id of the page got altered to 0 when BuddyPress was using it.

    When a page is loaded, we check if there are any ads that should be displayed by comparing the current pages ID to the IDs of the content specified by the display conditions the user has set. This does not work for the reason mentioned above.

    Is there a workaround for this issue and if there is none, what is the reason for this behavior?

    WordPress: 4.6.1
    BuddyPress: 2.6.2, 2.7-beta1

Viewing 5 replies - 1 through 5 (of 5 total)

  • shanebp


    The id is zero due to the way BP constructs those pages.
    The how and why is a long answer – you may want to look at the codebase to see the how.

    In any event, you will not be able to change that.
    Your best bet is to add to the display conditions the user has set.


    Give them an option to select the Groups Directory page.
    Then use bp_is_groups_directory() to check if they are on that page.

    Or maybe specific single groups.
    Then check to see if they are on a single group page by using groups_get_current_group().

    So the basic approach is to use template tags to find out where the user is and then show or not show an ad based on the the display conditions the user has set.



    A partial explanation about “why”can be found here:



    $component = bp_current_component();
    $bp_pages = get_option( 'bp-pages' );
    $page_id = $bp_pages[$component];



    Thank you for the fast and useful replies.

    I think we will probably using a solution similar to what shanebp suggested.




    just wanted you to know that we went with modemlooper’s suggestion in the end and everything is working fine right now.

    Thank you for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar