Skip to:
Content
Pages
Categories
Search
Top
Bottom

WP_Query and BP


  • jocics
    Participant

    @jocics

    Hi,
    I read here on forum about issue with BP, WP_Query and queried object,
    but could not see if it’s going to be resolved.

    On BP components, main WP_Query is modified by BP.
    Looks like BP replaces original queried object with BP contents
    (member or group etc.).

    For example, on Members page
    global $post is set as

    WP_Post Object
    (
        [ID] => 0
        [post_author] => 0
        [post_date] => 0
        [post_date_gmt] => 2015-03-19 11:48:56
        [post_content] => 
        [post_title] => Members
        [post_excerpt] => 
        [post_status] => publish
        [comment_status] => closed
        [ping_status] => closed
        [post_password] => 
        [post_name] => members
        [to_ping] => 
        [pinged] => 
        [post_modified] => 2015-03-19 11:48:56
        [post_modified_gmt] => 2015-03-19 11:48:56
        [post_content_filtered] => 
        [post_parent] => 0
        [guid] => http://localhost/bp/?page_id=5
        [menu_order] => 0
        [post_type] => page
        [post_mime_type] => 
        [comment_count] => 0
        [filter] => raw
        [is_404] => 
        [is_page] => 1
        [is_single] => 
        [is_archive] => 
        [is_tax] => 
    )

    Also, global $wp_query is altered
    $wp_query->queried_object_id = 0

    This happens on other pages too,
    like single member page:

    WP_Post Object
    (
        [ID] => 0
        [post_author] => 0
        [post_date] => 0
        [post_date_gmt] => 0
        [post_content] => 
        [post_title] => admin
        [post_excerpt] => 
        [post_status] => publish
        [comment_status] => closed
        [ping_status] => 
        [post_password] => 
        [post_name] => 
        [to_ping] => 
        [pinged] => 
        [post_modified] => 0
        [post_modified_gmt] => 0
        [post_content_filtered] => 
        [post_parent] => 0
        [guid] => 
        [menu_order] => 0
        [post_type] => page
        [post_mime_type] => 
        [comment_count] => 0
        [filter] => raw
        [is_404] => 
        [is_page] => 1
        [is_single] => 
        [is_archive] => 
        [is_tax] => 
    )

    This causes various issues when you want to call actions associated with specific post/page.

    Will this be resolved in future releases?

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

  • shanebp
    Moderator

    @shanebp

    Please use the code button when posting code.

    …when you want to call actions associated with specific post/page

    What are you trying to do with action calls?


    jocics
    Participant

    @jocics

    Sorry about code paste, I wanted to edit post but clicking ‘Edit’ button redirected me to homepage.

    I have theme option to select page where to display some custom post meta,
    so I’m having troubles detecting if user is on specific page and fetching custom field data.


    shanebp
    Moderator

    @shanebp

    You want to detect if they are on a non-BP page?
    Try using

    bp_is_blog_page() 
    return bool True if it's a non-BP page, false otherwise.

    jocics
    Participant

    @jocics

    No, I need page ID of current BP page.
    If I’m using e.g. ‘Our members’ page as BP Member page – I need it’s ID.


    shanebp
    Moderator

    @shanebp


    I need page ID of current BP page

    Which, as you’ve noted, will be 0.
    And don’t expect that to change any time soon, if ever.

    If you want to know which BP page you are on, via a boolean, see:

    Template Tag Reference


    jocics
    Participant

    @jocics

    OK, thank you very much.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP_Query and BP’ is closed to new replies.
Skip to toolbar