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

  • SEARCH
  • Home
  • 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 4612208
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:22:21+00:00 2026-05-22T01:22:21+00:00

what is the earliest wordpress action where the post that will eventually be shown

  • 0

what is the earliest wordpress action where the post that will eventually be shown can be detected reliably ? (either by using global $post or detecting the wp_query object or other way)

eg. my plugin needs to detect an incoming request from another plugin on a different site, at the moment it checks for a $_POST var as early as possible by using add_action('plugins_loaded' and the callback function uses $post = get_page_by_path($_SERVER['REQUEST_URI'],'','post') to get the $post object and then uses the post data to get any other information that is used to process the response which gets sent back before any headers or other standard WP processing happens with the intention of lessening the load on the blog receiving the request.

is there a better way?, I know there isn’t an earlier way because 'plugins_loaded' action gets called right after the , well, plugins get loaded but is there a more reliable way than using get_page_by_path ?

  • 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-05-22T01:22:22+00:00Added an answer on May 22, 2026 at 1:22 am

    I’d try the filter 'the_posts'. You find it in wp-includes/query.php function get_posts(). It passes the found posts as a array by reference, so you can use it like an action.

    Here is a plugin I use to inspect hooks:

    <?php
    /*
    Plugin Name: Hook Check
    Description: Inspects a hook and prints its information to the footer.
    Version:     1.0
    Required:    3.1
    Author:      Thomas Scholz
    Author URI:  http://toscho.de
    License:     GPL
    */
    ! defined( 'ABSPATH' ) and exit;
    
    $GLOBALS['hook_checks'] = apply_filters(
        'hook_check_filter'
    ,   array ( 'the_posts' )
    );
    
    foreach ( $GLOBALS['hook_checks'] as $hc_hook )
    {
        add_action( $hc_hook, array( 'Hook_Check', 'catch_info' ) );
    }
    add_action( 'wp_footer', array( 'Hook_Check', 'print_info' ) );
    
    class Hook_Check
    {
        static $info = array ();
    
        public static function catch_info()
        {
            $args = func_get_args();
            self::$info[ current_filter() ] = print_r( $args, TRUE );
            return $args[0];
        }
    
        public static function print_info()
        {
            if ( empty ( self::$info ) )
            {
                return;
            }
    
            print '<pre>';
            foreach ( self::$info as $filter => $catched )
            {
                print "<b>$filter</b>\n" . htmlspecialchars( $catched );
            }
            print '</pre>';
        }
    }
    

    Reduced sample Output:

    Array
    (
        [0] => Array
            (
                [0] => stdClass Object
                    (
                        [ID] => 112
                        [post_content] => The entire content …
                        [post_title] => An awesome title
                        [post_excerpt] => 
                        [post_status] => publish
                    )
            )
    )
    

    This should give you all information you need as early as possible.

    Oh, and I hope to see you on https://wordpress.stackexchange.com/ with such questions. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make Django view that will give JSON responce with earliest
I have a custom developed WordPress plugin that is using jQuery 1.4 and for
I'm using a UNION and a LIMIT to select the earliest occurence of a
When I commit a transaction in Oracle how can I get the earliest SCN
I am wanting to know when is the earliest point I can load additional
I am using c#.net I have two times pulled from a database (‘earliest start
I think this will be easy but I can't see how to do it!
Whats the earliest point I can programatically get to the name of the masterpage
When is the earliest point in which I can access HttpContext.User?
Can anyone familiar with the Twitter Search API tell me what the earliest possible

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.