php - Wordpress $wpdb->get_var results in blank page -


i'm trying simplest wordpress database function return result , shows blank. query works fine in phpmyadmin , returns result want, not via page template in wordpress.

this function running on page template that's based off twentythirteen theme page.php (i replaced the_content() function). code below:

<?php function ag_get_count_to_work(){     global $wpdb;     $num_posts = $wpdb->get_var("select count(*) wp_posts");     if ($num_posts) {        echo "<h1>" . $num_posts . "</h1>";     } else {        die(mysql_error());     } } ?> 

i might not have if statement setup correctly, trying without if statement (i.e., return result), result blank, , there no errors shown. can eagle-eyed developer tell me i'm missing please?

this not final function want, i'm trying break problem down origin , might it.

turns out function defined not called. because i'm used putting functions in functions.php file. once called seems work fine.


Comments

Popular posts from this blog

Receive udp packets in android gstreamer -

php - Extract Text from HTTP referer -

matplotlib - PYTHON: Annotate boxes disapear dependant on range -