• Resolved betic1

    (@betic1)


    I’ve read about using the pluggable functions and have tried to implement a simple override using one, but it keeps throwing an error. Here is a page that I read about doing this using the Twenty Eleven Theme: . I’m trying to do something similar with the Twenty Thirteen Theme.

    I’m simply trying to replace the arrows in the previous and next page links on the Twenty Thirteen Theme at the bottom with a small image on my Child-Theme. I don’t want to just hide the DIV with CSS as I need that DIV to show my image in. Here is the code I modified from the functions.php from Twenty Thirteen (I simply removed the 4 instances of the arrows and replaced that with the image link).

    <?php
    if ( ! function_exists( 'twentythirteen_paging_nav' ) ) :
    /**
     * Displays navigation to next/previous set of posts when applicable.
     *
     * @since Twenty Thirteen 1.0
     *
     * @return void
     */
    function twentythirteen_paging_nav() {
    	global $wp_query;
    
    	// Don't print empty markup if there's only one page.
    	if ( $wp_query->max_num_pages < 2 )
    		return;
    	?>
    	<nav class="navigation paging-navigation" role="navigation">
    		<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentythirteen' ); ?></h1>
    		<div class="nav-links">
    
    			<?php if ( get_next_posts_link() ) : ?>
    			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav"><img src="/images/ArrowL.png" /></span> Older posts', 'twentythirteen' ) ); ?></div>
    			<?php endif; ?>
    
    			<?php if ( get_previous_posts_link() ) : ?>
    			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav"><img src="/images/ArrowR.png" /></span>', 'twentythirteen' ) ); ?></div>
    			<?php endif; ?>
    
    		</div><!-- .nav-links -->
    	</nav><!-- .navigation -->
    	<?php
    }
    endif;
    
    if ( ! function_exists( 'twentythirteen_post_nav' ) ) :
    /**
     * Displays navigation to next/previous post when applicable.
    *
    * @since Twenty Thirteen 1.0
    *
    * @return void
    */
    function twentythirteen_post_nav() {
    	global $post;
    
    	// Don't print empty markup if there's nowhere to navigate.
    	$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
    	$next     = get_adjacent_post( false, '', false );
    
    	if ( ! $next && ! $previous )
    		return;
    	?>
    	<nav class="navigation post-navigation" role="navigation">
    		<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentythirteen' ); ?></h1>
    		<div class="nav-links">
    
    			<?php previous_post_link( '%link', _x( '<span class="meta-nav"><img src="/images/ArrowL.png" /></span> %title', 'Previous post link', 'twentythirteen' ) ); ?>
    			<?php next_post_link( '%link', _x( '%title <span class="meta-nav"><img src="/images/ArrowR.png" /></span>', 'Next post link', 'twentythirteen' ) ); ?>
    
    		</div><!-- .nav-links -->
    	</nav><!-- .navigation -->
    ?>

    I’ve tried deleting various amounts of this code to see where the error is and can’t seem to find it. It only goes away when I delete everything between the opening and closing PHP code or clear that away as well. It’s still only a local site, so I don’t have the link to the live site yet.

    Anyway, thanks for whatever advice you can give. I’m probably missing something obvious.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter betic1

    (@betic1)

    My apologies for posting a follow up to the above question, but there is no edit button for my post so I’ll just retype it all here…

    I’ve read about using the pluggable functions and have tried to implement a simple override using one, but it keeps throwing an error. Here is a page that I read about doing this using the Twenty Eleven Theme: link. I’m trying to do something similar with the Twenty Thirteen Theme.

    I’m simply trying to replace the arrows in the previous and next page links on the Twenty Thirteen Theme at the bottom with a small image on my Child-Theme. I don’t want to just hide the DIV with CSS as I need that DIV to show my image in. Here is the code I modified from the functions.php from Twenty Thirteen (I simply removed the 4 instances of the arrows and replaced that with the image link).

    I’ve tried deleting various amounts of this code to see where the error is and can’t seem to find it. It only goes away when I delete everything between the opening and closing PHP code or clear that away as well. It’s still only a local site, so I don’t have the link to the live site yet.

    Here’s the code:

    <?php
    if ( ! function_exists( 'twentythirteen_paging_nav' ) ) :
    /**
     * Displays navigation to next/previous set of posts when applicable.
     *
     * @since Twenty Thirteen 1.0
     *
     * @return void
     */
    function twentythirteen_paging_nav() {
    	global $wp_query;
    
    	// Don't print empty markup if there's only one page.
    	if ( $wp_query->max_num_pages < 2 )
    		return;
    	?>
    	<nav class="navigation paging-navigation" role="navigation">
    		<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentythirteen' ); ?></h1>
    		<div class="nav-links">
    
    			<?php if ( get_next_posts_link() ) : ?>
    			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav"><img src="/images/ArrowL.png" /></span> Older posts', 'twentythirteen' ) ); ?></div>
    			<?php endif; ?>
    
    			<?php if ( get_previous_posts_link() ) : ?>
    			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav"><img src="/images/ArrowR.png" /></span>', 'twentythirteen' ) ); ?></div>
    			<?php endif; ?>
    
    		</div><!-- .nav-links -->
    	</nav><!-- .navigation -->
    	<?php
    }
    endif;
    
    if ( ! function_exists( 'twentythirteen_post_nav' ) ) :
    /**
     * Displays navigation to next/previous post when applicable.
    *
    * @since Twenty Thirteen 1.0
    *
    * @return void
    */
    function twentythirteen_post_nav() {
    	global $post;
    
    	// Don't print empty markup if there's nowhere to navigate.
    	$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
    	$next     = get_adjacent_post( false, '', false );
    
    	if ( ! $next && ! $previous )
    		return;
    	?>
    	<nav class="navigation post-navigation" role="navigation">
    		<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentythirteen' ); ?></h1>
    		<div class="nav-links">
    
    			<?php previous_post_link( '%link', _x( '<span class="meta-nav"><img src="/images/ArrowL.png" /></span> %title', 'Previous post link', 'twentythirteen' ) ); ?>
    			<?php next_post_link( '%link', _x( '%title <span class="meta-nav"><img src="/images/ArrowR.png" /></span>', 'Next post link', 'twentythirteen' ) ); ?>
    
    		</div><!-- .nav-links -->
    	</nav><!-- .navigation -->
    ?>

    Anyway, thanks for whatever advice you can give. I’m probably missing something obvious.

    you seem to have missed to add the closing bracket and the ‘endif’ at the end of the second part of the code;

    try to chnage the last few lines to:

    </div><!-- .nav-links -->
    	</nav><!-- .navigation -->
    	<?php
    }
    endif;
    Thread Starter betic1

    (@betic1)

    That was it. Works perfectly now! I knew it had to be something simple. I never would have known to put the endif: statement in. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Child Theme functions.php error when trying us pluggable function from parent.’ is closed to new replies.