wordpress koşullu ifadeler

3 Cevap php

Ben farklı sayfaları yüklenen farklı içeriği görüntülemek için wordpress bu kodu kullanıyorum. Ben Ev, Bio, Çalışma, İletişim ve Notlar denilen sitede 5 sayfa var. Notlar sayfası, bir blog olarak kullanılıyor. İşte ben kullanıyorum kodudur.

                    <?php if (is_page('contact')) { ?>
                    get in touch with me
                <?php } elseif (is_single()) { ?>
                    a note from me
                <?php } elseif (is_page('notes')) { ?>
                    the notes of me
                <?php } else { ?>
                    the <?php the_title(); ?> of me
                <?php } ?>

Bu yüzden iletişim sayfası, eğer "Benimle temasa" görüntüler ve tek bir blog yazısı sayfası eğer "Bana bir not" görüntülenir. Ben bir sorun var nerede Ancak bu. Bu notlar sayfası açıkken bir sonraki deyimi "beni notları" göstermesi gerekir. Ancak, bu olmaz. Bunun yerine "else" deyiminde olduğu varsayılan içeriğini gösterir. Bu neden oluyor herhangi bir fikir?

3 Cevap

Bu yerine yapacağını budur.

            <?php if (is_page('contact')) { ?>
                get in touch with me
            <?php } elseif (is_page()) { ?>
                the <?php the_title(); ?> of me
            <?php } elseif (is_single()) { ?>
                a note from me
            <?php } else { ?>
                the notes of me
            <?php } ?>

sayfaları puslished yapılmadığının kontrol ediniz.

Akla gelen, o sayfa adı 'notlar' değil. Sayfanızın URL'sini kontrol edin ve sayfa adı ne olduğunu görmek.