Skip Navigation

[Fermé] Add Custom Post Type to main menu

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 réponses, has 1 voix.

Last updated by Eric Il y a 9 années et 7 mois.

Auteur
Publications
#3209

This is probably some super-simple thing that I missed...

I created a custom post type, a taxonomy, and a view for its posts. I can manually enter the URL, and see the custom post type's archive page, then link to its posts, which are using a View. It's working perfectly. Great plugins! How now do I add this to the main client-side menu? In wp admin Appearance/Menus I see the box with my custom post type, which contains the two test posts I created. I can select and add those posts to the menu (not what I need to do), but can't add the custom post type itself. I know I can create a custom link to it, but that just feels wrong? Have I missed a step, or some checkbox somewhere?

Thanks,
Eric

#3219

Could use some help (apologies for the verbosity)...

Before installing Types and Views, I had a category of posts called Packages. I had a page called Rates & Packages, which used a customized archive template to list all the posts in the Packages category. It worked fine, but my client asked me to create a custom post type for Packages. Fair enough.

I created the Packages Post Type, and a Package Type taxonomy (with "specials" so far being the only child).

I added a few test posts under the Packages Post Type.

I loaded up mysitedotlocal/packages which displayed an archive of the Packages posts (title, excerpt, thumbnail). Beauty!

Next I tried to add /packages to the primary menu (see above post). There's no built-in method to add the post type to the menu (far as I can tell), so I simply created a custom link. I don't love it, but whatever, it works.

The problem I have now, and it's ridiculous, is that the title of the page at mysitedotlocal/packages needs to read "Rates & Packages" (client requirement), but of course the title at mysitedotlocal/packages reads "Packages" because that's the name of the Packages Post Type, right?

I figured I'd try creating a new page entitled Rates & Packages, then pull in a View. So I created a View, called it Packages WordPress Archive, and under View Query I filtered Packages, and under View Layout I added Title, Excerpt and Featured Image. Saved it, then added [ wpv-view name="Packages WordPress Archive" ] to the Rates & Packages page.

I loaded up mysitedotlocal/rates-packages. It sorta worked, but not quite right. The featured image didn't appear, and the formatting wasn't that of an archive template. OH, because I hadn't changed the default page template in the Page Attributes box. Back to page editor, changed Template to "Archives" (which, remember, worked perfectly at /packages), updated, reloaded /rates-packages, boom, all content but title gone.

I'm left with two pages that aren't exactly what I need:

mysitedotlocal/packages
It's not an actual page in the admin, but rather something generated by Types, I presume
It uses packages-archives.php by default and looks perfect
Its title is "Packages" (name of custom post type), but it needs to read "Rates & Packages"

mysitedotlocal/rates-packages
This one's an actual page in the admin, using the view Packages WordPress Archive
If the default page template from Page Attributes is used, I lose the featured image and formatting
If the archive template from Page Attributes is used, I lose all body content
The title reads "Rates & Packages" b/c that's how I named it in admin, but everything else is hosed.

Unless I've completely missed the boat, I don't see how to fix this stupid page title issue without a hack. I can probably get it done with css :after, but that seems an ugly way to do it.

I've spent hours and hours trying to nail this down. I'd really appreciate a little support.

Thanks,
Eric

#3222

FWIW I just added this to my stylesheet

.archive-packages h1.loop-title:before { content: "Rates & "}

It works, but sure feels dirty...

I'm still interested to know if anything I described in my previous posts was done incorrectly.

#3225

I wasn't satisfied with that solution, so kept digging and experimenting, and finally worked it out. I'd already created a custom template for my Packages archive (archive-packages.php). The crucial missing element was this:

query_posts( array( 'post_type' => 'packages' ) );

I added that to the top of archive-packages.php and it worked like a charm. I hope someone else finds this helpful. I feel like I've been talking to myself in this thread for two days...

Le sujet ‘[Fermé] Add Custom Post Type to main menu’ est fermé à de nouvelles réponses.