Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionImagine that I have an HTML file as one of my WordPress blog pages (let's call it page B). I want to write an if condition inside a tag on page B to check if a specific element exists on another web page (page A).
My question is what function should I choose to check this condition? Should I also import the HTML file of page A inside page B? And what should I do on the server-side, if I have to?
Thanks
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionImagine that I have an HTML file as one of my WordPress blog pages (let's call it page B). I want to write an if condition inside a tag on page B to check if a specific element exists on another web page (page A).
My question is what function should I choose to check this condition? Should I also import the HTML file of page A inside page B? And what should I do on the server-side, if I have to?
Thanks
Share Improve this question edited Oct 1, 2020 at 12:46 Shima Masaeli asked Oct 1, 2020 at 12:41 Shima MasaeliShima Masaeli 32 bronze badges 1 |1 Answer
Reset to default 0If I understand you correctly, and you want to find an HTML element inside another page, you need to use some HTML parser.
Take a look at https://www.php/manual/en/domdocument.loadhtmlfile.php or https://github/paquettg/php-html-parser. I believe there are more tools that can help you with this.
On page B you load page A as a remote document by URL, then parse it and look for the desired HTML element.
.html
files in your site? What problem does this solve? It's a little too abstract/generic at the moment so context will help – Tom J Nowell ♦ Commented Oct 1, 2020 at 13:10