WordPress.org

Ready to get started?Download WordPress

Forums

functions.php vs plugin (3 posts)

  1. mores
    Member
    Posted 5 years ago #

    Hi all,

    in my quest to create self-contained themes, I discovered the functions.php and it's possibilities.
    So I basically took my own plugin that extracts post images and used it in a client's functions.php.
    Now I've done this before, but on my newest client's server I got empty pages permanently. The site would just show me an empty page, no source code. ALso, the admin was screwed up.
    Debugging showed that it's not a plugin incompatibility, but the functions.php that screws things up.

    But only on that server.

    Anyone know why this happens? Is there something I need to consider when using functions.php? All I used was this:

    function postheader() {
    
    	$images = get_children(array(
    		'post_parent' => get_the_ID(),
    		'post_type' => 'attachment',
    		'numberposts' => '-1',
    		'order' => 'DESC',
    		'orderby' => 'ID',
    		'post_mime_type' => 'image'));	
    
    	if ( $images )
    	{
    		foreach( $images as $image ) {
    			$attachmenturl=wp_get_attachment_url($image->ID);
    			$attachmentimage=wp_get_attachment_image($image->ID, 'full' );
    			$img_title = $image->post_title;
    
    			if (stristr($img_title, '[header]')){
    				echo "<img src=$attachmenturl>";
    			}
    		}
    	} else {
    		echo '<img src="/wp-content/uploads/header_start.jpg">';
    	}
    }

    I'd appreciate some pointers. Should I try to use plugins rather than a functions.php?

  2. jessai
    Member
    Posted 5 years ago #

    If you have the problem just on this server.

    try to put absolute way for source image.

  3. mores
    Member
    Posted 5 years ago #

    :) I removed the absolute link as to not publish the domain in question :)

    Uhm, it's not an image problem, it's the whole page that does not show up. Just blank page.

Topic Closed

This topic has been closed to new replies.

About this Topic