Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i will get id on current page.

<?php 
    $hasil = $wpdb->get_results("SELECT id,bab,tema FROM $tabel ORDER BY bab ASC");
    foreach ($hasil as $bab) :
    ?>
        <tr>
            <td><?php  echo $bab->bab;?></td>
            <td><?php  echo $bab->tema;?></td>
            <td><a href="<?php echo get_permalink(get_page_by_path('lks')).'?id='.$bab->id;?>">Kerjakan</a></td>
        </tr>
    <?php endforeach; ?>

then urls showing :

localhost/wordpress/lks?id=2

and works on after page if i call $_GET['id'].

but i will urls showing :

localhost/wordpress/lks/2

and i change permalink

<?php echo get_permalink(get_page_by_path('lks')).'/'.$bab->id;?>

Dont work on after page if i call $_GET['id'].

How can i get id 2 the url on after page?

or there are other ideas that I can get the id with the url?

Thanks.

share|improve this question
    
Please explain your question better. It is hard to understand your problem. –  toscho Aug 7 '13 at 22:30
    
@toscho my question is edit..sorry bad my english. –  defri Aug 7 '13 at 23:05
    
@s_ha_dum if i call get_permalink($bab->id); it's same if i call on page don't after page. –  defri Aug 7 '13 at 23:12
    
See the edit to my answer. –  s_ha_dum Aug 8 '13 at 0:10
add comment

1 Answer 1

I am not sure that I understand the question but if $bab->id is the ID in the $wpdb->post table then get_permalink($bab->id); will give you the permalink for the page.

If you are trying to get the ID of the page after you click those links, try:

echo $post->ID;
// or...
$pobj = get_queried_object();
echo $pobj->ID;

Again, it is very hard to tell what you are asking so I am making a series of guesses.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.