select a single val though a table in wordpress

Use the method get_var() instead. I’ve also tidied up your code (if you’re gonna use double quotes, take advantage of them!) & added data escaping with the handy prepare() method. global $wpdb; $cat_id = $wpdb->get_var( $wpdb->prepare( “SELECT category_id FROM {$wpdb->prefix}awpcp_categories WHERE category_name = %s”, $ad_cat ) );

What could cause a WP Option to get truncated?

It was a 👼 character. Make sure you sanitize everything that gets written as field values, even if it’s a username. trim(preg_replace(“/[^\w\s]+/”, “”, $user->full_name)) I assumed there are no special characters in Instagram usernames. Never assume. I don’t really use Instagram, just my plugin supports it. BTW it got truncated on the first occurrence of … Read more

how to get the top 10 popular blogs

If I understand you correctly, something like this should help you. global $wpdb; $results = $wpdb->get_results( “SELECT post_author, SUM(comment_count) as comments FROM {$wpdb->posts} WHERE post_type=”post” AND post_status=”publish” GROUP BY post_author ORDER BY comments DESC LIMIT 10″); This will return you 10 authors of most commented posts (with highest sum of comments count of each post … Read more

Load stylesheet in edit category page?

The way to enqueue admin styles and scripts in targeted pages is explained here: Difference between do_action(‘admin_enqueue_scripts’, $hook_suffix) and do_action(“admin_print_styles-$hook_suffix”) syntax The Category page is the same as the Tag page, /wp-admin/edit-tags.php. So, an extra check is needed and in this case using the global variable $current_screen. add_action( ‘admin_print_styles-edit-tags.php’, function(){ global $current_screen; // Not categories, … Read more

How to use existing hook in twentytwelve to all theme of wordpress?

A hook can only be implemented via actual function call. It is not possible without adding that call to theme template directly or via other method (calling it inside another, already available, hook for example). There is Theme Hook Alliance initiative to promote more standardized hooks in themes and increase flexibility, but adoption have been … Read more

Next Previous Post in wordpress with previous / next link with title?

You can do it like so, I guess: <div class=”alignleftfp”> <?php next_post_link(‘%link’, ‘<img class=”imgalign” src=”‘ . WP_CONTENT_URL . ‘/uploads/1.png” alt=”Next” /> %title’); ?> </div> <div class=”alignrightfp”> <?php previous_post_link(‘%link’, ‘%title <img class=”imgalign” src=”‘ . WP_CONTENT_URL . ‘/uploads/1.png” alt=”Next” />’); ?> </div> PS. You shouldn’t use next_post/previous_post functions – they’re deprecated. EDIT Just read the_content filter docs. … Read more

Update plugin settings option_name for big plugin update

I think changing array keys is more of a PHP problem // Get entire array $plugin_options = get_option( ‘plugin_options’ ); $new_options = array(); if( isset( $plugin_options[‘ga_accountId’] ) ) $new_options[‘ga_account_id’] = $plugin_options[‘ga_accountId’]; // Update entire array update_option( ‘plugin_settings_general’, $new_options ); // Delte old array delete_option( ‘plugin_options’ ); Any end-user who might be using using your plugin’s … Read more