Skip to:

Custom Fields not displaying when editing post

  • Preston


    WordPress Version: 4.0
    bbPress Version: 2.5.4
    Theme: Lightly modified Skeleton (

    I’m using this code: to add custom fields in a specific forum. Everything is working great except for when I try to edit an existing topic. When I try to edit an existing topic, the custom fields aren’t displayed on the page, and therefor aren’t editable. Only the normal Title and Content fields are displayed.

    The issue still happens while using an unmodified Twenty Fourteen theme (besides adding the relevant code to the functions.php file, of course).

    I haven’t had any luck finding out what the problem is, but I’m hoping it’s something simple.

    I appreciate any help!

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

  • Robin W


    At a guess (and I haven’t checked) I’d say that


    works for a new topic, but returns a null when editing, hense your ‘==’ is never fulfilled.

    Since you should have $topic_id set in either case, maybe try something like

    $forum_id = bbp_get_topic_forum_id( $topic_id );

    to get the forum or just use that if editing?

    Have a play and see if that fixes.



    Thanks, I got it figured out as far as text fields keeping content when editing.

    I changed the start of my bbp_applications_fields to the following (in case anyone comes accross this thread):

    function bbp_application_fields() {
    	$forum_id = bbp_get_forum_id();
    	$application_forum_id = 34;
    	$topic_id = bbp_get_topic_id();
    	$topic_edit_id = bbp_get_topic_forum_id( $topic_id );
    	if( $forum_id == $application_forum_id || $topic_edit_id == $application_forum_id ) {

    My select fields still don’t retain their content when editing, but I suspect that’s due to some jQuery I’m using to show/hide certain options based on other select boxes.

    It looks like none of the select fields come back with their saved value, just whatever the starter value is. I’ll keep playing around with it.



    One last follow up for anyone who comes across this later on.

    For the select drop downs on the edit page, I decided to “cheat” with jQuery to make sure the correct value is still selected.

    This is the code in my functions.php file that creates the select input:

    $play_os = get_post_meta( $topic_id, 'bbp_app_character_playos', true);
    echo '<br><label for="bbp_app_character_playos">Select Input Label</label><br>';
    echo '<select id="bbp_app_character_playos" name="bbp_app_character_playos" data-value="' . $play_os . '">
        <option value="Yes" class="os-yes">Yes</option>
        <option value="No" class="os-no">No</option>

    I’m displaying the current value in the data-value attribute so I can use it in the jQuery below:

    function appEditValues(){
        var playOsVal = jQuery('.topic-edit #bbp_app_character_playos').attr('data-value');
        if(playOsVal == "Yes"){
            jQuery('.topic-edit #bbp_app_character_playos').find('.os-yes').attr('selected','selected');
        } else if (playOsVal == "No"){
            jQuery('.topic-edit #bbp_app_character_playos').find('.os-no').attr('selected','selected');

    The jQuery code adds the “selected” attribute to the appropriate option on the edit page, which of course causes that value to be selected and save correctly again when you finish editing.

    Robin W


    great – thanks for posting the solution, so many don’t and it helps anyone coming across this later on. 🙂

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