• Hi everyone,

    How do I run this code?

    <?php wp_list_pages('title_li='); ?>

    within the page itself?

    I don’t think I can run php code like that in page? Do I need to install any plugin to run php code? If i do run some plugin, hope it won’t affect my other pages or something.

    I will only need to run that piece of code from 1 page only.

    Any help? Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You can’t use PHP within the page content. It has to be added to the page (or post) template file in your theme. Try creating a custom page template that includes wp_list_pages() and apply the new template to the page.

    Thread Starter chuawenching

    (@chuawenching)

    Thanks for sharing. Noted on that.

    What if I want to call <?php wp_list_pages(‘title_li=’); ?> in the widget? I have created a sidebar widget via register_sidebar.

    I dragged a text widget into my custom sidebar widget and it can’t seem to work.

    But if I drag the default pages widget into my custom sidebar widget, then it will work?

    does that means I need to create my own custom widget that can call the wp_list_pages too?

    What if I want to call <?php wp_list_pages(‘title_li=’); ?> in the widget?

    Then you’d need to use a specialised widget plugin that is designed for adding code.

    does that means I need to create my own custom widget that can call the wp_list_pages too?

    Why would you need to create a custom widget that uses wp_list_pages() when the default Pages widget does just that?

    There are other options, but if you just want to do that without much work try https://www.ads-software.com/extend/plugins/exec-php/

    Thread Starter chuawenching

    (@chuawenching)

    Hi esmi,

    I need to do some custom css and add “Home” at the 1st item on the list pages. Can I do that with the default page widget? If yes, any pointers on this one? Thanks in advance ??

    Thanks John for the suggestion too.

    You’d be better off creating & using a custom menu.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to call wp_list_pages() within the page itself?’ is closed to new replies.