Unsure on how to show the featured page as my homepage - handlebars.js

I am creating a Ghost Theme and I want to have my index.hbs show the featured post as the page. I have tried a range of things but nothing seems to work:
index.hbs
{{!< default}}
{{!-- The tag above means: insert everything in this file
into the {body} of the default.hbs template --}}
{{!-- The main content area --}}
<main>
{{#foreach posts}}
{{#has featured="true"}}
{{post}}
{{/has}}
{{/foreach}}
</main>

I think the best way to achieve having a featured post as the main page would be to use Dynamic Routing and route / to the post or page with featured flag. Alternatively, you could fetch and display the featured post using the {{get}} query described here.

Related

Wordpress - Hiding 'Next' article link on latest post and 'Prev' article link on the oldest post

I'm using the previous_post_link & next_post_link to display links to next & prev articles on a post single page. This works fine and the code I'm using is like this:
<div class="previous-article">
<h4>Previous Article</h4>
<?php previous_post_link('%link'); ?>
</div>
<div class="next-article">
<h4>Next Article</h4>
<?php next_post_link('%link'); ?>
</div>
Is there a statement I can use to hide / not display the 'Next' article link on the latest blog post because there is no 'next' so it display a blank entry (meaning that I can also hide the h4 headings I have in place) e.g.
So it looks like this:
And visa versa for the oldest post showing the 'Previous' article. Another solution would be to incorporate the heading into the php previous_post_link / next_post_link code. Maybe add class 'latest', 'oldest' to the body tag and I can hide using css. Is this possible?
Thanks
I should have searched better. For anyone else looking here is the solution to this how to get next/previous post hrefs and titles in wordpress

Ghost - how to get a specific page?

I'm a Ghost beginner, and I know I can get the list of pages doing like below.
{{#get "pages"}}
{{#foreach pages}}
{{{html}}}
{{/foreach}}
{{/get}}
But am I able to fetch a specific page? Let's assume that I have an "about" page that I'd like to fetch in order to show its contents into the blog's sidebar, for example, this is what I tried, but it's not working.
{{#get "pages/slug/about" as page}}
{{page}} // prints undefined
{{/get}}
Any help would be much appreciated.
The first parameter passed to the #get helper specifies the name of the resource you want to query. It should be either posts, tags or authors. In your use case it should be posts.
{{#get "posts" slug="pages/slug/about" as |post|}}
{{#post}}
<h1>{{title}}</h1>
<div class="post-content"> {{content}} </div>
{{/post}}
{{/get}}

How do I place a configurable meme at the bottom of the index page in ghost?

I'm working on a blog for a friend of mine who wants to put a meme picture at the bottom of the index page.
So the simplest way is to edit the template and reference it from there.
The problem is, it's not user friendly to keep editing and uploading a new template.
So I had this idea that I could create a static page and place it on that page and reference it from the template. But I see that when you upload an image to ghost.io it generates a name based on the date path. That's not going to work for a fixed URL in the template.
Another option might be to use the tags. As tags allows you to put a picture and has a URL. But I tried that it also has similar problems.
How can I make this work nicely?
Don't reference image URL in your theme. Reference page slug and load its content, which would be just an image.
Example with Ghost Handlebars API:
{{!-- If a static page "meme" exists - its content will be loaded here --}}
{{#get "posts" slug="meme" }}
{{#foreach posts}}
<div>
{{content}}
</div>
{{/foreach}}
{{/get}}

Ghost blog get featured posts on single post page

I want to show featured posts on sidebar, and I code like this:
{{#foreach posts}}
{{#if featured}}
<!-- do something -->
{{/if}}
{{/foreach}}
This works well for me on homepage, but when I turn to single post page it's broken.
Seeming that I can't use {{#posts}} on single post page?

Remove content after <!--more--> tag

I'm trying to show at the category page only the content of the post that is before the <!--more--> tag. I'm using the latest Wordpress version.
In other words the structure will go like this
Content
<!--more-->
Content I want to be removed and only shown if the single post is displayed.
I've already got rid of the "Read More" link, and I've already tryed to use CSS and display:none; but none of those works fine
The code generated by wordpress is the following
<h2 class="entry-title">Post Name</h2>
<div id="chan" class="blanco">Content Shown</div>
<p><span id="more-50"></span>Post description.</p>
At the index.php I've managed to make it work since it shows the link and not the content itself, however in the page.php doesn't work.
Thank you very much in advance!
<?php the_content(); ?> will output the content, trimmed to just before the <!-- more --> tag, if the tag is used.
From the codex:
If the quicktag <!--more--> is used in a post to designate the "cut-off" point for the post to be excerpted, the_content() tag will only show the excerpt up to the <!--more--> quicktag point on non-single/non-permalink post pages.

Resources