Multilingual Ghost CMS Blog: 2. Making 'More Posts' Multilingual

Multilingual Ghost CMS Blog: 2. Making 'More Posts' Multilingual

When you look at a post, you can see that even if it is an English post, the show_recent_posts section at the bottom displays all posts regardless of language. Let's fix this part.

0.0.2 · sanghunka/ghost-multilingual-theme@0e2b7a3
Multilingual show_recent_posts_footer

Edit post.hbs

{{#get "posts" filter="id:-{{id}}" limit="3" as |more_posts|}}

    {{#if more_posts}}
        <aside class="read-more-wrap outer">
            <div class="read-more inner">
                {{#foreach more_posts}}
                    {{> "post-card"}}
                {{/foreach}}
            </div>
        </aside>
    {{/if}}

{{/get}}

Delete the code above and add the code below.

{{#has tag="#en"}}
    {{#get "posts" filter="tag:en+id:-{{id}}" limit="3" as |more_posts|}}
        {{#if more_posts}}
            <aside class="read-more-wrap outer">
                <div class="read-more inner">
                    {{#foreach more_posts}}
                        {{> "post-card"}}
                    {{/foreach}}
                </div>
            </aside>
        {{/if}}
    {{/get}}
{{/has}}
{{#has tag="#ko"}}
    {{#get "posts" filter="tag:ko+id:-{{id}}" limit="3" as |more_posts|}}
        {{#if more_posts}}
            <aside class="read-more-wrap outer">
                <div class="read-more inner">
                    {{#foreach more_posts}}
                        {{> "post-card"}}
                    {{/foreach}}
                </div>
            </aside>
        {{/if}}
    {{/get}}
{{/has}}    

I modified the part that fetches the 3 most recent posts. If a post has the #en tag, apply filter="tag:en", and if it has the #ko tag, apply filter="tag:ko".

Result

Only posts that match the post's language tag are shown at the bottom.

Next post

Multilingual Ghost CMS Blog: 3. Adding a Language Selector
I finished the basic setup for a multilingual blog. I used the / and /ko/ paths to separate posts by language. Right now, you can only move from the English page to the Korean page, or vice versa, by manually entering the URL. For user conv