R
R
Rasul Gitinov2016-01-17 20:39:42
PHP
Rasul Gitinov, 2016-01-17 20:39:42

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";}

The bottom line is that I need to write a condition, but I don’t know how:
If the field for inserting a link to the logo is empty, then display the standard logo, and if there is a link, then display the user’s logo.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2016-01-17
@raselgit

Checking so

if( ! empty( $image_field ) ) {
    // Переменная содержит ссылку на загруженное изображение
    return '<img src="' . $image_field . '">';
} else {
    // Переменная пустая, выводим стандартную картинку
    return '<img src="' . get_template_directory_uri() . '/images/default_logo.png">';
}

Substitute yourself into the context of the Customizer API.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question