Jump to content

Archived

This topic is now archived and is closed to further replies.

dario

CPT switching content on page refresh

Recommended Posts

dario

I have two pages, created either by WP or by CPT UI (I'm not sure which).

I did not go into the WP Admin > Pages and create them.

 

Their URLs are:

site//article-categories/featured

site//article-categories/resources

 

Both pages have a Masonry gallery set to the same CPT (Articles) but using different metas.

 

I can get each page to display anything I choose, except that no matter how different the metas are, they only display identical content.

No matter what meta I put into the fields, upon refresh the pages mirror each other.

All caching is off.

 

When I do go to WP Admin > Pages and create pages for these categories (Featured and Resources), the same thing happens.

 

I set the metas up in the way I think Danny explains here (among 6 hours of additional ways I attempted today):

http://forum.pagelines.com/topic/34590-custom-post-types-meta-key-meta-key-value-not-returning/

 

FWIW, I have two CPTs on the site. One is Articles (which I am using for this question) and I also have another.

I can get both to display all their posts on their own pages just fine using a Masonry gallery, each.

 

I just cannot get different CPT archives of these CPTs to display unless I attach them to regular WP categories. Though that way does work, it seems incorrect and results in URLs like:

site/category/articles/featured

 

What am I doing wrong?

 

Also, shouldn't I expect to see something like one of the following URLs for a CPT category archive?

site/articles/featured

site//article-categories/featured

Share this post


Link to post
Share on other sites
dario

I've had this code in my child theme's functions.php since the beginning:

// Shows CPTs in WP category archives //
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {

$post_types = get_post_types();

$query->set( 'post_type', $post_types );
return $query;
}
}

Share this post


Link to post
Share on other sites
Danny

Hi,

 

If I understand your situation, these pages are from the same custom post type, but are basically different category archives. If my assumption is correct, the the cause of your issue is that DMS does not allow you to have unique templates on a category by category basis. Therefore, whatever sections you configure on one category will appear for all other categories for that post type.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
dario

Interesting. That might explain it Danny.

 

I just now restored the site from a pre-CPT taxonomy backup in order to start from scratch.

 

This time I added an Article Categories taxonomy term to my ARTICLES CPT.

I also set it up so that I would see the first screenshot in the Dashboard left-site menu.

 

Then, when I click on ARTICLES > Article Categories, I get to the second screenshot.

 

This allowed me to add categories to the ARTICLES CPT.

 

Then, on an ARTICLES post, I get the Dogs and Cats checkbox options on the right-hand side (screenshot 3).

 

The result, after I attach various ARTICLES posts to a mixture of Dogs and Cats is that WP properly displays to correct archives on either:

mysite/article-categories/dogs/

mysite/article-categories/cats/

 

They show up using the DMS Category Pages template which has a WP/Content Loop section on it.

 

If I'm following you, and what I've outlined above is error-free, you're saying that I cannot replace the WP/Content Loop section on these archive pages with a Masonic Gallery that shows only Dogs on its archive page and only Cats on its archive page?

Share this post


Link to post
Share on other sites
dario

As a solution, should I not be able to:

-Create a DOGS page and a CATS page in the WP Pages editor

-Then, on the DMS front-end, attach separate templates to each of those two pages which have Masonic Galleries added

-The Masonic Gallery on the DOGS page has a Post Type of ARTICLES

-The Masonic Gallery on the CATS page also has s Post Type of ARTICLES

-Each have metas which match metas as you explained in the other thread

Share this post


Link to post
Share on other sites
dario

Well, that doesn't work either.

Each page's Masonic Gallery mirrors the other, no matter what setting I give them.

 

Adding a WP Content/Loop section on each page's template only results in the addition of that page's featured image.

 

In a way, this issue makes CPTs somewhat useless from a design perspective as I cannot selectively style their archives.

Share this post


Link to post
Share on other sites
Danny

You can style Post Type archive pages, but you can not have a unique layout with sections configured differently on a category by category basis for the same post type. For example, lets say you have in your Posts post type two categories. One called Movies and the other called Music.

You will not be able to have two different templates assigned to these two categories, if you assign one to Music and another to Movies. Whichever you assign last will be applied to the other as well.

The same goes for Custom post types. However, you can set a template for different post type archives, such as categories. For example, you could have TemplateXYZ on your Posts post type categories archive for Movies and Music. Then set Template123 for your Animals Post type.

But you can not set individual templates per category for the same post type.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
dario

Thanks Danny, as always.

 

After your response on Sunday, and my further investigations, I finally figured out what terms to search for regarding this issue. Had I figured that out earlier I would have saved myself literally a full day's worth of time! ;)
That's the result of learning something as you go rather than from the beginning.

 

Anyway, your response today is most helpful as while I eventually saw (through you and other research) that:

 

 

. . . you can not set individual templates per category for the same post type.

 

I therefore also assumed that I could not differently style archive pages for different CPTs as well. That one can is most helpful and gets me half-way to where I'd like to be on this site. It will do for now.

I also see in other threads that setting individual templates per category for the same post type has been suggested to the devs. Hopefully it will eventually happen.

Share this post


Link to post
Share on other sites

  • Similar Content

    • Lisa Haran
      By Lisa Haran
      Hi 
      I have a map here http://www.iloveoffset.com/maps/
      I want to add several pointer locations to the map, but when I do they do not appear.
      On this map there are 2 pointer locations and as you can there is only one visible.
      Earlier today I added 7 and could only see 4 so there is something odd going on.
      My theme is up to date
    • clj182
      By clj182+
      Hello,
      I've been having trouble unlocking the template section for past couple of weeks. When I try clicking nothing happens. 
      I've deleted my custom css and removed plugins. Im down to having only the following plugins:
      Akismet
      Contact Form 7
      DMS Professional Tools
      Pagelines Updater
      WooCommerce
      It was working fine before i have no idea what's going on with it.
    • flourishdesignstudio
      By flourishdesignstudio+
      My DMS 2 site http://www.heart-stone.com/ will not save any new custom css... I can still edit templates and publish those but any custom css that I enter never saves.
      All WP files, themes, and plugins are up to date. 
      Any thought about what might be causing this?
    • flourishdesignstudio
      By flourishdesignstudio+
      Is there a way to edit the custom CSS via FTP? I know I can edit the custom code in the Chrome editor but is there a file path I can use to find and edit the CSS directly from our FTP?
      Thanks in advance for the help!
    • nizami
      By nizami+
      Using navbar section with correctly configured WP menu to display main navigation at https://elenaangel.com. 
      All fine in desktop viewport. Menu displays twice in hamburger mode. How to fix this please? 

×