php - file_exists(...) not working in wordpress -


trying use file_exists() function in wordpress unable expected result.

if(file_exists(wp_plugin_url.'/sinetiks-schools/images/t_1.jpg')){         echo "ok";     } else {         echo "not";     } 

you should try:

if(file_exists(plugin_dir_path( __file__ ).'/sinetiks-schools/images/t_1.jpg')){  } 

make sure getting correct path plugin_dir_path( __file__ )

you can find more information on plugin_dir_path function here


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -