Wordpress display child pages. Listing Pages in WordPress Using wp_list_pages() Function

Sometimes WordPress sites have a large number of material on static pages, not in posts. Such sites are used in cases where the information on the pages does not change and remains static. Basically, these are the pages on which they post information about personnel, organization regulations, safety rules, information about the product being manufactured, etc. In general, everything that has constant values.

If there are many such pages, then there is a need to create lists to display this information. However, there is no standard functionality for this in WordPress; the CMS can only display a list of posts.

Of course, a competent programmer is able to do anything with basic WordPress features. But what should novice users do? The Page-list plugin will help you. The add-on displays lists of pages using shortcodes, and it is also possible to fine-tune it.

WordPress Page-list Plugin

Download latest version plugin can be found in the WordPress console search. In the plugin description you can find out what shortcodes it contains. Install the plugin and activate it. Once activated, the plugin does not require any additional settings.

Now about displaying the list of pages. You just need to enter the shortcode in the required place on your page or post and the list will be displayed. If after adding the shortcode, a list of pages is not displayed instead, then you should write the following line in the function.php file:

add_filter('widget_text','do_shortcode');

You can also sort the page output using a shortcode. For example, you can set the display of all subpages of the page on which the shortcode is located, or set an exception for certain pages, and also determine the depth of display of child pages. Here are the shortcodes that are most convenient to use:

  • makes it possible to display a list of child pages.
  • – a list of child pages that have a common parent page.
  • displays a small picture of the page with a description next to it.

In the plugin settings you can set the maximum number of characters in the description and the maximum number of displayed images.

The WordPress page plugin is very easy to use and suitable for even the most inexperienced user. If there is a need to display a custom list of pages, then this plugin is the best solution.

Also learn how to create a custom grid list of posts.

WordPress pages, also known as pages, are stationary information posted on the site, which is not related to either the release dates of posts or home page site, nor with site headings.

WordPress Page Structure

WordPress pages are not linked to and pages are not tagged. However, pages, like categories, can be arranged in a hierarchy, such as Parent Page→Page.

The child page URL will be like this:

http://example.ru/Parent page/Page.

Editing a page

Editing the page is done on the tab Pages→Add new or Pages→All Pages→Edit. Editing a page is similar to editing posts. A page has a title, text, and metadata.

The page hierarchy is specified in the “Attributes” field. In the list of pages, you can also edit them: change (1), delete (2), change properties (3).

Pages and menus

A page may be included in a menu, but it is not a menu item and does not participate in organizing site navigation.

An example of a page in a menu could be a site map. All plugins for creation for the visitor require the creation of a separate page with a sitemap shortcode.

To include a page in the menu, open the tab Appearance→Menu. Select or create a new menu and on the left side select the pages that you want to add to the menu and add them. After saving, links to pages will appear on the site in this menu.

How to show pages on a website

To show pages on the site, you can use the widget ( Appearance→Widgets): Pages widget. This widget will show a list of all pages on your site.

WordPress Pages in Code and Template Files

The working template page template is the page.php file. To edit it you need to open the site editor, tab Appearance→Editor, and find the page.php file there.

If you have it installed, then you can separately, tab Appearance→CSS Editor. These changes will not disappear when you update the template.

Many modern templates WordPress supports individual page template changes, and these settings are available on the page creation tabs.

Conclusion

A page is a unique type of information on a WordPress site that is not “subject” to time and the main structure of the site.

Igor Serov specially for the site ""

In this article I will introduce you to the function wp_list_pages, which is used to display a list of pages in WordPress.
Once you master this function, you can easily display an ordered list of WordPress pages anywhere on your site.

In some cases, you may need to display a list of pages as a menu. You can, of course, use a widget pages for these purposes, but its functionality is very limited. In this case, you will be content with only choosing a method for sorting the pages included in the list and the ability to exclude individual pages. Agree, not very rich opportunities.

What if we want more? What if we need something special?

Then you should turn your attention to a more flexible tool with much greater capabilities.
In WordPress, such a tool is the function wp_list_pages.

Function wp_list_pages in wordpress it is usually used to display a list of pages in sidebars and headers as links. However, it can also be used in other, arbitrary places in templates.

The syntax for using the function is as follows

By default, the list of pages called using the function wp_list_pages is output as follows:

  • all pages and subpages are displayed
  • creation date is not displayed
  • The title of the list is “Pages”.
  • pages are sorted by order (ID), by heading (title)
  • pages are displayed in a hierarchical structure

The function has quite a lot of arguments, I will not talk about all of them in detail. To do this, you can always use the WordPress Codex.

It’s better that I focus only on the frequently used ones, knowledge of which will be enough to perform most standard tasks.

Sorting method ( sort_column)
Commonly used values:
'post_title'— sorting will be done by page names.
'menu_order'— sorting by page order.
'post_date'— sorting by creation date.

Sorting order ( sort_order) specifies the sorting order of pages in the list (descending, ascending).

include— allows you to display only specified pages (by ID) in the list.

exclude— allows you to exclude specified pages from the list (by ID).

child_of— displaying a list of descendant pages specific page(indicate the ID of the parent page).

title_li— sets the title of the list of pages.

Now let me give you a few examples of using the function wp_list_pages to display a list of pages

Example 1. List all pages

Example 2. Display a list of all pages (sorting by page name, alphabetically)

Example 3. Displays a list of all pages except pages with ID=3,5,7. List title – ‘My Pages’

    My pages");?>

Example 4. Displaying a list of pages with ID=5,10 sorted in descending order

Good luck everyone!

And those WordPress experts who love gadgets can buy Nokia Lumia 920 and start mastering Windows Phone 8.

Hi all Dear friends! Max Metelev talks to you openly, tells you and shows you in practice.

And today, as a snack for you in the morning, a portion of useful material with the following content - we will learn how to display a list of WordPress pages with pictures. The lesson is very simple and interesting. Go.

Most websites primarily use pages for text content. Because pages are different from posts, you may need ways to display them.

In addition to the main method of displaying WordPress pages with thumbnails, we will show how to display child and parent pages.

It will look something like this:

The first thing you need to do is install and activate the Page-list plugin. It works right out of the box, so we won’t go into the settings, since they are not there.

This plugin comes with a list of shortcodes with an extensive list of options. Let's start by making a simple display of all the pages of the site, that is, making a regular map

Create new page in WordPress and add the following shortcode to it [pagelist]

This shortcode will show a simple nesting of all your pages.

You can use either this or a number of other text widgets. If they do not work on your site, then you need to connect them by adding a line in the file functions. php your theme or to a specific area of ​​the plugin.

add_filter("widget_text","do_shortcode");

add_filter ("widget_text" , "do_shortcode" ) ;

Displaying Child Pages to Parent Pages in WordPress

All you need to do is add the desired shortcode [subpages] to the parent page.

You can also use shortcodes to insert into text widgets.

Adding related pages to WordPress

Related pages are essentially child pages that share the same parent. The output of such WordPress pages is carried out using the following construction [siblings]

Displaying pages with previews and text excerpts

The Page-list plugin comes with the following code [page_ext]. This embed code provides advanced options for displaying page lists in WordPress.

You can use it to display the structure of pages with a representative image of the article and a small excerpt of text from it. Like here:

[ pagelist_ext show_image = "1" image_width = "50" ]

You can set the image size yourself using the parameter image_width

You can also control the length of the text passage using the parameter limit_content

For example, you can set 100 characters, example [pagelist_ext limit_content = "100" ]

If you do not want to display text next to the article thumbnail, then use the following shortcode for the page [pagelist_ext show_content = "0" ]

Thanks for your attention and happy studying!

Internet