• I have contact us with a web link in every page the link is a php code (pasted below)
    https://<?php echo get_permalink(’28’); ?>

    This code executes in every page except in one page. Don’t understand why. The code actually gets the link url to contact form. Appreciate any help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Are you actually putting “https://&#8221; in front of <?php echo get_permalink('28'); ?>? Because that’s uneccessary.

    What exactly is happening on the page where it’s not executing?

    Thread Starter icswp1

    (@icswp1)

    Yes the https:// is there. It gives not available error because the url generated by the code is like this

    https://%3C/?php%20echo%20get_permalink(%2728%27);%20?%3E

    In pages where it is working the executed code produces an url like https://mydomain.com/contact/

    Have you tried just using:

    /contact/

    for the url?

    Why make WordPress do so much work when you know the URL folks need to get to?

    Thread Starter icswp1

    (@icswp1)

    Using /contact/ works. However, the reason it is coded this way is to minimise future changes easy. Say, you want to change the contact to some other location, all you have to change is point that id 28 in the database to the new location. No need to change code. If you hard code, then you have to change the code everywhere. BTW, the only page where the code is not executing is in the home page (Font Page).

    And it also points to any page id (28 in this case) with a slug of ‘contact’ too.

    Since you cannot have two slugs the exact same, I am still not agreeing with what would be easiest.

    Anyway, how about this:

    Please use Pastebin to share the both the Page Template in use for your Home Page and the Page Template for a Page that this works on?

    You are using Page Templates for this, yes?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Php code not executing in one page but executing in others’ is closed to new replies.