WordPress.org

Ready to get started?Download WordPress

Forums

slug equivalent for $post->ID ? (2 posts)

  1. marenm
    Member
    Posted 1 year ago #

    Hi there!
    Can anyone tell me if there is a slug equivalent to $post->ID ?

    Basically I'm dealing with a ton of different stylesheets and it would be great if I could organize them by slug rather than ID.

    I'm using this code/method in my functions.php file:

    function artStyle() {
        global $post;
        if (is_single()) {
            $currentID = $post->ID;
            $serverfilepath = TEMPLATEPATH.'/art-direction/style-'.$currentID.'.css';
            $publicfilepath = get_bloginfo('template_url');
            $publicfilepath .= '/art-direction/style-'.$currentID.'.css';
            if (file_exists($serverfilepath)) {
                echo "<link rel='stylesheet' type='text/css' href='$publicfilepath' media='screen' />"."\n";
            }
        }
    }
    add_action('wp_head', 'artStyle');

    from this source: http://digwp.com/2010/02/custom-css-per-post/

  2. michael.mariart
    Member
    Posted 1 year ago #

    If you look at the database table for wp_posts, you'll find this easily. it's $post->post_name;. You should be able to use this anywhere that you have a $post object.

Topic Closed

This topic has been closed to new replies.

About this Topic