2017-04-07, 17:02:50
I need check if exist some page slug.
example:
exist_page('page-21');
Please help Thanks.
example:
exist_page('page-21');
Please help Thanks.
HOW check if exist some page slug ???
|
2017-04-07, 17:02:50
I need check if exist some page slug.
example: exist_page('page-21'); Please help Thanks.
To check page exist you can use global $pagesArray variable, it contains cached page data:
Code: global $pagesArray; 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'; PS. Do not forget to sanitize the user input!
2017-04-07, 18:56:47
(2017-04-07, 18:20:21)Bigin Wrote: To check page exist you can use global $pagesArray variable, it contains cached page data: Nice solution I use this for my template functions.php Thank you. |
« Next Oldest | Next Newest »
|