Automatically adding shortcode to each users page

[ad_1]

Hi,

I’m just wondering if this is possible. I’ve seen a timeline plugin that i would like to use on a site. You use it by creating a shortcode block which takes the users posts and puts it in a timeline

My question is, is it possible to force the shortcode into just one page when a user creates a page?

Thanks

[ad_2]
2 Comments
  1. How is the shortcode distinguished between users? Is it automatic by their username like [timeline user=”dave”]
    If this is the case, yes you could automatically put this on all pages created by the user. You would have to add some code to your index or page.php

    However which page is it going to be as this would put the timeline on all page, you can specify which page you want it on using the page ID, but this has to be specified and isn’t automatic..

    So to help we’d need to know how the shortcode works, and which specific page it is required on.

  2. Only thing I can think of is to add a custom field to posts – and put the user ID in it. Then do a pre_get_posts() filter that checks what page you’re on, and if it’s the ‘my timeline’ page – filter posts by current user ID. Then the timeline plugin will only show users posts.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer