Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Global matrix for shortcodes/content for every page */
- $locations = array(
- array(
- 'location' => 'location 1',
- 'telephone' => '0121 34838383',
- 'email' => 'example@example.com'
- ),
- array(
- 'location' => 'location 2',
- 'telephone' => '92939393',
- 'email' => 'example2@hello.com'
- ),
- array(
- 'location' => 'location 3',
- 'telephone' => '343443433',
- 'email' => 'example3@help.com'
- ),
- array(
- 'location' => 'location 4',
- 'telephone' => '343433',
- 'email' => 'hello@theuk.co.uk'
- ),
- array(
- 'location' => 'Global Matrix Page',
- 'telephone' => '222 33 22',
- 'email' => 'wow@hey.com'
- )
- );
- function telephone_shortcode() {
- global $locations;
- $title = get_the_title();
- $key = array_search($title, array_column($locations, 'location'));
- if ($key)
- return $locations[$key]['telephone'];
- else
- return '';
- }
- add_shortcode('telephone', 'telephone_shortcode');
- function email_shortcode() {
- global $locations;
- $title = get_the_title();
- $key = array_search($title, array_column($locations, 'location'));
- if ($key)
- return $locations[$key]['email'];
- else
- return '';
- }
- add_shortcode('email', 'email_shortcode');
- /* End of Global Matrix */
- telephone = [telephone]
- email = [email]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement