If no author posts, echo out some text

Maybe this do the trick, put your if statement inside the function to check if the number of posts retrieved is >= 1, if so begin the foreach else print a message function get_related_author_posts() { global $authordata, $post; $authors_posts = get_posts( array( ‘author’ => $authordata->ID, ‘post_type’ => ‘kenniscentrum’, ‘post__not_in’ => array( $post->ID ), ‘posts_per_page’ => … Read more

Update Post Taxonomy Automatically Based On Date

You just need to set it up like this: if ( ! wp_next_scheduled( ‘check_event_status’ ) ) { wp_schedule_event( time(), ‘daily’, ‘check_event_status’ ); } add_action( ‘check_event_status’, ‘set_event_status’ ); install the Debug bar plugin and add the cron extension for it if You need some debuging info about the cron job and to be able to manually … Read more

My widget won’t update its values when save is clicked

In $control_ops = array( ‘width’ => 300, ‘height’ => 350, ‘id_base’ => ‘example-widget’ ); id_base should be without space and in your rollover image, your name is wrong, you have the name set to echo $this->get_field_name( ‘image’ ); when it should be echo $this->get_field_name( ‘rollover_image’ ); add_action ( ‘widgets_init’ , ‘my_widget’ ) ; function my_widget … Read more

Custom function for search form

bloginfo( ‘template_url’ ) will print the URL to the page and break the return of your function. You need to use get_bloginfo( ‘template_url’ ) to concatenate the result into the string. function clarity_wpsearch($form) { $form = ‘<form role=”search” method=”get” id=”searchform” action=”‘ . home_url( “https://wordpress.stackexchange.com/” ) . ‘” > <label class=”screen-reader-text” for=”s”>’ . __(‘Search for:’, ‘claritytheme’) … Read more

Limit number of characters in different excerpts

Put the following code into functions.php: // TRUNCK STRING TO SHORT THE STRINGS function trunck_string($str = “”, $len = 150, $more=”true”) { if ($str == “”) return $str; if (is_array($str)) return $str; $str = strip_tags($str); $str = trim($str); // if it’s les than the size given, then return it if (strlen($str) <= $len) return $str; … Read more

Remove submenu item from list

Use the API functions remove_menu_page and remove_submenu_page to remove menu items rather than manipulating global variables. This will remove the themes page under appearance: function wpa_remove_themes_submenu() { remove_submenu_page( ‘themes.php’, ‘themes.php’ ); } add_action( ‘admin_menu’, ‘wpa_remove_themes_submenu’, 999 );

Get users with different roles and call function on each of them (user_meta)

First, always var_dump() something if you aren’t sure what exactly you got. If you ain’t got XDebug installed and configured, just use printf( ‘<pre>%s</pre>’, htmlspecialchars( var_export( $dumpMe, true ) ) ); which will bring up an equally informative response. About the WP_User_Query) IIRC it returns objects which are instances of WP_User. You can test that … Read more