eddiesigner / liebling

Beautiful and clean Ghost theme that is easy and comfortable to use. To get the latest version please head over the releases page 👉🏼
https://github.com/eddiesigner/liebling/releases
MIT License
1.26k stars 598 forks source link

Featured post should not appear twice on main page #360

Closed fredpchang closed 3 years ago

fredpchang commented 3 years ago

I want to "feature" some articles on the home page, but featuring the most recent post results in duplicate entries. I hope the theme can be improved so that if article is in featured, it will not appear again next to it:

Screen Shot 2021-04-17 at 6 21 58 PM
eddiesigner commented 3 years ago

I'm not sure if this is really the desired behaviour, if you hide the featured articles because they appear in the slider there is a real chance that people won’t be able to see some of those posts, I think there is no issue if people see some post on different places, that's better than not seen some post at all.

If you really want to hide duplicate entries then you can do the following:

  1. Unzip the theme folder.

  2. Open the file partials/loop.hbs with a text/code editor.

  3. Locate the following line:

<article class="m-article-card {{#unless feature_image}}no-picture{{/unless}} {{post_class}}">
  1. Replace it with this other line:
<article class="m-article-card {{#unless feature_image}}no-picture{{/unless}} {{post_class}} {{#is "home"}}{{#if featured}}{{#has index="0, 1, 2, 3, 4"}}hide-card{{/has}}{{/if}}{{/is}}">

This line of code adds the class hide-card to the articles if they are featured, listed in the home page and if their index is less than 5 which is the max number of slides in the featured slider.

  1. Save your changes.

  2. Zip the theme folder and upload it again.

  3. Inject the following style in the Ghost Admin (Settings -> Code injection -> Site Header):

<style>
.hide-card {
  display: none !important;
}
</style>
  1. Save your changes.
fredpchang commented 3 years ago

Thanks, Eduardo! That worked :)