Get Archive Page Id But Return Post Id In WordPress

Get Archive Page Id But Return Post Id In WordPress

Outline

    Original Post

    Get Archive Page Id But Return Post Id In WordPress


    Original Post

    Get Archive Page Id But Return Post Id In WordPress


    I had this annoying problem many times. When I wanted to get page id with get_the_ID in archive page, it returned an id of post. This is the best solution I found.

    $url = 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
    $cur_post_id = url_to_postid( $url );

    Related Posts

    The Complete WordPress Customization Tutorial – Just Copy And Paste And Work



    Related Posts

    Aron

    A data scientist working in a retail company, with experience in web design and marketing. Recently dives into cryptocurrency and quantitative investing.

    facebook telegram
    Content Protection by DMCA.com

    Leave a Reply

    • Required fields are market * .
    • Your email address will not be published.
    • Please ensure your email address is correct, then you will get a notification once a new comment reply.

    Your email address will not be published. Required fields are marked *