Bumped by Community user
    Bumped by Community user
    Bumped by Community user
3 formating show code
source | link

UPDATE 28/12: IUPDATE 28/12:

I see two issues happening.

  1. Not possible to save When I hit the save & publish button, the "busy" icon appears, then disappears but the save & publish button remains unchanged. If I check in the database, nothing has been updated.

  2. Saved in db but not visible When I see the right entry in the database like this one:

    { "2016-Foundation6-v0.6::single_categories_location_priority": { "value": "0", "type": "theme_mod", "user_id": 1 } } I sometimes get no value when using get_theme_mod

    {
      "2016-Foundation6-v0.6::single_categories_location_priority": {
        "value": "0",
        "type": "theme_mod",
        "user_id": 1
      }
    }
    

I sometimes get no value when using get_theme_mod

Another thing I

I noticed that my success rate was higher when I do only one change. Let's say I go to the customizer for the first time, I change one thing and save, I get this: {"success":true,"data":{"setting_validities":{"single_carousel_location":true},"changeset_status":"publish" ,"next_changeset_uuid":"9aff0388-b0bc-4be8-ba1a-2fd3cf24772c"}}

{"success":true,"data":{"setting_validities":{"single_carousel_location":true},"changeset_status":"publish"
,"next_changeset_uuid":"9aff0388-b0bc-4be8-ba1a-2fd3cf24772c"}}

{"success":false,"data":{"message":"","code":"changeset_already_published","data":null}}

{"success":false,"data":{"message":"","code":"changeset_already_published","data":null}}

UPDATE 28/12: I see two issues happening.

  1. Not possible to save When I hit the save & publish button, the "busy" icon appears, then disappears but the save & publish button remains unchanged. If I check in the database, nothing has been updated.

  2. Saved in db but not visible When I see the right entry in the database like this one:

    { "2016-Foundation6-v0.6::single_categories_location_priority": { "value": "0", "type": "theme_mod", "user_id": 1 } } I sometimes get no value when using get_theme_mod

Another thing I noticed that my success rate was higher when I do only one change. Let's say I go to the customizer for the first time, I change one thing and save, I get this: {"success":true,"data":{"setting_validities":{"single_carousel_location":true},"changeset_status":"publish" ,"next_changeset_uuid":"9aff0388-b0bc-4be8-ba1a-2fd3cf24772c"}}

{"success":false,"data":{"message":"","code":"changeset_already_published","data":null}}

UPDATE 28/12:

I see two issues happening.

  1. Not possible to save When I hit the save & publish button, the "busy" icon appears, then disappears but the save & publish button remains unchanged. If I check in the database, nothing has been updated.

  2. Saved in db but not visible When I see the right entry in the database like this one:

    {
      "2016-Foundation6-v0.6::single_categories_location_priority": {
        "value": "0",
        "type": "theme_mod",
        "user_id": 1
      }
    }
    

I sometimes get no value when using get_theme_mod

Another thing

I noticed that my success rate was higher when I do only one change. Let's say I go to the customizer for the first time, I change one thing and save, I get this:

{"success":true,"data":{"setting_validities":{"single_carousel_location":true},"changeset_status":"publish"
,"next_changeset_uuid":"9aff0388-b0bc-4be8-ba1a-2fd3cf24772c"}}
{"success":false,"data":{"message":"","code":"changeset_already_published","data":null}}
2 added 1263 characters in body
source | link

UPDATE 28/12: I see two issues happening.

  1. Not possible to save When I hit the save & publish button, the "busy" icon appears, then disappears but the save & publish button remains unchanged. If I check in the database, nothing has been updated.

  2. Saved in db but not visible When I see the right entry in the database like this one:

    { "2016-Foundation6-v0.6::single_categories_location_priority": { "value": "0", "type": "theme_mod", "user_id": 1 } } I sometimes get no value when using get_theme_mod

Another thing I noticed that my success rate was higher when I do only one change. Let's say I go to the customizer for the first time, I change one thing and save, I get this: {"success":true,"data":{"setting_validities":{"single_carousel_location":true},"changeset_status":"publish" ,"next_changeset_uuid":"9aff0388-b0bc-4be8-ba1a-2fd3cf24772c"}}

If I try to make other changes (not related to the first one), I get this kind of message:

{"success":false,"data":{"message":"","code":"changeset_already_published","data":null}}

If I leave again, go back to the customizer and make one change and save, it usually works

I haven't changed a line of code in the whole process.

UPDATE 28/12: I see two issues happening.

  1. Not possible to save When I hit the save & publish button, the "busy" icon appears, then disappears but the save & publish button remains unchanged. If I check in the database, nothing has been updated.

  2. Saved in db but not visible When I see the right entry in the database like this one:

    { "2016-Foundation6-v0.6::single_categories_location_priority": { "value": "0", "type": "theme_mod", "user_id": 1 } } I sometimes get no value when using get_theme_mod

Another thing I noticed that my success rate was higher when I do only one change. Let's say I go to the customizer for the first time, I change one thing and save, I get this: {"success":true,"data":{"setting_validities":{"single_carousel_location":true},"changeset_status":"publish" ,"next_changeset_uuid":"9aff0388-b0bc-4be8-ba1a-2fd3cf24772c"}}

If I try to make other changes (not related to the first one), I get this kind of message:

{"success":false,"data":{"message":"","code":"changeset_already_published","data":null}}

If I leave again, go back to the customizer and make one change and save, it usually works

I haven't changed a line of code in the whole process.

1
source | link

Get_theme_mod not retrieving value

I'm using the Wordpress customizer feature to configure my theme and I constantly bumping into the same annoying issue, sometimes I don't get any value from get_theme_mod while I see the effect of my change in the preview window.

Here is some code:

    $active_type="home";
    $wp_customize->add_setting($active_type.'_categories_max',array(
            'default'      => '10',
            'transport'    => 'refresh'
            ));

    $wp_customize->add_control( $active_type.'_categories_max',array(
            'type' => 'select',
            'label' => 'Max Items',
            'section' => $active_type.'_categories_section',
            'choices' => array(
                    '5' => '2',
                    '10' => '10',
                    '15' => '15',
                    '20' => '20',
                ),
            )); 

on my php page, I have:

$test = get_theme_mod('home_categories_max');
echo $test;

When I'm in the customizer, each time I change the value, I do see the correct value in the preview window. If I save and then visit the page directly (without the customizer), I don't get the value all the time. Sometimes I get immediately the value, sometimes I don't get it at all without changing anything to the code.

I first thought that it was a caching issue but emptying cache on server and browser did not solve the issue. If I save the value, exit the customizer then come back, I see that the value has been saved but get_theme_mod still returns an empty value.

I really don't see what's wrong with my code as it sometimes work without changing anything.

Do you have any idea?

Thanks

Laurent