I want to show a css button and text field in PHP(functions.php of WordPress theme).
I am able to do everything but the issue is just the value="<?php echo wp_get_shortlink(get_the_ID()); ?>"
which does't execute if I use double quotes.
Here is my code:
function add_buttons_filter( $content ) {
$content .= ' <span class="abf">
<span class="abc">
<button class="bcd"><span class="dcb"><span></span></span>
</button>
</span>
<span class="abf">
<span class="abc-main">
<span class="abc-box" style="display:none;">
<input type="text" style=" max-width: 80px;" value="<?php echo wp_get_shortlink(get_the_ID()); ?>" onclick="this.focus(); this.select();" />
</span>
</span>
</span>
</span>';
return $content;
}
add_filter( 'the_content', 'add_buttons_filter' );
Could any one help me or show me a better solution to execute this in functions.php ?
Your statement is already embedded in php-Code, so it won't help to insert further code there - you can directly do the stuff:
function add_buttons_filter( $content ) {
$content .= ' <span class="abf">
<span class="abc">
<button class="bcd"><span class="dcb"><span></span></span>
</button>
</span>
<span class="abf">
<span class="abc-main">
<span class="abc-box" style="display:none;">
<input type="text" style=" max-width: 80px;" value="' . wp_get_shortlink(get_the_ID()) . '" onclick="this.focus(); this.select();" />
</span>
</span>
</span>
</span>';
return $content;
}
add_filter( 'the_content', 'add_buttons_filter' );
Try like this
<input type="text" style=" max-width: 80px;" value='.wp_get_shortlink(get_the_ID()).' onclick="this.focus(); this.select();" />
use this
value="' . wp_get_shortlink(get_the_ID()) . '"