wordpress prepare error

Use double percent sign like so: %%special-purpose%%. Or you could also use a placeholder, i.e. LIKE %s and then set the 6th parameter for $wpdb->prepare() to %special-purpose%, i.e. $wpdb->prepare( “your SQL query”, $earth_radius, $lat, $lng, $lat, ‘%special-purpose%’ )

Commenting out in HTML editor breaks template

My last comment reminded me about shortcodes, and lead me to this answer: function htmlcomment_shortcode( $atts, $content = null ) { return ‘<!– ‘ . $content . ‘ –>’; } add_shortcode( ‘htmlcomment’, ‘htmlcomment_shortcode’ ); Add that to functions.php or your plugin, and then use it in your content like this: normal text [htmlcomment]commented out text[/htmlcomment]

Where do I add an action hook & callback in my theme?

The best place for you is probably going to be in your Theme’s functions.php file. Navigate to /wp-content/themes/your-theme-name/functions.php. Paste it above/below any of the other code there, making sure to stay between any < ?php or ?> tags.

Remove Metaboxes

I don’t think this will ever fire…. Is_admin() detects admin UI not admin priveleges… Try: if (is_admin()) : function my_remove_meta_boxes() { if( !current_user_can(‘manage_options’) ) { remove_meta_box(…); }} add_action( ‘admin_menu’, ‘my_remove_meta_boxes’ ); endif;

How to write custom code on WordPress?

You can create a simple plugin file to add in the code that you want. In your WordPress folder there is a wp-content directory, and a plugins directory inside that. Create a php file inside the plugins directory, and name it something unique and descriptive; use dashes – to separate words in the name: ben-is-neat.php … Read more