Comments (3)
Thank you for using Fictioneer, I hope you can make use of it.
Regarding your request, this is not an improvement but an erratic feature. Which is perfectly fine, of course. Display your content how you like. But I cannot bloat the theme further with features barely anyone needs, there are too many of those already. And someone will always come with another, where would this end?
Anyway, you are in luck, because not only can this be achieved (obviously) but also with relative ease. Well, you do need a child theme for some custom code. If you check "Enabled advanced meta fields" under Fictioneer > General > Compatibility, you will be able to use the "Short Title" field in the chapter meta box. This is not actually used by the theme, it is meant for child theme customizations and pretty much the opposite of what you need. But a field is a field.
Put this into your child theme's functions.php:
function child_modify_chapter_header( $identity, $args ) {
// Setup
$password_class = empty( $args['chapter_password'] ) ? '' : ' _password';
$other_title = get_post_meta( $args['chapter_id'], 'fictioneer_chapter_short_title', true );
$icon_classes = fictioneer_get_icon_field( 'fictioneer_chapter_icon', $args['chapter_id'] );
$icon = '';
$meta = $identity['meta'];
// Abort if second title is not set
if ( empty( $other_title ) ) {
return $identity;
}
// Prepend icon (if any)
if ( ! empty( $icon_classes ) ) {
$icon = '<i class="' . $icon_classes . '"></i> '; // Mind the space afterwards
}
// Temporary remove meta row
unset( $identity['meta'] );
// Rebuild HTML
$identity['title'] = '<h1 class="chapter__title' . $password_class . '">' . $icon . $args['chapter_title'] . '</h1>';
$identity['other_title'] = '<h2 class="chapter-second-title">' . $other_title . '</h2>';
$identity['meta'] = $meta;
// Continue filter
return $identity;
}
add_filter( 'fictioneer_filter_chapter_identity', 'child_modify_chapter_header', 10, 2 );
You may need to add some custom style targeting the "chapter-second-title" CSS class. The chapter header is not set up for a second title. Why would it? I also prepended the chapter icon, in case you want that.
Modifying the title on the story page (or elsewhere) is a bit more tricky, at least until the next update 5.12.0 which will add a context parameter to the fictioneer_filter_safe_title
filter. The update is still a bit off, but not much. Alternatively, you could check whether the current template is the "single-fcn_story.php" and the $post_id belongs to the type "fcn_chapter", but that is not guaranteed to only hit the chapter list under certain circumstances. You should wait for the update (this code will throw an error until then).
function child_modify_chapter_list_title( $title, $post_id, $context ) {
// Only for chapter lists (story pages and shortcode)
if ( ! in_array( $context, ['story-chapter-list', 'shortcode-chapter-list'] ) ) {
return $title;
}
// Setup
$other_title = get_post_meta( $post_id, 'fictioneer_chapter_short_title', true );
// Abort if second title is not set
if ( empty( $other_title ) ) {
return $title;
}
// Append to title
$title = $title . ' — ' . $other_title;
// Continue filter
return $title;
}
add_filter( 'fictioneer_filter_safe_title', 'child_modify_chapter_list_title', 10, 3 );
Little extra advice: Be careful with adding meta fields, especially if you did not disable post revisions. Each field adds to your post_meta database table, and each revision adds a duplicate of that. So if you have a meta field for 1000 chapters, and each has at least three revisions (you updated it just two times), that means you now got +3000 rows in that database table. Now imagine using even more meta fields. Eventually, this will slow down your site.
Fictioneer has been built with that in mind and only saves what's actually needed. But there's a limit to what I can do. Anyway, I recommend turning off post revisions if you did not already.
from fictioneer.
With 5.12.0 released, this should now be good to go.
from fictioneer.
Seeing how there's no response coming, I'm closing this now.
from fictioneer.
Related Issues (20)
- How to get the same effect as the demo HOT 2
- Allow metrics for non-chaptered oneshot stories HOT 1
- on click of next button, fullscreen exit HOT 1
- display lock icon 🔒 for password protected-posts on chapter list view in stories pages & latest chapters cards HOT 2
- Display next scheduled chapter above chapter list on stories page HOT 2
- Bug: Collapse group chapters setting causing non-group chapters to disappear on story pages HOT 2
- Arrange select stories dropdown in chapters post_edit screen alphabetically HOT 1
- The words count is incorrect. HOT 5
- Bug: Shortcodes don't work as intended on child base theme HOT 2
- Light/Dark Mode Switcher is not visible! HOT 4
- Suggestion: Show support author buttons for locked chapter posts + Global password note for all chapters under specific story HOT 4
- Suggestion: View password-protected posts without entering passwords on front-end as admins HOT 4
- It is hard to apply your theme for wordpress newbie
- Upvote and Downvote on the Chapter and the comment sections HOT 1
- No backlink for suggested text comments HOT 3
- Index Page for All Stories Available HOT 6
- Follows/Reminders/Finished counts not always accurate
- Comments HOT 7
- Rating HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fictioneer.