Custom query with DECIMAL(5,2)

Answer taken from here: meta_query: using BETWEEN with floats and/or casting to DECIMAL add_filter(‘get_meta_sql’,’cast_decimal_precision’); function cast_decimal_precision( $array ) { $array[‘where’] = str_replace(‘DECIMAL’,’DECIMAL(5,2)’,$array[‘where’]); return $array; }

Limiting allowed html elements/strip harmful scripts from editor

Adjust HTML-Filter: <?php function fb_change_mce_options($initArray) { // Comma separated string od extendes tags // Command separated string of extended elements $ext=”pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]”; if ( isset( $initArray[‘extended_valid_elements’] ) ) { $initArray[‘extended_valid_elements’] .= ‘,’ . $ext; } else { $initArray[‘extended_valid_elements’] = $ext; } // maybe; set tiny paramter verify_html //$initArray[‘verify_html’] = false; return $initArray; } add_filter(‘tiny_mce_before_init’, ‘fb_change_mce_options’); ?> … Read more

Is there a way to rename “themes” directory name?

For themes you can use register_theme_directory() function to add additional directories for WP to be aware of. I don’t think I ever seen this used in practice, so not sure if there are any complications possible. For plugins you can define WP_PLUGIN_DIR and WP_PLUGIN_URL constants in wp-config.php.

Posting as different users

On the Edit Post page, click the Screen Options dropdown in the upper right hand corner. Enable the “Author” meta box. Now, on your main edit post page, you’ll find the author box, where you can simply select who the author of the post is from a drop down menu.

Adding action to save_post, post needs to be saved twice for function to work

This is a stab in the dark, but have you tried using the set_object_terms hook for your bam_save_event_cat function? function bam_save_event_cat( $post_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { $taxonomy = ‘categoria’; $tribe_cats = get_the_terms( $post_id, ‘tribe_events_cat’); foreach($tribe_cats as $tribe_cat) { if( empty($tribe_cat->name) ) continue; $catname = $tribe_cat->name; $cats[] = $catname; } wp_set_object_terms( $post_id, $cats, … Read more

Multiple Blogs on one site. Best Practise

I would go with option 4: A simple SQL statement (UPDATE {$wpdb->posts} SET post_type=”testimonial” WHERE post_type=”post” AND post_status=”publish” or something like that) to move the current “blog posts” testimonials to their own custom post type. You could also use a plugin to do this. Then use the blog (the “post” post type) as you normally … Read more

Include user defined styles without including wp-load

If you are going to enqueue a stylesheet you should be using wp_enqueue_scripts not wp_print_styles, but you are in a bit of a gray zone between doing things “WordPress-ie” and doing things correctly for performance. The “WordPress-ie” way is to enqueue a stylesheet, but from a performance standpoint you are loading an additional resource and … Read more

Convert an theme options page to use in customize.php also?

You need to add a control to it. function mytheme_customize_register( $wp_customize ) { $wp_customize->add_section( ‘mytheme_options’, array( ‘title’ => __( ‘MyTheme Options’, ‘ppr’ ), ‘priority’ => 35, ‘description’ => __(‘Allows you to customize some example settings for MyTheme.’, ‘ppr’), ) ); $wp_customize->add_setting( ‘link_textcolor’, array( ‘default’ => get_option( ‘your_theme_page_option_value’ ), THIS IS THE OPTION NAME YOU CREATED … Read more

Renaming wp_content problem

Just FYI: After struggling for hours, I found the aswer. The line that was causing the problem is the following in my wp-config.php file: define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . “https://wordpress.stackexchange.com/”); It turned out my WP_SITEURL is not working correctly because I changed the directory structure as described in the question. So I modified wp-config.php and … Read more

Edit admin post page

There are functions available in WordPress to add/remove the elements. For instance to remove existing elements on WordPress backend page editor you can use remove_post_type_support function. Below is example usage: <?php add_action( ‘init’, ‘my_remove_post_type_support’, 10 ); function my_remove_post_type_support() { remove_post_type_support( ‘post’, ‘custom-fields’ ); } ?> The above snippet will remove custom-fields box from edit page … Read more

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