>  기사  >  백엔드 개발  >  Wordpress设置只允许登陆用户查看内容短码调用问题,求助

Wordpress设置只允许登陆用户查看内容短码调用问题,求助

WBOY
WBOY원래의
2016-06-06 20:37:051091검색

在function.php中插入了如下代码实现登陆用户才能查看文章内容,在每篇文章需要登陆用户查看的地方插入[members_only] [/menmbers_only].

但是我在文章中使用FooGallery的短码后,FooGallery无法正常显示,请教如何解决?
[members_only]
[foogallery id="141"] 文章发布后这里还是显示[foogallery id="141"],并未调用短码。
[/menmbers_only]

<code>add_shortcode( ‘members_only’, ‘members_only_shortcode’ );

function members_only_shortcode( $atts, $content = null )

{

if ( is_user_logged_in() && !empty( $content ) && !is_feed() )

{

return $content;

}

return ‘注册并购买课程之后才能学习哦~';

}
</code>

回复内容:

在function.php中插入了如下代码实现登陆用户才能查看文章内容,在每篇文章需要登陆用户查看的地方插入[members_only] [/menmbers_only].

但是我在文章中使用FooGallery的短码后,FooGallery无法正常显示,请教如何解决?
[members_only]
[foogallery id="141"] 文章发布后这里还是显示[foogallery id="141"],并未调用短码。
[/menmbers_only]

<code>add_shortcode( ‘members_only’, ‘members_only_shortcode’ );

function members_only_shortcode( $atts, $content = null )

{

if ( is_user_logged_in() && !empty( $content ) && !is_feed() )

{

return $content;

}

return ‘注册并购买课程之后才能学习哦~';

}
</code>

return do_shortcode($content);

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.