1. Home
  2. Docs
  3. WORDPRESS
  4. REST API
  5. EXAMPLES

EXAMPLES

	$filter = 'per_page=30';
	$fields = '_fields=author,id,excerpt,content,title,_links,featured_media';
	
	$url = "https://physiomed.store/wp-json/wp/v2/posts?$filter&$fields&_embed=wp:featuredmedia";
	
	$json = file_get_contents($url);
	$posts = json_decode($json);
$url = "https://physiomed.store/wp-json/wp/v2/posts/$pid?_embed=wp:featuredmedia,author";

$json  = file_get_contents($url);
$_post = json_decode($json);

$title    = $_post->title->rendered;
$content  = $_post->content->rendered;
$content  = apply_filters( 'the_content', $content );

$alt = $_post->_embedded->{'wp:featuredmedia'}[0]->alt_text;
$src = $_post->_embedded->{'wp:featuredmedia'}[0]->media_details->sizes->full->source_url;

$author = $_post->_embedded->author[0];