Trying to get property of non-object wordpress error message

Given that the page works if you leave the original query alone, your solution is pretty simple. Leave the original query alone. You don’t need to overwrite that query in order to created secondary loops. Instead of this: query_single(‘dealers’, ‘publish’, ‘1’, $taxtype, $value); if (have_posts()) : while (have_posts()) : the_post(); You want: $myq = new … Read more

How to create an Underconstruction message and Setting for a WordPress website without using plugin

The quick and dirty way to do it is to create a file named .maintenance at the root of the site– same directory as license.txt— and add a bit of PHP: <?php die(); Of course, you can create whatever markup and messages you’d like before the die();, but there is very little WordPress available since … Read more

wp_get_http has been deprecated. Use WP_Http instead

WP_Http is a: Core class used for managing HTTP transports and making HTTP requests. so it should most likely be this link: https://developer.wordpress.org/reference/classes/wp_http/ instead of: https://developer.wordpress.org/reference/functions/WP_Http that redirects you to: https://developer.wordpress.org/reference/functions/wp_http_supports/ Then there are wrappers like wp_remote_get(), wp_remote_post(), wp_safe_remote_get(), wp_safe_remote_post(), wp_remote_retrieve_response_code(), download_url(), … etc, that makes it easier to use. Check out e.g. the HTTP … Read more

wp_new_comment requires author url and author email

The example from the codex, the array of argument is now required. global $post, $current_user; //for this example only 🙂 $commentdata = array(‘comment_post_ID’ => $post->ID, // to which post the comment will show up ‘comment_author’ => ‘Another Someone’, //fixed value – can be dynamic ‘comment_author_email’ => ‘[email protected]’, //fixed value – can be dynamic ‘comment_author_url’ => … Read more

Dynamically set taxonomy term and show admin notice on post save

Okay, so just in case anyone needs help on the same thing I did… here is my solution. Instead of a php/wordpress solution, I used javascript. Id love to see the php/wordpress solution if someone wants to post it. <?php // Admin Custom JS add_action(‘admin_head’, ‘admin_custom_js’); function admin_custom_js() { ?> <script> // update date (month) … Read more

Problem with display data from get_option

You inserting the value of the get_option(‘go_to_top_or_bottom’);as a property in the $this->options so when you actual try to print it like this print_r($this->options[‘turn_on’]);you get the index error because this is a property!!! Correct way will be $this->options[‘turn_on’]=get_option(‘go_to_top_or_bottom’); Update I see that the $options is a private meaning you cannot access it outside of the class. … Read more

admin notice on Insert Media popup screen

I’m unaware of any hooks that tap in in the pop up, but there might be. If not, you could use some jQuery to put your message on the pop-up when Add Media is clicked. I was able to with the following: add_action(‘admin_head’,’myplugin_add_media_popup_notice’); function myplugin_add_media_popup_notice() { ?> <script> jQuery(window).load(function() { // the MEDIA buttons you … Read more

Hide admin notice when user profile updated

You can simply check each of user meta details to see if they are blank or not. The code below is yours with with a check for first and last name. function wpse_user_welcome_notice() { // Make sure that the user is assigned to the subscriber role, specifically. $user = wp_get_current_user(); if ( !in_array( ‘subscriber’, $user->roles … Read more

Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?

WordPress redirects you back to the user-edit.php page upon successful user update, so while the admin_notices has yet been fired in your sulock_save_profile_fields(), the message (your custom admin notice) is never displayed because of the redirection. And one way to fix it, is by filtering the redirect URL via the wp_redirect filter: // In sulock_save_profile_fields() … Read more