wpdb query with dynamic column name?

This is simply a syntax error by the looks of it. You are using ” to open the string, and ‘ to close it. Use this: $which_column = ‘phone’; $data_check = $wpdb->get_var(“SELECT ” . $which_column . ” FROM wp_shopping_preferences WHERE wp_user_id = ‘$id'”); Fun fact: when using double quotes (“), you can directed insert a … Read more

Excerpt showing under title in admin columns

Atlast i found the solution, it was very silly mistake. It got nothing to do with plugin or theme or any code. It was one of the WordPress settings which i didn’t realize. Following pic shows the option to switch between excerpt view and list view of posts in wordpress. I by mistake selected excerpt … Read more

Output column number according to active sidebars

Use the array_filter() function, which will remove every array element that has false as the value. Then you can count the array length. So your example would look like this: $sidebars = array( is_active_sidebar( ‘footer-4’ ), is_active_sidebar( ‘footer-3’ ), is_active_sidebar( ‘footer-2’ ), is_active_sidebar( ‘footer-1’ ), ); $active_sidebars = array_filter($sidebars); echo ‘col-‘.count($active_sidebars);

Make a custom column sortable by a value from a different custom post type

(I was going to add this as a comment as it’s not a full answer, but I can’t yet…) I think you will need to use an SQL query as the standard meta_queries / orderby won’t work. Have a look at Custom Table Column Sortable by Taxonomy Query and http://wpdreamer.com/2014/04/how-to-make-your-wordpress-admin-columns-sortable/#sorting-posts-option-b for a couple of examples.

Admin: how to make a custom list filter button send GET queryvars

Thanks to @cybmeta I was able to solve my issue. Below I post all the relevant code. Keep in mind it refers to a ‘distributor’ custom post type that uses 4 custom taxonomies (‘italy’,’france’,’spain’,’world’). // add columns function add_distributor_columns($table_columns){ $area_column = array(‘area’ => ‘Area’); $macroarea_column = array(‘macroarea’ => ‘Macroarea’); // put them on the right … Read more

Custom Columns for Custom Post Type Manager

add_action(‘manage_edit-pricing_columns’, ‘manage_pricing_columns’); add_action(‘manage_pricing_posts_custom_column’, ‘manage_pricing_custom_columns’); function manage_pricing_columns($_columns) { $new_columns[‘cb’] = ‘<input type=”checkbox” />’; $new_columns[‘title’] = _x(‘Pricing Item’, ‘wp’); $new_columns[‘categories’] = _x(‘Type’, ‘wp’); $new_columns[‘date’] = _x(‘Created’, ‘wp’); return $new_columns; } function manage_pricing_custom_columns($column, $post_id){ global $post; switch($_columns) { case ‘pricing_type’: $pt = get_the_terms( $post_id, ‘pricing_type’ ); echo $pt[0]->name; break; default: break; } }

Add custom column for custom field

I adjusted the code for you. You can directly use the code in functions.php file. Here is more reference that can help you to understand more. Link 1 Link 2 // Adding Custom Column add_filter(‘manage_stfic_posts_columns’, ‘ST4_columns_head_only_stfic’, 10); add_action(‘manage_stfic_posts_custom_column’, ‘ST4_columns_content_only_stfic’, 10, 2); // CREATE TWO FUNCTIONS TO HANDLE THE COLUMN function ST4_columns_head_only_stfic($defaults) { $defaults[‘bookcode’] = ‘Book … Read more

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