Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
156 views
in Technique[技术] by (71.8m points)

php - How to display footer widgets on a page dependant on a url containing a specific string

I have realised that my events page does not display my footer widgets. I had this problem with my woocommerce pages and I fixed it by including the following in the functions.php file:

if ( is_woocommerce() )
    include( 'template-parts/footer-menus-widgets.php' );

So I need to do something similar. My thinking is to check the url so that if the url contains /events then display the footer widget.

Does anybody know how to do that?

Thank you

question from:https://stackoverflow.com/questions/66062701/how-to-display-footer-widgets-on-a-page-dependant-on-a-url-containing-a-specific

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is how I solved it, this code checks if the url contains a string of /events. Include this in the functions.php code:

 if (stripos($_SERVER['REQUEST_URI'], '/events' )!==false)
    include( 'template-parts/footer-menus-widgets.php' );

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...