WordPress: wp_list_pages() and private pages

09.05.2008 10:59 Uhr | Kommentare: 8 | Kommentar hinterlassen
Einsortiert in Software

wp_list_pages only lists public pagesIf you ever noticed that your private pages not listed by your WordPress theme after you are logged in?

Only published pages are listed. Also if you are logged in - your private pages are not listed!

Why not? Whats happens?

Your theme or your widget uses the wp_list_pages() function to list your pages. This function calls another function (get_pages) to retrieve the list from your database.

the read_private_pages capability is grantedAlso if you have the right capability “read_private_pages”, private pages are not listed. Neither your nor the private pages of your other users.

Note: The screenshot in the right is from my Role Manager Plugin.

The reason: get_pages() and therefore wp_list_pages() looks for pages only with the database-status “publish” as the attribute for public published pages.

Would not it be nice if the private pages appear in the list?

if the user has the right capability also private pages are listed by wp_list_pagesAfter some tests yesterday I wrote a patch to get a new option for wp_list_pages() and get_pages(). The default value in my patch is that private pages are included into the list if the user has the capability “read_private_pages”. With the new option you can switch off including private pages for those users. A small example with switched off private pages:

wp_list_pages('title_li=<h2>Pages</h2>&include_private_pages=0');

For users who are logged out or don’t have the capability “read_private_pages” nothing is changed - they see only your public pages.

If you like this feature and want see it in the core of WordPress, please vote for it at the trac ticket I opened.

8 Kommentare zu “WordPress: wp_list_pages() and private pages”

  • #1

    Hallo,

    erstmal danke für das klasse plugin! Leider kriege ich es mit der aktuellen WP Version (2.5.1) nicht zum laufen. Allerdings benutze ich zusätzlich auch noch das plugin wswwpx_fold_page_list() um die Sidbar zu gruppieren. Sollte die Ansicht der privaten Seiten damit auch funktionieren? Danke schon mal für die Bemühungen und liebe Grüße
    uTZFu

  • #2

    Vielen Dank für den Patch :)

    Funktioniert einwandfrei mit Wordpress 2.6.3 unter http://www.kjg-bilfingen.de/. Ich denke, ich werde den Patch auch bei meinem privaten Blog verwenden.

    Grüße, adi

  • #3
    Gravatar tickets berlin meinte

    Noch ein Klasse Patch von Dir! Danke sehr - werd ich gleich mal ausprobieren!

  • #4
    Gravatar Wanderer meinte

    Genau dieses Plugin hat mir noch gefehlt. Das wird demnächst eingebaut für QM und Usability Optimierung. Mein Author wird sich freuen ;-)

  • #5

    Hey danke super patch =)

  • #6

    Dieses Plugin habe ich lange gesucht und endlich gefunden Das werde ich gleich einbauenfür und auch alles dafür optimieren. Das wird mir ne menge Sache erleichtern. Vorallem beim texte verfassen.

  • #7
    Gravatar Dyscalcolon meinte

    Hallo. Wo kann man denn den Patch downloaden bzw. wo steht der Code für den Patch? Ich finde das irgendwie nicht auf dieser Seite. Oder bin ich blind?!

    Viele Grüße
    Dyscalcolon

  • #8
    Gravatar Dyscalcolon meinte

    Okay sorry. Hab den Link zum trac ticket gefunden. Kann man das in Form eines Plugins realisieren, sodass man nicht den Core verändern muss?

    VG

Hinterlasse einen Kommentar

Bitte beachten: Mit der Abgabe eines Kommentares oder dem Senden eines Trackbacks erklärst Du Dich mit den Kommentar- und Trackbackrichtlinien einverstanden!

XHTML: Diese Tags sind erlaubt: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Du kannst Deinen Kommentar nach dem Abspeichern noch 30 Minuten bearbeiten.

Kurznavigation

Featured Story

WordPress-Plugins

Tags

Kategorien

Empfehlungen

Hilfen und mehr ...

Kommerzielle Angebote

Anderes