• Resolved forum domini

    (@forumdomini)


    I notice TSF is quite straigthfoward

    But I want to be able to add some text to a certain post type on my website.

    How do I do that? I know I can do in every single page but it will take me forever since I have 4000 of such pages

    For example right now I have the default title to define the name of a store (AirBNB, Amazon)

    I want my page to have a title as “Coupon codes for Airbnb” instead of just “Airbnb”

Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    My apologies for getting back to you this late, we had some power issues; so I couldn’t access all my resources quickly.

    We have some title-related filters in place. What you’d want to do is prepend the Coupons codes for to the title for the post type.

    This is what your custom filter will look like, you just need to adjust the my_post_type value:

    /**
     * Modifies the auto-generated title for The SEO Framework.
     * 
     * @param string     $title The title.
     * @param array|null $args  The title arguments.
     */
    add_filter( 'the_seo_framework_title_from_generation', function( $title, $args ) {
    
    	if ( null === $args ) {
    		// Front-end, main query loop...
    
    		if ( is_singular() ) {
    			// Singular...
    			if ( 'my_post_type' === get_post_type() ) {
    				$title = "Coupon codes for $title";
    			}
    		} else {
    			// Taxonomy...
    		}
    	} else {
    		// Custom query...
    
    		if ( empty( $args['taxonomy'] ) ) {
    			// Singular...
    			if ( 'my_post_type' === get_post_type( $args['id'] ) ) {
    				$title = "Coupon codes for $title";
    			}
    		} else {
    			// Taxonomy...
    		}
    	}
    
    	return $title;
    }, 10, 2 );

    You can extend this functionality indefinitely. Please note, however, that the filter above does not affect custom meta titles. For that, you’d want to use the_seo_framework_title_from_custom_field, and also check if the first parameter is entered.

    I hope this helps! Cheers ??

Viewing 1 replies (of 1 total)
  • The topic ‘Add Text to some taxonomy or post type’ is closed to new replies.