admin管理员组

文章数量:1330628

Hello I have a metabox field called name this returns an iframe that I have placed but it returns all the code of the iframe and it was not executed. What is missing in my code to show it in the frontend?

$maintitlet =  get_post_meta( get_the_ID(), 'name', true );
echo $maintitle;

show the code. I have put that space because it did not allow me to publish the code iframe

<iframe src="link.html" width="670" height="500"></iframe>

Hello I have a metabox field called name this returns an iframe that I have placed but it returns all the code of the iframe and it was not executed. What is missing in my code to show it in the frontend?

$maintitlet =  get_post_meta( get_the_ID(), 'name', true );
echo $maintitle;

show the code. I have put that space because it did not allow me to publish the code iframe

<iframe src="link.html" width="670" height="500"></iframe>
Share Improve this question edited Jul 13, 2020 at 4:36 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jul 12, 2020 at 19:35 StymarkStymark 372 bronze badges 1
  • Your variable names don't match: $maintitlet and $maintitle are two different things. – fuxia Commented Jul 13, 2020 at 4:37
Add a comment  | 

1 Answer 1

Reset to default 1

The output is escaped, so it will not display html, try this :

just save the value of the src attribute

<iframe src="<?php echo esc_attr__( get_post_meta( get_the_ID(), 'name', true ) ); ?>" width="670" height="500">

本文标签: iframemetabox wordpress show in frontend