1

Hi this may look a little silly question but can someone let me know where is the location for theme_path? is it inside my own theme or very top level of the directory?

'menu_icon'  => theme_path . '/images/product-icon.png', 

A: www.awebsite.com/images/product-icon.png
B: www.awebsite.com/wp-content/themes/mytheme/images/product-icon.png

2

It's not entirely clear what you are referring to here. Judging from your code theme_path looks like a constant.

Usually when supplying/printing links to theme assets you would use get_bloginfo('key') with one of the keys template_directory or stylesheet_directory. Basically the latter will point at the child theme and the first to the parent theme if you are using a child/parent setup. Otherwise they are identical. Alternatively you could use get_stylesheet_directory_uri() or get_stylesheet_directory_uri() which behaves the same way.

In any case, they will return http://www.yoursite.com/path/to/wordpress/wp-content/themes/your-theme/, and you are responsible for appending the path with '/images/product-icon.png' or whatever is appropriate. Thus, alternative B in your question is correct.

One side note: WordPress generally uses the terms uri or url when referring to content your browsers will load, and the term path when referring to files on the servers local file system (i.e. resources that WordPress/PHP will load in itself).

3
  • Thanks Simon, what I am trying to do is creating a "Custom Page Type" and setting a menu_icon for that.As you know I am registering the page in function.php page, so what should I do now?
    – Suffii
    Jan 29 '13 at 8:13
  • Change the line in your example into 'menu_icon' => get_stylesheet_directory_uri() . '/images/product-icon.png' and it should workout fine, given that you have directory called images inside your theme holding the file product-icon.png.
    – Simon
    Jan 29 '13 at 8:16
  • Glad I could help!
    – Simon
    Jan 29 '13 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.