Support » How-To and Troubleshooting » [Resolved] How to get a slug from the db?

[Resolved] How to get a slug from the db?

  • Hi there,

    I need to “rebuild” a permalink-like link on the fly incorporating the slug …

    I am not a programmer and I am stuck. This is what I got and need but I have no idea what on earth I need there:

    $email_link = get_option('blog_base').'/'.$id.'/'.NEEDSTOGORIGHTHEREANDIDON'TKNOWHOW.'/';

    I have added the option blog_base to the db …. the wp-email script doesn’t like to function from urls different from the domain added in the blog … it even differentiates between www/non-www urls.

    Anyhow, so I want to force the plugin upon calling into action to link to the url it wants. That’s why I need to rebuilt the url looking almost like it ought to. Yet I can’t get the slug … Anybody able to assist me?

Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi


    Forum Moderator

    Where are you using this code? Inside a page or post? Inside the Loop?

    The email link shows up on page and post upon clicking headline or more. So each page or post has an icon embedded in an href and so far the function in each page or post looks like that:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
    	<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link:  <?php the_title(); ?>"><?php the_title(); ?></a></h2>
                 <!-- Rate / Print / Email Funktionality added with WP-Postrating, WP-Print and WP-Email, icons custom -->
                  	<!-- <div  style="float:left; padding-top:3px;"><small><?php if(function_exists('the_ratings')) { the_ratings(); } ?></small></div>-->
                        <div align="right"><?php if(function_exists('wp_email')) { email_link(); } ?> <?php if(function_exists('wp_print')) { print_link(); } ?></div>
    	    <!-- End of Adaptation --

    So basically I call wp_email() there. The code for wp_email is in the plugin itself, located of course in wp-content/plugins/wp-email or the like. WP-email.php calls for load.php and config.php.

    So I think I can use whatever it does in those. But that is about as far as my knowledge takes me.

    Check out the dynamic link for a post/page:


    It MAY help you!

    Nay, sadly not. What I need is to redo such dynamic link to be comprised of several individual parts. I am able to call almost all the parts I need … as in base url, than the relevant Id … but what is missing is the slug/post_name …..

    Check that post again… at the bottom 😉

    Did you see the section titled ‘Get Slug:’? is this not what you want?

    *cough* I missed that part … blond me *slap on forehead*

    Thank you guys for pointing out the obvious to me 🙂 That is very similiar to my attempts, which all failed as I was lacking appropriate grammar.

    I truly appreciate your help. Thank you soooo much. You guys have saved my evening.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] How to get a slug from the db?’ is closed to new replies.