Highlighting Sub topic in a post?

But am looking for a plugin or a code which can help me with adding this note every time I write a post. A shortcode to add that “note” is trivial. function note_sc_wpse_107275($atts,$content) { return ‘<p class=”note”><strong>’.$content.'</strong></p>’; } add_shortcode(‘note’,’note_sc_wpse_107275′); Then just add [note]Note content[/note] to your post body. That will give you exactly what you … Read more

How to execute SQL SELECT query and see the results?

Have a look at the $wpdb class, it does exactly what you want: $myrows = $wpdb->get_results( “SELECT id, name FROM mytable” ); Try to avoid SQL queries for basic operations though. WordPress offers you many convenience functions for 80% of the tasks you would every come up with. They provide a nicer interface and preserve … Read more

How to order posts by modified date without using ‘query_posts’?

You haven’t specified where you want this alteration to apply to so I’ve applied it to just the home page. You may alter to fit where this filter applies to: <?php function wpse10691_alter_query( $query ) { if ( $query->is_main_query() && ( $query->is_home() || $query->is_search() || $query->is_archive() ) ) { $query->set( ‘orderby’, ‘modified’ ); $query->set( ‘order’, … Read more

Custom $wpdb Query for Custom Post Type by Category

Don’t use $wpdb, use wp_query. Not only will your code be leaner and quicker, you’ll avoid issues like this. Unless you’re doing something with custom tables or seriously in-depth SQL, there’s no reason to do direct SQL calls on $wpdb. So, to answer your question – rewrite it from the ground up using wp_query, see … Read more

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