//Custom API For Page with custom fields // Custom rest API add_action('rest_api_init', function () { register_rest_route( 'bootscore-child-main/v1', 'home', array( 'methods' => 'GET', 'callback' => 'get_home_content', ) ); }); function get_home_content(){ $id= 8; $siteUrl = site_url(); $introTitle = get_cfc_field('home-banner-data', 'home-banner-title', $id ); $introDesc = get_cfc_field('home-banner-data', 'home-banner-sub-text', $id ); $introUrl = get_cfc_field('home-banner-data', 'home-banner-cta-url', $id ); if($introTitle){ $result['home-intro-title'] = $introTitle; } if($introDesc){ $result['home-intro-desc'] = $introDesc; } if($introUrl){ $result['home-into-url'] = $siteUrl.$introUrl; } return $result; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter