sourabhah
sourabhah

Reputation: 424

wagtail - How to get all pages in footer with slug

HI Tried with template tag

register = template.Library()

@register.simple_tag(takes_context=True)
def get_all_pages(context):
context['all_page'] = Page.objects.live()
return context

and in my template

{% get_all_pages as queries %}
        {% for each in queries %}
        {{each.page_title}}
        {% endfor %}

All pages are not passed in my templates , i want to add all pages in footer please help

Upvotes: 0

Views: 969

Answers (1)

gasman
gasman

Reputation: 25227

I can see two problems here:

  • As neverwalkaloner says, a simple_tag should return the value you want to output or assign, rather than updating the context dict:

    @register.simple_tag(takes_context=True)
    def get_all_pages(context):
        return Page.objects.live()
    
  • page_title is not a recognised property of a page object - it should be title:

    {{ each.title }}
    

Upvotes: 2

Related Questions