Tag Info

Hot answers tagged

3

There is not wp_undelete_post. You have to use any of these funcitons: wp_publish_post: if you want to move from trash to publish status. wp_update_post: to move from trash to any other status. For example, for a given post ID (of any post type, including pages): if( get_post_status( $post_ID ) == "trash" ) { wp_update_post( array( ...


2

WordPress has built-in support for posting via email. Go to Settings > Writing in your admin and enter your credentials under "Post via e-mail". Note it won't handle Gmail labels (it only works via POP3).


2

You can use the capabilities API to conditionally set screen options: if ( current_user_can( 'manage_options' ) ) { // Administrator, add some options } else { // Other roles, do something different }


2

I assume, you need something like editors can't see the category column or something like this. This snippet might help you: /** Remove "Options"-Panel, when User is not admin **/ add_filter( 'manage_posts_columns', 'change_columns_for_user', 10, 2 ); function change_columns_for_user( $columns, $post_type ){ if( 'post' != $post_type ) return ...


1

You can just grab the first post from the main query and see which post type it is: if ( have_posts() ) { $post_type = $wp_query->posts[0]->post_type; } If you run this code directly in a main template file you should be fine, but if it's in a function you will need to call global $wp_query; first.


1

get_post() returns a post object. So you can try the following $post = get_post( 1571 ); setup_postdata( $post ); the_title(); the_content(); wp_reset_postdata();


1

I have accepted the @websupporter answer according to my question. However I would like add few codes to specific question I have faced earlier. I need to remove Yoast SEO plugin extra columns from the non admin users. In that specific case Yoast SEO provide the hook to disable the columns. So I used that as below. /** Remove SEO columns when User is not ...


1

If I enter this shortcode: [download url="http://example.com"]Download[/download] it works fine. But you have to enter the link text as content yourself. You might have missed that, the way I read your question. Your [demo]-Shortcode throughs an error. To see this, you need to have WP_DEBUG set to true: Notice: Undefined variable: func in ...


1

I'm not quite sure what you want to do as frankly, your terminology is a bit scrambled, and you example shortcode is also quite a mess. Before I start, you should start of by checking the following very important links Shortcode API WP_Query You should first start of by defining your attributes (and their defaults) which you need to use and pass to the ...



Only top voted, non community-wiki answers of a minimum length are eligible