Posts of custom post type load the page template
OK, done. That’s because I need to refresh the permalink option in the Admin menu. Every time you change the rewrite or link thing, you need to go to the “Options->Permalink” and save it again.
OK, done. That’s because I need to refresh the permalink option in the Admin menu. Every time you change the rewrite or link thing, you need to go to the “Options->Permalink” and save it again.
The admin-init hook only fires on admin screens. The correct hook to use for registering post types is init. So change: add_action( ‘admin_init’, ‘smoelenboek’ ); … to … add_action( ‘init’, ‘smoelenboek’ ); … and flush your rewrite rules once (save permalink settings in admin) and all should be well.
You’ll need to use get_posts() to get the latest post, then pass it to get_the_permalink() to get the URL to it: <?php $latest_posts = get_posts( array( ‘numberposts’ => 1 ) ); if ( ! empty( $latest_posts ) ) : $latest_post = $latest_posts[0]; if ( $latest_post->ID !== get_the_ID() ) : ?> <a href=”https://wordpress.stackexchange.com/questions/284553/<?php echo get_the_permalink( $latest_post … Read more
To display different templates for the same post type I would make 2 different links, check on which link I’m currently on and decide which template to load. Working example: /** * Register event post type * * Registering event post type will add such a permalink structure event/([^/]+)/?$ */ function wpse_288345_register_event_post_type() { $labels = … Read more
As stated in the docs, if the quicktag <!–more–> is used in a post to designate the “cut-off” point for the post to be excerpted, the_content() tag will only show the excerpt up to the <!–more–> quicktag point on non-single/non-permalink post pages. WordPress adds <span id=”more-‘ . $post->ID . ‘”></span> to the content in this … Read more
Within the loop, you can do it this way, outside of the loop, pass the post ID to get_post_type function. : // Within the loop $cpt = get_post_type_object(get_post_type()); if($cpt !== NULL) { echo $cpt->name; echo $cpt->description; } If you need to see more about get_post_type_object you can find it in codex.
If I understand you correctly, then has_term should be solution for your problem… if ( has_term( ‘past-events’, ‘event_type’ ) ) { // do something }
Unless you have added the functionality with a plugin or custom code, Pages are not placed in Categories. Pages are organized with Parent Pages and Children Pages. This is why (I suspect) in_category() does not work in page.php The following code in functions.php will add categories to Pages. /** * Add categories to Pages. * … Read more
I know Twenty Eleven include this functionality by default and I’ve come to expect it as default behavior, so I hope I’m not missing something here. You should be able to add this to single.php by using the previous_post_link() and next_post_link() functions.
There are some global variables available (or not) to detect the current page number: if ( empty ( $GLOBALS[‘multipage’] ) or $GLOBALS[‘numpages’] === $GLOBALS[‘page’] ) echo ‘<a id=”lastPageLink” href=”#comment”>comment</a>’; The best way to understand what they do is a look at the internals of wp_link_pages(). (bool) $GLOBALS[‘multipage’] is TRUE if there is more than one … Read more