Answer the question
In order to leave comments, you need to log in
How to implement the condition for inserting a custom logo into a template?
I am a theme developer and I have this problem:
After purchasing my theme, the user, having installed it, should first of all see the logo of the author of the default template on the main page. Then through "Theme Settings", he can replace the default logo with his own.
My theme settings are implemented using the Theme Costumizer Wordpress API, and in the logo field there you need to insert a link to the logo. Next, the link is stored in the database, but as a serialized array, along with other parameters, like this:
a:4:{i:0;b:0;s:18:"nav_menu_locations";a:0:{}s:17:"copyright_textbox";s:34:"Все права защищены";s:9:"logo_load";s:72:"http://cr65948-wordpress.tw1.ru/wp-content/uploads/2016/01/logo-mini.png";}
Answer the question
In order to leave comments, you need to log in
Checking so
if( ! empty( $image_field ) ) {
// Переменная содержит ссылку на загруженное изображение
return '<img src="' . $image_field . '">';
} else {
// Переменная пустая, выводим стандартную картинку
return '<img src="' . get_template_directory_uri() . '/images/default_logo.png">';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question