adsense

How to Display Articles in a Wordpress Template





1. Open or create the index.php file for your template. The loop may also be duplicated in the blog.php, page.php and archive.php files inside your template folder. If modifying an active theme, you may also access the template files from inside your Wordpress Administration panel under 'Appearance > Editor.' You should always make a backup prior to modifying active files.
2. Insert the first cose snippet to tell Wordpress to grab the list of articles from the database:


3. Follow this with HTML representing how you want the article block to appear. Your structure should include the article title, the article content and some information about the article such as its publication date and author. Each text or link element will be replaced with a Wordpress template tag. An example of your beginning structure might look like this:

This is the article title


By Author Name, Post Date, in Category

This is where the post content will appear.

4. Replace your mocked-up title text with the title template tag '
' and the title's link with the permalink tag '
'.Your first line should look something like this:

'>


Wordpress will now dynamically send an article's title and full-page URL to the template where these tags appear.
5. Replace the Author Name, Post Date, Category and any other metadata placeholders with their corresponding template tags as defined in the Wordpress Codex.
6. Decide if you want this list of articles to display the entire contents of the post, or just an excerpt. By default, most blog layouts display only an excerpt. Replace your content placeholder text with either of the following template tags, depending on how much information you want displayed:


7. Close your loop by adding the following code below your article layout:




This code ends the query started with your opening statement, and provides a fail-safe in the event no posts are found.

Comments

0 Responses to "How to Display Articles in a Wordpress Template"

Post a Comment

Popular Posts

About