homemrobo
Forum Replies Created
-
Forum: Plugins
In reply to: [WP-PageNavi] [Plugin: WP-PageNavi] Wp page navi on custom post type pageFor those who have 404 problems with a custom post type indexing template, try to set ‘with_front’ to true:
'rewrite' => array( 'slug' => 'portfolio', 'with_front' => true),Forum: Fixing WordPress
In reply to: Expert help pls – WP upgraded to 3.1 RC5 developmental versionsame here, do you install ussing that one-click install on fantastico?
Forum: Fixing WordPress
In reply to: its possible to swicth the wp_query on category.php?Hey Mark! Thanks dude, your code works fine on a new WP install.. Maybe that database was corrupted, I really don’t know. I ended up doing this, now I can toggle the order using a meta_value and works fine:
<?php get_header(); $cat_obj = $wp_query->get_queried_object(); $querycatID = $cat_obj->term_id; //toggle link $neworder = ($order == 'asc') ? 'desc' : 'asc'; ?> <a href="?order=<?php echo $neworder; ?>">swap order</a> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; if (isset($order)){ query_posts('cat='.$querycatID.'&paged='.$paged.'&meta_key=Valor&orderby=meta_value_num&order='.$order); }else{ query_posts('cat='.$querycatID.'&paged='.$paged); } // the loop if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <!-- Do some ninja tricks here... --> <?php endwhile; endif; get_footer(); ?>Thanks again dude!
Forum: Fixing WordPress
In reply to: its possible to swicth the wp_query on category.php?How can I check if the problem is on the database Mark? Maybe mysql is not working properly.. I’ll try from scratch, again, building a new wp, after that I post here the results.
Forum: Fixing WordPress
In reply to: its possible to swicth the wp_query on category.php?Hey Mark.. don’t work. I always get this order of posts:
test 2
order test
test 1
z test
new testForum: Fixing WordPress
In reply to: its possible to swicth the wp_query on category.php?Hi Mark, thanks for your time.. here I go, this works:
<?php // category.php get_header(); $sidecat_id =4; // grab which order we want from the link order $get_order = isset($_GET["order"]) ? $_GET["order"] : NULL; // toggle neworder if oldorder is not null if (!is_null($get_order)){ $neworder = $get_order ? 0 : 1; } ?> <!-- this is the magical swap link --> <a href="?order=<?php echo $neworder; ?>">toggle</a> <?php // if get_order is set, we have a new order for this loop, using add_filter if (isset($get_order)) { // if neworder is 1, ASC, else DESC if ($neworder == 1){ query_posts( array_merge( $wp_query->query, array( 'posts_per_page' => 10) ) ); }else{ query_posts( array_merge( $wp_query->query, array( 'posts_per_page' => 1) ) ); } } // the category query, yes, paged, please //$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //query_posts($query_string .'&paged='.$paged.'&cat='.$cat_ID); // the loop if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> <?php endwhile; endif; ?>But when I try to swap order of the titles, nothing happens, I still got all posts ordered by date, like default category.php does:
if (isset($get_order)) { // if neworder is 1, ASC, else DESC if ($neworder == 1){ query_posts( array_merge( $wp_query->query, array( 'orderby' => 'title', 'order' => 'asc') ) ); }else{ query_posts( array_merge( $wp_query->query, array( 'orderby' => 'title', 'order' => 'desc') ) ); } }Note: I remove this code from functions.php:
add_action( 'parse_query', 'category_posts_per_page', 10, 1 ); function category_posts_per_page( $q_obj ) { if( is_category() ) $q_obj->query_vars['posts_per_page'] = 2; // Example value }🙁
Forum: Fixing WordPress
In reply to: its possible to swicth the wp_query on category.php?Hi Mark, the problem is, I try almost every possible way to get query_posts working and nothing…
I try to merge, I try other ways I try a similar approach like your code, but I’m not using that get_template_part stuff. I should delete some files of the theme? I remove all functions of that functions.php theme. I delete loop.php and start from scratch. Everything is fine, only this category page that breaks. That code above is my current category page.
I just want a clean category page and a link to toggle the order of the posts…
The only way to get this toggle working is using that filter. But in future I’ll need to order by custom field too (I’m almost crying right now to make more weird filters for custom fields with posts per page and pagination).
The problem is on the “category.php” file? I still dont get it… I have to use that get_template_part now?
Forum: Fixing WordPress
In reply to: Pagination in custom query for category.php not workingHi guys, just to say thanks. I got a similar script with a custom pagination and custom order in the category.php, maybe this can help others:
[resolved] its possible to swicth the wp_query on category.php?
@mark/t31os, why I cannot put “order” and “orderby” to work with query_posts? I don’t get it.
Forum: Fixing WordPress
In reply to: its possible to swicth the wp_query on category.php?Finally:
<?php // category.php get_header(); // get the category ID $cat_obj = $wp_query->get_queried_object(); $cat_ID = $cat_obj->term_id; // grab which order we want from the link order $get_order = isset($_GET["order"]) ? $_GET["order"] : NULL; // toggle neworder if oldorder is not null if (!is_null($get_order)){ $neworder = $get_order ? 0 : 1; } ?> <!-- this is the magical swap link --> <a href="?order=<?php echo $neworder; ?>">Swap order</a> <?php // if get_order is set, we have a new order for this loop, using add_filter if (isset($get_order)) { // if neworder is 1, ASC, else DESC if ($neworder == 1){ add_filter('posts_orderby', create_function('$a',' return " wp_posts.post_title ASC"; ')); }else{ add_filter('posts_orderby', create_function('$a',' return " wp_posts.post_title DESC"; ')); } } // the category query, yes, paged, please $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts($query_string .'&paged='.$paged.'&cat='.$cat_ID); // the loop if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <!-- Do some ninja tricks here... --> <?php endwhile; endif; ?>Some facts:
– you gonna get some ugly urls: /page/3/?order=1
– Didn’t reset the query before or after the loop
– I’m using WP 3.0.1
– This is the category.php from Twenty Ten 1.1 theme
– But I’m not using get_template_part or any Twenty Ten functions
– Works fine with WP-PageNavi 2.73, but you need this code on functions.php:add_action( 'parse_query', 'category_posts_per_page', 10, 1 ); function category_posts_per_page( $q_obj ) { if( is_category() ) $q_obj->query_vars['posts_per_page'] = 2; // Change this example value }For more info about this action, please, read this topic. Thanks @mark/t31os!
Some related reading:
– http://wpquestions.com/question/show/id/883
– http://mitcho.com/blog/how-to/external-orders-in-wordpress-queries/
I just want to know why I cannot use a simple tricks (query_posts) on this case?
If you have ideas and want to share, please share.
Forum: Fixing WordPress
In reply to: its possible to swicth the wp_query on category.php?Hi @alchymtyh, I try it.. but didn’t work. I think that there’s something to do with reseting the query. Or maybe it’s “category.php” default stuff.. I dunno.
Right now, I’m calling the cat_id with this:
$cat_obj = $wp_query->get_queried_object(); $cat_ID = $cat_obj->term_id; // get new order $valor_order = isset($_GET["valor_order"]) ? $_GET["valor_order"] : 0; $neworder = $valor_order ? 0 : 1;The result is always the same, order by title, this case: N, D, B.
If I swap $neworder values, $myargs is updated, but the loop bring always same results: N, D, B
Thanks, I’ll keep trying.
Forum: Fixing WordPress
In reply to: home > category > post title, What do you call this again?Using dimox function just remove the line 13 and 14.
Forum: Fixing WordPress
In reply to: Related Posts by Custom TaxonomyFor those who had problens like dinho, try this:
Where is
"$param_type" => $tag->slug,change to:
$param_type => $tag->slug,