WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i will get id on current page.

    $hasil = $wpdb->get_results("SELECT id,bab,tema FROM $tabel ORDER BY bab ASC");
    foreach ($hasil as $bab) :
            <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>
    <?php endforeach; ?>

then urls showing :


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

but i will urls showing :


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?


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

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

Your Answer


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.