• Resolved cyazhan

    (@cyazhan)


    hi all..

    i have problem in customization wordpress. i want to put this changes on single.php. the situation is related to post_id. i want to display different word based on the last number of post_id.. so i can have 10 different word for SEO purposed ??

    for example the post_id is 101: the last number is 1. so the word that i want to display is “Best”. if the the post_id is 102: the last number is 2, so the word that i want to display is “Top” and so on.

    Can anyone help me??

    the logic is:
    1. define the word to display (10 set)
    2. get post id
    3. check last number of the post (0-9)
    4. display the word

Viewing 2 replies - 1 through 2 (of 2 total)
  • Something like this maybe?

    <?php
    $words = array (
        'First',
        'Second',
        ...
    
        'Tenth'
    );
    
    $word_number = substr ($post->ID, -1, 1);
    echo "<p>Word number: '".$word_number."' from '".$post->ID."'</p>";
    $word = $words [$word_number];
    
    echo '<p>'.$word.'</p>';
    ?>
    Thread Starter cyazhan

    (@cyazhan)

    thank you so much!! thank you for the solution. this is exactly what i need.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post_id related customization’ is closed to new replies.