Having trouble figuring out how to add “read more” to related blog posts on product pages.
My current product section template includes related blog posts. The content in the template includes the following:
- Image (typically a logo)
- excerpt (some text)
I want to add a “read more” link to the template so that people can click to learn more about that technology.
Here’s my current code in the template:
{% assign selected_handles = product.metafields.accentuate.related_tech | split: '|' %}
{% for value in selected_handles %}
{% for image in articles[value].metafields.accentuate.blogmedia %}
{% endfor %}
{{articles[value].excerpt}}
{%endfor%}
Example of a product page: https://www.amclassic.com/collections/tires/products/copy-of-aggregate
And the related tech is the Rubberforce G, Stage 5S Armor, and Tubeless Ready on the right. As noted in the code, these include the logo and the excerpt.
“Read more” is currently being used my blog collection pages. Example: https://www.amclassic.com/blogs/tire-technology
The code in the template is as follows:
{{ 'blog.article.read_more' | t }}
And the final code that outputs in the browser is as follows:
Read more
Based on this, I attempted to add the code from the collection template into the product template and it generates the links. However, the links generated are for the page the user is already reading. I also tried adding {{articles[value].readmore}} and that didn’t work either.
I tried looking up additional values for articles and found this page: https://shopify.dev/api/liquid/objects
There doesn’t seem to be any values that provide the ‘read more’ link I desire. However, I did see a note about adding a link. The sample was this code:
{% assign article = articles['potion-notions/new-potions-for-spring'] %}
{{ article.title | link_to: article.url }}
And it is supposed to generate this link on the page:
New potions for spring
Were I to change article.title to article.read_more will this work?
Also, were I to add {{articles[value].url}} how do I get this to include ‘read more’ instead of the page title in the URL?