WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Hardeep Asrani
    Member
    Posted 1 year ago #

    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
    Member
    Posted 1 year 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.

    Jo

  3. anmari
    Member
    Posted 1 year ago #

    Actually Otto has a good writeup too that might help

    http://ottopress.com/2011/creating-a-site-specific-snippets-plugin/

  4. Mark / t31os
    Moderator
    Posted 1 year 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