Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing of archived post prefix/label on frontend #21

Closed
matthewmcvickar opened this issue Jun 30, 2020 · 2 comments · Fixed by #32
Closed

Allow changing of archived post prefix/label on frontend #21

matthewmcvickar opened this issue Jun 30, 2020 · 2 comments · Fixed by #32
Assignees
Milestone

Comments

@matthewmcvickar
Copy link

matthewmcvickar commented Jun 30, 2020

By default, calls to the_title() or get_the_title() return Archived: [post-title] for archived posts. It would be nice to be able to disable or change that prefix with a single line of code, or for there to be a filter for changing the label.

For anybody looking to do this now, the following WordPress filter function also works to accomplish this:

function remove_prefix_from_archived_posts( $title, $id ) {
  $title = str_replace( 'Archived: ', '', $title );
  return $title;
}
add_filter( 'the_title', 'remove_prefix_from_archived_posts', 10, 2 );
@joshuadavidnelson
Copy link
Owner

There are filters to support this as of v0.3.9, see the readme:

Remove the label

add_filter( 'aps_title_label', '__return_false' );

Place the label after the title

add_filter( 'aps_title_label_before', '__return_false' );

Change the separator

The separator is the string between the "Archived" label and the post title, including spaces. When the label appears before the title, the separator is a colon and space : , if the label is placed after the title it is a dash with spaces on each side -.

You can customize the separator with the following filter:

add_filter( 'aps_title_separator', function( $sep ) {
	$sep = ' ~ '; // replace with your separator
	return $sep;
});

@matthewmcvickar
Copy link
Author

Thank you, this is great!

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

Successfully merging a pull request may close this issue.

2 participants