Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get the page ID associated with a component


  • Garrett Hyder
    Participant

    @garrett-eclipse

    Hello,

    I found I needed to get the permalink and title for a component so needed to determine the page ID associated with a component.

    Currently there’s no method so I’ve opened a trac ticket;
    https://buddypress.trac.wordpress.org/ticket/7025#ticket

    And you can see how to do this below;

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

    *We simply take the component slug and use it to look up the page ID from the bp-pages option.

    Cheers

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

  • Henry Wright
    Moderator

    @henrywright

    Thanks for sharing, @garrett-eclipse 🙂


    melhergui
    Participant

    @melhergui

    Works like a charm!! Thanks!


    Garrett Hyder
    Participant

    @garrett-eclipse

    Glad it’s still working.

    Looking at the original Trac ticket there is now a bp_core_get_directory_page_id() method for this which takes the $component as a param or defaults to bp_current_component().

    Just wanted to follow-up for others looking to this as a solution… there’s now an official method which is probably more appropriate.

    Cheers

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