Convert custom fields to post categories

It’s a good question. There is many ways to apply a little script but the simplest way to do this take a few lines. A note about the following code: Most parameters might be added to the query like meta_query, category. wp_create_category(), will create a category once. wp_set_post_terms(), only work with native post types, will … Read more

List latest posts in WP-Admin

All you need is a table with class=”widefat” and get_posts(). Then you run through the results (if there are any) and print the table rows. Here is a very simple example as a dashboard widget. Note the lack of I18n – it is not ready to use! <?php /** * Plugin Name: Last posts table … Read more

How do you display posts in a dynamic table?

If you want do what the TablePress author recommended, you’d need first to create a custom page (or post category) template – see Codex for Page_Templates – I wouldn’t explained it better then there. 🙂 There you’d need to create a custom WP_Query, or get_posts() / get_pages() query to get the list of posts or … Read more

How to add metabox for post of specific category

Instead of if ($post_id->post_category[0] == 18) try if ( $post_id && in_category( 18, $post_id ) ) Also the ‘save_post’ action should be add_action(‘save_post’,’my_meta_save’, 10, 2); If you want the metabox to appear on a new post when the category is selected, then remove the outer category test if statement so that the metabox is always … Read more

disable password protected page for logged users

Disable the post password protection for (some) users You can try the post_password_required filter (4.7+) to override it for logged in users: add_filter( ‘post_password_required’, function( $returned, $post ) { // Override it for logged in users: if( $returned && is_user_logged_in() ) $returned = false; return $returned; }, 10, 2 ); or disable it for users … Read more

Publish pending article from front end with a button?

First create a function that will print the publish button : //function to print publish button function show_publish_button(){ Global $post; //only print fi admin if (current_user_can(‘manage_options’)){ echo ‘<form name=”front_end_publish” method=”POST” action=””> <input type=”hidden” name=”pid” id=”pid” value=”‘.$post->ID.'”> <input type=”hidden” name=”FE_PUBLISH” id=”FE_PUBLISH” value=”FE_PUBLISH”> <input type=”submit” name=”submit” id=”submit” value=”Publish”> </form>’; } } Next create a function to change … Read more

Post publish only hook?

The {$old_status}_to_{$new_status} and {$new_status}_{$post->post_type} hooks tend to generally solve the problem. To avoid running the code in case post status is changed to draft then published again (after already being published), implement a simple flag using the post_meta functionality. Note: the updated hook should be ‘draft_to_publish’ instead of ‘draft_to_published’ however, the code below is not … Read more

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