-
|
Hi all, hoping someone can help, although I understand if it's too out of scope! I'm essentially trying to augment the chapter icon functionality to display a lock based on a third-party content restriction plugin. I've been able to get this working on the home page (set up like the demo page) in the Latest Stories, Latest Updates, and Latest Chapters partials, but I'm running into trouble when it comes to getting the same functionality working in the chapter list on an individual story page. All adjustments are being made in a child theme. As far as I can tell, the code to affect these icons is in /includes/functions/_helpers-templates.php and the default code is as follows: I tried inserting my own elseifs, but these didn't work - could very well be user error; I do not know what I'm doing. I also found related code in /includes/functions/_setup-shortcodes.php, although comments say this is specifically for chapter lists outside of story pages and /includes/functions/hooks/_story_hooks.php which may be the actual code the story page runs off, rather than _helpers-templates.php? In order to try to determine which file is affecting the chapter list, I edited the relevant lines in these files from fa-lock to fa-calendar-days, refreshing in-between, expecting passworded posts to show the calendar icon in the chapter list when I hit on the right place to edit. However, none of these edits had any effect - the site continued to show a lock for passworded posts. I purged theme caches in Fictioneer -> Tools and the site cache my hosting provider installs by default is disabled. This makes me think I'm looking in the wrong place entirely for editing icon behaviour in the chapter list. Am I barking up the wrong tree? If so, where should I be looking? I understand that this isn't something that fictioneer was built to support and I'm happy to keep beating my head against a brick wall trying to get it working, but some assurance that it's the right brick wall would be very appreciated :). |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Hello. First of all, never write into the theme files. Any modification should happen in a child theme or plugin, because changes you make will just be overridden with the next update or you might break something. Well, I guess you can break things in your child theme too, but alas. What you want is to use a filter hooked to fictioneer_filter_chapter_icon. There are many tutorials on how to use WP filters. This filter runs on ALL chapter list icon, regardless where they are rendered. The filter, well, filters the icon HTML and gets the story and chapter IDs as params. So you can intercept the icon, use the IDs to figure out what you need, and change the icon accordingly. Yes, purging the caches is required or nothing changes. As for why you didn't see any changes, I cannot say from just this bit. Many possible reasons. Anyway, the filter is what you want to put into your child theme. |
Beta Was this translation helpful? Give feedback.
-
|
Hey Tetrakern, Thanks so much for the guidance (and for all your efforts in developing such a robust theme)! I've scrapped my child theme and have started again from scratch by setting up a filter hooked to fictioneer_filter_chapter_icon, but I'm still running into issues and I can't see why this wouldn't be working. I started off by making an if function that evaluated whether a user had access to the post through functionality of the content restriction plugin, but that didn't work. To simplify it and see if I at least had the structure right, I made the below simple if statement based on a chapter_id that is still not affecting icon display. The above code in a child theme functions.php file and the latest version of the parent fictioneer theme are the only theme coding running. As far as I'm aware, this should specifically override the icon display for the chapter with chapter_id 118, but the chapter remains stubbornly unaffected. If this is a general 'learn to wordpress' problem then send me off - I don't intend to make you do general tech support! - but is there something I'm missing? I note that when I search the parent theme for |
Beta Was this translation helpful? Give feedback.
-
|
Tetrakern, you're a legend! As much as I was beginning to think it was the last option, turns out that the caching plugin that I thought was not caching was in fact sneakily caching. Once I updated the story post my little if statement worked, which means I'm happy to take it from here :) I really appreciate your patience troubleshooting with me, thank you so much! |
Beta Was this translation helpful? Give feedback.
The name of the parameter doesn't matter, just the order. I tested this and it worked fine, although some CSS classes are missing to align it properly.
So there are only a few possible error sources I can think of.