WordPress 20th Anniversary Birthday Cake

WordPress Function Test get_option()

The following bit of code can be placed in your theme’s functions.php file to see a report of the values returned by the WordPress Core native funtion, get_option();

I knew I had this snippet lying around for precisely this purpose. I wanted to know how to get the id of the current theme dynamically, which is one of the bits of meta data that can be retrieved via get_option(). One might expect the parameter passed to be “theme_name”, or something of that nature, but actually get_option(“template”) returns the name of the active theme.

The function also includes get_bloginfo()

Try it out!

<?php

/**
* file: /wp-content/themes/your-theme/functions.php
*/

function test_get_options(){
 echo '<div><h2>List of get_option() options:</h2>
   <pre>get_option(home): '.get_option('home').'
  get_option("admin_email"): '.get_option("admin_email").'
    get_option("blogname"): '.get_option("blogname").'
  get_option("blogdescription"): '.get_option("blogdescription").'
    get_option("blog_charset"): '.get_option("blog_charset").'
  get_option("date_format"): '.get_option("date_format").'
    get_option("default_category"): '.get_option("default_category").'
  get_option("home"): '.get_option("home").'
  get_option("posts_per_page"): '.get_option("posts_per_page").'
  get_option("posts_per_rss"): '.get_option("posts_per_rss").'
    get_option("siteurl"): '.get_option("siteurl").'
    get_option("template"): '.get_option("template").'
  get_option("start_of_week"): '.get_option("start_of_week").'
    get_option("upload_path"): '.get_option("upload_path").'
    get_option("users_can_register"): '.get_option("users_can_register").'
  get_bloginfo("url"): '.get_bloginfo( 'url' ).'
    get_bloginfo("wpurl"): '.get_bloginfo( 'wpurl' ).'
    </pre>';
  }
add_action('admin_menu', 'test_get_options');
test_get_options();
?>

Whatchu do


Leave a Reply

Your email address will not be published. Required fields are marked *