Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Kupası
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPress’te Bir Üst Sayfa İçin Alt Sayfaların Listesi Nasıl Görüntülenir?

Editoryal Not: WPBeginner üzerindeki ortak bağlantılardan komisyon kazanıyoruz. Komisyonlar, editörlerimizin görüşlerini veya değerlendirmelerini etkilemez. Editoryal Süreç hakkında daha fazla bilgi edinin.

Geçenlerde bir okuyucumuz bize bir WordPress sayfasının alt sayfalarının nasıl görüntüleneceğini sordu.

WordPress web sitenizi üst ve alt sayfalarla düzenliyorsanız, alt sayfalarınızı veya alt sayfalarınızı ana üst sayfada görüntülemek isteyebilirsiniz. Ayrıca, kolay gezinme için her alt sayfada ana sayfayı göstermek isteyebilirsiniz.

Bu makalede, WordPress’te bir üst sayfa için alt sayfaların listesini nasıl kolayca görüntüleyebileceğinizi göstereceğiz.

Displaying a list of child pages for a parent page in WordPress

Çocuk Sayfalarının Listesini Göstermeniz Gerektiğinde?

WordPress, yazılar ve sayfalar adı verilen iki varsayılan yazı türüyle birlikte gelir. Yazılar blog içeriğidir ve genellikle kategoriler ve etiketlerle düzenlenirler.

Sayfalar, örneğin ‘Hakkımızda’ sayfası veya ‘Bize Ulaşın’ sayfası gibi her zaman yeşil kalan tek seferlik veya bağımsız içeriklerdir.

WordPress’te sayfalar hiyerarşik olabilir, bu da onları üst ve alt sayfalarla düzenleyebileceğiniz anlamına gelir.

Örneğin, Özellikler, Fiyatlandırma ve Destek için alt sayfaları olan bir Ürün sayfası oluşturmak isteyebilirsiniz.

Alt sayfa oluşturmak için WordPress‘te alt sayfa oluşturma hakkındaki kılavuzumuzu izleyin.

Üst ve alt sayfalarınızı oluşturduktan sonra, alt sayfaları ana üst sayfada listelemek isteyebilirsiniz.

Şimdi, bunu yapmanın kolay bir yolu, ana sayfayı manuel olarak düzenlemek ve bağlantıların bir listesini ayrı ayrı eklemektir.

Manually add child page links

Ancak, her alt sayfa eklediğinizde veya sildiğinizde üst sayfayı manuel olarak düzenlemeniz gerekecektir. Sadece bir alt sayfa oluşturabilseydiniz ve bu sayfa otomatik olarak ana sayfada bir bağlantı olarak görünseydi daha güzel olmaz mıydı?

Bununla birlikte, WordPress’te ana sayfada alt sayfaların listesini hızlı bir şekilde görüntülemenin diğer bazı dinamik yollarına bir göz atalım. Size üç yöntem göstereceğiz, böylece sizin için en iyi olanı seçebilirsiniz:

Yöntem 1. Bir Eklenti Kullanarak Alt Sayfaları Üst Sayfada Görüntüleme

Bu yöntem daha kolaydır ve tüm kullanıcılar için önerilir.

Öncelikle Page-list eklentisini yüklemeniz ve etkinleştirmeniz gerekir. Daha fazla ayrıntı için, bir WordPress eklentisinin nasıl kurulacağına ilişkin adım adım kılavuzumuza bakın.

Etkinleştirmenin ardından, ana sayfayı düzenlemeniz ve alt sayfaların listesini görüntülemek istediğiniz yere aşağıdaki kısa kodu eklemeniz yeterlidir.

[alt sayfalar]

Artık sayfanızı kaydedebilir ve yeni bir tarayıcı sekmesinde önizleyebilirsiniz. Tüm alt sayfaların basit bir madde işaretli listesini görüntülediğini fark edeceksiniz.

Plain list of child page links

İsterseniz, listenin görünümünü değiştirmek için bazı özel CSS ‘ler ekleyebilirsiniz. İşte başlangıç noktası olarak kullanabileceğiniz bazı örnek CSS’ler.

ul.page-list.subpages-page-list {
    list-style: none;
    list-style-type: none;
    background-color: #eee;
    border: 1px solid #CCC;
    padding: 20px;
}

Özel CSS’nizi uyguladıktan sonra ana sayfayı önizleyebilirsiniz. Test WordPress web sitemizde bu şekilde görünüyordu.

Child pages list with CSS

Eklenti, derinliği ayarlamanıza, sayfaları hariç tutmanıza, öğe sayısına ve daha fazlasına olanak tanıyan bir dizi kısa kod parametresi sağlar. Ayrıntılar için lütfen ayrıntılı dokümantasyon için eklentinin sayfasına bakın.

Yöntem 2. Kod Kullanarak Bir Üst Sayfa İçin Alt Sayfaları Listeleme

Bu yöntem biraz gelişmiş bir yöntemdir ve WordPress web sitenize kod eklemenizi gerektirir. Bunu daha önce yapmadıysanız, lütfen WordPress’te kod kopyalama ve yapıştırma hakkındaki kılavuzumuza bir göz atın.

Alt sayfaları bir üst sayfa altında listelemek için aşağıdaki kodu bir kod parçacıkları eklentisine veya temanızın functions.php dosyasına eklemeniz gerekir:

function wpb_list_child_pages() { 
 
global $post; 
 
if ( is_page() && $post->post_parent )
 
    $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
else
    $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
 
if ( $childpages ) {
 
    $string = '<ul class="wpb_page_list">' . $childpages . '</ul>';
}
 
return $string;
 
}
 
add_shortcode('wpb_childpages', 'wpb_list_child_pages');

WPBeginner olarak, WordPress’e her zaman WPCode eklentisi ile kod eklemenizi öneririz.

WPCode, tema dosyalarınızı düzenlemeden kolayca özel kod eklemenize olanak tanır, böylece sitenizi bozma konusunda endişelenmenize gerek kalmaz.

WPCode

Öncelikle, ücretsiz WPCode eklentisini yüklemeniz ve etkinleştirmeniz gerekir. Adım adım talimatlar için WordPress eklentisinin nasıl kurulacağına ilişkin bu kılavuza bakın.

Eklenti etkinleştirildikten sonra, WordPress panonuzdan Code Snippets ” Sn ippet Ekle bölümüne gidin. Buradan, farenizi ‘Özel Kodunuzu Ekleyin (Yeni Snippet)’ seçeneğinin üzerine getirin ve ‘Snippet kullan’ düğmesine tıklayın.

Add a new custom code snippet in WPCode

Ardından, snippet’iniz için bir başlık ekleyin ve yukarıdaki kodu ‘Kod Önizleme’ kutusuna yapıştırın.

Sağdaki açılır menüden kod türü olarak ‘PHP Snippet’ seçmeyi unutmayın.

Paste code into WPCode plugin

Bundan sonra, anahtarı ‘Etkin Değil’den ‘Etkin’e getirin ve sayfanın üst kısmındaki ‘Snippet’i Kaydet’ düğmesine tıklayın.

Activate and save your custom code snippet

Bu kod ilk olarak bir sayfanın bir ebeveyni olup olmadığını veya sayfanın kendisinin bir ebeveyn olup olmadığını kontrol eder.

Bir üst sayfaysa, kendisiyle ilişkili alt sayfaları görüntüler. Bir alt sayfaysa, üst sayfasının diğer tüm alt sayfalarını görüntüler.

Son olarak, bu sadece alt veya üst sayfası olmayan bir sayfaysa, kod hiçbir şey yapmayacaktır. Kodun son satırına bir kısa kod ekledik, böylece sayfa şablonlarınızı değiştirmeden alt sayfaları kolayca görüntüleyebilirsiniz.

Alt sayfaları görüntülemek için aşağıdaki kısa kodu kenar çubuğundaki bir sayfaya veya metin widget’ına eklemeniz yeterlidir:

[wpb_childpages]

Değişikliklerinizi kaydetmeyi ve bir tarayıcı sekmesinde önizlemeyi unutmayın. Test sitemizde bu şekilde görünmektedir.

Plain link list

Artık bazı özel CSS‘ler kullanarak bu sayfa listesine stil verebilirsiniz. İşte başlangıç noktası olarak kullanabileceğiniz bazı örnek CSS kodları.

ul.wpb_page_list {
    list-style: none;
    list-style-type: none;
    background-color: #eee;
    border: 1px solid #CCC;
    padding: 20px;
}

Yöntem 3. Herhangi Bir Kısa Kod Olmadan Çocuk Sayfalarını Dinamik Olarak Görüntüleme

Kısa kodları kullanmak kullanışlıdır, ancak bunlarla ilgili sorun, üst veya alt sayfaları olan tüm sayfalara kısa kodlar eklemeniz gerekmesidir.

Birçok sayfada kısa kodlara sahip olabilirsiniz ve bazen eklemeyi bile unutabilirsiniz.

Daha iyi bir yaklaşım, alt sayfaları otomatik olarak görüntüleyebilmesi için temanızdaki sayfa şablonu dosyasını düzenlemek olacaktır.

Bunu yapmak için ana sayfa.php şablonunu düzenlemeniz veya temanızda özel bir sayfa şablonu oluşturmanız gerekir.

Ana temanızı düzenleyebilirsiniz, ancak temanızı değiştirir veya güncellerseniz bu değişiklikler kaybolacaktır. Bu nedenle bir alt tema oluşturmanız ve değişikliklerinizi alt temada yapmanız daha iyi olacaktır.

Sayfa şablonu dosyanızda, alt sayfaları görüntülemek istediğiniz yere bu kod satırını eklemeniz gerekir.

<?php wpb_list_child_pages(); ?>

Hepsi bu kadar. Temanız artık alt sayfaları otomatik olarak algılayacak ve bunları düz bir listede görüntüleyecektir.

Stilleri CSS ve biçimlendirme ile özelleştirebilirsiniz. İşte OptinMonster web sitesinin ana sayfayı ve alt sayfaları nasıl gösterdiğine dair bir örnek:

OptinMonster Sub Pages Example

Umarız bu makale WordPress’te bir ana sayfa için alt sayfaları listelemenize yardımcı olmuştur. Ayrıca yeni bir WordPress web sitesinde oluşturulması gereken en önemli sayfalar hakkındaki kılavuzumuzu ve kod kullanmadan özel düzenler oluşturmak için en iyi sürükle ve bırak WordPress sayfa oluşturucuları karşılaştırmamızı görmek isteyebilirsiniz.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Açıklama: İçeriğimiz okuyucu desteklidir. Bu, bazı bağlantılarımıza tıklarsanız komisyon kazanabileceğimiz anlamına gelir. WPBeginner'ın nasıl finanse edildiğini, neden önemli olduğunu ve nasıl destek olabileceğinizi görün. İşte editoryal sürecimiz.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Ultimate WordPress Araç Kiti

Araç setimize ÜCRETSİZ erişim sağlayın - her profesyonelin sahip olması gereken WordPress ile ilgili ürün ve kaynaklardan oluşan bir koleksiyon!

Reader Interactions

81 yorumBir Cevap Bırakın

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

    • WPBeginner Support says

      The simplest method for what it sounds like you’re wanting would be to not have content on the parent page and only have your content in the child pages.

      Yönetici

  2. Emmanuel Husseni says

    Hello Wpbeginner,

    Please how can i sort all the child page alphabetically on the parent page. I’ve follow all step but the sub pages are showing randomly on the parent page.

    Waiting for response. ….Thanks

  3. Aaro says

    Can I assign a css class to this function? So that when I make css changes to ul elements it wouldn’t affect other ul’s on the site.
    Or any other simple solution for this?

  4. Keshav Murthy says

    Hi, WPB Team,

    Thank you so much for this Snippet and the tutorial.

    It saved my ton of time and helped me too.

    With Warm Regards,
    Keshav Murthy

  5. Gary Granai says

    I installed the plugin code snippets in wordpress 4.9.8

    I copied the code on https://www.wpbeginner.com/wp-tutorials/how-to-display-a-list-of-child-pages-for-a-parent-page-in-wordpress/#respond and added it to a new snippet in code snippets.

    I made a page and then a page which was given the attribute of having the first page as the parent page.

    The child parent relationship is shown in the list of pages in the attributes drop down.

    When I open the parent page I see nothing that shows a child page.

    I then tried using the functions.php page.

    I added the code copied from https://www.wpbeginner.com/wp-tutorials/how-to-display-a-list-of-child-pages-for-a-parent-page-in-wordpress/#respond to the bottom of the code on the functions page.

    When I open the parent page, I it does not display. What displays is an error message saying there is unexpected code.

    I restored the functions.php page to its original statuc.

    What changes must I make to what I have tried to do.

    • WPBeginner Support says

      Hi Gary,

      Make sure that you publish the child page before testing the code. Also carefully copy the code again to make sure that you are not copying the numbers or any unexpected characters.

      Yönetici

  6. Itika says

    I have a question. I have added sub pages in parent page but when I am opening the site in mobile and clicking on parent page it opens the empty parent page. To view the drop down sub pages one have to hold the button of parent page. How can I fix it. I don’t want that empty page to open. I want that if we touch on parent page it opens the drop down menu.
    Please suggest how to do it.

  7. Denise says

    For third level pages (grandchild), I want to show the same menu that is seen on the child pages (all the child links of the parent). With this snippet, when on a grandchild page, I only see the other grandchild pages in the menu. How would this code need to be modified to show the all child links even when on grandchild pages?

  8. Meredith L says

    I’m relatively new to blogging and I recently switched over to the Kale WordPress theme. I have been trying to do page attribute pages (under the parent page Recipes) so I can have separate categories for appetizers, desserts, etc. Everything seems to go through on the admin part but then on the site itself there are no page attributes/drop down form the Recipes category. What am I doing wrong? It is all set to public so I’m not sure what the problem is.

  9. Daves says

    Thank you for this code. But I don’t want this to be shown on the homepage (static page), just on the parent pages only. Please how can it be done?

    Thank you.

  10. Boris Budeck says

    I am using Generatepress Theme (created a child theme from it for customizing) and I can’t get this to work. The shortcode is displayed in the output page, it seems it is not even ercognized as being a shortcode. I use Elementor widgets and neither text nor shortcode widgets work.

    Any idea of how to make it work when using elementor widgets?

  11. Frederic says

    a great post, it’s exactly what I’m looking for since many hours ! and it works like a charm, just adding the code in the function.php of the theme then adding the short code in the page where I want the sub pages to appear, and voilà!!!
    wonderful, thanks a lot for your generosity !!

  12. Ron says

    Like with so many of the snippets we find, one has to go through all the comments in order to get it to work. What’s wrong with testing what you write?

  13. Rudy says

    Using this code ends up displaying the parent page along with the child pages, which is redundant. As I understand it, what we really need is to display only the child pages, not the parent page. Any suggested modification that can do this?

  14. Milos says

    On plugins update, for some strange reason I always get an error:

    Fatal error: Cannot redeclare wpb_list_child_pages() (previously declared in …/wp-content/themes/pagelines/functions.php:25) in …/wp-content/themes/pagelines/functions.php on line 34

  15. ethann says

    Hello great article,
    Can you please help me creating a dropdown of child pages in parent page.I need this functionality for one of my wordpress project and i am totally newbie to wordpress.

  16. Alex says

    Am I the only one that cannot get it to work?

    I have the following structure

    About
    — Page 1
    — Page 2
    — Page 3

    When on the “About” or a child page (1, 2 or 3) I would like to have a list with my parent page (About) and all children (1, 2, 3) – Anyone got that working?

    Thanks! :)

    • Kendra says

      OMG sorry this is annoying Please ignore my other posts. Didn’t realize you couldn’t paste code into the comments.

      I was NOT able to get it to work with wpb_list_child_pages();

      I WAS able to get it to work with echo do_shortcode( ‘[wpb_childpages]’)

      And to get the title of the parent page, i inserted this above the child page list:
      $current = $post->ID;

      $parent = $post->post_parent;

      $grandparent_get = get_post($parent);

      $grandparent = $grandparent_get->post_parent;

      PHP if ($root_parent = get_the_title($grandparent) !== $root_parent = get_the_title($current)) {echo get_the_title($grandparent); }else {echo get_the_title($parent);

  17. Jean Bishop says

    I am using this code and it works great. Is it possible to also display categories in menus along with pages?

  18. Michelle says

    Hi,

    I want to do the following

    Parent page must be either for sale and or for rent
    Then I want the child for example a province (gauteng) to link to the for sale and the for rent parent.
    How do I do that?

    Michelle

  19. Zakhar says

    How can i create shortcode with param, for example, [wpb_childpages id=”1″], where id=”1″ is an id of parent page?

  20. Aander says

    Thank you,

    Could you explain, please, how can I organize child pages in drop down list that would be accessible through the parent page? (I don’t want the visitors could see all child pages in a form of a blogroll.)

    I.e., on the parent page I want to create drop down list (listbox) to which child pages would be added in predefined order (say in alphabetical order). After reading Introduction a visitor can proceed by choosing any page from the list at her wish (child pages has no logical connection so in any case she will search the exact page).

    Is ‘my dream’ realizable?

    Thank you again.

  21. Astrid says

    Hi WPBeginner Staff,

    I used the code you guys provided with the “short code option” and it worked (links to child pages). However, I wanted to use the permanent option, and that didn’t work.

    When I added this line of code [ ] the parent page returns a 500 error and no child pages are displayed at atll.

    What am I doing wrong?

    On a side note if I wanted to display and excerpt with its respective image how would I go about it? Thanks!

    • Astrid says

      I was able to figure this out.

      I added the code snippet then added this shortcode [wpb_childpages] to the parent page where I wanted the child pages displayed. Awesome!

      Now in order to display excerpts and an image would I use the same queries– just like posts under a category.

      Thanks in advance :)

      • Jade says

        Hey I was wondering what you meant by ‘query’? How exactly did you get the excerpts and images to display in the parent page?

        Thanks!

  22. Pradeep says

    Could someone confirm that the example page used in this tutorial http://optinmonster.com/how-it-works/ uses this feature or not? To me it looks like it they are using tabs, instead of child pages.

    If I’m right, could someone direct me to a resource to get that feature, as I’m desperately looking for a fluid solution like the one they have in that page?

    Many thanks,

    Pradeep

  23. Andrew Roberts says

    For the non-shortcode option, you might want to let users know they need to either change
    return $string; to
    echo $string; or
    in their page template echo out the function
    echo page_list_child_pages();

    Thanks to Erik for pointing this out above

  24. Howard says

    Hi, I can get this to work when I am visiting my domain with a subdirectory (e.g – example.com/home) but when viewing the site without this (example.com) the list of sub pages is not listed. Can anyone point me as to where I am going wrong?

    Thanks in advance – very new to WordPress.

  25. Emily Jennewein says

    How do you get this function to display the parent page itself at the top of the list along with the list of child and grandchild pages? On the child pages it does not list the parent page.

  26. Jenny says

    Is there now a plugin that can do same ?

    and also can we decide where the box with submenus pages will go in any are of the page not just top of page? Using a plugin

  27. WPBeginner Staff says

    Yes it can be used for custom post types. Like this:


    function wpb_list_child_pages() {

    global $post;

    if ( 'movie' == get_post_type() && $post->post_parent )

    $childpages = wp_list_pages( 'post_type=movie&sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
    else
    $childpages = wp_list_pages( 'post_type=movie&sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );

    if ( $childpages ) {

    $string = '' . $childpages . '';
    }

    return $string;

    }

    add_shortcode('wpb_childpages', 'wpb_list_child_pages');

  28. dpc says

    Is there a way to modify this in order to print custom post type child posts on a custom post type post page? Thanks, it is very handy!

  29. Sokeara says

    It’s very greate for me! Anyways I would like to know how can I display title and thumbnail of child page to parent page.

    • Ashley Bell says

      Hi, I have the same query. I really like how the list is styled on the Beginners Blueprint page but I have no idea how to start. Can someone recommend an article to read or give some advice, thanks.

  30. amitabha197 says

    There is an error in the pages which are not having child pages so I have slightly modified
    if( count($childpages) != 0 ) {
    $string = ” . $childpages . ”;
    }

    instead of
    if( $childpages ){
    $string = ” . $childpages . ”;
    }

  31. Coen Siebenheller says

    I’ve added the code to the functions.php and when i add the [wpb_childpages] shortcode in side my text it works. But when try to add to one of my templates it doesn’t show a thing. Anybody knows what i’m doing wrong?

  32. Quin says

    This is brilliant, thanks.

    Is there a way to adapt it so the Parent displays the Grandchild, and not the Child?

Bir Cevap Bırakın

Yorum bırakmayı seçtiğiniz için teşekkür ederiz. Lütfen tüm yorumların yorum poli̇ti̇kasi uyarınca denetlendiğini ve e-posta adresinizin yayımlanmayacağını unutmayın. Ad alanında anahtar kelime KULLANMAYIN. Kişisel ve anlamlı bir sohbet edelim.