This website uses cookies to remember you and improve your experience. For more info see our Privacy Policy.

  • About
  • Websites
    • Business Websites
    • Author Websites
  • SEO
  • Portfolio
    • Author Web Design
    • Business Web Design
    • Custom Graphics
    • Logos
  • Services & Pricing
    • Author Website Packages
    • Website Hosting
    • Page Speed Optimization
    • SEO
    • Local SEO
  • MyBookTable
    • MyBookTable Support
  • Contact
  • Hire Us

Mobile Menu

  • Menu
  • Skip to right header navigation
  • Skip to main content

Stormhill Media

Custom websites for every type of business

Header Right

  • About
  • Websites
    • Business Websites
    • Author Websites
  • SEO
  • Portfolio
    • Author Web Design
    • Business Web Design
    • Custom Graphics
    • Logos
  • Services & Pricing
    • Author Website Packages
    • Website Hosting
    • Page Speed Optimization
    • SEO
    • Local SEO
  • MyBookTable
    • MyBookTable Support
  • Contact
  • Hire Us

Get Posts

Home » Code Snippets » Get Posts

This is a basic get_posts

<?php $args = array(
    'numberposts'     => 5,
    'offset'          => 0,
    'category'        => 5,
    'orderby'         => 'post_date',
    'order'           => 'DESC',
/*    'include'         => ,
    'exclude'         => ,
    'meta_key'        => ,
    'meta_value'      => ,
*/    'post_type'       => 'post',
/*    'post_mime_type'  => ,
    'post_parent'     => ,
*/    'post_status'     => 'publish' ); ?> 

<?php $newsposts = get_posts( $args ); ?>
<?php foreach($newsposts as $post) : setup_postdata($post); ?>

// normal post tags and content

<?php endforeach; ?>
Next »

Site Footer

Quick Links:

  • Contact Us
  • Pricing & Services
  • Sitemap
  • Terms/Conditions
  • Privacy Policy
  • Business Websites
  • Author Websites
  • SEO Services
(903) 213-5266‬

Copyright © 2026 · Stormhill Media All Rights Reserved.
Website by Stormhill Media
Log in