• Hi! is there any way to fetch the content of shortcode before saving the post to database?

    [shortcode]Hello[/shortcode]

    before this is saved to database, it should be replaced with logged in author.

    Shortcodes are working at the time of display only, not saving the content into database.
    How to use them for saving the content into database?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Shortcodes aren’t meant to do that sort of thing. There is a way to do what you want, but it does involve a bit of programming work on your side…

    What you want to do is create a plugin or add your code to your current theme. You need to look for a hook that gets the post content before it’s saved using add_filter(“content_filtered_save_pre”, “your_function”). Then you can write a function to replace whatever you need to inside the post. I’d stay away from using the current shortcode notation and use something of your own that won’t get confused for it.

    Thread Starter Jatinder Pal Singh

    (@j_p_s)

    Thanks. I got the solution. I used PHP preg replace function for the purpose.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fetching shortcode content before saving post’ is closed to new replies.