• Resolved Mr Press

    (@tahrirsquare)


    Trying to put two different shortcodes in separate page templates is not working. Both pages will display the top posts on the first visited page that contains the shortcode.

    Example

    Page 1:
    <?php echo do_shortcode( '[google_top_content pageviews=5 number=10 contentfilter=post showhome=no time=2628000]' ); ?>

    Page 2:
    <?php echo do_shortcode( '[google_top_content pageviews=5 number=5 contentfilter=post showhome=no time=2628000]' ); ?>

    If page 2 is the first one which gets visited, both page 1 and page 2 will show 5 posts.

    https://wordpress.org/plugins/google-analytics-top-posts-widget/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Mr Press

    (@tahrirsquare)

    There seems to be something else going on with the shortcode which is not correct.

    I have put the following shortcode in my template:

    <?php echo do_shortcode( '[google_top_content pageviews=5 number=5 contentfilter=post showhome=no time=2628000]' ); ?>

    Sometimes the shortcode shows the correct posts, but then it will start showing the ten most read posts for the last year instead. I have no top content widget activated and made sure to clear all transients and remove the second top content shortcode I was using which was interfering with the first one.

    This is the only thing that google top content puts in the database:

    (99740,'_transient_timeout_dw-gtc-list-google_top_content','1395095707','no'),(99741,'_transient_dw-gtc-list-google_top_content','<ol><li> ... followed by the posts.

    I have no idea why it changes to ten posts for the latest year.

    Thread Starter Mr Press

    (@tahrirsquare)

    Please disregard the last comment. It happened due to an oversight on my part. I did some reading up on shortcodes and realized that they need separate id’s to if they should have multiple instances. I’ll mark this as resolved and make it a feature request. Many thanks for the great plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode cannot be used twice in different pages’ is closed to new replies.