How to Remove Certain Screen Options and Table Columns from post type in wp_list_table?

What you need is to modify the $columns variable that is used during list display which you can modify using the ‘manage_posts_columns’ and ‘manage_pages_columns’ hooks for post_type=”post” and post_type=”page”, respectively. If you want to ignore custom post types you can inspect the 2nd parameter passed to ‘manage_posts_columns’ as I did in my example to show … Read more

How to add extra attribute to stylesheet link?

We can use style_loader_tag filter to filter the link that is being output. Here is the filter: $tag = apply_filters( ‘style_loader_tag’, “<link rel=”$rel” id=’$handle-css’ $title href=”https://wordpress.stackexchange.com/questions/231597/$href” type=”text/css” media=”$media” />\n”, $handle, $href, $media); Here the link $handle for which you want to add attribute is font-awesome so if the handle, so you can replace font-awesome-css with … Read more

Exclude drafts in all() view of edit.php

The show_in_admin_all_list parameter in the register_post_status() function, determines if a given post status is included in the All post table view. Probably the shortest version is: add_action( ‘init’, function() use ( &$wp_post_statuses ) { $wp_post_statuses[‘draft’]->show_in_admin_all_list = false; }, 1 ); but let’s avoid modifying the globals directly like this and override the default draft status … Read more

GPL and plugins

If you’re following the rules (you never want to start out by breaking them), then any WordPress plug-in you write and submit to the repository must be licensed as GPLv2. There was a huge storm of discussion over this last year because the example readme file mistakenly said “GPL, version 2 or any later version” … Read more

Replace image attributes for lazyload plugin (data-src)

instead of replacing the alt tag you could add-an-attribute-to-a-tag function add_lazyload($content) { $dom = new DOMDocument(); @$dom->loadHTML($content); foreach ($dom->getElementsByTagName(‘img’) as $node) { $oldsrc = $node->getAttribute(‘src’); $node->setAttribute(“data-original”, $oldsrc ); $newsrc=””.get_template_directory_uri().’/library/images/nothing.gif’; $node->setAttribute(“src”, $newsrc); } $newHtml = $dom->saveHtml(); return $newHtml; } note: i didn’t quite tested this code, so be careful 🙂

How to restore deleted pages/posts?

Then you should see a link “Trash” on the top of pages/posts listing section. Click on that link which will take you the section where all the trashed pages/posts are listed. Select the pages/posts using the checkboxes against them. Select Restore from Bulk Actions dropdown, then hit the Apply button. Now go to pages/posts listing … Read more

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