문제

Im trying to make a section in the backend of a wordpress site were a user can update the sites favicon, i understand how to implement the html of this

<link rel="shortcut icon" href="assets/favicon.ico" />

and im pretty familiar with php, but im unsure how to make the change to the backend of the wordpress cms to make a section that will allow for a user to upload the favicon.ico file, any ideas ?

Just to be clear im sure there a probably wordpress plugins for this, but i would like to know how to add it natively to the theme, rather than having to install a 3rd party plugin..

도움이 되었습니까?

해결책

You could create an options page that holds an upload form, which leverages the WordPress' Filesystem API that handles the file part of it. You just need to specify a solid place where the icon file is uploaded, as you want to keep the favicon data inside template file head section the same everywhere.

But remember to validate all uploads! Bad things happen when users are allowed to upload malformed data (either by accident or on purpose).

WP Codex also has a page on creating custom options pages, where this upload form could be inserted.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top