WordPress.org

Ready to get started?Download WordPress

Forums

Include by default a shortcode in posts (3 posts)

  1. Dunkkan
    Member
    Posted 5 years ago #

    Hi,

    I was thinking in a way to include by default a shortcode in the post editor content, maybe once I open it, or otherwise when the post is called by php (sorry if my approach is wrong, I'm quite ignorant about php).

    (I don't care about the position in the post markup the shortcode would be inserted in ; the begginig or the end, both possibilities are good for me.)

    Which core file should I modify to resolve something like that (if is a matter of modifying WP core files) ?

    I'd be very grateful if someone can answer this.

    I need to insert a contact form shortcode ([contact-form]), but in an automatized way.

    Thanks very much for any input.

  2. Dunkkan
    Member
    Posted 5 years ago #

    I guess it would look like something like this/

    function adding_your_shortcode($content)  {
       $yourshortcode = '[contact-form]';
       SOMETHING MAGIC HERE($yourshortcode);
       return $content;
    }
    
    add_filter('the_content','adding_your_shortcode', '10');

    Maybe something similar ?
    I just don't know which php actions can I use to insert the shortcode (the SOMETHING MAGIC section).

    Thanks if anyone can answer.

  3. Dunkkan
    Member
    Posted 5 years ago #

    anybody ? I really don't know how to build a function which can do that.

Topic Closed

This topic has been closed to new replies.

About this Topic