Hello. In cms Word Press created a rubric, in this rubric created a post, the post has id 46 (post = 46).

I want to display my code only on this record, for this I need a condition that checks on which record I am. I would be grateful for the information!

In order to make it clearer about what I mean: if I wanted to execute my code on a specific page, I would use the condition:

<? if ((is_page('15'))) { ?> первый код <? }else{ ?> мой код 2 <? } ?> 

    1 answer 1

    Getting the post ID in wordpress is as follows:

     $id = get_the_ID(); 

    Therefore, your condition should be:

     <? if (get_the_ID() == 46) { ?> 

    Documentation: https://developer.wordpress.org/reference/functions/get_the_id/

    • thank you very much. in 5min I will answer - iKey