Symbols | World
Books | Store | Blog
About | Contact

Help Request

This is a long question, so I posted it on my website . . .

Now that I have page ID’s, I would like to use them to help me manage my site. I think the simplest way to do that is to create a PHP switch. However, I don’t know how to do that in WordPress. I’m not even sure how to write PHP code in WordPress.

However, if you can set it up for me and create a few basic scripts, I should be able to follow your example and finish the project. This is what I have in mind . . .

First, if you visit https://symbols.geobop.com/world/north-america/usa/, https://symbols.geobop.com/world/north-america/usa/ak/, and https://symbols.geobop.com/symbols/sos/flag/north-america-flags/us-flags/ , you will find the following code at the bottom of each page:

USA

<div class="div–img div–home x–w25"><a href="/north-america/" title="North America"><img src="/wp-content/uploads/north-america-home.svg?v2" alt="North America Home"></a></div>

It looks like this:

North America Home
Alaska

<div class="div–img div–home x–w25"><a href="/usa/" title="United States"><img src="/wp-content/uploads/usa-home.svg" alt="United States Home"></a></div>

It looks like this:

United States Home
State Flags

<table class="table–85 x–w30">
<tr>
<td style="width: 50%;"><a href="/flag/" title="Flags"><img src="/wp-content/uploads/flag-home.svg" alt="Flags"></a></td>
<td><a href="/usa/" title="United States"><img src="/wp-content/uploads/usa-home.svg" alt="United States"></a></td>
</tr>
</table>

It looks like this:

Flags United States

I would like you to replace each of those three blocks of code with a PHP echo statement. (I think it’s called “short code” in WordPress.) It might look something like this:

[bottom-home]

I.

Next, we need to make [bottom-home] display the same code it replaced.

First, I need scripts (a PHP switch?) that define USA (id=”usa”) as the parent of Alaska (id=”ak”) and North America (id=”north-america”) as the parent of the U.S.

It might look something like this:

switch($ID)
‘usa’;
‘can’:
‘mex’;
$Parent = ‘North America’;
$Parent-URL = ‘north-america’;
switch($ID)
‘al’;
‘ak’:
‘ny’;
$Parent = ‘United States’;
$Parent-URL = ‘usa’;

Then I need another script that defines North American Flags (id=”north-america-flags”) as the parent of U.S. State flags (id=”us-flags”). For now, we can just use this:

IF $ID = ‘us-flags’ $Parent = ‘North American Flags’ and $Parent-URL = ‘north-america-flags’

II.

Now that these pages have parents, we can create scripts that determine what [bottom-home] displays on each page. Something like the following should work for the first two pages (USA and Alaska):

IF $Parent = ‘north-america’ OR ‘usa’

$bottom-home = ‘<div class="div–img div–home x–w25"><a href="‘.$Parent-URL.’/" title="‘.$Parent.’"><img src="/wp-content/uploads/‘.$Parent-URL.’.svg" alt="‘.$Parent.’ Home"></a></div>’;

For the third code (us-flags), just echo the same code that was on the original page, like this . . .

IF $ID = ‘us-flags’

$bottom-home = ‘<table class="table–85 x–w30">
<tr>
<td style="width: 50%;"><a href="/flag/" title="Flags"><img src="/wp-content/uploads/flag-home.svg" alt="Flags"></a></td>
<td><a href="/usa/" title="United States"><img src="/wp-content/uploads/usa-home.svg" alt="United States"></a></td>
</tr>
</table>;

Using your code for the first two pages, I can later figure out how to modify it and adapt it to work with similar pages.

* * * * *

If I’m doing something wrong, or you know a better way to do something, please let me know.

When you’re finished you can tell me how many credits I used up and how much I owe you. Or you can bill me first. Please tell me how to pay it.

Thank you!