I'm using the theme customizer to allow the user to select which pages to show the excerpt of on the front page. I've done this by using an array in the setting name:
$wp_customize->add_setting( 'learn_more' , array( 'default' => 1 ) ); $wp_customize->add_setting( 'learn_more' , array( 'default' => 1 ) ); $wp_customize->add_setting( 'learn_more' , array( 'default' => 1 ) );
I then create a control for each.
front-page.php template I then use
get_theme_mod('learn__more') to provide an array of pages to search for in a custom loop.
It works perfectly. Except...
I've reduced the number of items I want from 4 to 3. But, the 4th item is now stored in the database so each time I use the
get_theme_mod it returns an array of 4 items. As a result, the loop in my
front-page.php shows 4 items.
Is there a way to solve this? How can I delete the 4th item in the database? I can see a future position where I will want to adjust the number through a setting on the customizer, but that will cause this problem to happen each time I change the number of items.
Does anyone have any clever ideas?