• graham333

    (@graham333)


    I have removed the next/previous post links from my Category pages
    using the following in functions.php…

    remove_action(  'twentytwelve_content_nav', 'next_posts_link');
    remove_action(  'twentytwelve_content_nav', 'previous_posts_link');

    It works fine, and the page loads as it should but there is an error message at the bottom of the

    page

    Fatal error: Call to undefined function twentytwelve_content_nav() in ……./themes/2012-

    Child/category.php on line 34

    Fine, I thought I can fix that by commenting out the line in Category.php..

    that’s this line…

    twentytwelve_content_nav( ‘nav-below’ ); ?>

    Could I hell!

    I then get…

    Parse error: syntax error, unexpected ‘<‘

    this particular symbol is not shown in the Codex for some reason, and not being a coder I don’t know what it means.

    so I tried removing everything else below it

    Nope,

    I even tried making the deleting the whole Category.php child file

    Nope, that breaks the site.

    So my question…

    How do I remove the twentytwelve_content_nav( ‘nav-below’ ); ?> call from the child Category.php

    file?

    BTW
    I don’t ask for help unless desperate, I have looked at over 300 web pages to solve this problem,
    Nope!

    Theme is 2012 with child

    Here is the complete template contents for category.php (child)

    <?php
    /**
     * The template for displaying Category pages - 2012 CHILD THEME
     */
    get_header(); ?>
    
    	<section id="primary" class="site-content">
    		<div id="content" role="main">
    
    		<?php if ( have_posts() ) : ?>
    			<header class="archive-header">
    				<h1 class="page-title">
    <span><?php single_cat_title( '', false ); ?></span>
    </h1>
    
    			<?php if ( category_description() ) : // Show an optional category description ?>
    				<div class="archive-meta"><?php echo category_description(); ?></div>
    			<?php endif; ?>
    
    			</header><!-- .archive-header -->
    
    			<?php
    			/* Start the Loop */
    			while ( have_posts() ) : the_post();
    
    				/* Include the post format-specific template for the content. If you want to
    				 * this in a child theme then include a file called called content-___.php
    				 * (where ___ is the post format) and that will be used instead.
    				 */
    				get_template_part( 'content', get_post_format() );
    
    		endwhile;
    
    		twentytwelve_content_nav( 'nav-below' ); ?>
    
    		<?php else : ?>
    
    			<?php get_template_part( 'content', 'none' ); ?>
    		<?php endif; ?>
    
    		</div><!-- #content -->
    
    	</section><!-- #primary -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
Viewing 10 replies - 1 through 10 (of 10 total)
  • yomisimie

    (@yomisimie)

    What did you use to comment out the function??

    Moderator t-p

    (@t-p)

    did you make a backup of the file you changed?

    if yes, upload it to replace the one you modified.

    alternately, upload it from a fresh download of your theme.

    or, find where you made a mistake in the file and fix the structure.

    Thread Starter graham333

    (@graham333)

    @ Yomisimie

    I used /* */

    @tara
    Haha, yes I learn’t the hard way a long time ago to backup everything.

    and since posting this, I have deleted the child theme category.php and re-installed the 2012 parent which has actually cleared the error message.

    Unfortunately it has also put back the damned Older posts link despite still having the removal code in the functions.php

    yomisimie

    (@yomisimie)

    Remove those lines from functions.php. It does not help to disable the functions. The page still loads the PHP and does not find the function defined, hence the error.

    And remove this completely from category.php

    twentytwelve_content_nav( ‘nav-below’ );

    Or try single line commenting

    //twentytwelve_content_nav( ‘nav-below’ );

    Also, keep your comments inside the <?php ?> tags.

    Thread Starter graham333

    (@graham333)

    @yomisimie

    Thanks for your continued interest yomisimie, but if you read my original post again you will note the remove_action( code did indeed remove the action but any attempt to comment out or remove twentytwelve_content_nav( ‘nav-below’ ); call caused an error message to display on the category page (after it loaded ok)

    I just need to know the correct way to remove this call without breaking anything, as seemingly removing this line by commenting out or deleting is causing a problem for some reason.

    yomisimie

    (@yomisimie)

    Ok, so the problem seems to be here

    Parse error: syntax error, unexpected ‘<‘

    That “<” has no place in the Codex because it’s a simple opening bracket for coding.

    Here is the problem. It seems that by commenting it reads the next line that begins with ‘<?php’. From what your are telling it does not close the first PHP tag after the function. Can you paste me the commented part?

    endwhile;
    twentytwelve_content_nav( ‘nav-below’ ); ?>
    <?php else : ?>

    Thread Starter graham333

    (@graham333)

    I have removed it now but this how I tried it first…

    endwhile;
    
    /*			twentytwelve_content_nav( 'nav-below' ); */
    			?>
    
    		<?php else : ?>

    and I tried many variations of commenting out various parts to see if it had any effect.

    Thread Starter graham333

    (@graham333)

    Quick update,

    I have just added
    /* twentytwelve_content_nav( 'nav-below' ); */ to the PARENT template category.php and it has worked, the category pages are loading properly with no errors and the Older posts link has gone WTF? <scratches head>

    Thread Starter graham333

    (@graham333)

    That is not really the solution though is it, I need that to happen for category.php child

    yomisimie

    (@yomisimie)

    You can try removing the 2 line from functions.php

    remove_action( ‘twentytwelve_content_nav’, ‘next_posts_link’);
    remove_action( ‘twentytwelve_content_nav’, ‘previous_posts_link’);

    And only commenting th line in category.php of your child.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Fatal error: Call to undefined function – How to remove this call from template?’ is closed to new replies.