I’m having trouble getting the permalink sample on my custom post type edit page to work
Rename post_link_type to post_type_link 😉
Rename post_link_type to post_type_link 😉
Your problem is that you’re using the_ID() to give an ID to each taxonomy term, but the_ID() doesn’t output the ID of the current term in a foreach loop, it get’s the ID of the current post. Since you’re not resetting postdata in your custom queries this will be the ID of the last post … Read more
Should I store the Custom Post Type data in the Custom Table (vs. wp_posts)? Yes, wp_posts has really no space for custom data. The only place would be wp_postmeta. Since we’re throwing the argument out of the window, you’d store any additional info tied to a post in your custom table. Should I store the … Read more
You mostly got everything right. But the code you posted also gave an error caused by an ’ char in your code. add_filter (‘the_content’, ‘references’); function references( $content ) { // only run the code on singular views of the post type “my_custom_post_type” if( is_singular(‘my_custom_post_type’) ) { // insert your custom post type here // … Read more
The problem is the loop: foreach ( $hadices as $post ) : setup_postdata( $post ); if ( have_posts()) : while (have_posts()) : the_post(); setup_postdata( $post ); ?> <h2><a href=”https://wordpress.stackexchange.com/questions/302904/<?php the_permalink(); ?>”><?php the_title(); ?></a></h2> <?php the_content(); ?> <?php endwhile; endif; endforeach; wp_reset_postdata(); If we fix the indenting and format it properly we get: foreach ( $hadices … Read more
You have to add a taxonomy category for your new custom post type such as function mvli_customtype_category() { register_taxonomy( ‘customtype-category’, ‘customtype’, array( ‘label’ => __( ‘Category’ ), ‘rewrite’ => array( ‘slug’ => ‘customtype-category’ ), ‘hierarchical’ => true, ) ); } add_action( ‘init’, ‘mvli_customtype_category’ ); And then you can easily open the link like this website.com/customtype-category/ … Read more
The arguments for in_array() are the wrong way round. Looking at the documentation you can see that the first argument is the value you want to check (the ‘needle’) and the second argument is the array you want to check for it in (the ‘haystack’). So this means it’s always evaluating as false, meaning that … Read more
SOLUTION: I am answering my own question here since no responses were given and I presume this might be helpful to someone and in the mean while I found a solution.. I had to use the second version of ‘add_rewrite_rule’: add_rewrite_rule( ‘^products/directory/?([^/]*)/?’, ‘index.php?post_type=acme_product&c=$matches[1]’, ‘top’ ); I needed to register a query var,, since external query … Read more
Are you using any pre_get_posts hooks in your theme that might be affecting things? I’ve found that when the listing in the admin is screwed up, it’s usually some other code snippet or plugin that is causing the issue.
you can define a constant in wp.config.php or at the beginning of functions.php of your theme if (!defined(‘CAROUSEL_CPT’)) { define(“CAROUSEL_CPT”, “post”); } WP_Query(‘post_type=”.CAROUSEL_CPT);//….