Passing array of strings to a SQL statement in a WordPress plugin

$wpdb->prepare() accepts a single array of arguments as the second parameter, e.g. $wpdb->prepare( “SELECT * FROM table WHERE field1 = %s AND field2 = %d AND field3 = %s”, array( ‘foo-bar’, 123, ‘[email protected]’ ) ) Therefore you can use an array of placeholders with the SQL command (the 1st parameter), like so: // Create an … Read more

Query_posts $query_string

After some searching I found the parameters I needed: https://gist.github.com/luetkemj/2023628 (on Line 231) //////Search Parameter //http://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter ‘s’ => $s, //(string) – Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search ‘exact’ => true, //(bool) – flag to make it only match whole titles/posts – Default value is false. For more … Read more

Concatenate site_url and string doesn’t work

Without knowing exactly what you are trying to do, it seems you want to append query variables to the URL. WordPress has methods for handling that properly, without manual string concatenation. Look at the documentation for add_query_arg() for details: https://developer.wordpress.org/reference/functions/add_query_arg/ You can rebuild the URL and append query variables to the URL query by using … Read more

How to get “extended” path info from URL in a plugin

In reply to “Update 1“: The code worked fine for me. So, I’m still getting a 404 when I go to “mypage” with anything following the pagename, like so: http://example.com/mypage/foo. Because your RegEx pattern is ^category/([^/]+)/?, so the URL you should have visited is http://example.com/category/foo. But then, you shouldn’t use category because that “base” is … Read more

Add custom URLs to WordPress’s XML sitemap

Sitemap Provider It’s possible to create a so called custom sitemap provider and register it with wp_register_sitemap_provider(). It’s helpful to look at the core setup, e.g. for the WP_Sitemaps_Posts provider and also the dev notes. Basic Example – Sitemap with custom URLs Here’s a very basic example that adds the wpse provider that extends WP_Sitemaps_Provider, … Read more

How do I add a php statement to a jQuery string

You might want to try to use wp_localize_script() to allow your javascript to use data that are normally only available using php. Here is the link in the codex that will help you do what you need: https://codex.wordpress.org/Function_Reference/wp_localize_script Another way is to use a php to output your entire javascript code (in a php file, … Read more

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