<?php/*
Plugin Name: Simplify Post Edit List
Description: Show only the author's posts in the edit list
Version: 0.1
License: GPL
Author: Sarah Gooding
Author URI: http://untame.net
*/function mypo_parse_query_useronly($wp_query){if(strpos($_SERVER['REQUEST_URI'], '/wp-admin/edit.php')!==false){if(!current_user_can('update_core')){global$current_user;
$wp_query->set('author', $current_user->id );
}}}
add_filter('parse_query', 'mypo_parse_query_useronly');
03. The line in red can be modified as follows:
a. Limit to Edit: strpos($_SERVER['REQUEST_URI'], '/wp-admin/edit.php')!==false
b. Limit to All admin area: strpos($_SERVER['REQUEST_URI'], '/wp-admin')!==false
c. Limit to All admin area: strpos($_SERVER['REQUEST_URI'], '/[Post-Type here]')!==false
d. Combination of IF:
if(strpos($_SERVER['REQUEST_URI'], '/wp-admin')!==false ||
strpos($_SERVER['REQUEST_URI'], '/wp-admin/edit.php')!==false ||
strpos($_SERVER['REQUEST_URI'], '/[post-type]')!==false )
Step 02: Create a directory under wordpress-root\wp-content\plugins\DisplayListOfPosts
Step 03: Create a file under that directory called: DisplayListOfPosts.php
Step 04: The the following content to the plugin file:
<?php
/* Plugin Name: Display List of Posts Plugin URI: http://www.flash-jet.com Description: A plugin demo that will display list of Posts Version: 1.0 Author: Gabriel Magen Author URI: http://www.flash-jet.com */
?>
Step 05: From wordpress admin panel, activate the new plugin.
Step 06: Here an action of adding option to admin menu will be demonstrated. Add the following code to file:
//adding action to admin menu and bind it to function name
add_options_page(‘Display List Of Posts’,’Display List Of Posts’,’manage_options’,__FILE__,’DisplayListOfPosts_admin’);
//add_options_page(HTML Page title,Settings Submenu,hook only admin can see,php constant,function that will display the posts list);
}
function DisplayListOfPosts_admin() {
}
Step 07: Replace function DisplayListOfPosts_admin() with the following::
function DisplayListOfPosts_admin() {
global $wpdb; //wpdb wordpress database class $mytestdata=$wpdb->get_results(“select ID,post_title from $wpdb->posts”); //get a query into wpdb class echo “<br>Display list of posts:<br>”;
echo “<table border=1>”;//display the results as a table
foreach ($mytestdata as $singleraw) //loop inside the query { echo “<tr>”; echo “<td>”.$singleraw->post_title.”</td>”; echo “<td>”.$singleraw->ID.”</td>”; echo “</tr>”; }
echo “</table>”;
}
Step 08: Final code:
<?php
/* Plugin Name: Display List of Posts Plugin URI: http://www.flash-jet.com Description: A plugin demo that will display list of Posts Version: 1.0 Author: Gabriel Magen Author URI: http://www.flash-jet.com */
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptRead More
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.