Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:42:17+00:00 2026-06-09T12:42:17+00:00

In a plugin, via the add_action() routine, I try to run a check. But

  • 0

In a plugin, via the add_action() routine, I try to run a check. But getting the post ID as below doesn’t work, but why? What’s the correct way of getting the post ID and a related cat id?

add_action( 'wp', 'check_url', 10, 1 );

function check_url($wp){
    if( is_single() ){
        $cat_id = wp_get_post_categories( $post->ID );
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:42:18+00:00Added an answer on June 9, 2026 at 12:42 pm

    Add global to your function first before using $post to make it visible inside your function (this is why we love PHP):

    function check_url($wp){
      global $post;
      ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to disable/redirect Gallio's plugin cache via Gallio.Echo (or a configuration
Hi i am trying to access my plugin via a custome URL but i
I have a registration plugin embeded via an iframe on my website, The registration
I'm hoping to load jquery, jqueryUI, underscore & backbone, and non-AMD jquery plugin's via
I installed vim fugitive via pathogen plugin. Helptags created the tags for fugitive. In
I'm trying to enable Ruby via the plugin manager, and I receive the following
I have a really strange behavior with highchart (via rails plugin): The graph display
I've got an IE BHO plugin that sends out via a COM call the
My plugin DLL is really simple but references fifteen or so other DLLs. How
I am trying to use jquery validator plugin and form submit via ajax in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.