To count number of custom post types

#222419
  • Resolved Oleg
    Rank Math free

    Hello. I have custom post type Hospitals – it’s main post type on my website. can i output in the seo title amount of this post types?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Prabhat
    Rank Math agency

    Hello,

    Thank you for contacting us.

    I’m not sure whether I fully understand the question.

    Could you please describe what Amount do you intend to output in the SEO title?

    Looking forward to hearing back from you.

    Thank you.

    Oleg
    Rank Math free

    I have Custom Post Types “Hospitals”- at the moment I have 31 hospitals on my website. and I want to display this number – and when I get one more hospital on my website than I have 32 hospitals

    Hello,

    In this case, this may require you to modify our filter to create a custom variable since we don’t have a variable to count the number of CPT posts.

    Please refer to this code here to create a custom variable and use the shortcode %shortcode_var_name%:

    add_action( 'rank_math/vars/register_extra_replacements', function(){
    	rank_math_register_var_replacement(
    	   'shortcode_var_name', [
    	   'name'        => esc_html__( 'VAR name', 'rank-math' ),
    	   'description' => esc_html__( 'VAR description', 'rank-math' ),
    	   'variable'    => 'shortcode_var_name',
    	   'example'     => shortcode_var_name_call_back(),
    	   ],
    	   'shortcode_var_name_call_back'
       );
    });
    function shortcode_var_name_call_back(){
    	return "Value";
    }

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘To count number of custom post types’ is closed to new replies.