Jump to content

Archived

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

rmaxsg

Custom Post Type no show up in Content/Postloop

Recommended Posts

rmaxsg    7
rmaxsg

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
Erwan    37
Erwan

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"?


 

  • Like 1

Share this post


Link to post
Share on other sites
Rob    547
Rob

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.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
bfrye26    3
bfrye26

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
rmaxsg    7
rmaxsg

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

  • Like 1

Share this post


Link to post
Share on other sites
Erwan    37
Erwan

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
Rob    547
Rob

@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.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
rmaxsg    7
rmaxsg

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
bfrye26    3
bfrye26

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
rmaxsg    7
rmaxsg

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
Rob    547
Rob

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


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
bfrye26    3
bfrye26

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
Rob    547
Rob

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.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
bfrye26    3
bfrye26

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
bfrye26    3
bfrye26

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
Rob    547
Rob

What files does it contain?


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
bfrye26    3
bfrye26

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
bfrye26    3
bfrye26

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
bfrye26    3
bfrye26

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
Rob    547
Rob

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.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
bfrye26    3
bfrye26

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

  • Similar Content

    • art23130
      By art23130+
      I have uploaded a file shoing missing sections for Custom Post Type
      It is OK for categories and tags but not for a single post types. 
      This is the link. 
      https://www.geoinformation.com/geocode_library/10-10570-rsg-2016-003/
      Any idea?
      thanks 
      Binder1.pdf
    • PeriniNero
      By PeriniNero+
      We are building a Custom Post Type with Custom Fields and Custom Taxonomies.
      The only thing we dont understand is how to embed the Custom Fields including header tags and stuff in the Postloop (now we use a text-box below the postloop section but also SEO wise this is not best pratice).
      So we thought to copy the dms Postloop section to our child theme and rename this, to add an extra Postloop section to our theme. Is this the way?
      What exactly to adjust in those 3 files class.posts.php, section.php and style.less (at this point we know how to change the thumb LOL) and where to add the Custom Fields shortcodes?
      Thanks.
    • Audun MB
      By Audun MB+
      I'm using plugins such as Events Manager and WP Glossary. Basically I need to edit the meta information and the breadcrumb for the custom post types Event and Term. The plugins instruct me to add a single-event.php and single-glossary.php in my (child) theme.
      What should I use as a basis for these files? Can I use the templates in the Framework main theme as a basis (tpl-a.php)? Or should I use the whole page.php file?
       
    • ketri
      By ketri
      Hello,

      When I select a page template for a custom post type page, it also selects the same template for the children of this custom post type. 
      I want to have my custom post type template as a heavily customized loop that I've developed myself, and the children (they are articles) as a completely another template.
       
      Is there a function that would allow me to select different templates for them on DMS?

      Thank you very much in advance.
    • dawsonbarber
      By dawsonbarber+
      Hi Enrique
       
      I want to add a Starbar to a Custom Post Type.
       
      I've tried to simply copy/paste the full section code from the source code, but the animation doesn't happen.
       
      Any idea on what I'm missing/doing wrong?

      Cheers
       
      Dawson
×