Modify Global Posts Plugin

Can you use the SQL OFFSET statement: OFFSET 1 $query = “SELECT * FROM ” . $wpdb->base_prefix . “site_posts WHERE blog_public=”1″ AND post_type=”” . $recentglobalpoststype . “” ORDER BY post_published_stamp OFFSET 1 DESC LIMIT ” . $recentglobalpostsnumber;

Access Tables with number prefix

When in multisite, the wpdb prefix is always the prefix required to access the tables for the current site. This includes the site ID so this should work: $wpdb->get_results($wpdb->prepare(“SELECT * FROM “.$wpdb->prefix.”options WHERE …..”)); There should be no difference at all when using multisite, just make your queries as if it were single site.

sql for querying post and their category

To get a specific post in WordPress, you can use the get_post() function and get_the_category() to get the categories associated with it. You can then use the code found in this answer to dump the SQL queries used. <?php $post_ID = 7; $the_post = get_post( $post_ID ); $the_category = get_the_category( $post_ID );

Display old posts if no future posts exist

example: <?php query_posts(‘posts_per_page=5&order=ASC&post_status=future’); if ( !have_posts() ) query_posts(‘posts_per_page=5&order=DESC&post_status=publish’); if( have_posts() ) : while ( have_posts() ) : the_post(); ?>

Using wp_list_table how to trigger update function “inline”?

ok not the most handsome solution but it works i transported the update function to update.php also wp-load.php $(“.col_visitor”).click(function(){ visitorID = $(this).attr(‘id’); //alert(‘testing ‘+visitorID); $.ajax({ url: ‘update.php’, data: {action: visitorID}, type: ‘post’, success: function(output) { //alert(output); window.location.reload(); //reload so we see the updated values } }); });//#end click

learn to run wpdb class

Arbitrary SQL query can be run via wpdb by using get_results() method: $results = $wpdb->get_results( $query ); You can work through documentation for wpdb at Codex to gain basic understanding of how it works.

Mysql query and odd results

You have to enclose the OR part to brackets: $sql = “SELECT ID,post_title,post_content,post_date,post_type FROM {$wpdb->posts} WHERE (post_content LIKE {$stuff}) AND post_status=”publish” AND post_type=”{$post_type}” AND ID != {$post->ID} LIMIT {$limit}”; $results= $wpdb->get_results($sql); Try this one: SELECT ID,post_title,post_content,post_date,post_type FROM wp_posts WHERE (post_content LIKE ‘%Battery%’ OR post_content LIKE ‘%Watcher%’ OR post_content LIKE ‘%Widget%’ OR post_content LIKE ‘%matches%’ OR … Read more

Show links to child pages on both parent AND child pages

This seemed to work nicely for me; <?php $children = get_pages(‘child_of=”.$post->ID); if( count( $children ) != 0 ) { $id = $post->ID; } else { $id = $post->post_parent; } $args = array( “post_type’ => ‘page’, ‘post_parent’ => $id, ‘posts_per_page’ => -1 ); $system_query = new WP_Query($args); if ($system_query->have_posts()) : while ($system_query->have_posts()) : $system_query->the_post(); ?> <!– … Read more

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