Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to change title tag for BP activities ?


  • milemilosheski
    Participant

    @milemilosheski

    I’ve been trying to do this in order to change the <title> tag on single activity pages:

    
    add_filter( 'bp_get_activities_title', array( $this, 'bp_aioseo_filter_seo_title' ), 10, 1 );
    
    /**
         * Override title tag for BP Activity post type.
         *
         * @access public
         * @param string $title
         * @return string | seo modified title.
         */
    	public function bp_aioseo_filter_seo_title($new_title) {
    	    
    	    global $bp;
    	    global $bp_activity_title;
    
    	    echo '<pre>';var_dump('debug-m',$new_title, $bp_activity_title);die();
    
    		if ( bp_is_single_activity() || bp_is_activity_component() ) {
    			$activity_id = $bp->current_action;
    
    			$new_title = '';
    
    			if ($activity_id) {
    				$get_act = bp_activity_get(array('in'=>$activity_id));
    				$activities = ($get_act['activities']);
    				foreach ($activities as $activity)  {
    					$new_title = $this->cdbl_bp_aioseo_get_words(strip_tags($activity->content), 7);
    				}
    			}
    
    		}
    	    return $new_title;
    	}
    

    So far no luck, can you point or direct me since I’ve already tried all the hooks actions and filters and nothing is making any change

    Thanks,
    Mile

  • You must be logged in to reply to this topic.
Skip to toolbar