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?


  • Please explain your question better. It is hard to understand your problem. – fuxia 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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