I am using roots wordpress framework. I need to show comments of posts in Desc order by posted date , means the most recent shows at top.
If I use this in my commnets.php, it works fine
wp_list_comments(array('callback' = 'roots_comment','reverse_top_level'=>true,'reverse_children'=>true,'type'=>'comment'));
But if I try to restrict the number of comments , then it ignores the reverse arguments and shows the comments from bottom.
wp_list_comments(array('callback' => 'roots_comment','reverse_top_level'=>true,'reverse_children'=>true,'per_page'=>3,'type'=>'comment'));
Now this one is showing the first 3 comments from bottom(3rd,2nd ,1st ) in this order(means order is correct but it is counting the 3 comments from bottom, rather than the recent 3 submitted ) .
Does anyone know solution to this , apart from changing the core wp-includes/comments-template.php file . I can't do that as it is a multisite , so it will affect the other sites comment order.
Thanks
You should have an easier time modifying your settings by logging into your Dashboard and checking out Settings->Discussion.
Related
I have a WooCommerce 7.0.0 shop for which I'm programmatically creating products.
The price of these products is calculated according to various user input values.
I've done it before on other sites without problem, but I'm currently facing an issue : when the calculated price is a float, on the review order table, the price is not displayed correctly, and I'm getting a notice : A non well formed numeric value encountered in class-wc-cart.php on line 2151
Eg. if the price is 5.24€, I get 5.00€ on the product detail, subtotal, and total of the cart.
However, the price is displayed correctly as 5.24€ in the back-office.
Also, it is stored correctly in database.
Here's 2 methods I've tried to save the price before getting to checkout :
// Method 1
$product->set_price($total);
$product->set_regular_price($total);
$product->save();
// Method 2
add_post_meta($pID, '_regular_price', $total);
add_post_meta($pID, '_price', $total);
I tried various casting and rounding methods before saving (flotval, number_format, sprintf('%.2F') ) to no avail.
I also tried both , and . separators on the WooCommerce settings.
I'm running out of ideas, I must have missed something obvious but as it is, I can't put my finger on it.
Maybe something has changed on the newer versions of WooCommerce ? The last version I've used where I created products in the same way without issue, was 6.3.1.
Any help is welcome :)
Thanks,
I've been searching for hours, either for a plugin or some safe looking SQL to do this, but nothing seems to be exactly what I need...
I have a Wordpress site of approximately 32,000 posts, and we use various tags to help with administration on the back end (i.e. they're not visible on the front end or used for SEO, before anybody comments on too much usage of the same tag). About 30,000 of these posts include the tag 'new', but we need to now tag the remaining ~2,000 to match.
The WP administration panel isn't really up for the task - it would take somebody days to go through and apply a tag to 2,000 posts. Various plugins seem to exist but they don't really do what they claim in the descriptions. And the only SQL I could find that seemed helpful assumes that the tag is new and that I want to apply it to all posts in a single category. I suppose I could delete the existing tag (again, not a fun task with Wordpress' admin panel - it generally crashes after about 30 posts meaning somebody has to sit clicking the button over and over) and then run the SQL to apply a new.
Can somebody point me in the right direction please?
You could run a loop over all of your posts and use wp_set_object_terms() to add the desired tag:
http://codex.wordpress.org/Function_Reference/wp_set_object_terms
I had this problem today too. I tagged all of my posts with the following SQL. (Replace <prefix> with your DB prefix and "GlobalTag" with whatever you want your tag name to be.)
# create a term which will be your new tag
INSERT INTO <prefix>_terms (name, slug) VALUES ("GlobalTag", "global-tag")
# this is what defines the term as a Tag vs Category vs Video Category, etc
# only do this if you are creating the category through SQL, not the GUI
INSERT INTO <prefix>_term_taxonomy (term_id, taxonomy, count)
SELECT
(SELECT term_id from <prefix>_terms AS term WHERE term.name="GlobalTag") as "term_id",
"tag" as "taxonomy",
(SELECT COUNT(*) FROM <prefix>_posts AS posts WHERE (posts.post_status IN ("publish", "draft")) AND LENGTH(post_content) > 25) as "count"
# now tag every post with GlobalTag
INSERT INTO <prefix>_term_relationships
SELECT
id as "object_id",
(
SELECT term_taxonomy_id
FROM <prefix>_term_taxonomy AS term_tax
INNER JOIN <prefix>_terms ON <prefix>_terms.term_id = term_tax.term_id
WHERE <prefix>_terms.name="GlobalTag"
) as "term_taxonomy_id",
0 as "term_order"
FROM <prefix>_posts AS posts
WHERE (posts.post_status IN ("publish", "draft")) AND LENGTH(post_content) > 25
NOTE: you may want to tweak the posts query in here. This tags all posts that are published and/or drafts and that have content that is longer than 15 words.
I've been developing an e-commerce store for a client using WooCommerce and I've come across a very strange issue. All of my products are variable products and I have set them up like this:
Variation 1 - Weight (0,0.5,1.0,1.5,2.0...5.0 in Kgs)
Variation 2 - Units (0,1,2,3,4,5...10)
Variation 3 - Cut Type (Ground, Slices, Whole etc)
I set the variations in such a way that a customer has to choose either Variation 1 or Variation 2 (weight or in units) and Variation 3. If they choose to purchase a product by Weight (Weight is great than '0') the only choice in 'Units' is 0 and vice versa. This worked for me for a day or two and stopped working, I keep getting an error 'please select product options'..
I then changed the '0' value to 'Zero' and the combination works, has anyone come across this problem before?
I tried to switch to the default theme of WP and shut off all plugins except WooCommerce but nothing works.
Any ideas?
Link to a product page - http://www.best-foods-for-fat-burning.com/wordpress/?product=%D7%90%D7%A1%D7%90%D7%93%D7%95
Thanks,
Ofer
This is a bug. I've tested it on several different installation. Using the latest versions of Woocommerce 2.0.20 and WordPress 3.8.1. The best thing to do is add additional info like 0-Kgs to your attribute slug and that solves the problem until woothemes fixes this bug.
I have a creepy site running Wordpress 2.8.5. Its purposed to show events in my state (Bahia/Brazil).
Every event has it published date as the day of the event and the theme shows future posts bypassing WP's default to display until today.
It has a slide with some featured events and this is how it now selects what is to be shown in the slides:
$mes = date('n');
$ano = date('Y');
query_posts("
meta_key=dest_principal&
meta_value=1&
showposts=6&
year=$ano&
monthnum=$mes&
order=ASC
");
With this code the slide shows the first 6 posts in the current month. The problem I have is not being able to show the next 6 posts begining today. (to be clear, by today i mean the day of access)
I found this entry " wordpress query - next two events by metadata date " but could not translate it to my need.
It's not clear exactly what you're trying to do. Are you trying to show 6 posts starting from today and going back to the 6 previous posts? So essentially the 6 newest posts?
If so try this in place of query_posts...
$recent = new WP_Query("cat=3&showposts=6");
while($recent->have_posts()) : $recent->the_post();
You can use the 'cat=3' to display posts from a particular category, just change the '3' to your category id. Otherwise if you don't need to do this remove this 'cat=3&'.
BTW, I have a site focused on Bahia if you're interested in a link exchange get in touch.
How can one reset the number of post views in order to remove a specific page from appearing in the "Popular" pages Wordpress widget?
Late to the party, I know, but I needed to figure this out today, which I did. So in case anyone else needs to know (for reference, I'm running WordPress version 3.3.1):
Page views are stored in the wp_postmeta table with a meta_key of post_views_count. Here's the query I used to find the views of a single post:
SELECT * FROM 'wp_postmeta' WHERE 'meta_key' = 'post_views_count' AND 'post_id' = 1234
The query returned 2 results. I'm not sure why, but setting the meta_value of both to zero did the job for me.