Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:35:49+00:00 2026-06-12T22:35:49+00:00

This function creates <li> tags and im trying to give each li tag a

  • 0

This function creates <li> tags and im trying to give each li tag a unique CSS class name,
I’ve tried to create a for loop to generate numbers but this is producing the number 7 rather than counting down to the number 7 in <li> tag.

any help greatly appreciated!

function the_meta() {

if ( $keys = get_post_custom_keys() ) {
    echo "<ul class='post-meta'>\n";

 //tried to add this counter here to generate incremental numbers in the foreach loop
    for ($i = 0; $i <= 6; $i++) { } 

    foreach ( (array) $keys as $key ) {
        $keyt = trim($key);
        if ( is_protected_meta( $keyt, 'post' ) )
            continue;
        $values = array_map('trim', get_post_custom_values($key));
        $value = implode($values,', ');


        echo apply_filters('the_meta_key', "<li class='$i'><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);

    }


    echo "</ul>\n";
}
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:35:51+00:00Added an answer on June 12, 2026 at 10:35 pm

    This line of code:

    for ($i = 0; $i <= 6; $i++) { } 
    

    Will just increase $i until it get to 6,
    So when you’re getting to the “main loop” the variable $i will have the same value.
    Why having another loop to count?

    You can implement the counter inside your current loop:

    $i = 1; //Before the loop , set a starting value.
        foreach ( (array) $keys as $key ) {
            $keyt = trim($key);
            if ( is_protected_meta( $keyt, 'post' ) )
                continue;
            $values = array_map('trim', get_post_custom_values($key));
            $value = implode($values,', ');
    
    
            echo apply_filters('the_meta_key', "<li class='$i'><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);
    $i++; //Increase by one!!
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This function creates & stores a cookie, and here it stores the name of
I need to create a function that uses a loop. This function will open
I'm trying to do a bbcode parser class that can create personalyzed tags, but
I have this function in a Code Igniter model that creates a new video.
i'm referring this address for function olLiTree PHP function that creates a nested ul
ajax tutorial on w3school at http://www.w3schools.com/ajax/ajax_database.asp In this function (function GetXmlHttpObject()), it creates a
I have a function which creates an object of values, but im getting this
I have this function: CREATE OR REPLACE FUNCTION CREATE_AIRSPACE_AVAILABILITY_RECORD (cur_user VARCHAR, start_time VARCHAR, start_date
I have this function to create a request to another file to update the
I have created this function to check abecedarian with while loop (A word is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.