• Resolved AlexPR

    (@alexpr)


    I am using a shortcode with a parameter that refers to a different column. The shortcode [pl id='1212'] should return the permalink for the blog post with ID# = 1212. This works fine. However, when I want to refer to column G which contains the blog ID (1212) by using [pl id='G'] or [pl id="G"] or [pl id=G]I do get an empty string.

    Here is the source code of the shortcode

    How would I need to refer to column G and use the shortcode correctly?

    • This topic was modified 4 years ago by AlexPR.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    What do you mean with “column G” here? References can only be to single cells, but not to columns. Also, these references only work in TablePress formulas, but can not be used in Shortcodes like that. For that, the TablePress Single Cell Shortcode Extension from https://tablepress.org/extensions/table-cell-shortcode/ can be used – however, that also can not directly be used inside another Shortcode, due to how the WordPress Shortcode system works.
    So, unfortunately, I can’t really think of a solution for this here, sorry…

    That said, from my experience, I don’t really think that the scenario that you describe as the motivation for your Shortcode really is that common. First, WordPress actually maintains internal redirects when posts/pages are moved (i.e. get a new slug), so that you would be redirected automatically. And if the domain name changes, you could easily fix that using one of the available search/replace plugins (or, you could even leave out the domain from the link and use relative URLs (starting with / to indicate that it’s relative to the document root).

    Regards,
    Tobias

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi again,

    hold, this might actually work with a formula like

    =[pl id="{G2}"]
    

    where G2 would be the cell that contains a purely numeric ID.

    Regards,
    Tobias

    Thread Starter AlexPR

    (@alexpr)

    I see your point. Unfortunately I would need to refer to a whole column (similar to Excel). Could we use a DataTables function instead, e.g. the function Columns.Render?

    • This reply was modified 4 years ago by AlexPR.
    • This reply was modified 4 years ago by AlexPR.
    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    but how do you refer to a whole column? Or do you basically repeat this for every cell in the column?

    I don’t think that the DataTables approach would help, as that would all run in the browser, but you need the information on the server.

    Regards,
    Tobias

    Thread Starter AlexPR

    (@alexpr)

    That makes perfectly sense.
    Thank you very much, Tobias.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    sure, no problem!

    Best wishes,
    Tobias

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Shortcode with reference to different column’ is closed to new replies.