Checking if some condition is matched before inserting post into database
Checking if some condition is matched before inserting post into database
Checking if some condition is matched before inserting post into database
According to the Codex, if you use wp_transition_post_status() you will get both the old version and the new version. wp_transition_post_status( $new_status, $old_status, $post ) The ticket also says that the post type needs to support revisions for the save to work. Check the post type of the post objects before doing anything. If your post … Read more
An easy way to do this would be to create a simple Must Use Plugin and check for your page in a function hooked to an action, like wp_loaded function wpd_check_page_exists(){ $page = get_page_by_title( ‘The Page’ ); if( !$page ){ wp_mail( ‘[email protected]’, ‘a message from your site’, ‘the page is gone!’ ); } } add_action( … Read more
You are slightly confusing $wp_query global variable with WP_Query class/objects. $wp_query is an object instance of WP_Query, but not every WP_Query object has anything to do with $wp_query global. Function version of conditionals, such as is_search(), always act on main global query. You shouldn’t use them inside filters, since global state might be one thing … Read more
You can use get_the_ID(); function to fetch the Id of the current post For more Please visit here
There are two more possible ways Use the browser’s history API to manipulate the URL displayed at the address bar/ history. Use AJAX Redirection is the best solution for 100% browser support and it is probably the easiest to implement. You don’t need to use any hook with that just do the processing without generating … Read more
<?php echo get_the_title( $post_id ); ?> <?php get_post_image($post->ID,’large’); ?> You can customize these to your liking. or just go to http://codex.wordpress.org/Template_Tags/get_posts
When calling bp_loggedin_user_avatar(), you can set the ‘html’ attribute to false and it will return just the URL of the avatar (instead of the full HTML). Then you can style it how you want. Something like: $avatar_url = bp_loggedin_user_avatar( ‘html=false’ ); echo ‘<img class=”media-object” src=”https://wordpress.stackexchange.com/questions/157817/. $avatar_url .” width=”‘ . bp_core_avatar_thumb_width() . ‘” height=”‘ . bp_core_avatar_thumb_height() … Read more
Ok, I reworked the whole thing because I was obviously printing out my info prior to where I should have. It now looks like this: //SHOW SCREEN IF OPTION CHECKED add_action( ‘admin_notices’, ‘sbah_show_current_screen’ ); function sbah_show_current_screen() { $screenoptions = get_option(‘sbah_options’); if(isset($screenoptions[‘sbah_view_screen’][0])) { $takenscreen = $screenoptions[‘sbah_view_screen’][0]; } if(isset($takenscreen)) { if( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) … Read more
template_redirect and title