ThemeShaper Forums » Thematic

[closed]

override content breaking wp-admin??

(20 posts)
  • Started 11 years ago by maren.m
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. maren.m
    Member

    Hi there - I'm trying to override the content_init. Want to just have excerpts on the home page. It's working fine on the site itself, but whenever I go to "wp-admin" all I get is a blank screen. I can't figure out what I'm doing wrong!!

    function childtheme_override_content_init() {
    		global $thematic_content_length;
    
    		$content = '';
    		$thematic_content_length = '';
    
    		if (is_home() || is_front_page()) {
    			$content = 'excerpt';
    		} elseif (is_single()) {
    			$content = 'full';
    		} elseif (is_tag()) {
    			$content = 'excerpt';
    		} elseif (is_search()) {
    			$content = 'excerpt';
    		} elseif (is_category()) {
    			$content = 'excerpt';
    		} elseif (is_author()) {
    			$content = 'excerpt';
    		} elseif (is_archive()) {
    			$content = 'excerpt';
    		}
    
    		$thematic_content_length = apply_filters('thematic_content', $content);
    
    }
    	add_action('thematic_abovepost','childtheme_override_content_init');
    Posted 11 years ago #
  2. fwunder
    Member

    Hi maren.m,

    I'm still reading and learning, but what I did is simply add the following to my child theme functions.php:

    function childtheme_filter_content($content) {
            if (is_home() || is_front_page()) {
    		$content= 'excerpt';
    	}
    	return $content;
    }
    add_action('thematic_content','childtheme_filter_content');

    Then, because I wanted my "sticky post" to read full with no excerpt I modified it to:

    function childtheme_filter_content($content) {
    	if (!is_sticky() && (is_home() || is_front_page())) {
    		$content= 'excerpt';
    	}
    	return $content;
    }
    add_action('thematic_content','childtheme_filter_content');

    I hope that helps, but I would wait for confirmation from the more learned here. :)

    Posted 11 years ago #
  3. @fwunder, never tried w/ stickies but your filter approach is perfect for this case. the whole override is silly when only changing the one value.

    @maren.m, no need to add_action when using the override. probably is getting added 2x as a result.

    Posted 11 years ago #
  4. maren.m
    Member

    @fwunder: Yes, that definitely makes sense. Went ahead and tried that code...
    Works on the website itself but admin is still blank.

    Eventually achieved better results just customizing the index loop, but now I'm curious: why was @fwunder's code breaking my admin screen?

    I tried deleting all other functions in the my file and deduced that it's definitely coming from that one.

    Posted 11 years ago #
  5. if your admin was already broken (as you said in your original post) then it is obvious that fwunder's code is not responsible for breaking your site. i tested both his snippets and they work perfectly.

    when the shit hits the fan, you should temporarilyturn on debugging in your wp-config.php

    define('WP_DEBUG',true);

    you should also disabled all plugins and think about removing all code from your functions.php. re-enable things 1 at a time to isolate the problem.

    Posted 11 years ago #
  6. fwunder
    Member

    Yeah, what she said! ;)

    You might want to Google "Wp-admin blank page". Seems you're not alone.

    Posted 11 years ago #
  7. maren.m
    Member

    Yes, of course, I didn't mean that @fwunder's code was broken...just that i must be implementing it wrong...I seem to be getting this blank screen any time I mess with $content. gotta figure out what's happening there. apparently customizing the index loop is not the answer either....

    i've done the deleting of everything in the functions.php file and it's definitely coming from this issue.

    Posted 11 years ago #
  8. fwunder
    Member

    @maren.m, just a suggestion as it might help me understand this stuff better too...

    Is it possible you could post your functions.php and a link to the website? Not saying I can help, but I might learn something. Thanks.

    Posted 11 years ago #
  9. maren.m
    Member

    I seem to have (sort of) figured it out: I have a function where I'm adding some html before the header, something like this:

    function add_social() {
    //etc.
    }
    add_action('thematic_header','add_social', 1);

    It seems if I put this BEFORE the manipulating of the content in functions.php it breaks my admin. I'm sure it has something to do with important functions in the header that I'm pushing back...but haven't figured out the specifics. Right now I've just got it at the bottom of functions.php.

    I'm developing locally unfortunately :(

    But if you have any further thoughts please let me know!

    Posted 11 years ago #
  10. fwunder
    Member

    Ya know, I'm not clear on the hook position (edit: priority) (1, 2, 3, etc.), but I'm guessing that might have something to do with it. Perhaps @helgatheviking could splain.

    Posted 11 years ago #
  11. priority number just pertains to the ordering of functions on the same hook. there are several functions attached to thematic_header() so the priority tells WP in what order they should be fired.

    function add_social() { ?>
    <div id="bacon">I love bacon</div>
    <?php }
    add_action('thematic_header','add_social', 1);

    does not break anything here.

    you might have bad syntax somewhere. you might also have a plugin that has an add_social function. are you getting any debug errors? that would help us stop guessing.

    Posted 11 years ago #
  12. fwunder
    Member

    @helgatheviking, I know I'm getting off track here, but does that mean I could add another hook before or after your bacon hook:


    function add_anti_social() { ?>
    <div id="sausage">I love sausage</div>
    <?php }
    add_action('thematic_header','add_anti_social', 2);

    and my sausage div would display after your bacon div?

    Thanks!

    Posted 11 years ago #
  13. yes, but if you wanted to display 2 divs i would just put them both in the same function. there is no limit to what you can add in one function.

    other functions already on thematic_header()

    1 brandingopen
    3 blogtitle
    5 blogdescription
    7 brandingclose
    9 access

    what's the status w/ your busted admin?

    Posted 11 years ago #
  14. maren.m
    Member

    Ok so now the craziness has started. I turned on the debug mode and things went nuts. I got really overwhelmed by the number of bugs and decided to go back to square one.
    Basically I deleted everything I've done so far on this childtheme - functions.php and style.css back to "sample child theme" start point, plugins deleted.

    Somehow I'm still getting an error?! It's this one:

    Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /Users/carolramsey/Sites/casting/wp-includes/functions.php on line 3587

    Is it possible I somehow corrupted some internal part of wordpress?

    Posted 11 years ago #
  15. maren.m
    Member

    So I've done some searching around...is it possible that a part of thematic is not compatible with WordPress 3.3.1?

    I deleted my databases, reinstalled wordpress--no luck until I tried a different theme altogether. Don't get this enque error with Twenty Ten or Twenty Eleven. Tried switching back to Thematic and a thematic childtheme and it reappeared!

    could this be the root of my problemo? or just a second problemo?

    agh!

    Posted 11 years ago #
  16. whhoaaa... ok, that is just a Notice and not a fatal error. your site can and will still run w/ notices. the white screen of death you described in your original post is from a fatal error. wp_debug_mode will show both.

    thematic enqueues jquery directly from functions.php and it is now advised/required to enqueue jquery and all scripts on the wp_enqueue_scripts hook. this will be fixed in the new release, but i don't think it is the cause of your problem. i just activated the latest stable dev version on my local host (running 3.3.1) and there are no problems here that i can see.

    Posted 11 years ago #
  17. maren.m
    Member

    Ok. That's good to know. Whew!

    So at this point the only white screen of death that I'm getting is when I update, publish, or trash a post. I think it's coming from the new index loop I wrote. Debug isn't saying anything (other than the enque issue).

    I'm just going to copy and paste the whole thing here, but basically what I'm trying to do is get rid of the post content and replace it with the featured image.

    function childtheme_override_index_loop() {
    
    		global $options, $blog_id;
    
    		foreach ($options as $value) {
    		    if (get_option( $value['id'] ) === FALSE) {
    		        $$value['id'] = $value['std'];
    		    } else {
    		    	if (THEMATIC_MB)
    		    	{
    		        	$$value['id'] = get_option($blog_id,  $value['id'] );
    		    	}
    		    	else
    		    	{
    		        	$$value['id'] = get_option( $value['id'] );
    		    	}
    		    }
    		}
    
    		/* Count the number of posts so we can insert a widgetized area */ $count = 1;
    		while ( have_posts() ) : the_post();
    
    				thematic_abovepost(); ?>
    
    				<div id="post-<?php the_ID();
    					echo '" ';
    					if (!(THEMATIC_COMPATIBLE_POST_CLASS)) {
    						post_class();
    						echo '>';
    					} else {
    						echo 'class="';
    						thematic_post_class();
    						echo '">';
    					}
    
         				thematic_postheader();
    					the_post_thumbnail( 'full' ); ?>
    					<div class="entry-content"> 
    
    					<?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
    					</div><!-- .entry-content -->
    					<?php thematic_postfooter(); ?>
    				</div><!-- #post -->
    			</div><!--.highlight-->
    
    			<?php 
    
    				thematic_belowpost();
    
    				comments_template();
    
    				if ($count==$thm_insert_position) {
    						get_sidebar('index-insert');
    				}
    				$count = $count + 1;
    		endwhile;
    }
    
    ?>
    Posted 11 years ago #
  18. i don't think your index loop even gets called on the backend, so that almost can't be it. you have any plugins running? try disabling them all.

    Posted 11 years ago #
  19. maren.m
    Member

    Alright, I deactivated all plugins and deleted everything out of my functions.php file. Am STILL getting white screen after updating/publishing/trashing posts, now with this error in addition to enque:

    Warning: Cannot modify header information - headers already sent by (output started at /Users/carolramsey/Sites/casting/wp-includes/functions.php:3587) in /Users/carolramsey/Sites/casting/wp-includes/pluggable.php on line 866

    However the changes I make seem to be going through - they show up on the page if I go to it afterwards.

    I notice that it's referencing the same function line as the enqueue error (3587):

    Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /Users/carolramsey/Sites/casting/wp-includes/functions.php on line 3587

    Posted 11 years ago #
  20. headers already sent usually means there is some white space before the first <?php or after the last ?> .

    if all plugins are deactivated, then this has to be in your functions.php. the notice about wp_enqueue_scripts isn't going away until thematic updates.

    if you want to email me (username AT gmail) some WP and FTP creds i can take a quick look. might be faster than trying to diagnose via forum.

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.