Forums

[resolved] Query database without get_header() ? (3 posts)

  1. freshifreshy
    Member
    Posted 2 years ago #

    I want to create a php file that queries the database for posts, then I want to call on that php file with ajax to load in that content.

    I was hoping to do this without having to create a page and assign it a template, but it seems that if I don't do this, I can't use WordPress' query tags, etc.

    I'd like the PHP file to be as unobtrusive as possible.

    What would be the best, most secure way to do this?

  2. freshifreshy
    Member
    Posted 2 years ago #

    I guess what I'm asking is: Is there a way to take advantage of the WordPress codex for querying posts, etc., but without having to assign a template to the page?

  3. freshifreshy
    Member
    Posted 2 years ago #

    I think I've discovered that the answer is no. So instead I've used

    if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) { 
    
    // do something 
    
    }

    Using this, I created the page I need when the template loads.

    Was hoping to get around this, but ah well.

Topic Closed

This topic has been closed to new replies.

About this Topic