• I imported some blog posts from another site that is being merged with ours. I see the full posts in the database, but when I click on the summary link for each, I get a 404. I have the permalink set to postname, but if I change it to default, I can get to the full post in url. If I go in postname, 404. What do I need to do to get the posts to be referenced by name?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator t-p

    (@t-p)

    if I change it to default, I can get to the full post in url.

    If that works, then try reading Using_Permalinks before setting a custom permalink structure again.

    If clearing your Permalinks does not alleviate the issue, this could be attributed to anything from a web server configuration to a bad WordPress install.

    Thread Starter CaffinatedCoder

    (@caffinatedcoder)

    Thanks Tara. At first when I reset a custom plugin, it seemed to work. Now it doesn’t. How can I see if the issue is bad install or server config?

    Thread Starter CaffinatedCoder

    (@caffinatedcoder)

    OK, so it looks like this was due to the original author’s declaration of the Products post type (pasted below). I created a different implementation based off of Googling some examples (further below), but the only problem is one product type doesn’t work. Is there something amiss in what I did further below? In the original implementation, the add_rewrite tags are what kills the blog functionality.

    add_action('init', 'products_post_type');
    
    function products_post_type()
    {
    	global $wp_rewrite;
    
    	$labels = array(
    		'name'					=> 'Products',
    		'singular_name'			=> 'Product',
    		'add_new'				=> 'Add New',
    		'add_new_item'			=> 'Add New Product',
    		'edit_item'				=> 'Edit Product',
    		'new_item'				=> 'New Product',
    		'view_item'				=> 'View Product',
    		'search_items'			=> 'Search Products',
    		'not_found'				=> 'No Products found',
    		'not_found_in_trash'	=> 'No Products in the trash',
    		'parent_item_colon'		=> ''
    	);
    
    	register_post_type('products', array(
    		'labels'				=> $labels,
    		'public'				=> true,
    		'menu_icon'				=> 'dashicons-category',
    		'capability_type'		=> 'page',
    		'has_archive'			=> false,
    		'hierarchical'			=> true,
    		'menu_position'			=> 20,
    		'supports'				=> array('title', 'editor', 'custom-fields', 'revisions', 'page-attributes', 'thumbnail'),
    		'rewrite'				=> false
    	));
    
    	// Manually create Products rewrite rules without slug in URL (by default WordPress will prepend all URL's with custom post type's slug)
    	$wp_rewrite->add_rewrite_tag('%products%', '(.+?)', 'products=');
    	$wp_rewrite->add_permastruct('products', '%products%', array('ep_mask' => EP_PERMALINK));
    
    	/*echo '<pre>';
    	print_r(get_option('rewrite_rules'));
    	echo '</pre>';*/
    }

    ————————————————————————–

    function products_post_type() {
    
    	register_post_type( 'Products',
    	// CPT Options
    		array(
    			'labels' => array(
    				'name' => __( 'Products' ),
    				'singular_name' => __( 'Product' ),
    				'add_new'=> __( 'Add New' ),
    				'add_new_item'=> __( 'Add New Product' ),
    				'edit_item' => __( 'Edit Product' ),
    				'new_item' => __( 'New Product' ),
    				),
    			'public' => true,
    			'has_archive' => false,
    		)
    	);
    }
    // Hooking up our function to theme setup
    add_action( 'init', 'products_post_type' );
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Full Post Not Displaying’ is closed to new replies.