I’m surprised, your site works as desired, if you really call the_post
for the button. This function does not echo the post’s ID, it simply fetches the next post of the current query.
If I understood you correctly (and I’m not so sure about that), you only want to get the current post’s ID so you can work with it, right?
All you need to do is call the_ID();
wherever you want to output the ID. If you want to pass it to a function or in some way want to work with the data, use get_the_ID();
instead.
In your case, this would be:
<a href="#" onclick="amzn_onsitecartAdd('<?php the_ID(); ?>');" ...
Related Posts:
- How to put wordpress site behind AWS load balancer
- Hosting WordPress on AWS EC2 using CloudFront Dynamic Content Origins for page content
- Can’t Reach wp-admin
- How to prevent redirection from non-www to www or vice versa?
- How to Cache All WordPress Assets via CloudFront
- Pointing route 53 dns to wordpress site in AWS ec2
- WordPress hosted on AWS EC2
- Zoom in and cut images in Twenty Seventeen header image
- JW Player popup with s2member & amazon s3/cloudfront
- What is the difference between Amazon ECS and Amazon EC2?
- Difference between Amazon EC2 and AWS Elastic Beanstalk
- Emulator for Amazon Kindle
- S3 Bucket action doesn’t apply to any resources
- Your WSGIPath refers to a file that does not exist
- How to upload files straight to S3 without using local storage? [closed]
- How to run WordPress across 2 VMs for high availability
- Hosting a WordPress blog as a sub folder from a S3 website
- How does W3 Total Cache CDN URL rewrites work? [closed]
- Modify featured image path to Amazon S3
- Multisite, upload images directly to Amazon S3
- Using SMTP for outgoing mails (PHPMailer) on AWS instance?
- Upgrade to SSL Breaks Admin Dashboard
- How can I add programmatically custom taxonomy terms to a custom type post when saving posts?
- Using audio shortcode for .mp3 URLs with a query string
- Change “From” name in MailChimp STS plugin [closed]
- Securing my WordPress Files and Directories
- Enqueue AWS Script
- How To install AWS SDK for PHP in wordpress?
- PHP/MySQL issues when running WP on EC2 cloud [closed]
- How can I view or FTP into my WordPress site hosted on AWS?
- How to connect to AWS RDS external database (not for the core WordPress db)
- Upload media files to Amazon S3
- Getting 404 Hits on URI -/-/-/-/-/-/-/-/-/- . How to deal
- Is this the right set of records for Route53 domain to point to a mapped domain in a multisite? [closed]
- Use separate S3 buckets for separate sites in a multisite environment
- How to play amazon S3 videos in wordpress 3.6?
- WordPress remote file storage
- Amazon EC2 and static page Caching (Multisite): How to enable Caching with multiple instances?
- How to use author meta in shortcode?
- Alternate email sending service – eg: AWS SES [closed]
- Generate metadata for cloud images
- How to fix AWS SNS API end point code that cause site not to load?
- Importing existing s3 Media into WP
- Hosting wordpress on Amazon [closed]
- WordPress on git – need help with configuration
- EC2 WordPress install asks for connection info when auto-updating
- Bug: Deleting file, then uploading same file again places file in an old month folder
- Can’t Change the default theme on WordPress by BitnamI running on AWS
- Is it possible to set Featured Image using HTML?
- Why does WordPress uses HTTPS for JS, CSS on EC2
- Why do I have a reauth=1 redirection loop when I try to log in to WordPress hosted on AWS Fargate?
- Making a development site live, on Amazon EC2
- How to run wordpress site on “mysitewp.com”?
- SSL for Mapped Domains with WordPress Multisite on AWS
- How do I change the WordPress Address URL only and still login to wp-admin
- Minimum EC2 Requirements for a stable WordPress site
- Featured Image not showing on wordpress hosted under Amazon AWS
- Would Amazon AWS Services be a good alternative to my current hosting provider?
- How to stream a linked file in WordPress
- php “use” not working in template [closed]
- Allow users to download media files directly from Amazon S3 (AWS plugin)
- max_input_vars not updating through wp-config
- Run WordPress multisite from secondary volume on AWS EC2
- Show realtime Amazon price without API using shortcode
- Import process stuck migrating 30+ GB WordPress site from S3 bucket to AWS (Fargate) serverless WordPress evironment
- Replace SEO title tag with dynamically generated value
- How to use s3 bucket images on wordpress media library without plugin
- I created new instance from snapshot of wordpress instance. now default page loads as default apache page not wordpress page
- Convert all images on S3 to webp format