The options are being output within the loop, so are being repeated for each iteration of the loop.
To check within the loop and only output something on the first iteration:
while ( have_posts() ) : the_post();
if( $wp_query->current_post == 0 ):
// this is the first post
// output your options
endif;
// other loop stuff, title, content, etc.
endwhile;
similarly, to check if you are on the last post of the loop:
while ( have_posts() ) : the_post();
if( $wp_query->current_post == ( $wp_query->post_count - 1 ) ):
// this is the last post
endif;
endwhile;
Related Posts:
- Undefined function mysql_connect()
- MySQL “Or” Condition
- Transaction when using WP functions rather than vanilla SQL?
- Can i use php sql functions instead of $wpdb?
- How to validate WordPress generated password in DB using PHP?
- Custom query to get post names beginning with a digit
- How To Make Connection To WordPress Data Base In A Plugin?
- Jquery ajax to custom php file: returning blank data
- Add value to usermeta without removing previous values?
- How can I call a row of user specific data from a custom table added to the WP Database
- How to merge local and live databases?
- How to track a users progress through pages by inserting data into WordPress Database?
- the_author_meta not working
- Performance issues with large website [closed]
- Create a quick start wordpress installation [closed]
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- PHP/MySQL issues when running WP on EC2 cloud [closed]
- WordPress 3 – how are passwords stored and how do I compare to them?
- WordPress get pagination on wpdb get_results
- Theme Options: If There is No Input, Don’t Display?
- How to create another version of my site based on the same database
- how to echo all tables that start with a prefix
- Looking for most performant way to execute several similar WP queries within shortcodes
- How to select WooCommerce products by post_meta and order them
- Stumped on migration
- Displaying theme options in css
- PHP code inside shortcodes
- max_input_vars: how many am I using?
- Show MySQL errors that occur when I excute $wpdb->insert()
- Is XAMPP faster than running LAMP in WSL on Windows 10? [closed]
- Remove one value in dismissed_wp_pointers?
- WordPress Site Running Extremely Slow on Dedicated Server
- Accessing data from a non-WP database/table within a page content
- Get updated query results on page after insert in database
- WordPress not reflecting changed of the database
- Selectbox in admin panel function linking to CSS
- Using if/else statements with output from theme options
- How can I fix WordPress installation errors?
- How can I save unique user data on my site? [closed]
- Ordering users by custom user meta
- How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?
- Hacked WordPress website /Homepage redirect [closed]
- Refresh table data with Ajax
- Database query works fine outside WordPress
- Large Woocommerce Site (83,000 items), What Can I Do? [closed]
- Using custom tables for old posts
- Help with a $wpdb MySQL Query
- How i can obtain all the post meta for a specific post as an array?
- Three Questions with Twenty Eleven theme
- Multiple meta_key in one global $wpdb;
- WordPress member notification
- Can’t Query Custom Table Using $wpdb Method
- Moving wordpress site from localhost to live server using GoDaddy cPanel
- How does WP work in conjunction with a web server?
- $wpdb returns duplicate posts
- Update postmeta after theme switch
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Location of core code for database connection and get_header
- Creating Database Table vs. Adding MetaData to Post & User
- How to add drag and drop functionalities to a div inside option panel
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Most commented posts by time period (last 12h, last 24h and etc)
- Hide posts if user is added to it WP_query
- How to unserialize data from MySQL
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- WordPress WP_Query without query GET parameters
- Known Issues in WordPress When Upgrading PHP to ver 7
- Get the id of the row from database on click of a button [closed]
- WPDB secure custom form
- PHP if have image display image, if else text
- Query the links Database
- what does $options = get_option(‘test_theme’); do?
- making my own “related pages” / “pages you might like” section
- SQL error with custom query
- Modify WooCommerce used to get all orders in dashboard
- Display Results of SQL Query on WP site
- Weird fonts showing which are coming from database
- PHP Warning: mysqli_query(): after updating my websites php from 5.6 to 7.2
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- WordPress Bad Request Error 400
- I am facing this error Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- How to display MySQL table data which is stored as an array?
- What is the correct way to search 3 custom fields only in WordPress?
- cant insert data in a custom table in phpmyadmin
- How to import woocommerce custom fields data into another site?
- autocomplete in wordpress using ajax with json-data
- New database entry to trigger runing PHP/SQL query through link with token, without logging into the website
- Query doesn’t display text data with apostrophes
- I want show only data for today
- SQL Query Search page
- MySQL queries in WordPress
- Let users register weight each day and save it in DB
- Where are Sessions are being started? [closed]
- Setting field not saving on front-end
- How to pass username into form that sends data to database
- Your PHP installation appears to be missing the MySQL … After deleting and restarting from cpanel
- Getting invalid user ID error when creating a new user with wp_insert_user
- Custom form that stores data in mysql database
- Putting form result in my database
- How can I update a value of a field depending on outside source?