Support » Plugins » Hacks » [Plugin Category Shortcode] Wrong links (edit, permalink, etc) on parent page

  • Resolved Angela



    I’ve been hacking away at the Category Shortcode plugin and have successfully added several new options. I’ve noticed, however, that the original code has an odd side effect, and while I haven’t been able to fix it, I’ve been able to narrow it down to a specific function used in the plugin.

    The “Edit,” “Permalink,” and “Trackback” links on the parent page are those for the last displayed child page, and not for the parent page. You can see it in action here:
    You’ll notice that the links at the bottom that should point to the “/shop” page are instead pointing to the “Wobblecog Necklace” post.

    The problem *seems* to be with the set_postdata() call (first used on line 94 in the original code). The surrounding code looks a bit like this:

    90: global $post;
    93: foreach($rdcsc_posts as $post) :
    94:     setup_postdata($post);
    95:     $rdcsc_excerpt = get_the_excerpt();

    I’ve tried renaming certain variables or using different template tags, but nothing so far has worked. Here’s where I hope you lovely folks come in! 🙂 Is there a way to fix this problem?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Unless I’m missing something, the permalink and trackback link at the bottom of your page are directed correctly. Permalink goes to and the trackback goes

    Sorry, I’ve been playing with the code again. 🙂 The page should be displaying properly now. (Well, as properly as it’s ever been.)

    This weekend I’ll see if I can delve into the issue a little deeper, but I saw something similar to this once before where the post loop was basically overwriting all of the information for the page by the time it displayed it. I never found a really satisfactory solution from a plugin standpoint, but I was able to code around it by making a page template that explicitly pulled in the link for the displayed page. That may work for you as a solution – at least a temporary one.

    And if you or anyone else finds something – I’d be more than happy to merge the patch into my code and drop some acknowledgments into the description.

    There may be something to the reset query function to look into…

    Also as an idea, it should be possible to run the loop after the plugin runs and reacquire the original page’s data. I’m not sure that’s a good way of doing it from a coding standard viewpoint…I’d need to delve a little more into wordpress’ coding guidelines I guess.

    Thanks for the insight, Robert! I’ll keep digging around and see what I come up with, then post it here.

    Aha! I’d been looking into wp_reset_query() when you mentioned it. After a bit more poking, I found that adding it toward the bottom of the rdrakeCategoryShortcode_function() function does the trick, like so:

    156: wp_reset_query();
    157: $rdscf_output.='';
    158: return $rdscf_output;

    It has to be in that particular location; placing it at the very end of the function (before the closing }) essentially nullifies it.

    I’ll run a few tests this weekend and roll that into a patch. Thank you very much for the assistance with this!

    Released version 1.3 with your patch. Thank you again for your work with this.

    No problemo! Glad to have helped. 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin Category Shortcode] Wrong links (edit, permalink, etc) on parent page’ is closed to new replies.