I was creating a ghost blog and i created a custom component to display all the tags in the blog.
I used the below code to do so,
{{#get "tags" limit="all"}}
<ul class="tags">
{{#foreach tags}}
<li>
{{name}}
</li>
{{/foreach}}
</ul>
{{/get}}
I made the component to act as a filter. But I am facing some issues,
Tags with no posts are not displaying.
Also is there any way to know which tag filter is currently active?
can someone help me with what I am doing wrong.?
Thanks in advance.
I believe tags with no posts technically don't exist so they don't they don't create empty page routes, as all tags have their own tag page (/tag/example-tag/). As for knowing the active class I assume you're wanting to apply an active class to the tag link, which can be done with link_class:
<a class="tag {{link_class for=url class='tag-current'}}" href="{{url}}">{{name}}</a>
Related
I want to add some Owl Carousel Classes to the Related Products from <ul class="products columns-4"> to <ul class="products columns-4 owl-carousel four-col"> in the Unordered List, in the single product page.
The CSS classes I want to add are owl-carousel four-col.
Doing this I know requires some knowledge of WordPress hooks and filters.
Any idea on how to implement this will be appreciated :)
As far as I know there is no filter available to modify classes set to <ul class="products"> element.
This element is actually rendered with WC template templates/loop/loop-start.php and this template is called with woocommerce_product_loop_start() function. This is a pluggable function, meaning you can override it in your active theme/child-theme.
The better and simpler way would be to modify the related template directly, located in templates/single-product/related.php (learn how to properly override WC templates in your child-theme, do NOT modify WC source templates directly in plugin's folder).
It should be enough to replace this line in the related template:
<?php woocommerce_product_loop_start(); ?>
with this line:
<ul class="products columns-4 owl-carousel four-col">
Another approach would be to set those classes dynamically with jQuery, but I'm not sure whether it would work well with Owl Carousel (it might not load properly).
I've got a customized theme for Ghost. I nave a guest author once on a while. I'd love the ability to include any number of custom links to the authors page for each author.
I'm aware of the authors-{{slug}}.hbs convention I could use to create a complete custom page for each author, but that's a nightmare to maintain.
Instead I was trying to try to include a partial when it exists. According to the handlebars docs the {{#> partial }} should work. But that works when I know the exact name of the partial.
I need the name of the partial to be dynamic based on the context. In my case the ghost slug for the author. According to the handlebar docs I need to pass in a function...
I tried a few ways, but gscan dislikes all of them:
{{#> (concat "partials/socials-" slug) }}
{{#> (concat "partials/socials-" (lookup . 'slug')) }}
{{#> concat "partials/socials-" (lookup . 'slug') }}
{{#> "partials/socials-{{slug}}" }}
{{#> partials/socials-{{slug}} }}
All give me:
Checking theme compatibility...
Your theme has 1 error!
----
Errors
------
Important to fix, functionality may be degraded.
- Error: Templates must contain valid Handlebars
Files: author.hbs
Have you used content blocks before? They're a way to re-use template code but still allow for customisation, it's a method used in Casper which you've forked from. Check out these lines here in page.hbs: https://github.com/jessehouwing/jessehouwingnl-Casper/blob/customized/page.hbs#L58-L65
as well as this line shown in default.hbs: https://github.com/jessehouwing/jessehouwingnl-Casper/blob/customized/default.hbs#L127
What you could do is create a custom author template that inherits the existing author.hbs template. For this example I'm going to create a custom author page for the author 'ghost' by creating author-ghost.hbs:
{{!< author}}
{{#contentFor "links"}}
<ul>
<li>Example link</li>
<li>Example link</li>
<li>Example link</li>
</ul>
{{/contentFor}}
The above code inherits author.hbs and creates a block called links. Then in the original author.hbs template we can add the block reference to where we want the contents of the block to appear:
{{{block "links"}}}
Not only will this insert the code in the custom author template, but it'll also gracefully fallback to no output if there isn't a custom author template for the author.
Hope this helps!
I had the same issue and here how I solved. Just use the lookup in this syntax.
{{#foreach navigation}}
<li class="nav-{{slug}}">
<a href="{{url}}" class="social-link" target="_blank" rel="noopener">
{{>(lookup . 'slug')}}
</a>
</li>
{{/foreach}}
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}}
I have a wordpress menu plugin that comes with a theme, unfortunately the theme was limited in that, it did only provide on menu, I wanted to add another menu to it. I have found where I wanted to add my link in the theme. I found that one menu provided by the theme
<li>
</i> <?php _e('gallery', 'thematic'); ?>
</li>
And duplicated that twice, but the problem if the link takes me to a page http://foo.bar/?author=1
Is there anyway I can modify this link so it takes me to a page found http://foo.bar/playground ?
Can you change the href attribute of the link?
<li>
<i class="icon-suitcase5"></i> <?php _e('gallery', 'thematic'); ?>
</li>
When I go to my shop page products are displayed in a very strange way : Product details take lot of place. I tried to understand what have changed since yesterday and I notice (inspecting element via Chrome) that the html code before was :
<ul id=product ....>
<li class=product_item ...>
<div class=image container>...</div>
<div class=clearfix>...</div>
<div class=product details>...</div>
</il>
</ul>
and now I have this following code (and it destroy my product list display) :
<ul id=product ....>
<div class=t_singleproduct_cont>
<li class=product_item ...>
<div class=image container>...</div>
</il>
</div>
<div class=clearfix>...</div>
<div class=product details>...</div>
</ul>
As you can see the product details is outside the li tag and so my shop page is such a mess.
I tried to identify where this piece of code was coming from and I found that it was inside the content-product.php file but I can't see the line with "t_singleproduct_cont" div.
If you could help to deal with this problem I'll be very grateful !
Thank you very much
#Tayfun Akaltun. Have you installed plugin called enhanced e-commerce plugin for google analytics?