• I’m trying to change the footer based on what page you are on. This code seems to work then not work. Can someone please take a look and tell me what it could be?

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 13 replies - 1 through 13 (of 13 total)
  • you might need to reconsider what you are trying to output with:
    $urlAnchor = $catParent;
    this is definitively not clearly defined in archives and pages, and might be not defined if the first category in a single post does not have a parent category.

    can you describe in more detail, when the code works, and when not?
    possibly with a link to your site?

    Thread Starter patrickc1

    (@patrickc1)

    WTH? I don’t understand? I put code between backticks and it was removed.

    [mod: as the link to the forum rules states, there is a 10 line limit on direct posted code, to keep the forum space tidy]

    Thread Starter patrickc1

    (@patrickc1)

    <iframe src=”http://pastebin.com/embed_iframe.php?i=wT5gAQvm&#8221; style=”border:none;width:100%”></iframe>

    Thread Starter patrickc1

    (@patrickc1)

    I haven’t figured out when it works and when it doesn’t. I can’t tell if there is one thing causing it not to work. I’m very new to programming.

    Thread Starter patrickc1

    (@patrickc1)

    You can see it at lawnquipmentdealers . com go from page to page and look at the footer. It was all working, then it doesn’t work. Come back and it might work… πŸ™

    Thread Starter patrickc1

    (@patrickc1)

    Thread Starter patrickc1

    (@patrickc1)

    Im sorry. I’m trying to post the code and I just don’t understand. I went to pastebin and tried to embed both here.

    http://codex.ww.wp.xz.cn/Function_Reference/get_the_category

    this function only works for posts, and needs the post ID if not used in the loop.
    if used in an archive, without the post id, it is pure chance which post’s categories get returned.
    also, the first category in a post does not necessary have a parent category.

    these are probably the main causes for the stochastic functioning of your code.

    (seems to work fine on the front page, and on static pages.)

    Thread Starter patrickc1

    (@patrickc1)

    hmm so will this work but just take quite a bit more thought and recoding?

    yes – this can work, if you can put into words what you like to show as link text on single posts and on archives.

    Thread Starter patrickc1

    (@patrickc1)

    I”m trying to link from individual posts back to the city state category and from city posts back to the state category.

    So for instance:
    (post) bobs-dry-cleaning-in-atlanta-georgia would link to
    (archives) dry-cleaners-in-atlanta-ga which would link to
    (page) dry-cleaners-in-ga

    All done dynamically based on categories, etc.

    this would then only make sense in single posts (if the post does only have one category, and this category has a parent category – else the link text will be empty) and in category archives (where the category has a category parent – else the link text will be empty);

    maybe this could work:
    http://pastebin.com/PNcv4thf

    (also link url corrected for ‘is_page()’ )

    (untested)

    Thread Starter patrickc1

    (@patrickc1)

    Thank you! That does the link to the main page of the site and the main state page from the city archive / category correctly and consistently.

    It still sometimes adds a footer to the individual business page back to the state page but sometimes not.
    All of these should set up the same (parent category) business in state->business in city state (child category).

    for instance, this page should link back to the state page or the city page.
    www. lawnequipmentdealers . com/slayton-bros-in-jackson-al

    Thank you so much for your help. I’ve spent hours on this.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Echo link depending on page you are on code’ is closed to new replies.