How can I show my latest tweet in my wordpress blog?

function get_twitter_feed(){ $userID = ‘ImOttoman’; //your twiter username $url=”http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=$userID&count=1″; $xml = simplexml_load_file($url) or die(“could not connect”); foreach($xml->status as $status){ $text = $status->text; } echo $text; } add_filter(‘wp_head’,’get_twitter_feed’); You never said where you want it so this just pops it into the head (not a great idea), and is a bad example lol. Instead you should … Read more

Add a jQuery Function

First, don’t unregister and reregister jQuery. There’s no reason to do that at all. Second, you’re enqueuing on the wrong hook. Instead, use this in your functions file: // Enqueue Scripts function wpse78227_enqueue_scripts() { wp_enqueue_script( ‘jquery’ ); } add_action( ‘wp_enqueue_scripts’, ‘wpse78227_enqueue_scripts’ ); Now, to include that script you need to do a couple of things. … Read more

Accessing two databases wordpress

When enhancing WordPress functionality, always use the theme’s functions.php file (located, generally, in {WP root}/wp-content/themes/{your theme}/functions.php), or put your code into a plugin. The rules for hacking core code are similar to the rules for optimization. Don’t do it. (for experts only) Don’t do it yet.

Custom function causes a 503 error after a couple of hours

What about using the WordPress function get_ancestors(), which Returns an array containing the parents of the given object. To be exact an Array of ancestors from lowest to highest in the hierarchy We can easily create a function to return a list by using implode to do so: function wpse185971_get_ancestors_list( $object_id, $object_type=”category”, $separator=”,” ) { … Read more

Has is_archived() for sites in a multisite changed with WP 4.7?

Can you try out the following code somewhere and post the output? $mySites = wp_get_sites($args); foreach ($mySites as $blog){ print_r(get_blog_status($blog[‘blog_id’], ‘archived’)); } If this works, I suspect the code behind is_archived() used to understand blog-objects, but the function is supposed to recieve only the blog ID, not the whole object. Your code should be the … Read more

Removing specific menu items?

A much simpler solution is to use remove_menu_page , remove_submenu_page and remove_menu (admin bar). Your example of removing the sub-menu item for “add new” would be remove_submenu_page( ‘edit.php?post_type=page’, ‘post-new.php?post_type=page’ ); To remove it from the admin menu bar you can use the example in @BandonRandon’s post.

Wp admin – Set default value to 999 in comments

You can use add_filter(‘edit_comments_per_page’, ‘return_999’); function return_999(){ return 999; } since the user options are filtered in the WP_List_Table::get_items_per_page() class method : /** * Get number of items to display on a single page * * @since 3.1.0 * @access protected * * @return int */ function get_items_per_page( $option, $default = 20 ) { $per_page … Read more