Make sure you reference the global $wpdb
variable first, otherwise PHP doesn’t know what $wpdb
is or whether or not it has a get_results()
method or a prefix
property.
So just add global $wpdb;
to fix it:
<?php
global $wpdb;
$gallery_ids = $wpdb->get_results(
"SELECT gid FROM ".$wpdb->prefix."ngg_gallery ORDER BY gid ASC", ARRAY_A);
?>
Related Posts:
- How to exclude a widget from page 1 of a paginated post
- Add a plugin before main container
- Modify pages widget and make a plugin?
- Failed to load resource: the server responded with a status of 500 () post.php
- Python in WordPress – A “Hello World” implementation
- How to remove a css class for any wordpress page
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- Display static pages instead of category, in code
- Attachement title in wpallimport
- What are the differences between WPINC and ABSPATH?
- Should all plugins be encapsulated in a Class?
- How can I use WordPress functions in my stylesheet?
- Disable email notification after change of password
- How can I see all the actions attached to an “add_action” hook?
- Pass PHP variable to javascript
- wp_dequeue_style not working
- How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?
- Consuming an external API in WordPress?
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- Is there a way (plugin?) to restrict a user to being able to edit just one page?
- When unit testing a plugin, does the plugin need to be in the wp-content/plugins directory of the WordPress tests install?
- How can I prevent a plugin from updating unless it’s minimum PHP version is met?
- How to properly insert data into custom table via plugin
- How to get the active theme’s slug?
- Preserve custom URL parameter on more pages
- How can I import a class privately into a plugin?
- __(): What if I have to pass in a variable?
- PHP code on Visual Composer Plugin
- Creating a WordPress admin page without a menu for a plugin
- Run WP-CLI using PHP
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- How to make simply “report” button on posts
- What is the best page ordering plugin that works well with WPML? [closed]
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Plugin update error message
- Keep one user logged for a year?
- How to build an API as a plugin
- Customizing subject in comment notification e-mails
- category_name not working (not showing up in sql query debug)
- Plugin or mod for wordpress to make content publication SUPER easy
- if plugin is active? check if plugin is enabled or not?
- Using require_once in a Plugin?
- Get php var inside javascript file (making plugin)
- How can I make my custom shortcode work in a Custom HTML Widget?
- Simple form that saves to database
- WP showing “warning: call_user_func_array()”, What to do?
- How do I extend one plugin I’m writing with another I’m writing using classes?
- Best way to manage a lot of pages in Wp Admin [closed]
- Adding a text domain to every __(), _e() and __n() gettext call without a plan to create own translations
- Searching users with WP_List_Table plugin
- How to Loop Plugin Option Field Set?
- Create page when plugin is activated
- Find out what is using PHP sessions in WordPress
- Making plugin unique to not conflict with plugins with the same name
- Cropping, Re-sizing and Saving images from one folder to another folder in wordpress
- How to find out if option exists but is empty?
- How to call plugin path in JS?
- Get Current user email as a return string value
- Insert plugin content before body end
- PHP Deprecated: Non-static method should not be called statically
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- Generate custom output for page/URL in a plugin
- how to customize hello dolly plugin?
- How can I pass a variable to wp_ajax action?
- Update Multiple Post Meta for the Same Post In One call?
- WordPress Hook that will run when media file deleted
- jQuery plugin only in one page/post
- Adding Custom Fields for Img in Posts
- How to store ACF custom fields data in a custom table
- How to pass JavaScript variable to PHP in wordpress widget?
- Unable to add admin notice on plugin activation
- Bug in Stackoverflow styled badge system script
- How To Ignore a Filter On Applying Filter the Content In a Function
- Updating WooCommerce variable product stock issue
- How can I show drafts in wp_dropdown_pages list?
- Saving Plugin settings to the database
- Set a User as Author of all ‘New Posts’ posted
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- Post source link plugin – small modification
- Which hook callback has priority if both plugin and theme use the same hook?
- Pages with 2 Columns
- WordPress widget / plugin….fields not appearing in my widget
- How can I make content disappear when a user logs in?
- How to create a Page alias in WordPress
- Add CSS animation as Preloader to WordPress
- Include images from pages in wp search.php results in default wp search
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Change destination author link
- How to turn off email you receive when registered?
- How can I execute some small piece of PHP code in a sandbox area of my WP?
- How can I include PHP-Code to my post?
- Custom Widget outputs the input but doesn’t save anything inside the textarea
- Multi step form, custom plugin
- Plugin.php: PHP Notice: Undefined offset: 0 in
- How to Create a Directory in a Plugin Folder?
- Trying to disable plugins doens’t work
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- Thumb rating for wordpress – top user