I have a tech blog, what I want to do is to create an index page for articles in a certain category. For example, I want all the articles under the category “WordPress BasiX” to be arranged in an index (tabled preferably) at one page. Is there a way to do it in wordpress? Help please.
My wordpress version is 3.4.2
Leave a Reply
You must be logged in to post a comment.
There several different ways to achieve that: a custom template, a metabox, or a shortcode. In all cases you will probably use
get_posts()
orWP_Query
to fetch the posts and some method to set the category. The following sample code illustrates that with a shortcode.Basic usage
You just write the shortcode in your post editor on a page or a blog post:
The code
In a plugin you register the shortcode and you create a function to return the output. Be aware that a shortcode always just returns a string, it doesnât use
echo
orprint
.Thatâs very rough; I have just sketched it hastily. You have to register the script name separately if you need some kind of a table sorter (jQuery tablesorter is nice).
To understand the other parameters read the docs for
WP_Query
.To use the excerpt or thumbnail just add â¦
⦠or â¦
⦠where you need it.
For example like this:
The result
In TwentyEleven it looks like this:
The parameters
id
andclass
should offer enough flexibility to adjust the styles. 🙂