Home » Php » javascript – WordPress > HTML/PHP/JS > change text of footer on a specific page

javascript – WordPress > HTML/PHP/JS > change text of footer on a specific page

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’ll try and be as clear as possible.
Info:
– WordPress Website

The website has 2 Languages Hebrew & English. The problem lies in the Footer.
I have 4 lines that will say:
– Address: ……..
– Phone: …….
– Fax: ……
– Email: ……[email protected]…com

Now this is all written in Hebrew and I want to change these into English when someone is looking on the English page.
In short, a way to target the Page ID (let’s say the page ID is 20 for the English main page and 30 for the Contact Us page) I want to target those Pages Footer and change those specific lines to a different one. I am also using ACF Pro.

In theory it will function like this:
If Page ID is = to 20 & 30 change text in the footer.

I can give the h4 and ID if that will help. As for the ACF I can just make new ones and call them address_en and have the address in English. Of course if there is a better way please let me know.

I have no idea how to go about this.

/* Some CSS not relavent */
	<footer id="footer">
		<div class="container">
			<div class="row">
				<div class="col-sm-6">
        // Some Code here not relavent
        </div>
        	<div class="col-sm-4">
				    <h4>כתובת: <?php the_field('address', 24); ?></h4>
				    <h4>טלפון: <?php the_field('telephone', 24); ?></h4>
				    <h4 >פקס:00-000-0000</h4>
				    <h4>כתובת אימייל: <?php the_field('emailaddress', 24); ?></h4>
				</div>
				<div class="col-sm-2">
          // Something here not relavent
				</div>
        
			</div>
		</div><!-- container -->

	</footer>
        

Have a great day.

How to&Answers:

When you call the_field('address', 24); you’re getting the ACF field from the post with the ID 24. That may not be what you want to do in a global element like a footer. ACF has an options page element which might be better suited for setting something like that.

If you went that route, you’re if/then statement would be something like this.

<?php 
  if (get_the_ID() != 20 || get_the_ID() != 30){
      the_field('address', 'option');
    } else {
      the_field('address_en', 'option');
    }
;?>