0
如何通过在WordPress中使用帖子名称和类别名称来获取帖子ID?如何通过在WordPress中使用帖子名称和类别名称来获取帖子ID?
我有使用此代码,但它不帮助我。
$post_slug = get_post_field($post_name, get_post());
$args = array(
'name' => $post_slug,
'category_name' => $pcat_name,
'post_type' => 'post',
'post_status' => 'publish',
'numberposts' => 1
);
$my_posts = get_posts($args);
if($my_posts) :
$rid=$my_posts[0]->ID;
endif;
slu is是不行的。
我想检查邮政名称和它是必须的类别名称。
这不是我所期望的。我需要通过使用职位名称的职位编号,并检查类别名称。 –