Skip to content

Instantly share code, notes, and snippets.

@mklasen
Last active May 13, 2020 17:01
Show Gist options
  • Save mklasen/3d0c67774d19d183981fde3405b8f048 to your computer and use it in GitHub Desktop.
Save mklasen/3d0c67774d19d183981fde3405b8f048 to your computer and use it in GitHub Desktop.
Remove all filters from the_title in the post type is person
<?php
add_action( 'wp', function () {
if ( get_post_type() === 'person' ) {
remove_all_filters( 'the_title' );
}
} );
@cfoubert37
Copy link

As I said by email, I don't know where to put this code because it does not have any effect on the navigation even if I put it on the plug-in files...

@cfoubert37
Copy link

Who did you do to obtain the result with only the name of the person without the description between () ?

@mklasen
Copy link
Author

mklasen commented Mar 27, 2020

My bad. It should be hooked on 'wp' instead of 'init'.

@cfoubert37
Copy link

It works. I put the code on the functions.php of the wp-includes folder. Thank you.

Awaiting for the update of your plug-in.

Have a safe a nice week-end.

Claude (from France, at home, for few weeks more)

@cfoubert37
Copy link

I detected a new bug. As you can see on this page, https://batteriesevent.com/speakers/, when you click on a speaker, the previous and next button don’t follow the order of the speakers. Not the alpha order, not the specific order specified for each person. There is any logic…

Can you help me to fix that?

@mklasen
Copy link
Author

mklasen commented May 7, 2020

It works. I put the code on the functions.php of the wp-includes folder. Thank you.

Awaiting for the update of your plug-in.

Have a safe a nice week-end.

Claude (from France, at home, for few weeks more)

Please don't put any code in WordPress core files.
What you could do is add the code as a new plugin, like below:

<?php
/**
 * Plugin Name: Remove all filters from the_title
 */
add_action( 'wp', function () {
	if ( get_post_type() === 'person' ) {
		remove_all_filters( 'the_title' );
	}
} );

I detected a new bug. As you can see on this page, https://batteriesevent.com/speakers/, when you click on a speaker, the previous and next button don’t follow the order of the speakers. Not the alpha order, not the specific order specified for each person. There is any logic…

Can you check if this fixes it? :)

<?php
/**
 * Plugin Name: Sympose: Sort next/previous post navigation by menu order
 */
function wpse73190_adjacent_post_sort( $orderby, $post ) {
	if ( $post->post_type === 'person' ) {
		$orderby = "ORDER BY p.menu_order DESC LIMIT 1";
	}
	return $orderby;
}

add_filter( 'get_previous_post_sort', 'wpse73190_adjacent_post_sort', 10, 2 );
add_filter( 'get_next_post_sort', 'wpse73190_adjacent_post_sort', 10, 2 );

@cfoubert37
Copy link

cfoubert37 commented May 11, 2020 via email

@mklasen
Copy link
Author

mklasen commented May 11, 2020

You can create a new file in the wp-content/plugins folder and add the code above. Each code block above is a separate plugin.

You can also give the plugin it's own directory (wp-content/plugins/remove-all-filters/) and add the file inside of the directory.

@cfoubert37
Copy link

cfoubert37 commented May 11, 2020 via email

@cfoubert37
Copy link

Can you help me to fix the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment