How can I get the current Question Custom Post Type ID ?

4.30K viewsThemes
0

Hi Rahul,

I am trying to get the ID of the current question.

How can I do that in the function.php?

Thanks

0

It does not really matter as get_question_id() does not return anything right?

So I tried but it does not work.

0

Hello,

get_the_ID() not working because you are trying social shortcode outside loop. instead try get_question_id()

commented on answer

get_question_id(); does not seem to work neither.

What I’ve done :

if(function_exists(‘social_warfare’)){
$id = get_question_id();
echo do_shortcode(‘[social_warfare post_id=”$id”]’);
}
add_action( ‘ap_before’, ‘social_warfare’ );

There is a syntax error. it should be like:
echo do_shortcode('[social_warfare post_id=' . $id . ']');