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 column count doesn’t match value count at row 1 [closed]
- Undefined function mysql_connect()
- Fatal error: Call to undefined function mysql_connect()
- Fatal error: Call to undefined function mysql_connect()
- Deprecated: mysql_connect()
- MySQL “Or” Condition
- the_date() not working
- How to return number of found rows from SELECT query
- dbDelta support for FOREIGN KEY
- How to Remove all Instances of edit_post_link
- Transaction when using WP functions rather than vanilla SQL?
- Can i use php sql functions instead of $wpdb?
- is it possible to run some php code within a wordpress page?
- How to correctly submit a search form and display the result in an independent page
- Query both first_name and last_name from wp_usermeta at the same time
- Check if post of title already exists
- How to export/import theme customizer settings?
- $wpdb->delete column values IN ARRAY()?
- How to validate WordPress generated password in DB using PHP?
- How to get the list of WooCommerce product image of a certain category from database?
- How to use update and delete query in wordpress
- How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table
- Site Title and Tagline in Theme Options Page
- Custom query to get post names beginning with a digit
- How to make WordPress plugin check for database changes and then do something?
- Custom SQL query to get List of posts with featured image url
- How to detect if a revision was made by woocommerce or wordpress?
- WordPress WPDB::insert 13th param is always blank (only if format)
- Ajax not updating to database
- SQL Query Search page
- How can I display a query in a page?
- can’t delete a row from post_meta table
- Include a custom field in mysql query
- Send data from plugin to external database
- MySQL query in WordPress with AJAX
- Processing forms with php to wordpress database
- How to properly send many mysql queries via php and what happens with ajax requests after they are sent?
- Conditional statement within WP SQL query
- How to set max users to 17.000
- Passed variable gets undefined variable error on insert on next page
- directorypress theme error mysql_error() [closed]
- How to set up an auto delete post?
- WordPress upload images not displaying
- MySQL queries in WordPress
- two wordpress sites, two themes, one database, same content
- how to check for wordpress Query errors
- Insert double entry in DB
- How to connect database table to each registered wordpress user.
- retrieve wordpress post-meta using php not wordpress functions
- wp_customize_image_control default value
- Splash pages on a high traffic site
- WordPress Setting page can not be saved by html radio
- Using the same shortcode to show any table from the database
- Splitting One Big WordPress Site into Multiple Small Sites
- Let users register weight each day and save it in DB
- MySQL database migration to WordPress
- Not able to call class in NHP framework
- Changing 2011 theme header image based on user dropdown
- Category List in Theme Options Page
- Where are Sessions are being started? [closed]
- Cannot Upload Custom Header Image into WordPress Dashboard
- How to change a specific character in a theme option value – replace a space with a plus sign
- Custom query_posts() parameter
- MySQL update text field with ‘
- Setting field not saving on front-end
- How to pass username into form that sends data to database
- How to edit the default database of WordPress [closed]
- Query Concatenation
- Select area and checkbox data is not saving?
- Options.php loop won’t show!
- Predefine Magazine Style Layouts
- I am unable to fetch json data from wp_db
- How do I remove blog entries from home page Twenty Eleven child theme?
- Submit cf7 form to cfdb as pdf/BLOB [closed]
- Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\admin\products.php on line 148 [closed]
- Your PHP installation appears to be missing the MySQL … After deleting and restarting from cpanel
- How to send push notification in android using php? [closed]
- Display total count of products in orders of a specific order status
- How to set variable to specific field when querying
- How to get a database field value from a WordPress table? [closed]
- Getting invalid user ID error when creating a new user with wp_insert_user
- Execute multiple PHP Snippets causes error?
- Custom form that stores data in mysql database
- Error resetting database index using ALTER TABLE in $wpdb->query
- what to do after instlling cyberpanel on VPS
- Putting form result in my database
- How can I update a value of a field depending on outside source?
- running an existing WordPress site from Visual Studio Code?
- Can’t insert into a database wordpress
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax [closed]
- Global update of records after import WP All Import Pro
- WordPress Customizer – How to save list of checkbox of pages?
- Updates applied to staging WordPress site affecting production even with different databases
- Help with creating commenting system using PHP, jQuery and AJAX
- WP-CLI PHP Deprecated Warning
- WordPress install on new server not recognising MariaDB version
- How to properly prepare a column name if passed to a stored procedure?
- How to return count number from a wordpress database
- Trying to GET data with ajax from database and show in fullcalendar