• Resolved dlature1

    (@dlature1)


    I use this plugin, and also have the post types registered, and have added the code that includes my two major custom post types to show along with regular ‘post’ Post Types in the Loop. Problem is, The Post Calendar sidebar widget doesn’t seem to know about Custom Post Types. And the CPTs that show in the Loop are missing the line that says “Posted on Month xx, 2015 by Username — Leave a Reply(or x Comments if there are any)” . What is up with this? Shouldn’t this be a major option for CPTs when you first set them up?

    https://wordpress.org/plugins/custom-post-type-ui/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter dlature1

    (@dlature1)

    a related problem is that the calendar does not include any custom post types. When I had no “regular/default” posts that had been published in October, when November rolled around, the previous month link on the Calendar was labeled “Sep”. Sure enough, when I published a Draft I had done in October but never published, the prev month link changed to Oct. So how do we get the post date problem solved if we want WordPress to treat certain Custom Post Types just like it does default posts?

    Thread Starter dlature1

    (@dlature1)

    my site is at wp.theoblogical.org and the first problem can be seen in the first 3 posts. The first one is a normal, regular post. The next two are custome post types, and both do not have the line “Posted On -date” by -User” metadata that is under the Post Title on the first post.

    The second problem can be seen in the Post Calendar or in the Date archive like here: http://wp.theoblogical.org/?m=201509 and it shows only regular posts there, and the calendar prev next links skip over August, since all of my posts in August were CPTs.

    Thread Starter dlature1

    (@dlature1)

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    For the calendar part, is this the out-of-box calendar widget that WordPress comes with? or some other plugin-provided one? It’s likely that it doesn’t know to query for the post types as well. I’ve checked the WordPress core code as well, and it sadly has no filters for what post types to include in the calendar. This is something beyond our control with CPTUI.

    As a possible alternative solution for you there, I did find https://pippinsplugins.com/custom-post-type-calendar-widget/ which may help.

    For the “Posted on…” part, it’s hard to say for sure. It’s not something our plugin controls either. This is a the theme/template level. Curious if part of it is related to the special note at the top of https://codex.wordpress.org/Function_Reference/the_date

    For the date archive issue mentioned on twitter with http://wp.theoblogical.org/?m=201509 I’m curious if the custom post types are included in those queries as well.

    Thread Starter dlature1

    (@dlature1)

    Thanks Michael. It is the out of box Calendar widget. So where(what file) would I look to find and adjust the query? Same question for the Date display issue….what template is it using to display the CPT instances that is different from the nonCPT posts that do show the “Posted On…” line?
    Thanks again for your attention to this.

    Thread Starter dlature1

    (@dlature1)

    Seems the Calendar doesn’t handle what’s needed to make the correct links. I installed the calndar widget, and it displayed the links on the dates, but the links didnt work. They linked to the same format as the m= link I showed in my previous comments, but the post could not be found via that date archive. Something is missing in the date archive.

    Thread Starter dlature1

    (@dlature1)

    as for the “Posted On…” it seems that other themes can display it. But the links from the calendar remain broken. Seems the query that gets launched by the ?m=xxxxx parameter does not see the custom posts…any idea what page is trying that query?

    Thread Starter dlature1

    (@dlature1)

    I have a twitter plugin that creates custom post types called Tweets, and those get pulled into the default WP calendar, but the links from the calendar days dont work. Lots of incompatibilities in the various plugins with CPTs.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    You’re probably not going to have luck getting the out-of-box calendar working here, as you’d need to adjust the core WordPress files.

    Getting the post types into the date archives is going to take use of the pre_get_posts action hook. Not sure how code savvy you are, but it’s what needs to be done sometimes to take care of post type customizations.

    Not going to be much help with that other plugin and debugging it. It’s something I found from a trusted source with Pippin. May need to contact their support for that.

    The “page” that’s trying it is just a URL that has the correct query parameters to indicate that it’s a “Date archive”. There’s no spot in the WP admin under Admin Menu > Pages that would have something you can tweak for it.

    Thread Starter dlature1

    (@dlature1)

    Yes, I have made use of the pre_get_posts hook, in my functions.php of the theme for the loop. But apparently there’s another loop somewhere that handles a by date query that needs the CPT’s mentioned or something that grabs all the CPTs.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure at this point, to be honest. We’ve ventured past support for the CPTUI plugin itself, really, and into the realm of using custom post types in general. Our plugin doesn’t handle how things are used, it just handles getting them registered and with what properties.

    Thread Starter dlature1

    (@dlature1)

    ok, thanks. Let me know if you hear anything or run across something that might address this in general. Thanks for your willingness to help.

    Thread Starter dlature1

    (@dlature1)

    just a bit ago I found this, which seems to be working. I hope there are no unforseen problems here in this approach:

    // Add custom post types to archives - renamed some_function to CPT_ArchiveInclude  Develocom's code from https://css-tricks.com/snippets/wordpress/make-archives-php-include-custom-post-types/
    //11-22-15   keeping my fingers crossed!
    function CPT_ArchiveInclude( $query ) {
      if(!is_admin()) {
    
      // For categories, lets add 'nav_menu_item' to the array so we don't break our navigation.//
      if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array(
         'post', 'nav_menu_item', 'ecoecclesia', 'occupytheology'
        ));
        return $query;
      }
      if( is_archive() && !is_post_type_archive() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array(
         'post', 'ecoecclesia', 'occupytheology', 'aktt_tweet'
        ));
        return $query;
      }
      if( is_home() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array(
         'post', 'ecoecclesia', 'occupytheology'
        ));
        return $query;
      }
     }
    }
    add_filter( 'pre_get_posts', 'CPT_ArchiveInclude' );
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Looks fine to me, I’m not seeing any glaring issues other than perhaps a check for $query->is_main_query()

    https://codex.wordpress.org/Function_Reference/is_main_query

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘CPTs not showing Post Date’ is closed to new replies.