Missing argument 2 for wpdb::prepare() Issue

That was not exactly change in code, that was change to better inform people they are not using the method correctly. In line with wpdb documentation you need to properly pass values, or they won’t be properly escaped in query. In your case it would turn into something like: $wpdb->prepare(“SELECT id, name FROM %s”, $table_name) … Read more

Include files for a plugin not including

In your main plugin file, use plugin_dir_path to define a constant that you can then use in all of your includes. see the example on the above codex page. // define the constant in your main plugin file define( ‘MYPLUGINNAME_PATH’, plugin_dir_path(__FILE__) ); then, to include your file: include MYPLUGINNAME_PATH . ‘includeme.php’;

flush_rewrite_rules not working on plugin deactivation, invalid URLs not showing 404

Have you tried delete_option(‘rewrite_rules’); on deactivate? I came across the following when investigating this problem and it did the trick for me: Typically you register post types on init. Some time after that, you get the deactivation action. A responsible plugin would remove its rewrite rules by flushing. However, it can’t undo the registration, so … Read more

How to create a Page alias in WordPress

Those are actually post states; not aliases.. And you can do it through the display_post_states filter, like so, where we check if the post ID ($post->ID) is 123 and if so, we assign the XYZ Page state to that post (which could be a Page, Custom Post Type, etc.): add_filter( ‘display_post_states’, ‘my_post_states’, 10, 2 ); … Read more

How to override shortcodes.php core file?

You can’t “override” whole files or functions, except in special circumstances. That is basic PHP. WordPress has code in place that will let you override particular files and functions. For example, child themes can override parent theme files. That is because of the way the WordPress Template loader works. The override only works if the … Read more

Adding New Role

Happened to me first time. Not a matter at all. If you want how this thing works and how to debug it, read on. But if you want to hear the cause what just happened, go to the very bottom of this answer (#Specific Answer). If you contact the Codex page for add_role(), the second … Read more

Delivering a file instead of wordpress page

You’re on the right path with a rewrite rule. If you’re just delivering a file, you can hook an early action, check if a download was requested, then output the file and exit before WordPress ever gets to the stage of querying the database and deciding the request is a 404. // add the download … Read more