Print page content with formatting when doing custom SQL query

You need to run the post_content filters. It is a one line change from your current code. This… echo $footerElement->post_content; … should be … echo apply_filters(‘the_content’,$footerElement->post_content); That will give you all the same formatting as with normal posts. You can of course pick and choose which filters you want to run, instead of running them … Read more

Using color schemes with Color Picker

Don’t save everything as individual options, save all of your options as an array under a single key. One query to load it and save it, then just do all your manipulation in php. example structure and output: $colors = array( ‘current_scheme’ => ‘user_scheme’, ‘preset_schemes’ => array( ‘red’ => array( ‘menu’ => ‘#CC0000’, ‘footer’ => … Read more

How can I get all author written content?

Your question is not very detailed or very clear but get_user_meta will return all of the user metadata for a user. That should have all of your fields. You could also use get_users for the second tab. I am not dealing with the first since you state that your “have no idea how to do … Read more

SQL Bulk Move old posts by one author to another category

Try something like this: global $wpdb; $from_user = 2; $to_user = 5; $posts_table = $wpdb->prefix . ‘posts’; $users_table = $wpdb->prefix . ‘users’; $strQuery = “UPDATE `$posts_table` SET post_author = $to_user WHERE post_author = $from_user AND $posts_table.post_date < ’01/01/2013′ AND $wpdb->term_taxonomy.term_id IN (1,2,3) AND $wpdb->term_taxonomy.taxonomy = ‘category'”; echo $strQuery; $wpdb->query($strQuery); For more info please visit this … Read more

making php value numeric

Your question is more about SQL than WordPress. If you want to sort your term names as numbers, you can in general try SELECT * FROM wp_terms ORDER BY name+0 ASC or SELECT * FROM wp_terms ORDER BY name*1 ASC or use CAST: SELECT * FROM wp_terms ORDER BY CAST(name AS SIGNED) ASC where you … Read more

wpdb prepare sql problem

To get a % character into your SQL string without confusing sprintf() add it to the replacement string: $alabala_sql = $wpdb->prepare( ” SELECT * FROM $wpdb->posts p INNER JOIN $wpdb->term_relationships tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id=tt.term_taxonomy_id INNER JOIN $wpdb->terms t ON t.term_id=tt.term_id and t.slug= %s WHERE p.post_title LIKE %s AND … Read more

SQL: Select wordpress posts with given text string and add a custom field to them?

Here you go (you’re really close): INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT ID AS post_id, ‘customer_reviews’ AS meta_key, ‘On_or_delete’ AS meta_value FROM wp_posts WHERE wp_posts.post_content LIKE ‘%Customer Reviews%’ AND wp_posts.post_type=”post”; ` Edit: You could also just change IS IN to IN. I rewrote the from part of the query since a subquery was unnecessary … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)