How to add PHP code in functions.php wordpress

<?php //Insert ads after second paragraph of single post content. add_filter( 'the_content', 'prefix_insert_post_ads' ); function prefix_insert_post_ads( $content ) { $ad_code = '<div>Ads code goes here</div>'; if ( is_single() && ! is_admin() ) { return prefix_insert_after_paragraph( $ad_code, 2, $content ); } return $content; } Hi, how to repace <?php $a1 = get_field('fa1', 'option'); if ($a1) : … Read more

Question about repurposing WordPress 404 handler

I’ve been experimenting with repurposing WordPress’s 404 handler/template file for a Real Estate site that I’m developing. I understand that when a non-existent URL is requested, the 404 page gets served up and that it returns a 404 status code (instead of a 200). But I’ve recently found a way to adapt the 404 template file so that it does something a bit more creative. More specifically, I’m first parsing the non-existent URL that was requested, and then using the returned value to query an external API and then display the returned data. So far it’s working much better than I’d expected, though I’m aware of one significant issue that I’m hoping I can address.