dongzi1397 2017-04-24 15:03
浏览 70
已采纳

Wordpress:is_page()if语句未显示内容

I am trying to alter a shortcode dependent on the page which means I need to determine what page we are on and what shortcode to use.

When I try the below code the sidebar disappears completely leading me to believe that it clearly isn't working. The sidebar appears with the working shortcode when I remove the IF statement from the code however this is needed.

If you have any ideas on whats not working correctly then please feel free to shed some light on it (I have seen some similar questions however non of them have ever received answers).

<aside id="drinks-gallery" class="widget widget_gallery">
<div class="gallery-inner">
    <h3 class="widget-title">View The Gallery</h3>
    <p>Don't just take our word for it, take a look at some of our drinks!</p>
    <?php 
    if (is_page('drinks-packages')) {
        echo do_shortcode('[ngg_images source="galleries" container_ids="1" display_type="photocrati-nextgen_basic_thumbnails" override_thumbnail_settings="1" thumbnail_width="110" thumbnail_height="62" thumbnail_crop="1" images_per_page="20" number_of_columns="2" ajax_pagination="0" show_all_in_lightbox="0" use_imagebrowser_effect="0" show_slideshow_link="0" slideshow_link_text="&#91;Show slideshow&#93;" order_by="sortorder" order_direction="ASC" returns="included" maximum_entity_count="500"]')
    };?>
</div>

  • 写回答

1条回答 默认 最新

  • doulangtiao4508 2017-04-24 15:09
    关注

    The first line of your if statement seems incorrect.

    Change this:

    if (is_page('drinks-packages'){

    to:

    if (is_page('drinks-packages')) {

    and remove the last ) as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?