Tag Info

New answers tagged

0

The quick and dirty answer would be something like this: function custom_admin_menu_links() { $user = wp_get_current_user(); if ( $user->has_cap( 'manage_options' ) ) { $type = 'book'; $page = get_page_by_title('home','object',$type); if (!empty($page)) { add_menu_page( 'Home', 'Home', 'edit_posts', ...


0

There is a function called get_page_by_title that accepts a post title and returns the ID of that post. You might even use it in conjunction with get_edit_post_link by passing the ID and retrieve the edit link. However, how can you be sure the post's title will never change? You could go a little further and add a settings page where you would map a ...


1

For non-hierarchical terms (such as tags), you can pass either the term name or id. If you pass the id there is only one caveat: You must pass it as an integer, and it must be in an array. This is necessary because any non-array value passed will be converted to a string, which will be interpreted as a term name. $tag = '5'; // Wrong. This will add the tag ...


0

I really do think that my-sticky is not actually your term's name, but actually the slug. Usually, multiple words in the term name is separated by spaces, and the first letters are capitilized. Slugs are all small letters with multiple words separated by hyphens. So I would change name to slug in get_term_by(). Just one note, with multiple taxonomies and ...


0

This way would work ... the user_register action is fired when the user is stored in the data base. You can add meta data to a user with add_metadata. add_action( 'user_register', 'myplugin_registration_save', 10, 1 ); function myplugin_registration_save( $user_id ) { add_metadata( $user_id, 'unique_number', date( 'Y' ).str_pad( $user_id, 4 ) ); }


0

The easiest way would be using get_post_field(): $post_author = get_post_field( 'post_author', $post_id ); For more details on this issue: have a look at this StackOverflow answer.



Top 50 recent answers are included