Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HOW check if exist some page slug ???
#3
(2017-04-07, 18:20:21)Bigin Wrote: To check page exist you can use global $pagesArray variable, it contains cached page data:

Code:
global $pagesArray;
if(isset($pagesArray[$slug])) echo 'Page exist';
else echo 'Page does not exist';

Another, quicker option would be to check it manually with native file_exist() PHP method, for example:

Code:
if(file_exists(GSDATAPAGESPATH.$slug.'.xml')) echo 'Page exist';
else echo 'Page does not exist';

PS. Do not forget to sanitize the user input!

Nice solution Smile 
I use this for my template functions.php  
Thank you.
Reply


Messages In This Thread
HOW check if exist some page slug ??? - by angelo - 2017-04-07, 17:02:50
RE: HOW check if exist some page slug ??? - by angelo - 2017-04-07, 18:56:47



Users browsing this thread: 1 Guest(s)