Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End permalink shortcode bug

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #37622
    localpulse
    Member

    I need a permalink shortcode to use in a Genesis theme for the Post Meta region of WordPress post. The shortcode is needed because I’m adding a filter to the genesis_post_meta function. Anyway when I put this code into the functions.php file:

    function permalink_function($atts) {
    extract(shortcode_atts(array(
    'id' => the_ID(),
    'text' => "Buy" // default value if none supplied
    ), $atts));

    if ($text) {
    $url = get_permalink($id);
    return "$text";
    } else {
    return get_permalink($id);
    }
    }
    add_shortcode('permalink', 'permalink_function');

    /** Customize the post meta function */
    add_filter( 'genesis_post_meta', 'post_meta_filter' );
    function post_meta_filter($post_meta) {
    if (!is_page()) {
    $post_meta = '[permalink] [post_tags]';
    return $post_meta;
    }}

    I get this:

    Again, this is mostly the code from digwp.com yet I’m getting the post ID above the link anchor text. Any help is appreciated!

    #101159
    localpulse
    Member

    Sorry the link to the original article is Here.

    #101164
    localpulse
    Member

    I finally got it working. The probelms was with this line:
    get_permalink($id)

    get_permalink() gets the current ID by default. Also the ‘id’ offset (PHP array element) should be initialized to 1, as per the tutorial.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.