• 0

Custom Post Type no show up in Content/Postloop


Question

Posted · Report post

The Custom post type doesn't show up in Content/Postloop.  and can't even view in post section.  :startle:

 

Thank you

 

 

 

Share this post


Link to post
Share on other sites

20 answers to this question

  • 0

Posted · Report post

Hi,

FYI, the content (including custom fields) of my custom post types is correctly displayed for me in Content/PostLoop sections.

Wich kind of CPT are you using + what do you mean by "post section"?


 

1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Yes, I'm curious why any custom post type you create that goes in the post loop isn't displaying in the Content/PostLoop section, as it just pulls what WP has in the loop.

 

@Erwan  thanks for helping.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

You need to add the following code to the wp-content/themes/dms/includes/init.php file. This is much like any other theme. It needs this to be added to ensure the theme knows to sort and list the custom types. Hope this helps

 

function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag()  && empty( $query->query_vars['suppress_filters'] ) ) {
 
// Get all your post types
$post_types = get_post_types();
 
$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thank you for your input. i will get back to you :)

1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

rmaxsg"] I really doubt @[member="bfrye26 tip is mandatory/useful/recommanded... I would even say, if I may: never ever modify directly DMS core!

If you tell me or Rob with which kind of CPT you have issues, we or others might help ;)

Regards.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

@bfrye26  I have to add that Erwan is correct.  Never add a function or anything to DMS core files. It not only violates your license, potentially cutting off your support (and add ons) but, it is also very likely to crash your site.

 

That code you added is a function and belongs in a hook, set up in the pagelines-customize plugin in functions.php. 

 

You should read the docs which over this thoroughly.

 

Please remove the code from your file and fix this promptly.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Ok noted. thank you guys! i will try to explain my problem later. Thank you Rob and Erwan and bfrye26.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thanks for the note and for setting it straight. The pagelines customization plugin is still not out for the public, How would be the best way for rmaxsg and myself to add that function into DMS? I am thinking the best way would be with a child theme?

 

Are there any base child themes you could suggest to achieve this?  

 

Also, sorry rmaxsg for the bad advice, it may work in the short term but I see why you should not do it that way! Follow their advice and if you add it to a function with a child theme or the plugin it should work!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thank you for your help bfrye26.   maybe i will do it in the child theme,  since i already brought. Anyway thank you so much for all your input.   i'm greatful for it.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I'm glad everyone's happy and thanking each other. It's refreshing to see people behaving so nicely!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Rob can you suggest a base theme to use or if the customize plugin will be launched soon.  I would love to dig in and make the fix that is needed for the site

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

You can get the pagelines-customize plugin from the 2nd link down on the first post here:

http://forum.pagelines.com/topic/28568-framework-store-free-products/

 

It is no different for DMS than for Framework.

 

You can get a good child theme from one of the two links at the bottom of the first post here:  http://forum.pagelines.com/topic/28267-pay-attention-you-need-this-info/

 

I use the one from Dropbox.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

the Customize plugin from that link seems to be missing most of the files. Is there another one I am missing?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Okay there seems to be an issue. If i try and add the code to the functions.php file it gives a very broken output for the pages. Far worse then when I had it in the DMS file directly. Does anyone know why this could be?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

What files does it contain?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

the template contains these files:

 

functions.php

info.txt

setup.php

style.css

style.less

 

I added: 

 

unction add_custom_types_to_tax( $query ) {
if( is_category() || is_tag()  && empty( $query->query_vars['suppress_filters'] ) ) {
 
// Get all your post types
$post_types = get_post_types();
 
$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );
 
you can see the output of this here:
 
although if I added the same code to the wp-content/themes/dms/includes/init.php file
 
it all worked. Any help would be amazing!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I should mention that i did add: function add_custom_types_to_tax( $query ) {  and not unction add_custom_types_to_tax( $query ) { since that would not be valid code

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Rob"] @[member="Erwan I have taken a screen shot to show what happens if the custom post code is placed in the functions.php

 

If you have any ideas why this would be taking place let me know. I am stumped and have tried a few settings for the custom post code. The same code works on all other themes. Any help would be amazing!

 

awt408.jpg

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Can you tell me:

1  Which functions.php you add it to?

2. Provide the exact hook you added the code to and provide the entire code.

 

All you've posted above is the code that goes in a hook, so I'm unclear how you added it or where it's located.

 

Thanks.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I managed to get it working! It was a permalink issue. I flushed the permalinks and it suddenly worked! Thanks for all the help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now