INSERT in table row fatal error

This is more or less a programming question. $wpdb is not available everywhere. It’s a global variable. If you want to use it inside your own functions, just add global $wpdb; at the first line of the function. For general programming questions, this might be another discovery for you: stackoverflow.com,it is about programming in specific. … Read more

Are there action hooks for comments?

In WordPress, almost anything is possible. It all depends at times how hard you want to work for it. 🙂 The Comment Post form of course uses HTTP POST to submit to /wp-comments-post.php so you could use that except for the NONCEs if you want to post unfiltered HTML. You’d have to write a page … Read more

Change custom post type GUID in RSS

The feed template files call the_guid(), which calls get_the_guid(), which has a filter named (surprisingly) get_the_guid. You can hook into this filter to change the output. The filter only gets the current GUID, not the post ID, so look this up in the global variable if you need it. add_filter( ‘get_the_guid’, ‘wpse17463_get_the_guid’ ); function wpse17463_get_the_guid( … Read more

run script on publish

It looks like it could be because the filter cannot find the include file. Try using: include( ABSPATH. “/path/to/file/jobsfeed.php” )

Display Plugin Panels Outside of Admin Areas

Look at the markup for the callback function called by add_theme_page() or add_settings_page(), and use that markup to create a custom Page template. For code that simply outputs content, this should be fairly straight-forward; for code that actually saves settings, you’re probably going to have to do more work in order to create front-end data … Read more

Defining hooks within (php)classes?

Hook can only be identified by string. So the only option to have dynamic hook is is use some variable(s) in its name: do_action( $some_string_variable . ‘_top_page_hook’ ); Depending on what you are trying to do this can be something meaningful (like prefix, defined by configuration) or something randomly generated to be unique ID (not … Read more

How to add a filter to the get_body_class function?

The body_class() function simply calls the get_body_class() and creates a HTML class string from it. function body_class( $class=”” ) { echo ‘class=”‘ . join( ‘ ‘, get_body_class( $class ) ) . ‘”‘; } So, the body_class filter applies to both functions.

Modify posts listing at back end

You can do this easily using the edit_posts_per_page hook or edit_{$post_type}_per_page hook for pages and custom post types You can change based on the user role: function my_edit_post_per_page_role_based( $per_page, $post_type ) { //admin sees 25 posts per page if (current_user_can(‘administrator’)){return 25;} //editor sees 20 posts per page elseif(current_user_can(‘editor’)){return 15;} //author sees 10 posts per page … Read more