Search code examples
ghost-blog

Ghost: Get URL of post in foreach loop


I'm looking to get the URL of a post accessed using a {{#foreach posts}}{{/foreach}} helper. The structure I am using right now is :

            <div class="pfdflxbx">            
                {{#get "posts" limit="3" include="tags, authors" filter="featured:true"}}
                    {{#foreach posts limit="3"}}
                        {{title}}
                    {{/foreach}}
                {{/get}}
            </div>

When I insert a {{url}} helper between {{title}} and {{/foreach}}, the URL that gets returned to me is the url of the site's home page.

If I use the following structure:

            <div class="pfdflxbx">            
                {{#get "posts" limit="3" include="tags, authors" filter="featured:true"}}
                    {{#foreach posts limit="3"}}
                    {{#post}}
                        {{title}}
                    {{/post}}
                    {{/foreach}}
                {{/get}}
            </div>

Nothing renders to the DOM, as in, no posts populate.

Could someone help shed some light on the correct practice here?


Solution

  • The first solution I posted was correct. There is a bug in the back end version I am working with which causes the URL of the blog posts to redirect to the welcome page.