Posted By

mejamiewilson on 09/15/11


Tagged

image wordpress widget featured


Versions (?)

Using Pages in Wordpress to power Widgets


 / Published in: PHP
 

Using the ID of a page, you can get the content, the featured image and the title to power widgets in your template.

  1. <?php
  2.  
  3. //Use the Page Id
  4. $page_data = get_page(86);
  5.  
  6. $title = $page_data->post_title;
  7. $content = apply_filters('the_content', $page_data->post_content);
  8. $image = get_the_post_thumbnail($page_id);
  9. $link = preg_replace("/[^A-Za-z0-9]/","",$title);
  10.  
  11. echo '<a name="'.$link.'"></a>';
  12. echo '<h3>'.$title.'</h3>';
  13. echo $content;
  14. echo '<a href="'.get_option('siteurl').'/services/enquire?service='.$link.'">Enquire</a>';
  15.  
  16. ?>

Report this snippet  

You need to login to post a comment.