Documentation/Reference
Free

Developer examples

Read saved values, escape output and display public related-post titles.

On this page

Read values in a WordPress template

$value = customfields_get( 'project_title', get_the_ID() );
echo esc_html( (string) $value );

User/term helpers and customfields_get_option() read registered fields for trusted template code. Authorize private data and escape output for its context. Authenticated post REST support is for editing; the plugin does not add a public metadata endpoint.

Display public related-post titles

This PHP template example is for a Related items field whose object kind is Posts. Replace related_projects with its storage name. It excludes private, password-protected and attachment records. It is not a shortcode and does not handle user or term relationships.

$ids = customfields_get( 'related_projects', get_the_ID() );
foreach ( (array) $ids as $id ) {
    if ( ! is_numeric( $id ) ) {
        continue;
    }
    $related = get_post( (int) $id );
    if ( ! $related || 'attachment' === $related->post_type
        || ! is_post_publicly_viewable( $related )
        || ! empty( $related->post_password ) ) {
        continue;
    }
    printf(
        '<a href="%s">%s</a><br>',
        esc_url( get_permalink( $related ) ),
        esc_html( get_the_title( $related ) )
    );
}

Keep permission and output escaping checks when adapting a template. For an authenticated private-content view, review the authorization requirements separately.

Other content locations

Use the registered user, term and site-option helpers for those contexts. The value block and [customfield] shortcode read post fields. Match the registered storage name and pass the correct object; do not expose private values through an unrestricted endpoint.

Read the formatting rules for scalar, choice, media and structured values. Definition import and CLI behavior is documented separately.