Hi nblauw
The sum of guestbook entries is saved in $num_rows1, I saw you already implement it on Bartbroersen.nl 🙂
Greetings,
Dani
Thread Starter
nblauw
(@nblauw)
Hello,
I didnt implemented yet! I do it by myself at the moment.
I know $num_rows1 stands for the sum of questbook entries. But how can I implement a shortcode that I can use in a page title, like what I did with the gallery. See this thread (http://wordpress.org/support/topic/how-to-place-code-in-page-title).
Thank you very much for your help so far!
Nick,
Hi nblauw
1.) create a new function in function.php:
function countGuestbookEntries($guestbook) {
global $wpdb;
$table_name = $wpdb->prefix . "dmsguestbook";
$query = $wpdb->get_results("SELECT id FROM $table_name WHERE flag != '1' && guestbook = '" . sprintf("%d", $guestbook) . "' && spam = '0' ");
return $wpdb->num_rows;
}
2.) insert following code in your theme, where you want to display the guestbook count:
echo countGuestbookEntries(0);
“0” = your first guestbook
“1” = your second guestbook if you have more than one
…
3.) Shows sum of entries only on guestbook page:
if($post->ID == 48) {
echo countGuestbookEntries(0);
}
“48” is your post ID (You will see that on “DMSGuestbook -> Guestbook settings -> Basic”
Greetings,
Dani
Thread Starter
nblauw
(@nblauw)
Thank you very much,
How can I make a short code like [post_count] of echo countGuestbookEntries(0);
So I can use it in pagetitles, like my pagetitle would be:
Gastenboek ([post_count])
Again, thank you!
function.php
function title_guestbook_count( $title, $post_id ) {
global $wpdb;
$table_name = $wpdb->prefix . "dmsguestbook";
$query = $wpdb->get_results("SELECT id FROM $table_name WHERE flag != '1' && guestbook = '" . sprintf("%d", 0) . "' && spam = '0' ");
$guestbook = do_shortcode( $wpdb->num_rows );
if ( preg_match( '/\[\s*post_count\s*\]/', $title ) ) {
$title = preg_replace( '/\[\s*post_count\s*\]/', $guestbook, $title );
}
return $title;
}
Theme:
add_filter( 'the_title', 'title_guestbook_count', 10, 48 );
Greetings,
Dani
Thread Starter
nblauw
(@nblauw)
Thank You, its fully working now. Big thanks,
Great plugin with great support ! 🙂
I will leave You à small donation.
Nick
Thread Starter
nblauw
(@nblauw)
Hello again,
So it’s working in a post, as page title and in my dashboard. Only the name in my browser displays “Gastenboek ([post_count])”
I made a photo of it:
http://bartbroersen.nl/Seethis.png
Hi Nick
Insert this piece of code between the <title> tags of your theme instead wp_title():
echo preg_replace('/\[\s*post_count\s*\]/', wp_title_guestbook_count(), wp_title('|', false, 'right'));
function.php:
function wp_title_guestbook_count() {
global $wpdb;
$table_name = $wpdb->prefix . "dmsguestbook";
$query = $wpdb->get_results("SELECT id FROM $table_name WHERE flag != '1' && guestbook = '" . sprintf("%d", 0) . "' && spam = '0' ");
$entries = $wpdb->num_rows;
return $entries;
}
More infos about wp_title
Greetings,
Dani
Thread Starter
nblauw
(@nblauw)
You are amazing,
Thanks for helping and for the link, very usefull. I made à small donation for you.
Dear sir
We are updated post message link below page
http://72.20.125.90/?page_id=21
this is different different forum below the link
http://72.20.125.90/?page_id=38
http://72.20.125.90/?page_id=76
we want show post message different posts on page id but no we saw all post in all pages we want separate post on particular pages only show
this is possible how and change let me know the link asap
Thank and regards
AJP