How can i list current author’s categories?
try something like this… you need to first call global $post; then get the author id like $author_id = $post->post_author;
try something like this… you need to first call global $post; then get the author id like $author_id = $post->post_author;
The WP_List_Table class ultimately uses the single_row_columns method to output each table cell. If we look at that method, we’ll see this part: … elseif ( method_exists( $this, ‘column_’ . $column_name ) ) { echo “<td $attributes>”; echo call_user_func( array( &$this, ‘column_’ . $column_name ), $item ); echo “</td>”; } … Add a method to … Read more
Works perfectly when this code is in main plugin file: <?php function createTable(){ global $wpdb; $query = “CREATE TABLE IF NOT EXISTS ” . $wpdb->prefix .”UsersExtra ( user_id INT NOT NULL, first_name VARCHAR(25) NOT NULL, last_name VARCHAR(25) NOT NULL, address VARCHAR(80) NOT NULL, city VARCHAR(30) NOT NULL, province CHAR(2) NOT NULL, postcode CHAR(7) NOT NULL, … Read more
Should I just bring these forms out into templates instead? It depends on the form, and you haven’t printed much detail about what your forms do. Shortcodes are nice but are not the right tool for every job. I would: Prefer a dedicated template to a shortcode, especially for long forms. You start to get … Read more
As the testing database is (usually, and should be) a separate database, you will need to set the appropriate option value in the setUp routine (using add_option or update_option). I would also recommend deleting or reseting the option in the teardown method as well, but I have had issues when trying to drop tables (see … Read more
Instead of manually removing the safety filters like this, you should simply set the correct user for these processes to be running as. When you are logged in and running a process manually, you are logged in and thus you have your credentials being used, and your permissions being used. I’m betting you’re an administrator … Read more
When you just have raw image files, that you want to assign to a post, wp_insert_attachment will do the job. With attachments already present in your database you can use wp_update_post to set the attachment’s post_parent. Like this: wp_update_post( array( ‘ID’ => $attachment_id, ‘post_parent’ => $parent_post_id, )); To recieve a post’s attachments you can use … Read more
Use the $pagename global variable or pull it from the url $slug = basename(get_permalink()); or grab the title before the loop starts: $page_title = $wp_query->post->post_title;
Create a no-revs.php Set the contents to <?php defined(‘WP_POST_REVISIONS’) or define (‘WP_POST_REVISIONS’, false); Place it in the Must Use Plugins Folder located at wp-content/mu-plugins. Be warned; It is recommended that you to have at least 3 post revisions to avoid any loss of data.
This has to do with the fallback_cb argument in wp_nav_menu(). Most nav menus do not set this parameter, so the default value is used, which is wp_page_menu. If you look at the source code of wp_nav_menu(), with no fallback_cb set (defualt wp_page_menu), you will see the following lines of code executes if ( ( !$menu … Read more