Custom page with queries returns 404

WordPress rewrites standard wordpress urls from /category/post-name/ or whatever your selected permalink type is, into index.php?…. You are adding query vars to a link that is already getting rewritten into index.php?… and thus you are getting a 404. My advice to you would be to use something similar to an already asked question at Custom … Read more

Custom Loop Query For Search Page

You have to pass the search query too. To get the search query, you can use the get_search_query() function, and pass it to the query’s s parameter: $search_string = get_search_query(); $args = array( ‘s’ => $search_string, ‘posts_per_page’ => 12, ‘order’ => ‘DESC’, );

Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]

Let’s unwrap it to more readable form: <?php if ( ! empty( get_the_author_meta( ‘facebook’, $part_cur_auth_obj->ID ) ) ) { ?><a href=”https://wordpress.stackexchange.com/questions/305172/<?php echo get_the_author_meta(“facebook’, $part_cur_auth_obj->ID);?>”> <i class=”fab fa-facebook-f”></i> </a><?php}?> End the last line is a problem. There are no spaces around curly bracket and it causes the error. Just change it to <?php } ?> and … Read more

Delete all drafts?

draft is not a post_type, it’s a post_status. So you should use your second block of code with that substitution: DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_status=”draft”

Is it possible to query from external database? [duplicate]

You can use wpdb to setup a new connection. Add something similar to this below in your functions.php and you can then query just like you would normally but using the new connection. $second_db = new wpdb(DB_USER, DB_PASSWORD, $database_name, DB_HOST); $results = $second_db->get_results($your_query); references: https://wordpress.stackexchange.com/a/1673/86845 https://stackoverflow.com/a/36759606/3204142

SQL query, error

You have the where clause of the query in the wrong place. Your query should be written like this: $query= “SELECT * FROM files WHERE custom > 0 ORDER BY id DESC LIMIT $from, $site”; As specified here https://dev.mysql.com/doc/refman/8.0/en/select.html in the MySQL reference.

correct sql query

You should use prepare only when you’re using SQL query – this function takes query and params and returns a safe SQL query filled with given params. Its result is a SQL query. So you can (and should) use it whenever you’re creating a SQL query and put some params in it. With $wpdb->delete or … Read more

correct validate and sql query

What you’re doing is safe. However, some notes: See the WP_User_Query class in the Codex. This is the, “official,” way to do something like this, although you’ll get an integer-indexed array of WP_User objects. Instead of the ARRAY_A that you’ve specified. You probably don’t want _my_table, unless your table is called something like wp__my_table (note … Read more