Home how to change url of a single page based on title of page?
Reply: 1

how to change url of a single page based on title of page?

Ahmad
1#
Ahmad Published in 2018-01-13 10:49:12Z

I'm developing wordpress and in a single page I want to change the URL of my button based on title of page. that need php code(wordpress) to each page for portfolio.

<p><a href="<?php  get_site_url() ?>" target="_blank" class="btn-portfolio">show site</a></p>
yivi
2#
yivi Reply to 2018-01-13 13:11:15Z

You are not telling us what would you be looking for in the page title, nor where would you be getting the URL to use in the template; so a complete example simply can't be written.

But basically you'd need to check the response of get_the_title();

Something along the lines of:

if (strpos('example', get_the_title()) !== false) {
   $url = get_site_url();
} 
else {
{
   $url = 'https://www.google.com');
}
?>
<p><a href="<?php echo $url ?>"
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308912 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO