Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Why Doesnt meta_value_num Work For Me! WordPress

  • REFUNDED

Ive Tried to Arrange My Posts in the Category Using this Query

query_posts('orderby=meta_value_num&cat='.$cat);
But It Doesnt Work,Ive Tried orderby=title it worked Just Wondering Why meta_value_num doesnt work, I Checked wp-includes/query.php


Anyone Answer Anyone? Prize Money 20$

Answers (4)

2011-01-09

Pippin Williamson answers:

Here you go. This is a really sweet plugin that allows you to choose the order of your posts through a drag and drop ajax interface. It's a premium plugin, but only $6.

[[LINK href="http://codecanyon.net/item/reorder-reorder-posts-and-pages/112877?ref=mordauk"]]http://codecanyon.net/item/reorder-reorder-posts-and-pages/112877[[/LINK]]


Marvin Shaker comments:

i dont want to do it manually, i want it to be automatic + if the plugin is deactivated i have to reorder them again


Pippin Williamson comments:

Since none of the answers given so far work, you'll have to do it with [[LINK href="http://kovshenin.com/archives/customize-posts-order-in-wordpress-via-custom-fields/"]]Custom Fields[[/LINK]]

2011-01-09

Monster Coder answers:

Hello,
There is no way to do it without plugins. However the following plugin provides some preset to order on. You may check it too:
[[LINK href="http://hungrycoder.xenexbd.com/scripts/wordpress-blogpost-reorder.html"]WordPress Blog Reorder[[/LINK]]


Marvin Shaker comments:

Hello The Plugin You Mentioned Shows all My Posts Which is Around 14,000 So Loading that many Posts Will Take a Long time, So I Cant Use it, If Someone Has Any Other Solutions Please Tell Me!

2011-01-09

Sébastien | French WordpressDesigner answers:

<?php

//The Query
query_posts('orderby=title');

//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();


Marvin Shaker comments:

That Wont Work, That Would Order According to title which Will Not Make any Changes


Sébastien | French WordpressDesigner comments:

??
If your titles are

Family Guy Episode 15
Family Guy Episode 13
Family Guy Episode 14
Family Guy Episode 16

with this code your title are ordered and will be

Family Guy Episode 16
Family Guy Episode 15
Family Guy Episode 14
Family Guy Episode 13

Have you try ?


Sébastien | French WordpressDesigner comments:

here is the normal order (by date) :[[LINK href="http://demo.archiparmentier.com/category/test2"]]http://demo.archiparmentier.com/category/test2
[[/LINK]]
and here is the result with my code :[[LINK href="http://demo.archiparmentier.com/category/test2"]]http://demo.archiparmentier.com/category/test[[/LINK]]

With this query your title are classified by title in the alphabetical order (asc or desc)
So if you have this posts :

Breaking Bad episode 8
Dexter episode 5
Breaking Bad episode 2
Dexter episode 9
Breaking Bad episode 4
Dexter episode 3



the return will be :

Breaking Bad episode 2
Breaking Bad episode 4
Breaking Bad episode 8
Dexter episode 3
Dexter episode 5
Dexter episode 9


Is it not what you want ?



Marvin Shaker comments:

i looked at the demos it doesnt work

i was them to be ordered numerically not alphabetically


Marvin Shaker comments:

Lets Say Your Code Works How Can I Make it Work in the Category.php template


Sébastien | French WordpressDesigner comments:

add

query_posts('orderby=title&cat='.$cat);



before
if ( have_posts() ) : while ( have_posts() ) : the_post();


Marvin Shaker comments:

That Did not Work
Heres the URL - http://anime-exceed.net/prince-of-tennis/


Sébastien | French WordpressDesigner comments:

you must use
episode 09
not
episode 9

paste the code of your category.php if that doesn't work in your site


Marvin Shaker comments:

Sorry I Cant Change, 9 to 09 that will be a pain, If Anyone Manages to Solve this I WIll Pay 20$


Sébastien | French WordpressDesigner comments:

you can go to your phpmyadmin and use a code for replace each "episode 9" by "episode 09";
Paste this code in the tab "sql"
UPDATE wp_posts SET post_title = replace(post_title, 'episode 9', 'episode 09');

and after the same think with episode 1, episode 2... episode 8


Marvin Shaker comments:

What If I Have Over 600 Episodes What Will I do then?

Im Not Going to Spend Hours ReWriting Every Title

I Will Have to Change 10 to 010
2 to 002
I Will Have to do 600 steps


What About query_posts('orderby=meta_value_num&cat='.$cat);

That Doesnt Work For Me Why?


Sébastien | French WordpressDesigner comments:

if you have 60 episodes or if you have 6 000 000 episodes that's the same thing
you must just use this code for replace
episode 1 by episode 01
episode 2 by episode 02
episode 3 by episode 03
episode 4 by episode 04
episode 5 by episode 05
episode 6 by episode 06
episode 7 by episode 07
episode 8 by episode 08
episode 9 by episode 09


Sébastien | French WordpressDesigner comments:

for your new problem you must add the meta key
uery_posts('meta_key=my_mea_key&orderby=meta_value_num&cat='.$cat);


Sébastien | French WordpressDesigner comments:

and the order :

query_posts('meta_key=my_mea_key&orderby=meta_value_num&order=ASC&cat='.$cat);


Marvin Shaker comments:

Hey Philip, Its the same problem, not a new one, what does the meta_key do?

Your the Winner Anyways Since your the only one replying.


Sébastien | French WordpressDesigner comments:

I'm Sebastien, not Philippe.

I said "new problem" because your question is now about meta_value_num
or the first probelm have a solution : the code i have write above.

So if you want use the meta_value_num, you must use meta_key to specify the name of the field which contain the numeric value


Marvin Shaker comments:

Sorry Philippe, Oops Sebastien,
meta_value_num is part of the ordering posts,
What About Google? Wont this Affect my Searches? Like im on the top of the list for Dragon Crisis Episode 3 and the 2nd top for Dragon crisis Episode 2.

2011-01-09

philip answers:

If you don't want a plugin, it may be doable through the template:

http://codex.wordpress.org/Function_Reference/query_posts#Orderby_Parameters

Your categories and naming conventions would need to be in good order. If not with 14,000 posts your DB skills may need exercising!

Good luck!


Marvin Shaker comments:

I Got the Above Mentioned Plugins, It Took forever to load, and how can I Use this

meta_value_num