WordPress.org

Ready to get started?Download WordPress

Forums

Shortcode Exec PHP
[resolved] How to use [Url Toto][/Url] ? (9 posts)

  1. Agnes
    Member
    Posted 1 year ago #

    The plugin works fine, yet I have troubles to use for URLs
    I am setting
    [UrlToto] to output <a href="toto">
    [UrlElse] to output <a href="else">
    and would like to use
    [/Url] to output </a>
    But that breaks something there.
    I guess there must be a better way to do?

    http://wordpress.org/extend/plugins/shortcode-exec-php/

  2. Agnes
    Member
    Posted 1 year ago #

    OK, What I am really trying to do is to be able call an URL (using a global variable) but be able to import my own text in there

    Typically: Here is [UrlGamme text="my text"]
    That would output:

    <a href="$myUrlGamme">my text</a>

    For now I have put this in a shortcode:

    [UrlGamme]
    global $myUrl_Gamme;
    echo '<a href="';
    echo $myUrl_Gamme;
    echo '">';

    But I dont know how to pass the text parameter.... The doc I find is not for this plugin...

    Thanlks for help?

  3. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    Look at the bottom of the plugin page for a quick hint to pass parameters.

    If you need more information, follow the link 'Shortcode API' in the 'Resources' section in the left top of the plugin page.

  4. Agnes
    Member
    Posted 1 year ago #

    It is actually the quick hints that let me think I can do better than simple use :)

    I cant find the API link?

    Thanks for the support

  5. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

  6. Agnes
    Member
    Posted 1 year ago #

    Oh, I thought you were talking of an API for the plugin. But that is right, thanks!

  7. Agnes
    Member
    Posted 1 year ago #

    Thanks the Codex, I ve found the way to make one complicate one!

    This outputs the name and link of a top parent (Gamme), with the posibility to append a text bore the name and after the name, yet in the link.

    I can use
    [gamme] for the name and link to the Gamme (ex: "buffets")
    [gamme before="the best" after ="in Paris"] (ex: "the best buffets in Paris")
    [gamme] you won't forget[/buffets] (ex: "buffets you won't forget")

    $parents = get_post_ancestors( $post->ID );
    $myId_Gamme = ($parents) ? $parents[count($parents)-1]: $post->ID;
    $myUrl_Gamme = get_permalink($myId_Gamme);
    $myName_Gamme = get_the_title($myId_Gamme);
    extract(shortcode_atts(array(
    	"before" => '',
    	"after" => '',
    	), $atts));
    
    echo '<a href="'.$myUrl_Gamme.'" title="'.$myName_Gamme.'">'.$before.''.$myName_Gamme.''.$after.''.$content.'</a>';

    It would be nice to put on bottom of the plugin settings a link to the API WP codex that gives examples.

    Thanks for the prompt support!

  8. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    I am glad you sorted everything out.
    The link to the WordPress codex is in the yellow resources panel in the top right of the plugin page.

  9. Agnes
    Member
    Posted 1 year ago #

    Thanks!
    I suggest yet to add it to the bottom of the plugin settings page, aside the mentions on parameters - son one understand they are actually just nromal ones.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.