How can one utilize a variable as a callback function name for add_settings_field

Do not use different callbacks, use the the sixth parameter for add_settings_field() instead. That is an array, and you can pass any data to the callback here. Example: foreach( $theOptions as $k => $v ) { add_settings_field( $k, $v, ‘my_callback’, $the_options, $the_group, array ( ‘special’ => $k ) ); } function my_callback( $args ) { … Read more

Setting featured image with function, 1 part not working

You have to set the $single paramter of get_post_meta to false (or don’t set it) to get an array. Here is a sped-up version: if ($attachment_id = get_post_meta($post_id, ‘featured_image’, true)) : elseif ($attachment_id = get_post_meta($post_id, ‘upload_single_image’, true)) : elseif ($attachment_id = get_post_meta($post_id, ‘create_gallery’, false)) : $attachment_id = $attachment_id[0][‘upload_image’]; endif; Note: I did not test this. … Read more

How do I add customize_register action AFTER adding a custom taxonomy

AFAIK it shouldn’t be a problem to get taxonomy data at the customizer_register hook state. So that problem might have different reasons, but they aren’t apparent from your question. Besides I’m not sure what you are trying to achieve, so you might want to fill the information gaps according to @Rarst’s questions. Aside from that … Read more

Exclude Empty Child Categories in Menu

I would go about this slightly differently. Still using the wp_get_nav_menu_items filter, but first I’ll build an array containing the IDs of all empty terms. Then I’ll compare each of the $items to this for potential exclusion: add_filter( ‘wp_get_nav_menu_items’, ‘wpse177082’, 10, 3 ); function wpse177082 ( $items, $menu, $args ) { global $wpdb; $empty = … Read more

wp_link_pages: display current page number only if has multiple page breaks?

The $multipage is constructed inside the setup_postdata() method of WP_Query. It’s called when you run the_post(). So just as @s_ha_dum explained, you have to make a loop around it: You can try this: if( have_posts() ) { the_post(); // Make a call to setup_postdata(). echo sbwp_get_current_chapter(); // Display the current chapter. rewind_posts(); // Rewind back. … Read more