Jump to content

WordPress Archives in PHP


Recommended Posts

I successfully have WordPress on the site that I am currently trying to finish. My whole goal was to display the posts, titles, and dates on my actual page rather than in my WordPress blog. This required two PHP codes. The first one, in the header, looked something like this:

<?php	 // Include Wordpress 	 define('WP_USE_THEMES', false);	 require('./mdblog/wp-load.php');	 query_posts('showposts=5');?>

My first question is: Is it impossible to load an external PHP script in the header? If not, how would I do that? Because the script didn't work for me when I had it as external and tried to include it.Now, the second script.

<?php if (have_posts() ) : while (have_posts()): the_post(); ?>	<!-- Header -->	<div class="blogHead">				<!-- Title -->		<div class="blogTitle">			<span class="blogTitle">				<?php the_title(); ?>			</span>		</div>				<!-- Date -->		<div class="blogDate">			<span class="blogDate">				<?php the_date(); ?>			</span>		</div>	</div>		<!-- Content -->	<div class="blogContent">		<?php the_content(); ?>	</div>	<?php endwhile; ?><?php endif; ?>

Now, I'm not sure if this code is that important to what I am trying to do. I would like the PHP script to find if there are more posts than the five showing (as defined in the first script), and if there are, I want a button that says "Older Posts" at the top and the bottom of the content box so that a user can click that and it takes them to the next 5 most recent posts, and on and on. Obviously there will also be a "Newer Posts" button enabled once you click the Older Posts button.Also, I think it would be good to have an Archive page with a list of every post by the title, sorted by the date it was posted. I think based on what I have and the little bit I've done with PHP before, I can probably do this pretty easily.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...