Tag Info

New answers tagged

0

you need to set the global variable for this.and then use this code $post->ID it will work for you. global $post


0

When you call the_post, it sets the value of $post, and will do so every time you call it. They give you the same value because they are the same object, they aren't separate. Your linked to code is missing most of your main loop, and also lacks a wp_reset_postdata to cleanup at the end of your WP_Query loop


1

Use the following before $post->ID in your code: global $post


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 ...



Top 50 recent answers are included