• Hi WP-ists….

    I writing a simple plugin for WordPress, albeit slowly.

    I’ve got it writing to the database, but it’s getting the info out that I can’t seem to do

    In my brain, this should work:

    function displayCatImg(){
            global $wpdb;
            $getImg = $wpdb->query("SELECT imageurl FROM wp_blogcathead WHERE id = '7'");
                echo $getImg;
    }

    Basically, it should pull a URL from a new table in the WP database.

    Do I need to use foreach?
    There is only one value being taken from the database though.

    Should I be using something other than echo?

    Anyone? Class? Anyone?

    Cheers
    Toby

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tobydecks

    (@tobydecks)

    Ahh $wpdb->query did it ??

    Now, another question is can I get the current category for the post I’m viewing and store it as a variable?

    Thanks

    Thread Starter tobydecks

    (@tobydecks)

    The category ID number, rather than the name.

    I have `$category = get_the_category();
    $catid = $category[0]->cat_name;`
    That gave me the name of the category, but I want the ID number instead.
    Can I adapt the above to give me the number rather than the name?

    Fanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting results from WP database’ is closed to new replies.