• Resolved ZillaConsulting

    (@zillaconsulting)


    I hope I am posting this in the correct forum, and if not, please feel free to move it.

    I have spent the entire day learning how to create a custom post type, implement it in my child theme and then create and implement the associated templates for the custom post type.

    I have a local implementation of WordPress where I managed to get everything working, so then uploaded the required files to the same folder on the server, but when clicking on the custom post type I am getting a 404.

    I have notice a difference in the links locally and on the server. Here are the results I get:

    For the purposes of explaining I will refer to the custom post type as ‘custom_post_type’ and the custom post as ‘custom_post’

    Locally: localhost/?custom_post_type=custom_post
    Server: example.com/custom_post_type/custom_post

    Why am I getting a different link on the server to what I am getting locally?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ZillaConsulting

    (@zillaconsulting)

    Let me rather put some clearer details to make it easier to understand the problem.

    Here is the code I used to create the custom post type in functions.php of my child theme:

    <?php
    
    	add_action( 'init', 'create_post_type' );
    	function create_post_type() {
    		register_post_type( 'artist_profile',
    			array(
    				'labels' => array(
    					'name' => __( 'Artists' ),
    					'singular_name' => __( 'Artist' )
    				),
    			'public' => true,
    			'publicly_queryable' => true,
    			'has_archive' => true,
    			'rewrite' => array('slug' => 'artists'),
    			'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'page-attributes'),
    			'can_export' => true,
    			)
    		);
    
    		register_taxonomy('artist_stage', 'artist_profile', array('hierarchical' => true, 'label' => 'Stage', 'query_var' => true, 'rewrite' => true));
    		register_taxonomy('artist_songs', 'artist_profile', array('hierarchical' => true, 'label' => 'Songs', 'query_var' => true, 'rewrite' => true));
    		register_taxonomy('artist_tags', 'artist_profile', array('hierarchical' => true, 'label' => 'Tags', 'query_var' => true, 'rewrite' => true));
    
    	}
    
    ?>

    So for the purposes of the example, I have a page template I am using to display the custom post type in a portfolio type layout with a filer for each ‘Stage’ rather than ‘Category’, which you will see in the taxonomy ‘artist_stage’.

    The result I am getting locally when viewing the page and hovering on the artist is as follows:

    http://localhost/avada/?artist_profile=test-artist

    The result I am getting on the server when viewing the same page and hovering on the artist is as follows:

    http://www.example.co.za/artists/test-artist/

    Thread Starter ZillaConsulting

    (@zillaconsulting)

    It really does help to type thing out… I figured out what the problem was.

    Locally I had my permalink settings set to ‘Default’ while on my server I have them set to ‘Post Name’.

    This wouldn’t normally pose a problem, but to resolve the issue, all I had to do was re-apply my Permalink settings and it was fixed.

    *High Five* to me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post & Page Template works locally but not remotely’ is closed to new replies.