How to display the user that published a pending post?

The reason that get_the_modified_author() is not working is that it relies on being used within the WordPress loop. wp_get_recent_posts() does not set up a global post object. Here is a complete example based on your original code that replaces get_the_modified_author() with some simple code to get the name of the last person who edited the … Read more

How to make ajax call in wordpress in right way?

Your ajax hook add_action(‘wp_ajax_load_user_feed’, ‘ajax_load_user_feed’); is for logged in users only, if you want none logged in users (guests or visitors) then add: add_action(‘wp_ajax_nopriv_load_user_feed’, ‘ajax_load_user_feed’); and you should be fine.

Filter Custom Post Type in Admin

Just like in Adding a Taxonomy Filter to Admin List for a Custom Post Type? the filter parse_query could be used, but here I’m using posts_where. The row All | Published | … is controlled by views_edit-{$post_type} and the $views array contains each item that’s a simple anchor tag. First, we insert a couple of … Read more

wp_list_table search box does not show

You must use $list_obj->prepare_items() before $list_obj->search_box(‘Search’, ‘search’) function! Example: <form method=”post”> <input type=”hidden” name=”page” value=”<?php echo $_REQUEST[‘page’]; ?>” /> <?php $this->sales_obj->prepare_items(); $this->sales_obj->search_box(‘Search’, ‘search’); $this->sales_obj->display(); ?> </form>

White screen of death only in wp-admin

As a rule of thumb, always remove the ending ?> of your .php files, especially if it’s a functions or config file that gets parsed before headers are sent to the page. If after that ?> you accidentally add a space, a tab character or a new line, there’s your invisible error.

Edit specific nodes in WP_Admin_Bar

Yes I recently ran into the situation where I wanted to change the profile link in the user-info section of the admin bar. The problem is that you can only get all nodes, add and remove them. Not edit. And you also cannot modify the $wp_admin_bar->nodes property due it is private. When easily removing and … Read more

Why are admin scripts not printed

Use the admin_enqueue_scripts hook instead of admin_init Note: you should use hooks that target admin pages as specifically as possible. e.g.: Plugins: Use the admin_print_scripts-{plugin-page} hook Themes: Use the admin_print_scripts-{theme-page} hook (where {theme-page} is whatever string you use in the add_theme_page() call) Custom Post-Type Edit Page: Use the admin_print_scripts-edit.php hook, For Custom Post Types, inside … Read more

Is there un-wp_autop function?

I just ran into this situation. Here is a function I used to undo wpautop. I might be missing something, but this is a good start: function reverse_wpautop($s) { //remove any new lines already in there $s = str_replace(“\n”, “”, $s); //remove all <p> $s = str_replace(“<p>”, “”, $s); //replace <br /> with \n $s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)