如果找到快捷码,是否显示文本消息?

时间:2019-04-03 作者:Nicolas Logerot

几个小时来,我只想在有图片库的情况下显示一条消息,但没有成功,一个想法?

已尝试此代码,但不起作用:

    /**
 * galeries content
 */
function iconic_galeries_endpoint_content() {
    echo /* Template Name: Client Area */

get_header();
?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main">
        <section>
        <header class="entry-header">
                    <h1><?php _e( \'Photos gallery.\', \'my-theme\' ); ?></h1>
                </header>
            <article>

                <div class="entry-content">
                <?php
                $current_user = wp_get_current_user();

                if ( isset( $current_user->user_email ) ) {
                    echo \'<p>\' . sprintf( __( \'%s, here is your client area\', \'my-theme\' ), $current_user->display_name ) . \':</p>\';

                    if($output == \'<li class="picu-status-\' . get_post_status() . \'"><a href="\' . get_permalink() . \'">\' . get_the_title() . \'</a></li>\') echo \'<div class="woocommerce-MyAccount-content">
    <div class="woocommerce-notices-wrapper"></div>
    <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
        Your gallery.   </div>

</div>\';
else echo $output;

                    $output = do_shortcode( \'[picu_list_collections email="\' . $current_user->user_email . \'"]\' );

// the shortcode returns an empty <ul> tag, if there is no gallery 
// https://plugins.trac.wordpress.org/browser/picu/trunk/frontend/includes/picu-template-functions.php#L464

if($output == \'<ul class="picu-collection-list"></ul>\') echo \'<div class="woocommerce-MyAccount-content">
    <div class="woocommerce-notices-wrapper"></div>
    <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
        There is no gallery.    </div>

</div>\';
else echo $output;
                }

                ?>
                </div>
            </article>
            </section>
        </main>
    </div>

<?php
}
提前谢谢你

1 个回复
最合适的回答,由SO网友:Qaisar Feroz 整理而成

Try this:

<article>

                <div class="entry-content">
                <?php
                $current_user = wp_get_current_user();

                if ( isset( $current_user->user_email ) ) {
                    echo \'<p>\' . sprintf( __( \'%s, here is your client area\', \'my-theme\' ), $current_user->display_name ) . \':</p>\';


                    $output = do_shortcode( \'[picu_list_collections email="\' . $current_user->user_email . \'"]\' );

                    // the shortcode returns an empty <ul> tag, if there is no gallery 
                   // https://plugins.trac.wordpress.org/browser/picu/trunk/frontend/includes/picu-template-functions.php#L464

                   if($output == \'<ul class="picu-collection-list"></ul>\') {
                        echo \'<div class="woocommerce-MyAccount-content">
                                 <div class="woocommerce-notices-wrapper"></div>
                                 <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
                                   There is no gallery.
                                </div>
                             </div>\';
                   }
                   else {
                       echo \'<div class="woocommerce-MyAccount-content">
                                <div class="woocommerce-notices-wrapper"></div>
                                <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
                                    Your gallery.
                                </div>
                         </div>\';
                       echo $output;
                  }
  }

                ?>
                </div>
            </article>

相关推荐

Shortcode is not working

通过阅读教程,我创建了一个简单的快捷代码:<?php /* Plugin Name: GT NoTranslate Shortcode Description: Shortcode to wrap a span with the \"notranslate\" span around text. Version: 0.1 BETA Author: Andrew Truckle Author URI: http://www.trucklesoft.co.