admin管理员组文章数量:1391918
I've created a code snippet with its shortcode to hide part of the post content for non-logged users: [private] ... [/private]
works great but when I try to put another shortcode (contact form 7) inside its not recognized. What could be the problem?
This is my code snippet:
function bp_contenido_privado( $atts, $content = null ) {
if ( is_user_logged_in() )
return $content;
return '<p style="font-weight:bold;padding-top:10px;">Este contenido esta reservado para los usuarios registrados. Registrate <a href="'.wp_registration_url().'">aquí</a> o <a href="'.wp_login_url(get_permalink()).'">inicia la sesión</a> para poder verlo..</p>';
}
and this is the post content:
[privado]
<h4>Por favor llene los datos solicitados. Los formatos aceptados para subir archivos son pdf y jpg con un tamaño máximo de 2mb.</h4>
[contact-form-7 id="3584" title="Formulario de Inscripción"]
[/privado]
I've created a code snippet with its shortcode to hide part of the post content for non-logged users: [private] ... [/private]
works great but when I try to put another shortcode (contact form 7) inside its not recognized. What could be the problem?
This is my code snippet:
function bp_contenido_privado( $atts, $content = null ) {
if ( is_user_logged_in() )
return $content;
return '<p style="font-weight:bold;padding-top:10px;">Este contenido esta reservado para los usuarios registrados. Registrate <a href="'.wp_registration_url().'">aquí</a> o <a href="'.wp_login_url(get_permalink()).'">inicia la sesión</a> para poder verlo..</p>';
}
and this is the post content:
[privado]
<h4>Por favor llene los datos solicitados. Los formatos aceptados para subir archivos son pdf y jpg con un tamaño máximo de 2mb.</h4>
[contact-form-7 id="3584" title="Formulario de Inscripción"]
[/privado]
Share
Improve this question
edited Mar 23, 2020 at 15:26
ominem
asked Mar 23, 2020 at 15:17
ominemominem
231 silver badge5 bronze badges
5
|
1 Answer
Reset to default 0You can wrap the entire return
output in a do_shortcode()
. That will render the shortcode as well as output the regular content.
function bp_contenido_privado( $atts, $content = null ) {
if ( is_user_logged_in() ) {
return do_shortcode( $content );
}
return '<p style="font-weight:bold;padding-top:10px;">Este contenido esta reservado para los usuarios registrados. Registrate <a href="'.wp_registration_url().'">aquí</a> o <a href="'.wp_login_url(get_permalink()).'">inicia la sesión</a> para poder verlo..</p>';
}
本文标签: postsContact Form 7 Shortcode not recognized inside another shortcode
版权声明:本文标题:posts - Contact Form 7 Shortcode not recognized inside another shortcode 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744643831a2617277.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
$content
inreturn do_shortcode( $content );
As a side note, I would strongly recommend wrapping yourif
statement in{}
. Much easier to read. – disinfor Commented Mar 23, 2020 at 15:51