Forums

How to get a serialized option (3 posts)

  1. cognitions
    Member
    Posted 2 years ago #

    Could someone indicate how to retrieve a specific option value from a Plugin which has serialized values.

    For example. A Plugin has a row in the options table "my_plugin_options".

    It has serialized data but we know the unserialized form is:
    themecolor: red
    sidebarwidth: 300px
    headerimage: apples

    This does not work:

    echo get_option (my_plugin_options_themecolor)

    like it does for non serialized options. I have studied themes and plugins but to no avail.

    Many thanks.

  2. cognitions
    Member
    Posted 2 years ago #

    Discovered it through trial and error>

    $my_site_options = get_option('my_site');
    echo( $my_site_options['option_name'] );

    Hope that is useful for someone.

  3. nadine00
    Member
    Posted 2 years ago #

    Hmm. I'm trying to pull serialized data out of custom filed. Would you have any suggestions on how to use this method in that kind of set up?

    http://wordpress.org/support/topic/394398

    using the get_post_meta() just comes back blank:

    <?php
    		$my_grade = get_post_meta($post->ID, 'lesson-type', true);
    		echo( $my_grade['Secondary'] );
    		?>

    Thanks for posting your trial and error findings btw. :)

    Nadine

Topic Closed

This topic has been closed to new replies.

About this Topic