Getting started with WordPressget_bloginfo()Enqueuing scriptsMaking network requests with HTTP APIEnqueuing Styleshome_url()Custom Post Typestemplate_includeThe Loop (main WordPress loop)AJAXThe $wpdb ObjectActions and Filterswp_get_current_user()Add/remove contact info for users with user_contactmethods filter hookCreating a custom templateCustomizer Hello WorldCustomizer Basics (Add Panel, Section, Setting, Control)The Admin Bar (aka "The Toolbar")Querying postsAlternating main loop (pre_get_posts filter)ShortcodeCreate a Post Programmaticallyget_template_part()Taxonomiesget_template_part()ShortcodesPost FormatsCustom exerpts with excerpt_length and excerpt_morePlugin developmentSecurity in WordPress - EscapingTemplate hierarchyRemove Version from Wordpress and StylesheetsChild Theme Basicsadd_action()get_template_part()Shortcode with attributeSidebarsSecurity in WordPress - SanitizationinitCreate Template for Custom Post TypeFunction: add_action()Add ShortcodeHow Can I integrate Markdown editor with Advance Custom Field's repeater Add-on.Installation and Configurationwp_get_current_user()WP-CronSecure your installationOptions APIFunction : wp_trim_words()WP_Query() LoopUpdate WordPress ManuallyThemesWP-CLIDebuggingadd_menu_page()add_submenu_page()get_option()get_permalink()get_the_category()the_title()get_the_title()add_editor_style()add_theme_support()WordPress Plugin creationRun WordPress local with XAMPPAdmin Dashboard WidgetsSite MigrationMeta BoxRemove Auto Line Breaks From Content and Excerptget_home_path()Wordpress theme and child-theme developmentREST API

get_option()

Other topics

Remarks:

List of arguments for $option

  • 'admin_email'
  • 'blogname'
  • 'blogdescription'
  • 'blog_charset'
  • 'date_format'
  • 'default_category'
  • 'home'
  • 'siteurl'
  • 'template'
  • 'start_of_week'
  • 'upload_path'
  • 'users_can_register'
  • 'posts_per_page'
  • 'posts_per_rss'

Show blog title

Code

<h1><?php echo get_option( 'blogname' ); ?></h1>

Output

Name of the blog in H1 style

Show Character Set

Code

<p><?php echo esc_html( sprintf( __( 'Character set: %s', 'textdomain' ), get_option( 'blog_charset' ) ) ); ?></p>

Output

Character set: UTF-8

Handling non-existing options

Code

<?php echo get_option( 'something_bla_bla_bla' ); ?>

Output

false


Code

<?php echo get_option( 'something_bla_bla_bla', 'Oh no!' ); ?>

Output

Oh no!

Syntax:

  • get_option( $option, $default )

Parameters:

ParameterDetails
$option(string) Name of option to retrieve. Expected to not be SQL-escaped.
$default(mixed) (Optional) Default value to return if the option does not exist.

Contributors

Topic Id: 9194

Example Ids: 28542,28543,28544

This site is not affiliated with any of the contributors.