Wordpress template page for custom posts - wordpress

I have a custom post type (that I'm using on a template page), the custom post type is called 'Headerhome'.
When I post say a gallery there I'm trying to get it to redirect to 'single-Headerhome.php', yet it always just goes to 'single.php'.
The name of the custom post type itself is arbitrary, the name of the templage page it's on is 'home'.
I'm really confused, I'm not the best at WP yet so when something simple like this doesn't work I have no idea how to fix it, even after pouring over the codex for an hour.

The name of the custom post type itself is arbitrary, the name of the templage page it's on is 'home'.
Reading this implies that you have a home.php file in your theme, which would automatically display as your front page of your site. This may not be what you desire? More on this here: http://codex.wordpress.org/Creating_a_Static_Front_Page
An example of a custom post type might be an Event. The Event might have custom fields associated with it, like Location, Date, Time, Description. We would probably want new Events to show up on our front page, but also would want to create a custom theme file so when a user clicks on an Event from the home page to view the Event then the Event page shows our Date, Time, Location, Description, etc. We would then create a single-event.php to do this and put in any custom code their.
So (another example), a custom post type of Fruit would have an associated theme file of single-fruit.php. If their is no single-fruit.php then Wordpress will use single.php as the default theme file to display. More on this here: http://codex.wordpress.org/Post_Types#Template_Files
Hope this helps set you in the right direction.

Related

Permalink Goes to Old Page

I have been working on a site created by another developer. I have been fixing the site to make it more visually appealing. I am also responsible for adding new events and pictures which i self taught myself to do.
I have a situation where I have a page with the following permalink:
http://www.cic-nj.org/events/
The problem is that this link goes to a page that does not show the edits that i am making under that page and there is no other page listed that shows the info it actually displays.
this is what I have in the editor box on wordpress that I want it to show.
enter image description here
this is what appears when url is used or when i click view
enter image description here
I have been sure to click update and renewing page to view it. it's like its going to a ghost page i can not edit.
Can anyone point me in the right direction on this?
Thanks in advance...
You are experiencing "slug collision": more than one thing in your WP install has the same slug.
The problem that you have is events is a custom post type, with a slug set to events - therefore the url http://www.cic-nj.org/events/ is directing to the listing of events. This is an automatic feature of WordPress. (Note - you can see more details to support this conclusion by the fact that you've got individual events accessible at url's such as http://www.cic-nj.org/events/blue-apron-info-session/ )
Note that custom post type slugs will always take priority over a page / post slug.
You have a couple of options:
If you want a page to display the content that you've created, the page's slug / permalink must be different than events
If it's acceptable, you can rename the slug of the "events" custom post type to something different. This has the potential consequence of losing SEO "juice".
If it's acceptable, you can remove the custom post type, if you aren't going to use them any longer.
NOTE: It may be tempting to ask "how do I remove the custom post type", or "how do I change the post type slug". Those are different questions, and if you need to ask, they should be asked in a different question - not added as a comment below.

Add a new section to the wp-admin edit post page

One of my post types is called Events and on here I have typical things like a post title, body, event date, etc.
In the site's code (on a custom template), I am programmatically adding meta to events when a user signs up (custom array of values).
The problem is that an admin can't see this data.
I wanted to know how I could add a custom section or template so when an admin inside wp-admin goes to any given event, and edits this single post/event, they can see the metadata associated.
I want to just add a new field section somewhere, called "Registrations", and then I'd programmatically access the meta and format it how I want, put some HTML/CSS in there, etc.
If anyone could point me in the right direction I would appreciate it.
Thanks!

Map a Static Page to Custom Post Type archive page

I've registered a custom post type named portfolio. It's archive enabled, so I can visit it's archive page by visiting http://example.com/portfolio/ permalink.
Now, I want to create a static page with any given slug e.g. courses and I want to resolve this static page ID (as slug may change) to archive-portfolio.php page mentioned above.
Additionally, I also want to use that static page to be able to set as front page (just like any other static page) without losing it's ability to map to portfolio archive page.
How do I achieve this functionality?
Note: I want to implement this functionality in a commercial theme, so, any solution suggested must work out of the box i.e. without forcing end-user to deal with the file strucutre.

Wordpress Page Hierarchy

I have the following page on a site in development:
http://telamon.com.s137737.gridserver.com/media/press/
I want to do some stuff outside the loop, so I created page-press.php based on my understanding of the WP page hierarchy (http://codex.wordpress.org/Template_Hierarchy). It isn't working. I've reset permalinks as well. This isn't the first time I've had problems here and I just ended up creating a template, but this should work shouldn't it?
Yes it is true that the hierarchy should work like that, but for it to work you need the following to be true:
It needs to be in the Single mood
The page need to be a static page
You can't apply any other custom template on the page
The slug of the page needs to be "press"
If all of these are true, then it should work. If not, then check the following, find the id of the page and create a page-$ID.php and check if that works. See if you end up in the page.php template file, or if you end up in index.php try to use var_dump on a few variables like is_single() and so on.
EDIT:
Single mood is when the page is listed by it's own, not in a list.
Static page means this is not a post, or a list view like archive or something like that
Custom template is when you create a page to be a specific "page template" available to choose from, when you edit you page (down right).
Slug is not the same as your title, nor you id. It's most likely a url friendly variation of your title.

Wordpress custom post type page

When creating a custom post type and fill it with some posts wordpress generates a page for that custom post type.
But I want to be able to add content to that page so I create a regular page and choose a template where I manually call the custom post type posts and loop them out. And now I can just add content in the wysiwyg editor. But this causes a conflict between these two pages, especially if the CPT has the same name as the page.
And now the question: Is there a way to always show the page where I have chosen the template for the CPT to always show? Even when someone try's to manually enter the url for the CPT generated page?
Here is what I understood from your question. You have custom post type. Then you created a page-template, that loops through your custom post types and output them. Now when you create a new page and assign it the page-template you have created you run into problems, if it has the same name as the custom post type.
Solution: I think what you need to do is change the custom-page slug from the admin menu. Then you would be able to directly reference it by the URL.

Resources