Can't get any code changes to work in functions.php file in theme-help!!

I need the theme developer to help me with making code changes to the functions.php file in the social theme. I have made a child theme for the changes, but everytime I try to add code to the functions.php file, the url white screens. I then have to delete the copy of the functions.php file in the child folder and then it works again. I want to add the following code in the functions.php file. Please tell me exactly what line and any blank spaces needed as to where I can add this code which adds a "register" feature to my login page....Thanks :slight_smile:

function cuw_custom_login_footer() {
    ?>
<div class="cuw_registration_link">
<a href="http://changingurworld.com/wp2/registration/" title="Create An Account">Do You Need An Account</a>
</div>
<?php
}
add_action('login_footer', 'cuw_custom_login_footer');
  • Philip John

    Hiya!

    I can't be sure as there isn't any specific documentation for that hook but I think your code should be;

    function cuw_custom_login_footer($content) {
        $content .= '<div class="cuw_registration_link">
    <a href="http://changingurworld.com/wp2/registration/" title="Create An Account">Do You Need An Account</a>
    </div>';
        return $content;
    }
    add_action('login_footer', 'cuw_custom_login_footer');

    Note also that when you're pasting code into the forum you should use the "Code" option on the toolbar to make sure it appears nicely. I edited your original post for you.

    Cheers,
    Phil

  • mavellino

    It is exactly the file that comes in the Social theme.... I don't know how to cut and paste it in the right format. Should I re-download the theme? Here is the only way I know how to cut and paste...

    <?php
    define('TEMPLATE_DOMAIN', 'bp-social');
    define('EDITOR_BG_ENABLE', 'no'); //should be yes or no...
    define('USE_NEW_COMMENT_FORM','no');
    ////////////////////////////////////////////////////////////////////////////////
    // load text domain
    ////////////////////////////////////////////////////////////////////////////////
    load_theme_textdomain( TEMPLATE_DOMAIN, TEMPLATEPATH . '/languages/' );

    ////////////////////////////////////////////////////////////////////////////////
    // browser detect
    ///////////////////////////////////////////////////////////////////
    add_filter('body_class','browser_body_class');
    function browser_body_class($classes) {
    global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;

    if($is_lynx) $classes[] = 'lynx';
    elseif($is_gecko) $classes[] = 'gecko';
    elseif($is_opera) $classes[] = 'opera';
    elseif($is_NS4) $classes[] = 'ns4';
    elseif($is_safari) $classes[] = 'safari';
    elseif($is_chrome) $classes[] = 'chrome';
    elseif($is_IE) $classes[] = 'ie';
    else $classes[] = 'unknown';
    if($is_iphone) $classes[] = 'iphone';
    return $classes;
    }

    function wp_add_css_ie_tweak() {
    global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
    if($is_IE) { ?>
    <?php print "<style type='text/css' media='screen'>"; ?>

    .picture-activity-thumb {
    width: 100px;
    height: 100px;
    display: block;
    }
    img.feat-thumb { height/**/:disappointed:**/ auto; }
    <?php print "</style>"; ?>
    <?php }
    }
    add_action('wp_head','wp_add_css_ie_tweak');

    ///////////////////////////////////////////////////////////////////////////
    // Update Notifications Notice
    ///////////////////////////////////////////////////////////////////////////
    if ( !function_exists( 'wdp_un_check' ) ) {
    add_action( 'admin_notices', 'wdp_un_check', 5 );
    add_action( 'network_admin_notices', 'wdp_un_check', 5 );
    function wdp_un_check() {
    if ( !class_exists( 'WPMUDEV_Update_Notifications' ) && current_user_can( 'edit_users' ) )
    echo '<div class="error fade"><p>' . __('Please install the latest version of our free Update Notifications plugin which helps you stay up-to-date with the most stable, secure versions of WPMU DEV themes and plugins. More information »', 'wpmudev') . '</p></div>';
    }
    }

    ////////////////////////////////////////////////////////////////////////////////
    // Get Featured Post Image
    ////////////////////////////////////////////////////////////////////////////////
    function wp_custom_post_thumbnail($the_post_id='', $with_wrap='', $wrap_w='', $wrap_h='', $title='', $fetch_size='',$fetch_w='', $fetch_h='',$alt_class='') {
    // do global first
    global $wpdb, $post, $posts;
    $detect_post_id = $the_post_id;
    if($with_wrap == 'yes') {
    $before_wrap = "<div style='width: $wrap_w; height: $wrap_h; overflow: hidden;'>";
    $after_wrap = "</div>";
    }
    ?>

    <?php if(get_the_post_thumbnail() != "") : ?>

    <?php
    $image_id = get_post_thumbnail_id();
    if($fetch_size == 'original') {
    $image_url = wp_get_attachment_image_src($image_id,'large');
    } else {
    $image_url = wp_get_attachment_image_src($image_id,array($fetch_w,$fetch_h));
    }
    $image_url = $image_url[0];
    ?>
    <?php echo $before_wrap; ?>
    <img width="<?php echo $fetch_w; ?>" height="auto" class="feat-post-thumbnail <?php echo $alt_class; ?>" title="<?php the_title(); ?>" alt="" src="<?php echo $image_url; ?>">
    <?php echo $after_wrap; ?>

    <?php else: ?>

    <?php
    $images = get_children(array(
    'post_parent' => $the_post_id,
    'post_type' => 'attachment',
    'numberposts' => 1,
    'post_mime_type' => 'image')); ?>
    <?php if ($images) : ?>
    <?php foreach($images as $image) :
    if($fetch_size == 'original') {
    $attachment= wp_get_attachment_image_src($image->ID,'large');
    } else {
    $attachment= wp_get_attachment_image_src($image->ID, array($fetch_w,$fetch_h));
    } ?>
    <?php echo $before_wrap; ?>
    <img width="<?php echo $fetch_w; ?>" height="auto" class="feat-post-attachment <?php echo $alt_class; ?>" title="<?php the_title(); ?>" alt="" src="<?php echo $attachment[0]; ?>">
    <?php echo $after_wrap; ?>
    <?php endforeach; ?>

    <?php elseif( !$images ): ?>

    <?php
    $get_post_attachment = $wpdb->get_var("SELECT guid FROM " . $wpdb->prefix . "posts WHERE post_parent = '" . $detect_post_id . "' AND post_type = 'attachment' ORDER BY menu_order ASC LIMIT 1");
    // If images exist for this page

    if($get_post_attachment) { ?>
    <img width="<?php echo $fetch_w; ?>" height="auto" class="feat-post-wp <?php echo $alt_class; ?>" title="<?php the_title(); ?>" alt="" src="<?php echo $get_post_attachment; ?>">

    <?php } else { ?>

    <?php
    $first_img = '';
    ob_start();
    ob_end_clean();
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    $first_img = $matches[1][0]; ?>

    <?php if($first_img) { ?>
    <?php echo $before_wrap; ?>
    <img width="<?php echo $fetch_w; ?>" height="auto" class="feat-post-regex <?php echo $alt_class; ?>" title="<?php the_title(); ?>" alt="" src="<?php echo $first_img; ?>">
    <?php echo $after_wrap; ?>
    <?php } ?>

    <?php } ?>

    <?php endif; ?>

    <?php endif; ?>

    <?php }

    ///////////////////////////////////////////////////////////////////////////
    // Custom footer code
    ///////////////////////////////////////////////////////////////////////////
    function wp_network_footer() {
    global $blog_id, $current_site, $current_blog;
    if( is_multisite() ) {
    $current_site = get_current_site();
    $current_network_site = get_current_site_name(get_current_site());

    if ( function_exists( 'bp_exists' ) ) {
    $current_network_domain = bp_get_root_domain();
    } else {
    if(function_exists('network_home_url')) {
    $current_network_domain = network_home_url();
    } else {
    $current_network_domain = 'http://' . $current_site->domain . $current_site->path;
    }
    }

    if( BLOG_ID_CURRENT_SITE != $current_blog->blog_id && BP_ROOT_BLOG != $current_blog->blog_id ) { ?>
    <?php _e('Hosted by', TEMPLATE_DOMAIN); ?> site_name; ?>" href="<?php echo $current_network_domain; ?>"><?php echo $current_network_site->site_name; ?>
    <?php } ?>

    <?php
    }
    }
    ////////////////////////////////////////////////////////////////////////////////
    // new code for wp 3.0+
    ////////////////////////////////////////////////////////////////////////////////
    if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
    // Add default posts and comments RSS feed links to head
    add_theme_support( 'automatic-feed-links' );
    add_theme_support( 'post-thumbnails' );

    if(EDITOR_BG_ENABLE == 'yes') {
    // This theme styles the visual editor with editor-style.css to match the theme style.
    add_editor_style();
    // This theme allows users to set a custom background
    add_custom_background();
    }

    set_post_thumbnail_size( 200, 150, true ); // Normal post thumbnails
    add_image_size( 'single-post-thumbnail', 650, 9999 ); // Permalink thumbnail size
    add_theme_support( 'menus' ); // new nav menus for wp 3.0
    if ( ! isset( $content_width ) ) $content_width = 900;

    }

    if ( function_exists( 'register_nav_menus' ) ) {
    // This theme uses wp_nav_menu() in one location.
    register_nav_menus( array(
    'main-nav' => __( 'Main Navigation',TEMPLATE_DOMAIN )
    ) );
    ///////////////////////////////////////////////////////////////////////////////
    // remove open ul to fit the custom bp navigation.php
    ///////////////////////////////////////////////////////////////////////////////
    function bp_wp_custom_nav_menu($get_custom_location='', $get_default_menu=''){
    $options = array('theme_location' => "$get_custom_location", 'menu_id' => '', 'echo' => false, 'container' => false, 'container_id' => '', 'fallback_cb' => "$get_default_menu");
    $menu = wp_nav_menu($options);
    $menu_list = preg_replace( array( '#^<ul[^>]*>#', '#$#' ), '', $menu );
    return $menu_list;
    }
    function revert_wp_menu_page() { //revert back to normal if in wp 3.0 and menu not set ?>
    <?php wp_list_pages('title_li=&depth=0'); ?>
    <?php }

    function revert_wp_menu_cat() { //revert back to normal if in wp 3.0 and menu not set ?>
    <?php wp_list_categories('orderby=id&show_count=0&use_desc_for_title=0&title_li='); ?>
    <?php }
    } // end register_nav_menus check

    ////////////////////////////////////////////////////////////////////////////////
    // get post id outside loop
    ///////////////////////////////////////////////////////////////////////////////
    function get_post_id_outside_loop() {
    global $wp_query;
    $thePostID = $wp_query->post->ID;
    return $thePostID;
    }

    ///////////////////////////////////////////////////////////////
    // includes
    ////////////////////////////////////////////////////////////////
    include( TEMPLATEPATH . '/_inc/functions/conditional-functions.php' );
    include( TEMPLATEPATH . '/_inc/functions/widgets-functions.php' );
    include( TEMPLATEPATH . '/_inc/functions/options-functions.php' );

    ///////////////////////////////////////////////////////////////
    // includes custom-functions.php - rename _inc/functions/custom-functions-sample.php
    ////////////////////////////////////////////////////////////////
    //include( TEMPLATEPATH . '/_inc/functions/custom-functions.php' );

    if($bp_existed == 'true') {
    include( TEMPLATEPATH . '/_inc/functions/bp-component-functions.php' );
    include( TEMPLATEPATH . '/bp-functions.php' );

    ///////////////////////////////////////////////////////////////////////
    /// check if is friend
    ///////////////////////////////////////////////////////////////////////
    function bp_displayed_user_is_friend() {
    global $bp;
    $friend_privacy_enable = get_option('tn_buddysocial_friend_privacy_status');
    $friend_privacy_redirect = get_option('tn_buddysocial_friend_privacy_redirect');

    if($friend_privacy_enable == "enable") {
    if ( bp_is_profile_component() || bp_is_member() ) {
    if ( ('is_friend' != BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $bp->displayed_user->id )) && (bp_loggedin_user_id() != bp_displayed_user_id()) ) {
    if ( !is_super_admin( bp_loggedin_user_id() ) ) {
    if($friend_privacy_redirect == '') {
    bp_core_redirect( $bp->root_domain );
    } else {
    bp_core_redirect( $friend_privacy_redirect );
    }
    }
    }
    }
    } //enable
    }
    add_filter('get_header','bp_displayed_user_is_friend',3);

    ///////////////////////////////////////////////////////////////////////
    /// add like it facebook stream
    ///////////////////////////////////////////////////////////////////////
    function add_stream_facebooklike_button() { ?>
    <?php if(is_user_logged_in()) { ?>
    <iframe src="http://www.facebook.com/plugins/like.php?href=<?php bp_activity_thread_permalink() ?>&layout=standard&show-faces=true&width=450&action=like&font=arial&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; float: right; width: 300px; height: 30px; overflow:hidden;"></iframe>
    <?php } ?>
    <?php }

    $tn_buddysocial_stream_facebook_like_status = get_option('tn_buddysocial_stream_facebook_like_status');

    if($tn_buddysocial_stream_facebook_like_status == 'enable') {
    add_action('bp_activity_entry_meta', 'add_stream_facebooklike_button');
    }

    ///////////////////////////////////////////////////////////////
    // check privacy
    ////////////////////////////////////////////////////////////////
    function check_if_privacy_on() {
    global $bp;
    $privacy_enable = get_option('tn_buddysocial_privacy_status');
    $privacy_redirect = get_option('tn_buddysocial_privacy_redirect');
    if($privacy_enable == "enable") {
    if ( bp_is_profile_component() || bp_is_activity_component() || bp_is_page( BP_MEMBERS_SLUG ) ) {
    if(!is_user_logged_in()) {
    if($privacy_redirect == '') {
    bp_core_redirect( $bp->root_domain . '/' . BP_REGISTER_SLUG );
    } else {
    bp_core_redirect( $privacy_redirect );
    }
    }
    }
    } //off
    }
    add_filter('get_header','check_if_privacy_on',1);

    function check_if_create_group_limit() {
    global $bp;
    $create_limit_enable = get_option('tn_buddysocial_create_group_status');
    $create_limit_redirect = get_option('tn_buddysocial_create_group_redirect');
    if($create_limit_enable == "yes") {
    if( bp_is_group_create() ) {
    if ( current_user_can( 'delete_others_posts' ) ) { //only admins and editors
    } else {
    if( $create_limit_redirect == '' ) {
    bp_core_redirect( $bp->root_domain . '/' );
    } else {
    bp_core_redirect( $create_limit_redirect );
    }
    }
    }

    } //off
    }
    add_filter('get_header','check_if_create_group_limit',2);

    ////////////////////////////////////////////////////////////////////////////////
    // single bp adminbar
    ////////////////////////////////////////////////////////////////////////////////

    if($multi_site_on == "false") {
    function buddypress_single_adminbar_css() {
    // only work for wpmudev buddypress theme with theme options
    ?>
    <?php // save site options
    $active_themename = get_option('template');
    $check_if_theme_save = get_option('blog_1_active_theme');
    if($check_if_theme_save == '') {
    add_option('blog_1_active_theme', $active_themename);
    } else {
    update_option('blog_1_active_theme', $active_themename);
    }
    ?>

    <?php $main_blog_active_theme = get_option('blog_1_active_theme'); // styling global started here ?>
    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/global-adminbar.php" type="text/css" media="screen" />
    <?php }

    add_action('wp_head', 'buddypress_single_adminbar_css'); // init global wp_head
    add_action('admin_head', 'buddypress_single_adminbar_css'); // init global admin_head
    }

    } // end check if bp exist

    ////////////////////////////////////////////////////////////////////////////////
    // excerpt the_content()
    ////////////////////////////////////////////////////////////////////////////////
    function custom_the_excerpt($limit) {
    $excerpt = explode(' ', get_the_excerpt(), $limit);
    if (count($excerpt)>=$limit) {
    array_pop($excerpt);
    $excerpt = implode(" ",$excerpt).'...';
    } else {
    $excerpt = implode(" ",$excerpt);
    }
    $excerpt = preg_replace('\[[^\]]*\]','',$excerpt);
    return $excerpt;
    }

    function custom_the_content($limit) {
    global $id, $post;
    $content = explode(' ', get_the_content(), $limit);
    if (count($content)>=$limit) {
    array_pop($content);
    $content = implode(" ",$content).'...';
    } else {
    $content = implode(" ",$content);
    }
    $content = preg_replace('/\[.+\]/','', $content);
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    $content = strip_tags($content, '<p>');
    return $content . "<p>" . __('...Click here to read more »', TEMPLATE_DOMAIN) . "</p>";
    }

    ////////////////////////////////////////////////////////////////////////////////
    // register sidebar
    ////////////////////////////////////////////////////////////////////////////////

    function social_widgets_init() {
    global $bp_existed;
    register_sidebar(
    array(
    'name' => __('home-left', TEMPLATE_DOMAIN),
    'id' => __('home-left', TEMPLATE_DOMAIN),
    'description' => __('Home Left Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    $layout_style = get_option('tn_buddysocial_blog_home_layout_style');
    if($layout_style == "" || $layout_style == '3-column') {
    register_sidebar(
    array(
    'name' => __('home-center', TEMPLATE_DOMAIN),
    'id' => __('home-center', TEMPLATE_DOMAIN),
    'description' => __('Home Center Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );
    } // end check

    register_sidebar(
    array(
    'name' => __('home-right', TEMPLATE_DOMAIN),
    'id' => __('home-right', TEMPLATE_DOMAIN),
    'description' => __('Home Right Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    $index_style = get_option('tn_buddysocial_blog_index_layout_style');
    if($index_style == '' || $index_style == '3-column') {
    register_sidebar(
    array(
    'name' => __('sidebar-left', TEMPLATE_DOMAIN),
    'id' => __('sidebar-left', TEMPLATE_DOMAIN),
    'description' => __('Sidebar Left Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );
    } // end check

    register_sidebar(
    array(
    'name' => __('sidebar-right', TEMPLATE_DOMAIN),
    'id' => __('sidebar-right', TEMPLATE_DOMAIN),
    'description' => __('Sidebar Right Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    if($bp_existed == 'true') {

    $member_page_layout = get_option('tn_buddysocial_member_page_layout_style');

    if($member_page_layout == '3-column' || $member_page_layout == '') {
    register_sidebar(
    array(
    'name' => __('member-left', TEMPLATE_DOMAIN),
    'id' => __('member-left', TEMPLATE_DOMAIN),
    'description' => __('Member Left Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    register_sidebar(
    array(
    'name' => __('group-left', TEMPLATE_DOMAIN),
    'id' => __('group-left', TEMPLATE_DOMAIN),
    'description' => __('Group Left Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    register_sidebar(
    array(
    'name' => __('member-right', TEMPLATE_DOMAIN),
    'id' => __('member-right', TEMPLATE_DOMAIN),
    'description' => __('Member Right Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    register_sidebar(
    array(
    'name' => __('group-right', TEMPLATE_DOMAIN),
    'id' => __('group-right', TEMPLATE_DOMAIN),
    'description' => __('Group Right Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    } else if($member_page_layout == '2-column') {

    register_sidebar(
    array(
    'name' => __('member-right', TEMPLATE_DOMAIN),
    'id' => __('member-right', TEMPLATE_DOMAIN),
    'description' => __('Member Right Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    register_sidebar(
    array(
    'name' => __('group-right', TEMPLATE_DOMAIN),
    'id' => __('group-right', TEMPLATE_DOMAIN),
    'description' => __('Group Right Widget', TEMPLATE_DOMAIN),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
    )
    );

    } else if($member_page_layout == '1-column') {

    }

    } // end bp checked
    }
    add_action( 'widgets_init', 'social_widgets_init' );

    /////////////////////////////////////////////////////////////////////////
    //make text string shorter
    /////////////////////////////////////////////////////////////////////////
    function short_text($text, $wordcount) {
    $text_count = strlen( $text );
    if ( $text_count <= $wordcount ) {
    $text = $text;
    } else {
    $text = substr( $text, 0, $wordcount );
    $text = $text . '...';
    }
    return $text;
    }

    ///////////////////////////////////////////////////////////////////////////////
    // fetch post img
    //////////////////////////////////////////////////////////////////////////////
    function custom_get_post_img ($the_post_id='', $size='', $attributes='', $height='') {
    $detect_post_id = $the_post_id;

    $images = get_children(array(
    'post_parent' => $the_post_id,
    'post_type' => 'attachment',
    'numberposts' => 1,
    'post_mime_type' => 'image'));
    if ($images)
    foreach($images as $image) {
    $attachment=wp_get_attachment_image_src($image->ID, $size); ?>

    <div style="width: 100%; height: auto; background: url(<?php echo $attachment[0]; ?>:wink: no-repeat center center; overflow:hidden; height: <?php echo $height; ?>px;"></div>

    <?php
    }
    }

    ////////////////////////////////////////////////////////////////////////////////
    // one-category
    ////////////////////////////////////////////////////////////////////////////////

    function custom_the_category() {
    $parentscategory ="";
    foreach((get_the_category()) as $category) {
    if ($category->category_parent == 0) {
    $parentscategory .= ' cat_ID) . '" title="' . $category->name . '">' . $category->name . ', ';
    }
    }
    echo substr($parentscategory,0,-2);
    }

    ////////////////////////////////////////////////////////////////////////////////
    // short code for img features
    ////////////////////////////////////////////////////////////////////////////////

    function dez_get_images($the_post_id = '') {
    global $wpdb;
    $detect_post_id = $the_post_id;
    $get_post_attachment = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$detect_post_id' AND post_type = 'attachment' ORDER BY menu_order ASC LIMIT 1");
    // If images exist for this page
    if($get_post_attachment != '') {

    foreach($get_post_attachment as $attach) {
    $attach_img = $attach->guid;
    $sImgString = '' . '<img src="' . $attach_img . '"alt="Thumbnail Image" title="Thumbnail Image" />' . '';
    echo "$sImgString";
    }

    } else {
    }
    }

    ////////////////////////////////////////////////////////////////////////////////
    // WP-PageNavi
    ////////////////////////////////////////////////////////////////////////////////

    function custom_wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
    global $request, $posts_per_page, $wpdb, $paged;
    if(empty($prelabel)) {
    $prelabel = '«';
    }
    if(empty($nxtlabel)) {
    $nxtlabel = '»';
    }
    $half_pages_to_show = round($pages_to_show/2);
    if (!is_single()) {
    if(!is_category()) {
    preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches);
    } else {
    preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
    }
    $fromwhere = $matches[1];
    $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
    $max_page = ceil($numposts /$posts_per_page);
    if(empty($paged)) {
    $paged = 1;
    }
    if($max_page > 1 || $always_show) {
    echo "$before <div class=\"wp-pagenavi\"><span class=\"pages\">Page $paged of $max_page:</span>";
    if ($paged >= ($pages_to_show-1)) {
    echo '« First';
    }
    previous_posts_link($prelabel);
    for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
    if ($i >= 1 && $i <= $max_page) {
    if($i == $paged) {
    echo "<strong class='current'>$i";
    } else {
    echo ' '.$i.' ';
    }
    }
    }
    next_posts_link($nxtlabel, $max_page);
    if (($paged+$half_pages_to_show) < ($max_page)) {
    echo 'Last »';
    }
    echo "</div> $after";
    }
    }
    }

    ////////////////////////////////////////////////////////////////////////////////
    // Comment and pingback separate controls
    ////////////////////////////////////////////////////////////////////////////////

    $bm_trackbacks = array();
    $bm_comments = array();

    function split_comments( $source ) {

    if ( $source ) foreach ( $source as $comment ) {

    global $bm_trackbacks;
    global $bm_comments;

    if ( $comment->comment_type == 'trackback' || $comment->comment_type == 'pingback' ) {
    $bm_trackbacks[] = $comment;
    } else {
    $bm_comments[] = $comment;
    }
    }
    }

    ////////////////////////////////////////////////////////////////////////////////
    // get attach post img
    ////////////////////////////////////////////////////////////////////////////////

    function dez_get_attachment($the_post_id = '', $open_class = '', $close_class = '') {
    global $wpdb;
    $detect_post_id = $the_post_id;
    $get_post_attachment = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE post_parent = '$detect_post_id' AND post_type = 'attachment' ORDER BY menu_order ASC LIMIT 1");
    // If images exist for this page

    if(!$get_post_attachment) {

    $attach_img = get_template_directory_uri();
    $sImgString = $open_class . '' . '<img src="' . $attach_img . '/_inc/images/header.jpg' . '" class="full" />' . '' . $close_class;
    echo "$sImgString";

    } else {

    $sImgString = $open_class . '' . '<img src="' . $get_post_attachment . '" alt="ui" class="full" />' . '' . $close_class;
    echo "$sImgString";

    }

    }

    ////////////////////////////////////////////////////////////////////////////////
    // excerpt features
    ////////////////////////////////////////////////////////////////////////////////

    function the_excerpt_feature($excerpt_length='', $allowedtags='', $filter_type='none', $use_more_link='', $more_link_text = '', $force_more_link=true, $fakeit=1, $fix_tags=true) {

    if (preg_match('%^content($|_rss)|^excerpt($|_rss)%', $filter_type)) {
    $filter_type = 'the_' . $filter_type;
    }
    $text = apply_filters($filter_type, get_the_excerpt_feature($excerpt_length, $allowedtags, $use_more_link, $more_link_text, $force_more_link, $fakeit));
    $text = ($fix_tags) ? balanceTags($text) : $text;
    echo $text;
    }

    function get_the_excerpt_feature($excerpt_length, $allowedtags, $use_more_link, $more_link_text, $force_more_link, $fakeit) {
    global $id, $post;
    $output = '';
    $output = $post->post_excerpt;
    if (!empty($post->post_password)) { // if there's a password
    if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
    $output = __('There is no excerpt because this is a protected post.', TEMPLATE_DOMAIN);
    return $output;
    }
    }

    // If we haven't got an excerpt, make one.
    if ((($output == '') && ($fakeit == 1)) || ($fakeit == 2)) {
    $output = $post->post_content;
    $output = strip_tags($output, $allowedtags);

    $output = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $output );

    $blah = explode(' ', $output);
    if (count($blah) > $excerpt_length) {
    $k = $excerpt_length;
    $use_dotdotdot = 1;
    } else {
    $k = count($blah);
    $use_dotdotdot = 0;
    }
    $excerpt = '';
    for ($i=0; $i<$k; $i++) {
    $excerpt .= $blah[$i] . ' ';
    }
    // Display "more" link (use css class 'more-link' to set layout).
    if (($use_more_link && $use_dotdotdot) || $force_more_link) {
    //$excerpt .= "" . __('
    ...Click here to read more »', TEMPLATE_DOMAIN) . "
    ";
    } else {
    $excerpt .= ($use_dotdotdot) ? '...' : '';
    }
    $output = $excerpt;
    } // end if no excerpt
    return $output;
    }

    ////////////////////////////////////////////////////////////////////////////////
    // wp 2.7 wp_list_comment micro classes
    ////////////////////////////////////////////////////////////////////////////////
    function comment_add_microid($classes) {
    $c_email = get_comment_author_email();
    $c_url = get_comment_author_url();
    if (!empty ($c_email) && !empty ($c_url)) {
    $microid = 'microid-mailto+http:sha1:' . sha1(sha1('mailto:' . $c_email) . sha1($c_url));
    $classes[] = $microid;
    }
    return $classes;
    }

    add_filter('comment_class', 'comment_add_microid');

    ////////////////////////////////////////////////////////////////////////////////
    // wp 2.7 wp_list_comment
    ////////////////////////////////////////////////////////////////////////////////
    function list_comments($comment, $args, $depth) {
    $GLOBALS['comment'] = $comment;
    ?>

    <li <?php comment_class();?> id="comment-<?php comment_ID();?>">
    <div class="comment-meta-list">
    <div class="comment-meta-avatar">
    <?php echo get_avatar($comment, 48);?>
    </div>
    <div class="comment-meta-post">
    <div class="comment-content">
    <?php if ($comment->comment_approved == '0') : ?>
    <?php _e('Your comment is awaiting moderation.') ?>
    <?php else : ?>
    <?php comment_text() ?>
    <?php endif;?>
    </div>
    <div class="comment-author">
    " rel="no follow" href="<?php comment_author_url();?>"><?php comment_author();?>
    <small><span class="inlink">comment_ID)) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></span><?php edit_comment_link(__('edit'), ' | ', '') ?>    <?php if (is_user_logged_in()) {?><?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?><?php }?></small>

    </div>
    </div>
    </div>

    <?php
    }

    ////////////////////////////////////////////////////////////////////////////////
    // wp 2.7 wp_list_pingback
    ////////////////////////////////////////////////////////////////////////////////
    function list_pings($comment, $args, $depth) {
    $GLOBALS['comment'] = $comment;
    ?>

    <li <?php comment_class();?> id="comment-<?php comment_ID();?>">
    <h6><?php comment_author_link();?></h6>
    <p><?php comment_text();?></p>

    <?php
    }

    add_filter('get_comments_number', 'comment_count', 0);

    function comment_count($count) {
    global $id;
    $comments_by_split = get_comments('post_id=' . $id);
    $comments_by_type = & separate_comments($comments_by_split);
    return count($comments_by_type['comment']);
    }

    ///////////////////////////////////////////////////////////////////////////////
    // Get total count of multiple categories
    //////////////////////////////////////////////////////////////////////////////
    function dev_multi_category_count($catslugs = '') {
    global $wpdb;
    $catslug_array = $catslugs;
    $slug_where = "cat_terms.term_id IN (" . $catslug_array . ")";

    $sql = "SELECT COUNT( DISTINCT cat_posts.ID ) AS post_count " .
    "FROM " . $wpdb->term_taxonomy . " AS cat_term_taxonomy INNER JOIN " . $wpdb->terms . " AS cat_terms ON " .
    "cat_term_taxonomy.term_id = cat_terms.term_id " .
    "INNER JOIN " . $wpdb->term_relationships . " AS cat_term_relationships ON " .
    "cat_term_taxonomy.term_taxonomy_id = cat_term_relationships.term_taxonomy_id " .
    "INNER JOIN " . $wpdb->posts . " AS cat_posts ON " .
    "cat_term_relationships.object_id = cat_posts.ID " .
    "WHERE cat_posts.post_status = 'publish' AND " .
    "cat_posts.post_type = 'post' AND " .
    "cat_term_taxonomy.taxonomy = 'category' AND " .
    $slug_where;

    $post_count = $wpdb->get_var($sql);
    return $post_count;

    }

    ///////////////////////////////////////////////////////////////////////////////
    // get blogs posts and comments count
    //////////////////////////////////////////////////////////////////////////////
    function get_the_current_blog_post_count() {
    global $wpdb;
    $numposts = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "posts WHERE post_status = 'publish' AND post_type= 'post'");
    return $numposts;
    }

    function get_the_current_blog_comment_count() {
    global $wpdb;
    $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "comments WHERE comment_approved = '1'");
    return $numcomms;
    }
    ///////////////////////////////////////////////////////////////
    // http and https detect function
    ////////////////////////////////////////////////////////////////
    function server_https_detect() {
    if($_SERVER['HTTPS']){
    $the_server_ssl = 'https://';
    } else {
    $the_server_ssl = 'http://';
    }
    return $the_server_ssl;
    }

    ////////////////////////////////////////////////////////////////////////////////
    // get members-login slug
    ////////////////////////////////////////////////////////////////////////////////
    function get_the_page_template_slug($tpl) {
    global $wpdb;
    $get_page_template = $wpdb->get_var("SELECT post_id FROM " . $wpdb->prefix . "postmeta WHERE meta_value = '". $tpl ."' AND meta_key = '_wp_page_template'");
    $get_page_template_slug = $wpdb->get_var("SELECT post_name FROM " . $wpdb->prefix . "posts WHERE ID = '" . $get_page_template . "' AND post_type='page'");

    return $get_page_template_slug;
    }

    ////////////////////////////////////////////////////////////////////////////////
    // get google web font
    ////////////////////////////////////////////////////////////////////////////////
    function font_show(){
    $bodytype = get_option('tn_buddysocial_body_font');
    $headtype = get_option('tn_buddysocial_headline_font');

    if ($bodytype == ""){ ?>
    <?php } else if ($bodytype == "Cantarell, arial, serif" ){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Cantarell' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Cardo, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Cardo' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Crimson Text, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Crimson+Text' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Droid Sans, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Droid Serif, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Droid+Serif' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "IM Fell DW Pica, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=IM+Fell+DW+Pica' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Josefin Sans Std Light, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Josefin+Sans+Std+Light' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Lobster, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Molengo, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Molengo' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Neuton, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Neuton' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Nobile, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Nobile' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "OFL Sorts Mill Goudy TT, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=OFL+Sorts+Mill+Goudy+TT' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Reenie Beanie, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Reenie+Beanie' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Tangerine, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Old Standard TT, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Old+Standard+TT' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Volkorn, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Volkorn' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Yanone Kaffessatz, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz' rel='stylesheet' type='text/css'/>
    <?php } else if ($bodytype == "Just Another Hand, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Just+Another+Hand' rel='stylesheet' type='text/css'>
    <?php } else if ($bodytype == "Terminal Dosis Light, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Terminal+Dosis+Light' rel='stylesheet' type='text/css'>
    <?php } else if ($bodytype == "Ubuntu, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Ubuntu:light,regular,bold' rel='stylesheet' type='text/css'>
    <?php }

    if ($headtype == ""){ ?>
    <?php } else if ($headtype == "Cantarell, arial, serif" ){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Cantarell' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Cardo, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Cardo' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Crimson Text, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Crimson+Text' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Droid Sans, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Droid Serif, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Droid+Serif' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "IM Fell DW Pica, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=IM+Fell+DW+Pica' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Josefin Sans Std Light, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Josefin+Sans+Std+Light' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Lobster, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Molengo, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Molengo' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Neuton, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Neuton' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Nobile, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Nobile' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "OFL Sorts Mill Goudy TT, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=OFL+Sorts+Mill+Goudy+TT' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Reenie Beanie, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Reenie+Beanie' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Tangerine, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Old Standard TT, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Old+Standard+TT' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Volkorn, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Volkorn' rel='stylesheet' type='text/css'/>
    <?php } else if ($headtype == "Yanone Kaffeesatz, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz' rel='stylesheet' type='text/css'>
    <?php } else if ($headtype == "Just Another Hand, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Just+Another+Hand' rel='stylesheet' type='text/css'>
    <?php } else if ($headtype == "Terminal Dosis Light, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Terminal+Dosis+Light' rel='stylesheet' type='text/css'>
    <?php } else if ($headtype == "Ubuntu, arial, serif"){ ?>
    <link target='_blank' href='http://fonts.googleapis.com/css?family=Ubuntu:light,regular,bold' rel='stylesheet' type='text/css'>
    <?php }

    }

    ?>

  • Jonathan

    Firstly if that is your child themes function.php file then you have just copied it from the parent. And that is why you are having such a hard time. Child themes automatically use all the code from the parent theme.
    Here is a small manual:
    https://premium.wpmudev.org/wpmu-and-buddypress-themes/what-are-parent-and-child-themes/

    Your child theme functions.php usually starts off as empty.
    So the empty functions.php file goes here

    wp-content / themes/ bp-social-child / funtions.php

    the functions.php contents ...

    <?php
    // Nothing
    
    ?>

    The reason you are getting errors (white screen) is because you are using duplicate code.

    I replied here with solution:
    https://premium.wpmudev.org/forums/topic/add-background-image-to-wp-loginphp-file-help#post-121432

    EDIT: And look below Phil commented and gave you the right code for your functions.php file :wink:

  • Philip John

    Ah ok, I believe that's your problem. You don't need to copy the functions.php into your child, that causes a conflict with the parent.

    Instead, your child functions.php should look like this I believe;

    <?php
    // get the parent functions
    include(get_bloginfo('template_directory').'/functions.php');
    
    // add custom code below this line
    
    ?>

    Then add your other code at the bottom, as instructed.

    Phil

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.