• For some reason, my get_permalink entry is not translating to the actual url, which also messes up the layout…

    Here’s what shows in the text tab of my page editor:
    <p class="float_right"><a class="pushbutton" style="width: 48px;" title="Features & Benefits" href="<?php echo get_permalink( 91 ); ?>">Explore</a></p>

    Here’s what comes out in the page’s source:
    <p class="float_right"><a class="pushbutton" style="width: 48px;" title="Features & Benefits" href="<?php echo get_permalink( 91 ); ?>*#8220;>Explore</a></p>

    I replaced & with * in character code so it wouldn’t translate in this post… sometimes it doesn’t get replaced. Very inconsistent.

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Are you trying to do this through the wordpress editor, or an external text editor.

    You can’t natively put PHP into the wordpress page editor.

    Also, I see you have a “fancy” quote after the PHP tag and that probably won’t process correctly.

    Thread Starter buddyglass_00

    (@buddyglass_00)

    Thanks greendemiurge,

    I am using the text tab in the wordpress page editor, which shows the html code included with content.

    If I can’t use template tags in the page editor at all, can you give advice on how I insert links that will be relative to the site when I migrate it from my local wamp installation?

    Sure can.

    The easiest way is to use the link tool like normal, but delete out your base url in the URL field.

    So, if you are given http://localhost/sample-page you would delete http://localhost so that only “/sample-page” is left (assuming wordpress isn’t going to be installed in a directory. The first slash tells it to find the page in the root).

    A better long-term strategy if you are going to be spending more time developing with WordPress is to get comfortable porting sites by using MySQL queries. With WAMP you should have PHPMyAdmin available. If you run these two queries it will change both your base domain and, more importantly, the image permalinks that are easy to overlook:

    UPDATE db_name.wp_options SET option_value = “http://newdomainname.com&#8221; WHERE option_value = “http://olddomainname.com&#8221;

    UPDATE db_name.wp_posts SET post_content = replace(post_content, ‘http://olddomainname.com&#8217;, ‘http://newdomainname.com&#8217;);

    db_name is the name of the database (as can be identified in your WP-Config.php file. http://olddomainname.com can be any old domain, whether you are going from localhost (http://localhost), a directory on localhost (http://localhost/sampledirectory) or another hosted domain.

    Running these two queries will fix 99% of all migration issues, including dead images.

    Using relative urls with WordPress is not a Good Idea(tm). They can behave quite unpredictably, It would far better to use a PHP plugin that allows to post code in widgets and then use the appropriate PHP template functions – eg: <?php echo get_permalink( 91 ); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_permalink not working’ is closed to new replies.