Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7013583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:24:26+00:00 2026-05-27T22:24:26+00:00

Ok, I’m going crazy over the_permalink() function. This is not going to be easy

  • 0

Ok, I’m going crazy over the_permalink() function. This is not going to be easy to explain the issue, but I will try. When I’m on the index page of my website(index.php), and when I click on a link that’s in the footer section, it will take me to the recent post (single.php), and that is fine. However, when I start off on the index page(index.php), and when I use the navigation bar to navigate to a certain page(page.php)(which has the same layout as the index.php), and then, when I click the same link that’s in the footer section it should take me to the recent post (single.php), but it is not. It’s taking me to the current page(page.php) instead of single.php. Here is a snippet of my code:

The footer:

   <div id="clear"></div>

        <div id="video">
            <!--<a href="http://www.youtube.com/watch?v=WYc4ZOxRX-4" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/video_03.png" alt="Video" border="0" width="263" height="193" title="Video" /></a>-->
            <iframe width="263" height="208" src="http://www.youtube.com/embed/WYc4ZOxRX-4?rel=0" frameborder="0" allowfullscreen></iframe>
        </div><!-- end of video -->

        <div id="weeklyadbox">
            <p id="content"><a href="<?php the_permalink(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/weeklyad.jpg" height="147" width="178" alt="Weekly Specials" border="0" title="Click to See Our Weekly Specials" /></a></p>
        </div><!-- end of weeklyadbox -->


        <div id="weathericon">
            <a href="<?php bloginfo("url"); ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons_03.png" border="0" alt="Weather Icon" title="See Weather" height="96" width="83" /></a>
        </div>

        <div id="directionsicon">
            <a href="<?php bloginfo("url"); ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons_04.png" border="0" alt="Directions Icon" title="Get Directions" height="94" width="96" /></a>
        </div>

        <div id="webcamicon">
            <a href="<?php bloginfo("url"); ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons_05.png" border="0" alt="Web Cam Icon" title="Web Cam" height="96" width="84" /></a>
        </div>

        </div><!-- end of container --> 

        <div id="footer">
        &copy;<?php echo date("Y"); echo " "; bloginfo('name'); ?>
         </div>

</div>

<?php wp_footer(); ?>

The_permalink() is fine when I’m in the index section, but not when I’m on a different page. I tried using echo get_permalink(53), and it worked, but what happens when a client goes in the dashboard and creates a new post? The new post will have a different post ID, and that link will not point out to the new post, but will point out to the old post that has an ID equals to 53.

If you need to see other code, please let me know!

Any advice? Thank you for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:24:27+00:00Added an answer on May 27, 2026 at 10:24 pm

    It looks like you are using the_permalink() outside the WP loop. get_permalink() works outside “the loop” because you are explicitly passing the “Post ID” to the function.

    Read this page explaining “the loop”
    http://codex.wordpress.org/The_Loop

    From looking at the snippet you posted that appears to be the problem.
    I posted some sample “loop” code below:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 
    <?php /** YOUR CODE HERE **/ ?>
    <?php endwhile; else: ?> 
    <p><?php
    _e('Sorry, no posts matched your criteria.'); ?></p> 
    <?php endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.