Articles of get option

Serialize data for wp options

I am creating my first ever plugin, its purpose is to show a notice when some conditions are met, I created the function in jQuery and initially I had to manually edit the file everytime I wanted to change the notice message, so I decided to create a settings page so that the user could […]

How to find what index page a post is on?

Here is a simple example of what I am wanting to figure out. Say I have WordPress set to show 5 posts per page. And say I there is a post 17 posts back chronologically. The formula would be 17 / 5 = 3.4. Round up 3.4 to a whole page of 4 and that […]

Save wp_editor() content as option

I’m having some troubles with a extra feature i’m writing for my theme. The admin should be able to make some special posts, those posts are stored as an option. The options are atored as an array and WP makes it’s own json for arrays. So, the user has a wp_editor(), and the array stored […]

shortcode causing the_content() to return blank?

I have a shortcode that just retrieves some info from the options table in the database. For whatever reason, when the content reaches a certain character limit the_content() to return blank? The function is pretty basic and I can’t for the life me figure out why this is happening? Here’s an example of the code: […]

Minimal wordpress load for only `get_option` to work (because ajax…)

In a plugin I use ajax to get_option() which takes much longer than it has to because entire wp gets loaded. How do I set things up so that it (my ajax) loads only what is needed? (get_option())

Why does WordPress stores widget options in a multidimensional array?

I have a widget with 6 different options. When I use get_option, it gives me a multidimensional array, with all my options inside the inner array, like so: $options = get_option(‘widget_widgetname’); var_dump($options); And the output for var_dump is: array(2) { [2]=> array(5) { [“string”]=> string(6) “Search” [“title”]=> string(12) “WDSearchForm” [“show_wrapper”]=> string(0) “” [“animate”]=> string(0) “” […]

How to fetch serialized data from wordpress options

I have the following serialized data in a wp option a:2:{s:5:”Title”;s:11:”your title”;s:7:”Message”;s:20:”Hola testing testing”;} I would like to return it to be used in a form, and show it also in the front end, I tried <?php echo get_option(‘notice_data[Message]’); ?> this is the array $notice_data = array( ‘Title’ => ”, ‘Message’ => ” ); add_option(“notice_data”, […]

get option framework options returns Call to undefined function of_get_option()

I have this kind of twitter feeds fetcher and as the twitter API requires consumer key, consumer secret, access token, access secret so I created those fields using option framework in my theme and then created a config file (config.php) to used for the twitters api define(‘CONSUMER_KEY’, of_get_option(“enable_tw”) && of_get_option(“tw_consumer_key”) ? of_get_option(“tw_consumer_key”) : ‘assume my […]

How to use get_option() without any filter?

I’m using the newest WordPress 3.3.1 and newest qTranslate 2.5.27. I have made some an AJAX script which returns a value and message in the current language. Here I get my first problem, I solve it by sending in AJAX lang from qtrans_getLanguage() and using messages with qtrans_use($lang, ‘<!–:pl–>PL message<!–:–><!–:de–>DE message<!–:–>’); I have an wp_option […]

Why does get_theme_mod return blank (or default value) but get_option returns saved value?

Why does get_theme_mod return blank (or the default value if specified) but get_option returns the correct (saved) value? I have a colour picker in the customizer color-primary which functions correctly and saves selected value to the database, however, get_theme_mod returns blank while get_option returns the saved value. echo get_option(‘color-primary’); //returns saved value echo get_theme_mod(‘color-primary’); // […]