Inicio › Toolset Professional Support › [Resuelto] Showing comment count of related CPT
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Este tema contiene 16 respuestas, tiene 2 mensajes.
Última actualización por duongN-3 hace 2 años, 8 meses.
Asistido por: Minesh.
Tell us what you are trying to do?
Show comment comment of a related custom post type.
Is there any documentation that you are following?
Code I'm using: [wpv-post-comments-number none='(0)' one='(1)' more='(%)' item="@related-drama.parent"]
This is showing 0 comments. I'm using Disqus plugin on my site, so I'm not sure if this is affecting the count or not.
Thanks.
Hello. Thank you for contacting the Toolset support.
I just run a test with the shortcode:
[wpv-post-comments-number none='(0)' one='(1)' more='(%)']
And I can see it does displays correct comment count.
Can you please share bit more details about where you added the [wpv-post-comments-number] shortcode.
- What is the slug of your post relationship
- What post types you included with your post relationship and what post relationship you created?
I have 2 custom post types:
1. Drama Title (comments turned on and using Disqus plugin)
2. Subtitle Project (comments turned off)
Subtitle Project links to Drama Title using a relationship `drama-subs`
I'm using `related-drama` on Subtitle Project types form to link them.
It's a many-to-many relationship.
To display the many-to-many post relationship, you will require view.
Can you please check the following Doc and within your view, you should add a "Fields and Text" block and there you should try to display the shortcode:
[wpv-post-comments-number none='(0)' one='(1)' more='(%)']
=> https://toolset.com/course-lesson/many-to-many-post-relationships/#displaying-related-posts
If you still require further help, please share problem URL where you want to display comment count and admin access details. I have set the next reply to private which means only you and I have access to it.
Which post types will I need to add?
I selected these, but it just queries everything and not the related drama/movie/special.
You will require to only select the post type for which you want to display the comment count.
And then within the "Query Filter" section, you should add a Post relationship filter and select your post relationship and set the option from where post relationship value is related.
Hi Minesh, I'm still having issues.
The count keeps showing 0.
This is the Drama title: enlace oculto
It has 4 comments, although some may be Guests, but I commented myself to test as well.
Subtitle Project: enlace oculto (this will be blocked for you as a guest, so I'm sharing a screenshot)
Initially I added the Title of the post and this code `[wpv-post-comments-number none='(0)' one='(1)' more='(%)']` into the new View I created and the correct Title was pulling via the relationship, but the count stays at 0.
Can you please share admin access details so I can check whats going wrong with your setup.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I'm not sure as when I see on post relationship page: enlace oculto
I can see the post relationship "Dramas Subtitles" which is set to many-to-many: Dramas [*] <<>> Subtitle Projects [*]
But when I visit the subtitle-project single post you shared:
- enlace oculto
When I edit the above post:
- enlace oculto
I do not see any posts connected to "Drama" posts and even I do not see the post relationship box for relationship:
- "Dramas Subtitles"
I see you created many post relationship and it seems you have complex post relationship structure.
Even on drama edit post screen I do not see the post relationship box for the many-to-many post relationship "Dramas Subtitles":
- enlace oculto
Have you connected the posts of post type Dramas and Subtitles using post-relationship?
Hi Minesh,
I created this Post form to "Add Subtitle Projects":
WP Dashboard: enlace oculto
Front-end CRED form: enlace oculto
Please check attached screenshot to see how Drama cpt are attached to Subtitle Projects cpt.
This is the cred_field I'm using to add "Related Drama" to "Subtitle Projects"
[cred_field field='related-drama' force_type='field' class='form-control' output='bootstrap' select_text='--- Search Dramas ---']
Is this the wrong way to go about associating the 2 post types?
Thanks,
-Duong
We can talk bit later for frontend but first I would like to know why post relationship-box is not displayed on post add/edit form.
Please check the following test site, you can auto-login using the following link:
- enlace oculto
On post relationship page, you will see a many-to-many post relationship created between post types "Gyms" and "Personal Trainers", the post relationship name is: "Gyms Personal Trainers"
- enlace oculto
Now, when I try to add/edit post on either "Gyms" or "Personal Trainers" post type, I will be able to see the post relationship-box for the post relationship I've created "Gyms Personal Trainers":
Gym Post example - notice the post relationship-box at bottom of this edit post: section "Gyms Personal Trainers", from where you can see the related posts attached to this Gym, we can say list of personal trainers belongs to this Gym
- enlace oculto
Personal Trainer post example: notice the post relationship-box at bottom of this edit post: section "Gyms Personal Trainers"
- enlace oculto
Now, it seems there must be some conflict or post-relationship is not created as expected or corrupted or you did hide the post-relationship box in backend - have you added any custom code to hide it?
As shared with my previous reply:
- https://toolset.com/forums/topic/showing-comment-count-of-related-cpt/#post-2311011
I visit the subtitle-project single post you shared:
- enlace oculto
When I edit the above post:
- enlace oculto
I do not see any posts connected to "Drama" posts and even I do not see the post relationship box for relationship:
- "Dramas Subtitles"
Even on drama edit post screen I do not see the post relationship box for the many-to-many post relationship "Dramas Subtitles":
- enlace oculto
So, my first initial question is where post-relationship-box is gone, why its not get displayed.
If you try a clean install and create many-to-many post relationship between your desired post type, you will see the post-relationship box on post add/edit screen at bottom of post as you can see with the test site I shared.
Hi Minesh,
I understand the relationships and how to associate them. There is an option under Post Types that allows you to turn off the relationships in the Post editor. I didn't add any special code for this. Please take a look at the screenshot.
I've set up relationships for other parts of the site, but like I said before, for Subtitle Projects I'm using different cred_fields to associate 2 posts.
Subtitle Projects as you can see from the screenshot has relationships with many Post Types and I set it up differently compared to my other Post Types.
If you go to Custom Fields, there's a Subtitle Provider Section (Post Field Group). Under this section I used the cred_field Post Reference to add the relationships (see 2nd screenshot).
Ok got it. Thanks for the information. I did not know that you disabled the post-relationship box and that answers my question.
Now, let me tell you that you are not using the normal WordPress comment system. What you are using "Disqus for WordPress" is totally different and needs extra configurations.
I followed the following link:
- enlace oculto
And to the content template "Template for Subtitle Projects" I've added the following code at top of the content template as per the above link:
- enlace oculto
<script id="dsq-count-scr" src="//dramaotaku.disqus.com/count.js" async></script> <a href="[wpv-post-url item="@related-drama.parent"]#disqus_thread"></a>
I can see at top of the page - before the post title, it does displays the correct comment count:
- enlace oculto
You can move the code at what ever place you want to display the comment count.
<a href="[wpv-post-url item="@related-drama.parent"]#disqus_thread"></a>
I'm really happy to help but anything beyond this is custom code which is beyond the scope of our support policy.
Please check previous reply for solution shared.
Thanks Minesh!
Just to confirm, I do not need this code anymore, correct?
[wpv-post-comments-number none='(0)' one='(1)' more='(%)']
I only need to use the code you added?
Thank you again!