gearheaddeals
Forum Replies Created
-
anyone have any help on adding the IF statement just above this post?
So which functions.php file is accessed through /wp-admin?
Isn’t that the child theme file?I am having this same problem with a customer’s site. They are running graphene theme and it moves the sidebar to the bottom of all pages. I tried the above fix by editing the functions.php file and it killed the site giving a 404 error. I had to reload wordpress because as many times as I tried and different ways to re-upload the original functions.php, it would not resolve itself.
I’ve contacted the owner of woocommerce and we are discussing over email. Hopefully they can build in a robust bit of code that prevents this from happening.Anyone else?
now I would like to use an IF statement so in conjunction with the sorting it would be something like:
IF expiration_date – todays_date > 0
display post
ELSE
ENDso that expired deals would not be posted, even though their checkbox for this category is checked
any ideas on this one?
ok somehow I got it working. I copied my entire code from my regular template into my new “category-expiring.php” template, then added the code you had given before
<?php query_posts( $query_string . '&meta_key=expiration_date&orderby=meta_value_num');?>
and somehow it worked this time.
thank you very much.
actually replaced the query with some text “test” to make sure it would put “test” above the posts on that category page and got this:
Parse error: syntax error, unexpected T_ENDIF in /home/foxst2/public_html/filepath…/archive.php on line 27
But putting the word “test” outside the IF and before the loop, i see what I expected.
I tried changing the field to take the number date in the form
20111005
20111006and sort ascending but it still isnt working.
I put this before the loop:
<?php if (is_category('category-expiring')): query_posts( $query_string . '&meta_key=expiration&orderby=meta_value_num&order=ASC'); endif; ?>
still nothing.
Does anyone have an idea on what I’m doing wrong here?
currently the key is like this 2011-10-05 and the plugin “more fields” is set to take in a date of that format.
[Code moderated as per the Forum Rules. Please use the pastebin]
So that’s what I have, and this is what I get
https://www.gearheaddeals.com/category/expiring/
The exp. date shown there is unrelated to the meta_key. It is just written in the post, but the meta keys match that date and you can see that it is not in order.
I also changed the meta_key variable name to “expiration” for simplicity
when I insert your snippet, it just shows up on the top of the category page above the first post. is there another location I should try?
and the date format needs to be 10/05/2011 or 20111005 or something else?
thank you very much by the way
thank you, and where is that placed in the first code block?
Here is part of the code where I believe the new code should be inserted:
<div id="main" class="clear"> <div id="content"> <?php while (have_posts()) : the_post(); ?> <h1 class="title"><?php the_title(); ?></h1> <div class="entry page"> <?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail( 'index-thumb', array( 'class' => 'single-post-thm alignright border' ) ); ?> <?php the_content(); ?> <?php edit_post_link(__( 'Edit', 'traction' )); ?> <?php wp_link_pages(); ?> </div><!--end entry-->
I am looking to use this code snippet but do not know where in there to put it and retain the while loop:
$querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'date' AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY STR_TO_DATE(wpostmeta.meta_value, '%m/%d/%Y') ASC "; $pageposts = $wpdb->get_results($querystr, OBJECT);
I’ve been trying to use that, but am really a novice at this part of wordpress.