I am trying to: Display the total child post count on the parent page
The total count is correctly displayed when I am logged in into the website. However once I log out, the count shows as zero. (Please see the attached screenshots - logged-in.png and logged-out.png
Link to a page where the issue can be seen: hidden link
This is happening for all the posts in this custom post type. Not only for the link above.
I expected to see: Please see the screenshot attached.
Instead, I got: Please see the screenshot attached.
Hello. Thank you for contacting the Toolset support.
Well - could you please tell me how you are displaying the total counts using which shortcode so I can test with my local test install and try to reproduce the issue.
Additionally - the post type you are displaying is in post relationship (parent/child)?
Well - could you please tell me how you are displaying the total counts using which shortcode so I can test with my local test install and try to reproduce the issue.
1) I am displaying the count using a view. The shortcode for the view is [wpv-view name="total-order-count"]
The code for the view is placed in Loop Editor:
[wpv-layout-start]
[wpv-items-found]
[wpv-found-count]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-post-body view_template="Loop item in Total Order Count"]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]0[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
Loop item in Total Order Count is empty.
Additionally - the post type you are displaying is in post relationship (parent/child)?
2) The post type with the slug 'activity' has a one to many relationship with the post type with the slug 'order-count'.
This was earlier a parent- child relationship which was migrated to the new relationship.
well - this is really strange. I just added the shortcode [wpv-found-count] just before the view's look as you added and check with or without login but I do not able to reproduce the issue.
I can see the total number of counts displays with or without login. I need to check on your install whats going wrong there.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Well - I see you are using number of third party plugin and you also acknowledge that you find the culprit that causing the issue.
As I also mentioned I do not able to reproduce the issue with minimum setup but Yes, I can confirm that I can see the issue on your site here: hidden link
Maybe there is conflict between the 'Permalinks Customizer' or any other third party plugin you are using. If you confirm that issue is with 'Permalinks Customizer' plugin - I will try to reproduce it and if I confirm the issue, I will report it to our compatibility department.
To do so, I need plugin zip or link from where I can download the plugin.
I have set the next reply to private which means only you and I have access to it.
Well - I just checked by installing the plugin and adding the custom permalink for one of the custom post type and I still not do not have any issue with total post count.
This is something really specific to your page and site where its not working. So I suggest to isolate the issue and report to us if the issue belongs to Toolset. However, I do not see here that Toolset is issue here.
1) I deactivated all cache plugins / disabled cache through cPanel / web hosting.
I deactivated all plugins one by one (except all toolset plugins) and then switched to the default WordPress theme. The issue persisted till the time I deactivated the Permalinks Customizer plugin.
I am confused because the total reviews count - which is displayed using the view [wpv-view name="activity-reviews-total-count"] is showing the count properly.
But, the total orders count, which is displayed using the view [wpv-view name="total-order-count"] is not showing the count when logged out.
I compared both the views and they are exactly the same. Both the views display the child posts count (one to many) on the parent page.
2) I have another view named [wpv-view name="total-order-count-on-view"] which displays the order count inside another view.
The order count is showing up properly on the homepage hidden link
(The order count on the view used on the homepage is [wpv-view name="total-order-count-on-view"]
Whereas the order count us not showing up on the page hidden link which uses the exact same view [wpv-view name="total-order-count-on-view"].
Can you please guide me with the next steps I should perform / how I can find the issue?
I deactivated all plugins one by one (except all toolset plugins) and then switched to the default WordPress theme. The issue persisted till the time I deactivated the Permalinks Customizer plugin.
==> You mean once you deactivate Permalinks Customizer plugin - issue is solved? If yes:
There must be a unknown conflict or something thats causing this. To debug this issue deeply I need duplicator copy of your site to debug this issue further:
=> https://toolset.com/faq/provide-supporters-copy-site/
I have set the next reply to private which means only you and I have access to it.
So, I've created a new snippet with the custom shortcode which will fetch the total count.
=>hidden link
function func_get_total_count( $atts ){
global $post;
$childs = toolset_get_related_posts(
$post->ID, // the parent post
array('activity','order-count'), // the relationship slug
'parent', // the $post->ID role in this relationship
10000, // the maximum number of results
0, // the offset
array(), // additional query arguments
'post_id', // return format
'child', // role to return
'',
'ASC'
);
return count($childs);
}
add_shortcode( 'show_total_count', 'func_get_total_count' );
And I just called it just besides your view in your layouts cell:
=> hidden link
I have created a snippet from your code to display the total reviews count. The relationship between Reviews and Campsites is one-to-many. Each campsite can have multiple reviews. The code you had shared worked fine for 'activities' and 'order'counts. Can you help with this?
I want the shortcode to display the total review count for that each post (campsite).
function func_get_total_campsite_review( $atts ){
global $post;
$childs = toolset_get_related_posts(
$post->ID, // the parent post
array('campsite','review'), // the RFG slug
'parent', // the RFG role in this relationship is 'child'
10000, // the maximum number of results
0, // the offset
array(), // additional query arguments
'post_id', // return format
'child', // role to return
'',
'ASC'
);
return count($childs);
}
add_shortcode( 'show_total_campsite_reviews', 'func_get_total_campsite_review' );