- This topic has 5 replies, 3 voices, and was last updated 4 years, 4 months ago by Tom.
-
AuthorPosts
-
November 21, 2019 at 9:08 pm #1071773An Nguyen
Hi all,
May I ask you a question with custom hook?
I want to make a hook to insert number of comment shortcode after title in blog page (inside anchor tag of title) like markup below in GP 2.4 version.
<a class=“title”> The important of SEO [insert SHortcode here] </a>
I tried with after-archived-title but it is below anchor tag.
<a class=“title”> The important of SEO </a> [insert SHortcode here]
I like it next to text-title.
I’ve just updated to new official version and Iam not sure if we have a new hook to do that.Thanks in advance.
GeneratePress 2.4
GP Premium 1.9November 22, 2019 at 8:45 am #1072815TomLead DeveloperLead DeveloperAs of right now it’s not possible to hook anything into the title like that – WordPress itself makes it very difficult.
To do this, you would need to remove the default content title, and then hook in your own content title along with the shortcode.
I mentioned the same thing here: https://generatepress.com/forums/topic/support-on-summary-and-entry-title/#post-1042934
You can remove the default title by creating a Layout Element and using Disable Elements to disable the content title.
Then you can add your own title code by using
the_title()
in a Hook Element: https://developer.wordpress.org/reference/functions/the_title/November 22, 2019 at 9:13 am #1072849An NguyenHi Tom,
Thanks for feedback! I knew this method because you’re already mentioned in my previous post.
But I dont want to change the current layout for just a light customised stuff.
Can you help me with CSS instead?
I want like number of comment and its icon display at the end of Text-title Ex: “TOGAF – Enterprise Architecture Framework icon+3 ”
Now current markup is:
<header class="entry-header"> <h2 class="entry-title" ><a>TOGAF – Enterprise Architecture Framework</a></h2> <span class="text-number"> <i class="fa fa-comment"></i> 3 </span>
November 22, 2019 at 2:01 pm #1073146DavidStaffCustomer SupportHi there,
the Post titles are variable in length and may span across more then one line, which makes it impossible to put the shortcode inline with the title using CSS.
The method Tom suggested is the only way to do this.
November 22, 2019 at 6:50 pm #1073286An NguyenHi David,
Finally, I can find the solution for my case. We can wrap number-comment with p tag and use flex-box to solve the problem and it works like a charm without editing template.
Thanks David & Tom.
November 23, 2019 at 8:03 am #1073921TomLead DeveloperLead DeveloperGlad you got it working 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.