Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ($url="https://test.wordpress.com/wp-json/wp/v2/posts/".$_GET ['id']) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_URL,$url);
- $result=curl_exec($ch);
- $posts = json_decode($result, true);
- echo "
- <div class='d-flex w-100 justify-content-between'>
- <h2 class='mb-1'>".$posts['title']['rendered']."</h2>
- <small>".date('F j, Y', strtotime($posts['date']))."</small>
- </div>
- <p class='mb-1'>".$posts['content']['rendered']."</p>
- ";
- }
- else {
- $url="https://test.wordpress.com/wp-json/wp/v2/posts?per_page=3";
- foreach ($posts as $post) {
- echo "
- <div class='col-md-4 wow fadeInUp'>
- <div class='about-col'>
- <h2 class='title'>
- <a href='".base_url('pages')."?id=".$post['id']."'>
- <h5 class='mb-1'>".$post['title']['rendered']."</h5>
- <small>".date('F j, Y', strtotime($post['date']))."</small>
- </a>
- </h2>
- ".$post['content']['rendered']."
- </div>
- </div>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement