• Hi

    From last 2 weeks im trying to add a feature as 250 words of post on page appear and rest of the article access by Read More Links

    I have tried Tags and many tutorial but its seems my selected theme is not allowing or has bug in it. Alot of search I have found the following code which need to be add in function.php

    <?php
    
    add_filter( 'the_content_more_link', 'my_more_link', 10, 2 );
    
    function my_more_link( $more_link, $more_link_text ) {
    	return str_replace( $more_link_text, 'Continue reading &rarr;', $more_link );
    }
    
    ?>

    Taken from

    https://justintadlock.com/archives/2009/07/01/how-to-filter-a-wordpress-themes-more-link-text

    Here is my theme function Code. Please tell me how to adjust above code into my function.php file.

    <?php
    
    /**
    
     * Coded by misbah ([email protected])
    
     */
    
    if ( function_exists('register_sidebar') ) {
    
    	register_sidebar(array(
    
    		'name' => 'Primary Sidebar',
    
    		'before_widget' => '<li id="%1$s" class="widget">',
    
    		'after_widget' => '</li>',
    
    		'before_title' => '<h4 class="widget-title">',
    
    		'after_title' => '</h4>',
    
    	));
    
    	register_sidebar(array(
    
    		'name' => 'Secondary Sidebar',
    
    		'before_widget' => '<li id="%1$s" class="widget">',
    
    		'after_widget' => '</li>',
    
    		'before_title' => '<h4 class="widget-title">',
    
    		'after_title' => '</h4>',
    
    	));
    
    }
    
    //Check for widgets in widget-ready areas https://www.ads-software.com/support/topic/190184?replies=7#post-808787
    
    //Thanks to Chaos Kaizer https://blog.kaizeku.com/
    
    function is_sidebar_active( $index = 1){
    
    	$sidebars	= wp_get_sidebars_widgets();
    
    	$key		= (string) 'sidebar-'.$index;
    
    	return (isset($sidebars[$key]));
    
    }
    
    include(TEMPLATEPATH.'/includes/template-options.php');
    
    include(TEMPLATEPATH.'/includes/plugins.php');
    
    /*
    
    add_action('widgets_init', 'remove_default_widgets', 0);
    
    function remove_default_widgets() {
    
    	if (function_exists('unregister_sidebar_widget')) {
    
    		unregister_sidebar_widget('Search');
    
    	}
    
    }
    
    include(TEMPLATEPATH.'/includes/widgets.php');
    
    /**/

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Add Read More Code in Theme Function’ is closed to new replies.