functions.php return custom text

You can use get_blog_details() to do it. Use it the following way:– function greeting() { global $blog_id; $current_blog = get_blog_details( $blog_id ); if ( ‘one’ == $current_blog->blogname ) { echo ‘hello’; } elseif ( ‘two’ == $current_blog->blogname ) { echo ‘goodbye’; } }

call wp_insert_user in custom class doesnt work

In addition to the debugging advice from @s_ha_dum, you could try to catch the possible WP_Error thrown by wp_insert_user(): $user_id = wp_insert_user($params); if ( is_wp_error( $user_id ) ) { echo $user_id->get_error_message(); } else { printf( ‘User created with user_id = %d’, $user_id ); } Maybe the user already exists? You could also use email_exists() and … Read more

Breaking up multiple words and inserting an image after first word

Assuming you know that there will always be two words separated by a space, you can use explode. Something like this: $pieces = explode(” “, get_the_title()); $word1 = $pieces[0]; $word2 = $pieces[1]; $output .= ‘<li><a href=”‘.get_permalink().'” class=”‘.$page_id->post_name.’-link”><div class=”‘.$page_id->post_name.’-info”><h2>’.$word1.'</h2><div class=”‘.$page_id->post_name.’-img”>’.get_the_post_thumbnail($page->ID,’icons’).'</div><h2>’.$word2.'</h2></div></a></li>’;

User meta and public function security

functions.php is not more nor less secure than any other file in your WordPress installation, just like post meta is not more nor less secure than any other table in your WordPress database. That means that they are secure until your site is hacked. So question become “is WordPress secure?” and I think that: that … Read more

Retrieve First Image Function

Hmm that looks familiar 😉 You are missing the orderby parameter, in this case you want to order by menu_order. Also there is no reason to query all the data using -1 when you just want one image returned so instead use 1. $attachments = get_children( array( ‘numberposts’ => 1, ‘order’=> ‘ASC’, ‘post_mime_type’ => ‘image’, … Read more

Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]

As @Milo said , WP loads jQuery in no conflict mode so shortcut $ is not available for jQuery to use .You should not use the $ variable for jQuery within WordPress.As you said you are not into jQuery i’m just giving the code below..Try it. jQuery(function ($) { $(window).load(function() { $(‘#main-slider’).flexslider({ animation: “slide”, useCSS: … Read more