Skip to:
Content
Pages
Categories
Search
Top
Bottom

New tab + it's content from a wp page ..?

  • @jibsoux

    Participant

    hi i want to add a new tab in the bp profile so it work :

    
    function my_setup_nav() {
          global $bp;
          bp_core_new_nav_item( array( 
                'name' => __( 'Invitation', 'buddypress' ), 
                'slug' => 'invitation', 
                'position' => 60,
                'screen_function' => 'my_invitation_template',
          ) );
    }
    add_action( 'bp_setup_nav', 'my_setup_nav' );
    

    So now i have a wp page and i want to load it in the new tab how i can do that ?

    Or simply how can i add a link on the new tab button ?

    Thanks in advance !

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

    Participant

    I found how to redirect to the page using screen_function but i want to load the content in the tab :p

    Tx a lot anyone who help !

    @shanebp

    Moderator

    It can be rather complex.
    And you don’t want to call a whole WP page into that area.
    You only want part of that page, probably the_content.
    The easiest way is to simply put your markup up in a function…

    function my_invitation_template() {
      add_action( 'bp_template_content', 'my_invitation_template_content' );
      bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function my_invitation_template_content() {
      echo "put content here";
    }

    To call a custom template, do a search for bp_get_template_part.
    More info:
    https://codex.buddypress.org/plugindev/how-to-enjoy-bp-theme-compat-in-plugins/

    @jibsoux

    Participant

    Thanks i will try that with but with your solution i cant call the content, but simply echo somthing ?

    If i have a wp page that use the default template the slug of this page is /invitation/ i can grab only the content of that page to load it in the new tab in bp profile ?

    @shanebp

    Moderator

    >Thanks i will try that with but with your solution i cant call the content, but simply echo somthing ?

    Correct.

    >If i have a wp page that use the default template the slug of this page is /invitation/ i can grab only the content of that page to load it in the new tab in bp profile ?

    Use get_post

    @jibsoux

    Participant

    Okey so simply ? in the function that is call on tab click i use Get_post or else to grab only the content of a page i want ?

    Thanks i will try that and get back here 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘New tab + it's content from a wp page ..?’ is closed to new replies.
Skip to toolbar