You’d need to use something like:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'orderby' => 'title',
'paged' => $paged
);
query_posts($args);
?>
in your theme’s category template.
http://codex.ww.wp.xz.cn/Function_Reference/query_posts#Orderby_Parameters
(And thank you – although Mother’s Day was almost 2 months ago for some of us…)
Thanks for your help, time to go study the codex!
Another solution, for those who like me have limited coding knowledge, is the plug-in WP Post Sorting.
http://ww.wp.xz.cn/extend/plugins/wp-post-sorting/
Moderator
t-p
(@t-p)
Hi esmi,
You’d need to use something like:… in your theme’s category template.
In WP default theme, which file that would be?
I would like to implement this (i was searching for something like this!).
Thanks esmi.
In the default theme, copy archive.php and name the new file category.php. Then add your new custom query to this new file.
Moderator
t-p
(@t-p)
Thanks esmi,
I copied archive.php and named it category.php
I do not know where exactly to place this code in the category.php
I tried placing your code below this line but it did not do the trick
<?php if (have_posts()) : ?>
please guide. thanks esmi.
Hi ESMI
would be glad if you can help me out,
<?php
// Plugin Name: test test test
?>
<?php
function create_table()
{
global $wpdb;
$table_name = $wpdb->prefix."test";
if($wpdb->get_var("show tables like '$table_name'") != $table_name){
$myquery = "CREATE TABLE ".$table_name." (
ID mediumint(10) NOT NULL AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
UNIQUE KEY ID (ID)
);";
require_once(ABSPATH. '/wp-admin/includes/upgrade.php');
dbDelta($myquery);
}
}
register_activation_hook( _FILE_,'create_table');
?>
I can activate this plugin, but it does not create a table at all,
When activate this plugin “register_activation_hook( _FILE_,’create_table’);” should call create_table, isn’t it?
@khiangte: Don’t highjack another poster’s thread. Please post a new topic.
@t-p: Try adding it just before the start of the Loop.
Moderator
t-p
(@t-p)
Thanks esmi,
Try adding it just before the start of the Loop.
please pardon me for my ignorance of the subject. Where is the start of the loop?
I tried placing immediately before and after
<?php if (have_posts()) : ?>
I still see posts exactly as in their default state.
Thanks again esmi.
Edit: regardless if place the code before or after <?php if (have_posts()) : ?>, these are the results:
1. posts show up with title and all the contents
2. posts are indexed from Z-A instead of A-Z.
Moderator
t-p
(@t-p)
Hi esmi,
I played around with it little bit more.
I added ‘order’=> ‘ASC’, to your code.
And if I place the code before <?php if (have_posts()) : ?>
I see all post in ascending alphabetic order.
But i still cannot figure out how to get the post with their title ONLY. The it is now, the entire post is listed along with the title. But I would like to see only the title.
please guide. Thanks esmi.
Remove <?php the_content();?> from that template file.
Moderator
t-p
(@t-p)
Thanks esmi.
That worked. Appriciate your help .