Get post id in a function when edit/add a post

Your function get_postid() does not return anything. It should return the id: function get_postid() { global $post; return $post->ID; } If you are going to use the $post_id I guess your first if statement is wrong, because the $post_id should be evaluated to true not false. So it should be like this: if ( $post_id … Read more

Return encoded Page Title outside of a loop

Here’s the answer: Load wp_get_document_title(); into a variable. Use ‘rawurlencode’ on the variable. Also, apparently one can use a ” , ” to join to strings and not just ” . “ global $wp; $url = home_url( $wp->request ); $page_title = wp_get_document_title(); ?> <?php echo ‘<p class=”side-bar-buttons”><i class=”fa fa-envelope” aria-hidden=”true”></i> ‘; echo ‘<a href=mailto:?subject=” , … Read more