Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get the current page URL

  • @theradcoza

    Participant

    I have tried using the following code to get the current URL

    global $wp;
    $current_url = home_url( add_query_arg( $_GET, $wp->request ) );

    $current_url is always null.

    The end goal is to have a banner that depends on a custom field on the member-loop page.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @shanebp

    Moderator

    Try using bp_get_requested_url()

    bp_get_requested_url

    @theradcoza

    Participant

    Thanks for the reply.

    it returns the following URL:

    https://SITE_URL/wp-admin/admin-ajax.php

    the SITE_URL is correct but no slugs. I tried with the user logged out and get the same result.

    @shanebp

    Moderator

    I think the issue is the context of your call; somehow related to an ajax call.
    Are you using a hook?

    @theradcoza

    Participant

    No.

    I’ve tried calling it from bp-custom.php and from members-loop.php but I get the same answer.

    @shanebp

    Moderator

    Try using a function and a hook.
    Your approach probably won’t work in the loop.
    And definitely will not work in bp-custom.

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