Support » Plugin: AMP » Adding bbPress Comments and Breadcrumbs to Forums for AMP Legacy

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support James Osborne

    (@jamesosborne)

    Hi Josh,

    While I’m unsure whether all features of BBPress will work in AMP have you tried to create overrides for the AMP reader mode templates, and inserting the various functionality into the templates? To do so you can create an “amp” folder in your parent themes root directory. Within that folder insert any of the reader mode templates you like, while making whatever modifications you wish. The templates inside this directory will override the default reader mode templates.

    Let me know if that answers your question.

    Plugin Author Weston Ruter

    (@westonruter)

    The Legacy theme is so minimalistic yet esthetically pleasing I would rather use that than any other theme.

    Have you considered using Twenty Twenty-One or Twenty Twenty as the Reader theme? This will give you all the normal template features. These themes can be configured to be similarly minimalistic via the AMP Customizer.

    • This reply was modified 6 months, 3 weeks ago by Weston Ruter.
    Thread Starter T4G

    (@tips4gamers)

    @westonruter, yes, we used Twenty Twenty, Twenty Twenty-One, then Astra. Astra was the fastest out of those three but the Legacy theme is by far the fastest according to Google PageSpeed Insights and speed is what we’re focusing on. The total score was a 40-50 point difference in comparison to the Legacy theme.

    Unfortunately, the AMP Customizer for those themes couldn’t make it as minimalistic as the Legacy theme because bbPress’s features are fully compatible with AMP so there is not much difference in appearance between mobile and AMP.

    Is there a way to customize those theme’s AMP files themselves? If that is something I could take a peek at then I could add to the Legacy theme.

    Thank you @jamesosborne and @westonruter for getting back to me with help! I appreciate it.

    Plugin Author Weston Ruter

    (@westonruter)

    We do have documentation for how to customize the legacy/classic templates: https://amp-wp.org/documentation/playbooks/classic-templates/

    However, the approach you shared of appending the bbPress comments and breadcrumbs via filtering the_content seems like it will be the easiest.

    I’m not familiar with developing with bPress, but you can find a list of template tags here (which may not be up-to-date): https://codex.bbpress.org/legacy/template-tags/

    Perhaps you’re looking for the bbp_get_breadcrumb() function which you can append to the $content.

    Thread Starter T4G

    (@tips4gamers)

    I actually have that documentation bookmarked and I just haven’t found anything for forums or maybe I just don’t understand it fully. I am not sure where I can find other theme’s AMP code, such as Twenty Twenty-one, etc.

    The bbp_get_breadcrumb() is exactly what I am looking for. I implemented the following code and it didn’t work, unfortunately:

    add_filter(
    	'the_content',
    	function( $content ) {
    		if ( 
    			function_exists( 'amp_is_request' )
    			&&
    			amp_is_request()
    			&&
    			function_exists( 'amp_is_legacy' )
    			&&
    			amp_is_legacy()
    			&&
    			shortcode_exists( 'bbp_get_breadcrumb()' ) 
    		) {
    			$content = '[bbp_get_breadcrumb()]<hr>' . $content;
    		}
    		return $content;
    	}
    );

    I have tried different variations and tried adding it to the $content that already exists, which I have provided opening the topic. I don’t fully understand how to write PHP but I understand a little.

    I don’t expect you or anyone else to give me the correct code as it may fall beyond support. I will do more digging and try to figure something out. Thank you both for your help, you are much appreciated!

    Best regards

    Plugin Author Weston Ruter

    (@westonruter)

    It looks like you’re not calling the breadcrumbs function properly. This should work better:

    add_filter(
    	'the_content',
    	function( $content ) {
    		if ( 
    			function_exists( 'amp_is_request' )
    			&&
    			amp_is_request()
    			&&
    			function_exists( 'amp_is_legacy' )
    			&&
    			amp_is_legacy()
    			&&
    			function_exists( 'bbp_get_breadcrumb' ) 
    		) {
    			$content = bbp_get_breadcrumb() . '<hr>' . $content;
    		}
    		return $content;
    	}

    Again, I’m not familiar with the bbPress API functions, so I don’t know if bbp_get_breadcrumb() is right. But if that is the right function, then this code should work.

    Thread Starter T4G

    (@tips4gamers)

    Thank you for that code. I tried it out and there was a critical error. Then I removed that period after the breadcrumb code $content = bbp_get_breadcrumb() . '<hr>' and the critical error was gone but the breadcrumbs weren’t there.

    However, we ended up switching to the Astra theme in the Reader Mode because there were things we just couldn’t do with the Legacy theme that we can Astra or any other AMP theme listed there.

    We are getting an “Error in required structured data element” via the Search Console. When I tested the structured data I got Missing field “image”. This was true with Legacy, Astra, and Twenty Twenty-One. Not sure if you would like me to open another ticket for this or if this is on Yoast SEO and I should contact them instead?

    This issue is not related to all AMP pages, just 4 out of 100 so far.

    Best regards

    Plugin Author Weston Ruter

    (@westonruter)

    Yes, that would be something to investigate with Yoast.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding bbPress Comments and Breadcrumbs to Forums for AMP Legacy’ is closed to new replies.