bp_core_get_post_id_by_slug( $slug )

Get Post id by Post SLUG

Description

Parameters

$slug

(Required)

Return

(array)

Source

File: bp-core/bp-core-functions.php

4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
function bp_core_get_post_id_by_slug( $slug ) {
    $post_id = array();
    $args    = array(
        'posts_per_page' => 1,
        'post_type'      => 'docs',
        'name'           => $slug,
        'post_parent'    => 0,
    );
    $docs    = get_posts( $args );
    if ( ! empty( $docs ) ) {
        foreach ( $docs as $doc ) {
            $post_id[] = $doc->ID;
        }
    }
 
    return $post_id;
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.