Title: Problem using shortcodes
Last modified: August 24, 2016

---

# Problem using shortcodes

 *  Resolved [supertrooper2](https://wordpress.org/support/users/supertrooper2/)
 * (@supertrooper2)
 * [11 years ago](https://wordpress.org/support/topic/problem-using-shortcodes/)
 * The shortcode used on our website is as follows:
 *     ```
       <h3>Top-Viewed Posts Last 30 Days</h3>
       <?php echo do_shortcode('[google_top_content pageviews="5" titleremove= "Focusing on Wildlife" contentfilter="post" catfilter="3173" number="10" showhome="no" time="2628000"]'); ?>
       ```
   
 * The list of top-viewed posts looks good but there are no page load numbers at
   the end of each line.
 * Is there an error in the shortcode?
 * Thanks for your help.
 * [https://wordpress.org/plugins/google-analytics-top-posts-widget/](https://wordpress.org/plugins/google-analytics-top-posts-widget/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [supertrooper2](https://wordpress.org/support/users/supertrooper2/)
 * (@supertrooper2)
 * [11 years ago](https://wordpress.org/support/topic/problem-using-shortcodes/#post-6135643)
 * Hi Justin
 * A couple of years ago you helped me to get GATCW working in conjunction with 
   GAD using the following two pieces of code:
 * **1) Installed in the single.php file**
 *     ```
       <?php echo do_shortcode('[google_top_content pageviews="5" titleremove= "Focusing on Wildlife" contentfilter="post" catfilter="3173" number="10" showhome="no" time="2628000"]'); ?>
       ```
   
 * **2) Installed in the functions.php file:**
 *     ```
       add_filter( 'gtc_pages_filter', 'gtc_add_viewcount_title' );
       function gtc_add_viewcount_title( $pages ) {
   
           if ( !$pages )
               return false;
           // loop through the pages
           foreach ( $pages as $key => $page ) {
               // and add the page count to the title value
               $pages[$key]['children']['value'] = $pages[$key]['children']['value'] . ' ['. $pages[$key]['children']['children']['ga:pageviews'] .' Views]';
           }
           return $pages;
       }
       ```
   
 * Now after replacing GAD by “Google Analytics by Yoast”, the 10 top posts are 
   still being listed correctly but the page count is not showing after each post
   title.
 * Do I need to change something in either of the 2 pieces of code to get the page
   counts to show up?
 * Please advise
 *  Plugin Author [Justin Sternberg](https://wordpress.org/support/users/jtsternberg/)
 * (@jtsternberg)
 * [11 years ago](https://wordpress.org/support/topic/problem-using-shortcodes/#post-6135645)
 * Hey, yah, those parameters have changed a bit w/ the new plugin integration. 
   We actually have a handy title filter now as well. To accomplish what you’re 
   asking, you would use this (functions.php) snippet instead:
 *     ```
       function gtc_page_title_add_viewcount_total( $title, $analytics ) {
   
       	if ( isset( $analytics['value'] ) ) {
       		// Add the page view count to the title value
       		$title .= ' ['. absint( $analytics['value'] ) .' Views]';
       	}
   
       	return $title;
       }
       add_filter( 'gtc_page_title', 'gtc_page_title_add_viewcount_total', 10, 2 );
       ```
   
 *  Thread Starter [supertrooper2](https://wordpress.org/support/users/supertrooper2/)
 * (@supertrooper2)
 * [11 years ago](https://wordpress.org/support/topic/problem-using-shortcodes/#post-6135657)
 * Hi Justin
 * The top 10 posts with view count works perfectly now after updating the functions.
   php file and can be seen in action on the following typical post (scroll down
   to the bottom of the page to see the post rankings):
 * [http://focusingonwildlife.com/news/promoting-wildlife-conservation/](http://focusingonwildlife.com/news/promoting-wildlife-conservation/)
 * I have added an addendum to the positive review. Thanks once again for responding
   so quickly with the coding solution to this issue.
 *  Plugin Author [Justin Sternberg](https://wordpress.org/support/users/jtsternberg/)
 * (@jtsternberg)
 * [11 years ago](https://wordpress.org/support/topic/problem-using-shortcodes/#post-6135669)
 * Awesome!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Problem using shortcodes’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/google-analytics-top-posts-widget.
   svg)
 * [Google Analytics Top Content Widget](https://wordpress.org/plugins/google-analytics-top-posts-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analytics-top-posts-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analytics-top-posts-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analytics-top-posts-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analytics-top-posts-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analytics-top-posts-widget/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Justin Sternberg](https://wordpress.org/support/users/jtsternberg/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/problem-using-shortcodes/#post-6135669)
 * Status: resolved