[Resolved] Extra GP Hooks

Home Forums Support [Resolved] Extra GP Hooks

Home Forums Support Extra GP Hooks

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #59117
    Pete

    Can we please have some extra hooks…
    archive.php

    • before and after the category title
    • before and after the category description

    Thanks

    #59931
    Pete
    #60335
    Pete

    This dynamically allows you to put some php code after the category title as well as some text/html before and after the category title.

    Place the below code inside your functions.php

    You need to install the Real-Time Find and Replace plugin as well, as explained in the code below.

    add_filter( 'single_cat_title', 'before_after_code_single_cat_title' );
    
    function before_after_code_single_cat_title( $text ) {
    	/*** important info ***/
    	/*** 
    	you need to install the Real-Time Find and Replace plugin to hide the original h1 tags. Use the following find text. Copy all in between the [] (make sure you keep the spaces).
    	
    	[<h1 class="page-title">
    					hide</h1>]
    	***/ 
    	echo 'hide</h1>';
    	echo '<p>Before the category title</p>';
    	echo '<h1 class="page-title">';
    	
    	//YOUR CODES HERE - MUST BE STRING MANIPULATIONs; example://
    	$append = '';	
    	// Show an optional term description.	
    	$term_description = term_description();
    	if ( ! empty( $term_description ) ) :
    
    	$append .= sprintf( '<div class="taxonomy-description2">%s</div>', $term_description );
    
    	$text = $text . '</h1><p>Text after the category title and before the code insertion is optional</p>' .  $append . ' <p>Text after the code insertion is optional</p>';
    	endif;
     
    	return $text;
    

    }

    #60336
    Pete

    Unfortunately the echoing before the single cat title screws up the cat page title

    #60337
    Pete

    This can be fixed with Yoast’s SEO plugin with Force rewrite titles ticked.

    #60338
    Pete

    Modified code, using 1 plugins as per the comments…

    add_filter( 'single_cat_title', 'code_before_single_cat_title' );
    function code_before_single_cat_title( $text2 ) {
    	$append2 = '';	
    // Use the Shortcode Exec PHP plugin to convert your code into a shortcode and insert it here	
    	$append2 .=  do_shortcode('[text2]' );
    	$text2 = '</h1>' .  $append2 . '<p>Some text/html can be inserted after the top code here</p><h1 class="page-title">' .  $text2 . '</h1><p>Some text/html can be inserted after the category title here</p>';
    	return $text2;
    } 
      
    add_filter( 'single_cat_title', 'before_after_code_single_cat_title' );
    function before_after_code_single_cat_title( $text ) {
    	$append = '';	
    // Use the Shortcode Exec PHP plugin to convert your code into a shortcode and insert it here 
    	$append .=  do_shortcode('[text]' );
    	$text = $text . '</h1><p>Some text/html can be inserted before the bottom code here</p>' .  $append . ' <br /><p>Some text/html can be inserted after the bottom code here</p>';
     	return $text;
    }
    #60346
    Pete

    OK I’ve added in the shortcode function so now no plugins are needed… I’ll make a new post.

    #60542
    Tom
    Lead Developer
    Lead Developer

    I’ll take a look at adding those hooks as well ๐Ÿ™‚

    Thanks!

    #60682
    Pete

    Hi Tom there’s no hook in content-single.php between .entry-content and .entry-meta. A hook here would be very useful. ๐Ÿ™‚

    #61096
    Tom
    Lead Developer
    Lead Developer

    Thanks for letting me know – will look at that as well.

    #61336
    Tom
    Lead Developer
    Lead Developer

    I’ve added all of these hooks to 1.2.5.

    Thanks!

    #61338
    Pete

    Awesome thanksTom.

    #737274
    Pete

    resolved

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.