Skip Navigation

[Resolved] Showing comment count of related CPT

This support ticket is created 2 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

This topic contains 16 replies, has 2 voices.

Last updated by duongN-3 2 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2307441

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.

#2307455

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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?

#2307457

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.

#2307459

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2307489
Screen Shot 2022-03-03 at 3.58.22 AM.png

Which post types will I need to add?

I selected these, but it just queries everything and not the related drama/movie/special.

#2307499

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2307863
Screen Shot 2022-03-03 at 1.16.44 PM.png
Screen Shot 2022-03-03 at 1.15.31 PM.png

Hi Minesh, I'm still having issues.
The count keeps showing 0.
This is the Drama title: hidden link
It has 4 comments, although some may be Guests, but I commented myself to test as well.
Subtitle Project: hidden link (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.

#2308191

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2311011

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm not sure as when I see on post relationship page: hidden link

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:
- hidden link

When I edit the above post:
- hidden link

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":
- hidden link

Have you connected the posts of post type Dramas and Subtitles using post-relationship?

#2311609
Screen Shot 2022-03-08 at 12.50.28 PM.png

Hi Minesh,
I created this Post form to "Add Subtitle Projects":
WP Dashboard: hidden link
Front-end CRED form: hidden link
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

#2311909

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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:
- hidden link

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"
- hidden link

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
- hidden link

Personal Trainer post example: notice the post relationship-box at bottom of this edit post: section "Gyms Personal Trainers"
- hidden link

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:
- hidden link

When I edit the above post:
- hidden link

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":
- hidden link

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.

#2311995
Screen Shot 2022-03-09 at 12.57.06 AM.png
Screen Shot 2022-03-09 at 12.47.43 AM.png

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).

#2312103

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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:
- hidden link

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:
- hidden link

<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:
- hidden link

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.

#2312105

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Please check previous reply for solution shared.

#2312107

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!