Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter vincent soo

    (@vincent-soo)

    Hi Swanson,

    I still can’t get it work, it since like the code from this link have error
    http://www.wprecipes.com/wordpress-function-to-get-postpage-slug

    function the_slug() {
    $post_data = get_post($post->ID, ARRAY_A);
    $slug = $post_data[‘post_name’];
    return $slug;
    }

    <?php echo the_slug(); ?>

    I try copy and paste exactly without changing any thing and it show error in the page…

    Thread Starter vincent soo

    (@vincent-soo)

    Thanks for the quick reply…
    Sorry my scripting knowledge is really beginner

    I have insert this script in function.php
    function the_slug() {
    $post_data = get_post($post->ID, ARRAY_A);
    $slug = $post_data[‘project-123’];
    return $slug;
    }

    And in my page.php when I call this function out, it just throw out error
    <?php echo get_the_post_thumbnail(the_slug(), ‘thumbnail’); ?>

    I know the way I insert the_slug() is wrong, I try a lot of way to writing it
    the_slug()->ID ,
    I even not using function straight
    $post_data = get_post($post->ID, ARRAY_A);
    $slug = $post_data[‘project-123’];

    <?php echo get_the_post_thumbnail($slug ‘thumbnail’); ?>

    But all just went wrong…can point me out the correct way of writing it?
    Thank you

    Thread Starter vincent soo

    (@vincent-soo)

    Hi Swanson,

    I am using Bones themes , Reason I wan it to be slug is because I will turn it to become a custom field, so I can just insert slug name instead of ID name.

Viewing 3 replies - 1 through 3 (of 3 total)