If you want to reach the “single” page of a custom post type (or even a regular post), you can do this by going to http://example.com?p=[post_id]&post_type=[post_type_name]
. If you use Pretty permalinks WordPress will redirect you to the “canonical” link, which may look like http://example.com/my-post-type/my-post-name/
.
So by changing the target
of your form and the post_id
hidden input to p
it should work:
<form class="product_form" action="checkout" method="get" target="<?php home_url(); ?>">
<input name="p" type="hidden" value="<?=$post->ID?>"/>
<input type="image" src="https://wordpress.stackexchange.com/questions/17532/<?php bloginfo("template_url'); ?>/images/buy.png' class="wpsc_buy_button" />
</form>
Related Posts:
- Get posts for custom post type with WP_Query
- Custom Post Type Data in Sidebar widgets?
- Custom Post Type Permalink / Rewrite not working immediately
- How to add custom content template part for a custom post type on main query using a plugin
- Custom sortable columns ordered by meta-value?
- Unregister post type from child theme
- Many to Many Relationship between Two Custom Post Types
- How to get term link that crosses different custom post types?
- Custom post type Admin Page
- Enforcing canonical URLs with multiple custom post types
- Multiple Paginations on one Page
- Set post title from two meta fields
- Where to put archive-{post-type}.php
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- WordPress custom post type category pagination 404 Error
- Custom-Taxonomy as categories: Remove “most-used” tab?
- Custom Permalinks for Custom Post Types and Taxonomies
- how to group custom post type posts by custom taxonomy terms
- Showing current taxonomy terms
- Custom Taxonomy order by Custom Field
- Custom post types – non-visible title and how it affects URL
- Limit search form to 4 custom post types only
- “More” span making trouble
- Custom post type permalink missing /post_type/ front
- Single Post Pages for Custom Post Types
- Show ACF field from custom taxonomy and display on the single template
- Add Content Exclusively to a Custom Post Type Feed
- How to rename image at uploading on specific plugin or post-type in WordPress
- ‘Pages’ widget alternative for custom post types?
- Including Custom Post Type posts in a page template contextually (or should I widget?)
- Loop on front-page.php
- How to insert multiple images into a single post within a CPT
- the_title filter returning wrong post type
- Why would this IF statement not work? [closed]
- Parent field missing from custom post type in the block editor
- Custom posts don’t work
- Pagination is not working in custom post type
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- allow BOTH post slug and meta key value in permalink for custom post type
- A simple script to allow sorting of custom posts in admin?
- Is it possible to create relational metabox values in a custom post?
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- Two Custom Post Types Many to Many Relationship
- Problem with displaying posts in the CPT category
- URL rewrite add author as base
- filter custom post in rest api with custom function
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- Custom Post Type slug same as page name
- manage_edit-{post_type}_sortable_columns sorts, but wrong!
- Custom Post Type Pagination Paginates Only in URL Structure
- Deny user access to edit post while allow him to edit custom post type
- Ordering custom post type by multiple custom fields
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- Check if post with same meta value exists
- Pros and cons of a custom page vs custom post type template file
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Running a song lyrics site on WordPress
- Getting all ID’s matching a title in a custom post type
- Unable to display selected post title in frontend from metabox wp_dropdown_pages()
- Get Posts by Category, Tag , and CPT Taxonomy
- How can i add multiple variable to a !== query
- Topic won’t save for a custom post type — how to debug?
- How to Create a Separate Page for Blog Posts in WordPress
- Migrating Hierarchal Taxonomy Categories Between Post Types
- Advanced custom fields Post Object image field not displaying in custom post type single.php
- Override Plugin Custom Post Type ‘single’ view
- how to retain the ability to modify the post slug after applying a post_type_link filter?
- Removed custom post type archive page shows blog page
- Getting Twitter Content on My Blog
- Use different categories for a custom post
- Why does my URL keep returning 404 error code?
- Filter posts by specific custom category and current tag
- Wp PageNavi only works with default permalinks on a custom post type?
- Custom category URL not displaying posts
- Multiple Stylesheets For Post and post type?
- Why doesnt my tag page populate with this custom post type?
- Slow CPT in backend
- How best to structure multiple CPTs and tax within a ‘resources’ section
- Sync posts via JSON API
- Custom query using one category that is used in all custom post types
- Cannot modify header information – header already sent (CPT related)
- Display all posts from specific category and CPT
- Post Filtered by Custom Field Value
- tax_query not working?
- Query post type created by a plugin
- Fetch loop of custom post types with AJAX
- Generating Custom Post Type list, within admin of another custom post type
- How to display custom post type in a submenu?
- Get full control over custom post type url
- Get data from custom post type to another custom post type?
- Custom Post Type Posts Not Showing Up in Admin
- Using get_terms() as shortcode attribute
- Author.php not displaying post type posts
- Custom Post type as Taxonomy
- Getting 404.php instead of single-.php [duplicate]
- Display div based on Group metabox selection [closed]
- ACF Field to set Publish Date – Post Duplication upon Update
- add_rewrite_rule not working in Custom Post Type UI Plugin
- Is it possible to make is_category() recursive?
- Delete old thumbnail when updating new