Reputation: 183
I am making my first steps learning to code. I made some courses in Codeacademy and now I decided to continue learning while I build a wordpress child theme.
The thing is that I have a menu toggle. It's a button called menu:
<button id="menu-toggle" class="menu-toggle"><?php _e( 'Menu', 'twentysixteen' ); ?></button>
What I'm trying to do is to replace the name "Menu" and give it the name of the actual page or post title.
I tried to make this but it doesn't work:
<button id="menu-toggle" class="menu-toggle"><?php _e( '<?php the_title(); ?>', 'twentysixteen' ); ?></button>
Do you have some suggestion? Maybe the solution is something more complex than this that I try to imagine?
Upvotes: 1
Views: 221
Reputation: 5099
Welcome to the awesome world of PHP and WordPress development 🙂
The opening php tag ( <?php
) is used already in button, using it again inside __()
function would result in an error...
Also, the_title()
would echo the title, not return it which will not pass the value to __
translation function...
Best thing to do is to remove __()
translation function altogether so that your code looks like this...
<button id="menu-toggle" class="menu-toggle"><?php the_title(); ?></button>
Hope that helps...
Upvotes: 2