Fetch customizer image and output as an inline css style background image
Fetch customizer image and output as an inline css style background image
Fetch customizer image and output as an inline css style background image
There’s not really any trick, you need to check all the values. You can save a little space though, by omitting the != ”, which is redundant: if ( get_theme_mod( ‘myplugin_h2_color’ ) || get_theme_mod( ‘myplugin_h3_color’ ) || get_theme_mod( ‘myplugin_p_color’ ) || get_theme_mod( ‘myplugin_p_size’ ) ) { However, it’s possible to save Customiser settings into a … Read more
retrieve “Link Color” value
Getting text from custom field from customizer
Filter the get_theme_mod() function (wp-includes/theme.php): add_filter( ‘theme_mod_header_image’, ‘localized_header’ ); function localized_header( $img ) { // Do something awesome with the $img path. return $img; }
You should never access directly theme files, form submissions, ajax, and even just get requests will be blocked at the server level by some security hardening measure. Ignoring that for a moment, the reason your code fails is because wordpress wasn’t bootstrapped and therefor there are no core functions available. It is actually not 100% … Read more
I am not very familiar with Customizer part of code, but my immediate guess would that number is attachment ID for the uploaded image. IDs are most typical and reliable way to store connection to particular media item within WP installation. It is trivial to get from ID to other representations, such as URLs to … Read more
Ends up that “alt” is not stored in wp_get_attachment_metadata so I pulled it from the post meta: $custom_logo_id = get_theme_mod(‘custom_logo’); if ($custom_logo_id) { $image = wp_get_attachment_image_src($custom_logo_id, ‘full’); $meta = wp_get_attachment_metadata($custom_logo_id); **$alt_text = get_post_meta($custom_logo_id, ‘_wp_attachment_image_alt’, true);** echo ‘<img src=”‘ . $image[0] . ‘” alt=”‘ . $alt_text . ‘” width=”‘ . $meta[‘width’] . ‘” height=”‘ . $meta[‘height’] … Read more
Use the official CLI tool: wp search-replace ‘http://localhost’ ‘https://yoursitecom’ It will automatically deserialize any post meta, options, theme mods, etc and adjust them to match the new URL. Fundamentally though, it’s bad practice to store URLs to images posts and assets in the database. Store the post ID instead, and this problem goes away
You have to register the menu location first. Also, I’ve added else statement to be sure $menu_id is defined when menu exists. Otherwise, you’ll see the PHP Notice about undefined variable. WP_DEBUG must be turned on when you develop, that’s why you don’t see the notice. // Initialize name and location $menu_name=”Simple Inventory Menu”; $menu_location … Read more