Support » Plugins » Hacks » shortcode function

  • Resolved danielpol


    Hi guys
    I have an issue with this function

    What the function does is to replace the shortcode from a page with specified post title. The shortcode from the page is like [[123]] , where 123 is the ID of the post.
    It works but needs a little tweaking and my php skills suck.
    It returns the titles like <li> title </li> but I want all the <li> inside <ul> ... </ul>.
    The return $content; returns not just the <li>title</li> but also the content of the page where the shortcode is .

    Anyone can help ?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi, please take a look here:

    I added 2 lines around $postTitleText (line 20, 22).

    This will only work if your shortcodes are next to each other, if you have other text in between it will wrap it all in the </ul>

    Hope it helps!

    shabar I added the 2 lines but bothing happens, it’s the same with or without the 2 lines.
    Thanks for your time.

    Did you change line 21 too? You need to add the ‘.’ like this:

    $postTitleText .=

    oops, sorry.
    changed it now but still doesn’t work as expected
    I get this

         the page content

    This is strange

    Can you paste the post content so I can see what you’re running this on?

    I used something like this and it worked:

    Page content here

    This is what i have

    866  841  866  841
    <h4>Lorem ipsum </h4>

    Because you’re replacing a particular post id using the regular expression, it will replace each occurrence of the post id at the same time.

    So. If you try [[866]] [[841]] only the code should work fine.

    The problem in the example is that both times [[866]] occurs it is being replaced by the link that logically opens the<ul>.

    Does that make sense? Please try without duplicate post ids, it should work.

    Ah, it WORKS. Silly me 🙂
    Thanks a lot shabar.
    I owe you

    My pleasure.
    That’s what the forums are for 😀

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘shortcode function’ is closed to new replies.