Please make sure to update to WPML 4.3.4 before reporting any issue

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 7 replies, has 2 voices.

Last updated by Makarand Mane 7 months ago.

Assigned support staff: Radu.

Author Posts
April 11, 2019 at 10:56 am #3586421

Makarand Mane

Hi,

We have 113 published course & it shows only 68 in count. Have you used the 'wp_count_posts' hook in WPML? If yes, then does it affect all course count value in WPLMS All Courses page.

Check this link: hidden link

April 11, 2019 at 2:58 pm #3589443

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hey,

It seems that the number of courses displayed on the archive is the right one and only the count number is wrong. Now, can you try to activate a default theme (like Twenty Nineteen) and see if this number is still wrong. Also, you can deactivate all the plugins (including WPML) without WPLMS and see if the count is going back to normal. Please let me know how things work after you do these changes.

Thanks,
Radu

April 16, 2019 at 2:29 pm #3622937

Makarand Mane

Mr. Radu,

First thing, this is WPLMS depend website. course functionality coming from theme and their plugin. Dont give option to switch theme.

Second point, without WPML counting comes correct. After WPML counting is wrong. Now you can count is zero.
When I check function in this theme, they counted and showing count of all published courses. Now it is showing 0.

hidden link
hidden link
hidden link

WPML affecting output (count) of this function

function bp_course_get_total_course_count( ) {
	// If no explicit user id is passed, fall back on the loggedin user
	$c = wp_count_posts('course');
	$count_course = $c->publish;
	if(!isset($count_course)) $count_course =0;
	return apply_filters('bp_course_total_count',$count_course);
	}
}
April 17, 2019 at 7:51 am #3628029

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hey,

Thank you for looking for the code that's displaying the count part. Is there any chance that you could create a duplicator package of your website so I can install it on my computer and see why is this count calculate the wrong way, please? I set the next reply to have the duplicator field active so you can attach the link to archive.

Thanks,
Radu

April 17, 2019 at 3:58 pm #3632493

Makarand Mane

create a duplicator package of your website? How I can do it

duplicator field ? what is that?

April 18, 2019 at 7:18 am #3636747

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hey,

I was asking for a duplicator package in order to copy your website on my computer and look at this part. However, in the meantime I found that the wp_count_posts will always return the count of all the published courses, no matter the language.

In order to have the number of courses for each language, you'll need to replace the function you mentioned with this one:

function bp_course_get_total_course_count( ) {
    // If no explicit user id is passed, fall back on the loggedin user
    $args = array(
		'posts_per_page' => -1,
		'post_type' => 'course',
		'suppress_filters' => false
	);  
	$result = new WP_Query($args);

    $count_course = $result->post_count;
    if ( !isset( $count_course ) ) 
    	$count_course = 0;
    return apply_filters('bp_course_total_count', $count_course);
}

Can you give this a try and tell me how it works, please?

Thanks,
Radu

April 19, 2019 at 12:37 pm #3645731

Makarand Mane

Your code fail at

$c = $result->post_count;

it should be

 $count_course  = $result->post_count;

I did some more debug with theme. It was having there own hook on bp_course_total_count, to recalculate count if WPML is active. I just disabled that. Now it is working fine

April 19, 2019 at 12:37 pm #3645757

Makarand Mane

My issue is resolved now. Thank you!

The topic ‘[Closed] Getting All Courses count issue?’ is closed to new replies.