Using MY Includes in WordPress

On my non-WordPress sites, I generally insert information common to multiple pages in one of two ways:

  1. Simply include a file containing the information
  2. Include a simple value in the article stored in the database (e.g. $Symbol - without the PHP tags), then use str_replace to replace that value with something

Can someone tell me how to do that in WordPress? I started playing with the Custom Field and Shortcode functions, but I’m not getting anywhere. It’s needlessly complex, and the directions are very confusing.

I think the simplest solution would be to include a separate PHP file by default.

For example, let’s say I create a file at wp-content/themes/twentyfifteen-child/custom.php

How could I include that in every post by default? If I can accomplish that, I could then create a switch that displays certain blocks of information based on a post’s URL, tags, etc.

Thanks.

One way you could do this would be to put that content in a post maybe with a specific category. Then place a loop in page.php or single.php (if you’re inserting it into a post) where you want that content to go that queries that particular category.

Thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.