Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

wpdb

Custom $wpdb Query for Custom Post Type by Category

August 2, 2022August 1, 2022 by Magenaut

I am using the following code to output a list of items in my ‘documents’ Custom Post type by Year and Month.

Categories Q&A, Wordpress Tags query, wpdb Leave a comment

WPDB prepare – like % – placeholders?

August 2, 2022August 1, 2022 by Magenaut

Are these {xxx...} placeholders for % in a LIKE statement normal? If so, when do they get converted back to %‘s?

Categories Q&A, Wordpress Tags wpdb Leave a comment

Pagination with custom SQL query

August 2, 2022August 1, 2022 by Magenaut

I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I’ve used the offset and limit to return appropriate posts depending on a page being displayed. That’s working fine.

Categories Q&A, Wordpress Tags navigation, pagination, sql, wp-query, wpdb Leave a comment

Detecting errors generated by $wpdb->get_results()

August 2, 2022August 1, 2022 by Magenaut

How do I detect errors when using $wpdb->get_results()?

Categories Q&A, Wordpress Tags database, errors, wpdb Leave a comment

SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999

August 1, 2022July 31, 2022 by Magenaut

Overview: I am not trying to return a post. I simply want the single highest value for a particular meta_value across all posts… just the value itself.

Categories Q&A, Wordpress Tags custom-field, meta-query, meta-value, sql, wpdb Leave a comment

Why $wpdb->show_errors() and print_error() is showing an output even if the query output is correct?

August 1, 2022July 31, 2022 by Magenaut

In order of figuring out the following issue, see https://wordpress.stackexchange.com/questions/178995/sanitize-a-working-query-string-by-using-wpdb-prepare-fails-with-mysql-db-er i ran into an rather odd behaviour. Even that my used query was correct and showing the right output.

Categories Q&A, Wordpress Tags errors, wpdb Leave a comment

Can i use php sql functions instead of $wpdb?

August 1, 2022July 31, 2022 by Magenaut

I’m new to WordPress and was wondering why in WordPress API do they tell you to use functions such as prepare(), insert(), get_col(), get_row(), query(), etc. when technically I can use the built-in PHP-SQL functions such as mysqli_query(), mysqli_fetch_assoc(), etc.

Categories Q&A, Wordpress Tags mysql, php, wpdb Leave a comment

Does dbDelta delete columns as well?

August 1, 2022July 31, 2022 by Magenaut

I created a table using the dbDelta function and then removed a few columns and added a few. The new columns did get created but the old columns did not get deleted from the table.

Categories Q&A, Wordpress Tags database, dbdelta, wpdb Leave a comment

Return only Count from a wp_query request?

August 1, 2022July 31, 2022 by Magenaut

Is it possible with the standard build-in tools in WordPress to get wp_query to only return the count of an query?

Categories Q&A, Wordpress Tags count, mysql, query, wp-query, wpdb Leave a comment
Newer posts
← Previous Page1 … Page4 Page5
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress