WordPress.org

Support

Support » How-To and Troubleshooting » get_permalink() returns empty for certain page IDs

get_permalink() returns empty for certain page IDs

  • <ul class="stageList2">
        <li><a class="sel">Stage 1</a></li>
        <li><a href="<?php echo get_permalink(1030); ?>">Stage 2</a></li>
        <li><a href="<?php echo get_permalink(1032); ?>">Stage 3</a></li>
        <li><a href="<?php echo get_permalink(1034); ?>">Stage 4</a></li>
        <li><a href="<?php echo get_permalink(1036); ?>">Stage 5</a></li>
        <li><a href="<?php echo get_permalink(1038); ?>">Stage 6</a></li>
        <li><a href="<?php echo get_permalink(1040); ?>">Stage 7</a></li>
        <li><a href="<?php echo get_permalink(1042); ?>">Stage 8</a></li>
        <li><a href="<?php echo get_permalink(1044); ?>">Stage 9a</a></li>
        <li><a href="<?php echo get_permalink(1046); ?>">Stage 9b</a></li>
    </ul>
    
    <ul class="stageList2">
        <li><a href="<?php echo get_permalink(1048); ?>">Stage 10</a></li>
        <li><a href="<?php echo get_permalink(1050); ?>">Stage 11</a></li>
        <li><a href="<?php echo get_permalink(1052); ?>">Stage 12</a></li>
        <li><a href="<?php echo get_permalink(1054); ?>">Stage 13</a></li>
        <li><a href="<?php echo get_permalink(1056); ?>">Golf Stage 1</a></li>
        <li><a href="<?php echo get_permalink(1058); ?>">Golf Stage 2</a></li>
        <li><a href="<?php echo get_permalink(1060); ?>">Golf Stage 3</a></li>
        <li><a href="<?php echo get_permalink(1062); ?>">Golf Stage 4</a></li>
        <li><a href="<?php echo get_permalink(1064); ?>">Golf Stage 5</a></li>
        <li><a href="<?php echo get_permalink(1066); ?>">Golf Stage 6</a></li>
    </ul>

    I have this code on part of my page. I am trying to get the permalinks for these specific pages, but it returns nothing and the href attribute of the links are empty. If I use other IDs than these ones listed here, the permalinks are returned fine. Also, if I use these IDs to get a permalink on another part of the site, it is returned fine there too. There is something about this specific part of this page template and these specific page IDs that won’t allow me to return the permalinks.

    Has anybody ever experienced anything like this before? Is it some kind of bug that can be fixed?

    I have moved my entire WordPress website to a new server, and these permalinks were working completely fine on the other server. I have also disabled all my plugins to see if any of them were causing any errors, but it is still not working.

    Cheers,
    Ben

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘get_permalink() returns empty for certain page IDs’ is closed to new replies.