I have got your blog along with a website, the 2 are seperate things altogether, for instance I've
world wide web.domainname.com because the primary site, and also the blog could be at,
world wide web.domainname.com/blog/, it is a wordpress blog, however I'm not going people searching in the WordPress frontend, so I must write a php function that will pull the posts from WordPress to some seperate page around the primary site.
The function i have got to date is the following:
<div id="blogPosts"> <?php require('../path1/path2/wp-blog-header.php'); ?> <?php $posts = get_posts('numberposts=10&order=DESC&orderby=post_title'); foreach ($posts as $post) : start_wp(); ?> <h4 class="blogDate"> <? the_date(); ?> </h4> <hr /> <h5 class="blogTitle"> <? the_title(); ?> </h5> <p class="blogText"> <? the_excerpt() ?> </p> <br /> <?php endforeach; ?> </div>
It'll display the page fine, but it is not posting the posts the page whatsoever, any ideas why it will not work?
first, put this before u include wordpress-blog-header.php
and i believe you're searching wordpress_query not get_posts, if you wish to make use of the loop functions
$the_query = new WP_Query( $args ); while ( $the_query->have_posts() ) : $the_query->the_post(); the_title(); endwhile; wp_reset_postdata();
Just from the quick search I observe that use of
get_posts( $args ) needs
$args to become an assortment with one of these optional values
$args = array( 'numberposts' => 5, 'offset' => 0, 'category' => , 'orderby' => 'post_date', 'order' => 'DESC', 'include' => , 'exclude' => , 'meta_key' => , 'meta_value' => , 'post_type' => 'post', 'post_mime_type' => , 'post_parent' => , 'post_status' => 'publish' );
Are you certain you are receiving the posts? Try dumping you once you fetched them, such as this:
Does the $posts-variable contain anything? Otherwise, you most likely will not obtain the posts, because $wpdb (the database connection class) continues to be undefined.
Next, what goes on whenever you try
<?php echo $post->post_date ?>
<? the_date(); ?>
Maybe wordpress does not understand you're in a loop and because of this the loop-functions (e.g. the_date, the_title, ...) will not work.
tell me if one of these simple things works.