[resolved] How to create a plugin to add a little snippet to function.php? (4 posts)

  1. Hey, I'm new to WP and trying to create a simple plugin. Can you explain how to create a simple plugin which adds just a little snippet to blog's function.php file. For example I want to add this simple snippet to function.php (just for example)

    add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

    Can you post full php structure of it (without header information). It would be great, please I'm new to WP and php and trying to learn some basic things :)

  2. Jo Biesta
    Posted 3 years ago #

    Hi Hardeepasrani,

    Have a look at http://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme
    you can hook your function for adding theme support into this which should work for you.


  3. anmari
    Posted 3 years ago #

    Actually Otto has a good writeup too that might help


  4. Mark / t31os

    Posted 3 years ago #

    You should leave the theme support to the theme, it's not your plugin's place to go modifying the theme's files, especially the functions file.

    If your plugin requires that support, write it into the installation instructions, the FAQ section of the plugin page and/or explicitly display a message on the plugin's setup page that states what users are required to add to their themes to properly use the plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic