Custom Fields
Re-Envisioned
Support General Custom Field available for all posts

  • Creator
    Topic
  • #29525
    Dragan Marian
    Participant

    Hi Guys

    I would like to create a 'master' custom field ( ex. a text area ) that when filled it will be available for all posts, that is to say it will appear at the end of all posts.

    I could just throw the text at the end of the my "content-single.php" post template but I'd like to offer the client the possibility to actually change the text from the backend of the website.

    Would this be possible?

    Thank YOU

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #29528
    Long Nguyen
    Moderator

    Hi Dragan,

    I think you can create a settings page. The get the field value from a settings page and show it for all posts in the post template. Get more details on the documentation https://docs.metabox.io/extensions/mb-settings-page/

    #29529
    Dragan Marian
    Participant

    HI

    Thank you. It works great. I managed to render the my text field at the end of the posts using a settings page.

    $step1 = rwmb_meta( wysiwyg_6ij16pfr8wx, ['object_type' => 'setting'], 'optname' );
    echo $step1;

    However I have trouble displaying my 'Single Image' custom field.

    I tried

    $step2 = rwmb_meta( single_image_wzsxrnm25hl, ['object_type' => 'setting'], 'optname' );
    echo $step2;

    And what it renders is "array" ....

    I have however managed to render my 'single image' custom field when that field is attached to a normal post via:

    $large = rwmb_meta('single_image_wzsxrnm25hl', array('size' => 'large'));
    echo '<img src="' . $large['url'] . '" />';

    but I cannot get it to work when the 'single image' custom field is attached to the 'settings page'

    Thank YOU

    #29533
    Long Nguyen
    Moderator

    Hi,

    You can add the size setting to the second argument like this

    $step2 = rwmb_meta( 'single_image_wzsxrnm25hl', ['object_type' => 'setting', 'size' => 'large'], 'optname' );
    echo '<img src="' . $step2['url'] . '" />';

    Refer to this topic https://metabox.io/support/topic/settings-page-image-output-stuck-in-150x150-configuration/

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