Skip to:
Content
Pages
Categories
Search
Top
Bottom

Shortcode on the page php


  • galiulinr
    Participant

    @galiulinr

    How to make a page conclusion shortcode bbp-single-forum using custom fields?
    I created a custom field ‘idbbp’, found ID single topic.
    On the page posted the following code:

    
    <?php 
        $idbbp = get_post_meta($post->ID, 'idbbp', true);
        $forum_id = bbpress()->current_forum_id = $idbbp;
        echo( bbpress()->shortcodes->display_forum($forum_id));
    ?>
    

    but it does not work for me. Tell me please what I did wrong.

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

  • Robin W
    Moderator

    @robin-w

    Possibly lots of things.

    I appreciate that you English may not be good, but can you explain in more detail what you are trying to do?

    Also

    1. php won’t work in a page without a plugin
    2. there is no shortcode display_forum
    2. normally you’d use

    [bbp-single-forum id=$forum_id]

    in a page and in php you’d use

    echo do_shortcode( ‘[bbp-single-forum id forum id =”5”]‘ );


    galiulinr
    Participant

    @galiulinr

    Hi, Robin!
    I want to replace on the page comment form on the relevant topic in the forum. To do this, on each page I create a custom field in which prescribe ID created threads.
    echo do_shortcode( ‘[bbp-single-forum id forum id =”custom_field”]‘ );
    does not work.


    Robin W
    Moderator

    @robin-w

    sorry but what is the ‘page comment form ‘, where on ‘each page’ are you putting the code, and what is ‘each page’

    I am trying to hep you, but you do need to do a detailed response so that I can help.

    For instance

    ” I go into dashboard and select forums and then edit the xx forum and change the content from … to….”

    or

    ‘I edit the page.php file and in line xxx I add YYY’


    galiulinr
    Participant

    @galiulinr

    I installed the plugin Easy digital downloads that creates custom record types post_type = download. I edited single.php file removed <? Php comments_template ();?> And I want to insert the code to show the theme of the forum bbpress renamed to the new file single-download.php
    In the custom field on the product page I insert ID Forum.


    Robin W
    Moderator

    @robin-w

    ok, well without spending hours recreating your issue, I’d suggest you try

    <?php
     $idbbp = get_post_meta($post->ID, 'idbbp', true);
     $forum_id = bbpress()->current_forum_id = $idbbp;
    $x='[bbp-single-forum id forum id ="'.$forum_id.'"]‘ ;
     echo do_shortcode( $x);
    
    

    galiulinr
    Participant

    @galiulinr

    Oh great, Robin. It works for me. Thank you very much!

    <?php
    $idbbp = get_post_meta($post->ID, 'idbbp', true);
    $forum_id = bbpress()->current_forum_id = $idbbp;
    $x='[bbp-single-topic id ="'.$forum_id.'"]';
    echo do_shortcode($x);
    ?>


    Robin W
    Moderator

    @robin-w

    Great – glad you’re fixed !!

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