[resolved] How to get a slug from the db? (8 posts)

  1. chartinael
    Posted 5 years ago #

    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?

  2. esmi
    Forum Moderator
    Posted 5 years ago #

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

  3. chartinael
    Posted 5 years ago #

    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.

  4. Ryan Paul
    Posted 5 years ago #

    Check out the dynamic link for a post/page:


    It MAY help you!

  5. chartinael
    Posted 5 years ago #

    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 .....

  6. Ryan Paul
    Posted 5 years ago #

    Check that post again... at the bottom ;)

  7. vtxyzzy
    Posted 5 years ago #

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

  8. chartinael
    Posted 5 years ago #

    *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.

Topic Closed

This topic has been closed to new replies.

About this Topic