Page template ?
-
Hi,
I created a child theme, I made page templates (attachment.php, sitemap.php), for a friend.
But I’m forced to leave the 3.8.4 Version.
I don’t see how to make template pages with the new version.
Coding is too complicated, less accessible for non-encoders, like me.
-
Hi @noaneo, just create new page template as per WP guide. What’s complicated? It uses hook system.
Hi @romik84 ,
With the hooks, it’s more complicated.
before I took again part of the code of the page.php to respect the design.
But here I tried, several files, page.php, content-page.php, and nothing.I have a blank page.
<?php /* Template Name: sitemap get_header(); */ ?> <div id="content"> <h2><?php _e('Pages', 'evolve'); ?></h2> <ul><?php wp_list_pages("title_li=" ); ?></ul> <h2><?php _e('RSS Feeds', 'evolve'); ?></h2> <ul> <li><a title="Full content" href="feed:<?php bloginfo('rss2_url'); ?>"><?php _e('Main RSS' , 'textdomain'); ?></a></li> <li><a title="Comment Feed" href="feed:<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Comment Feed', 'textdomain'); ?></a></li> </ul> <h2><?php _e('Categories', 'evolve'); ?></h2> <ul><?php wp_list_categories('sort_column=name&optioncount=1&hierarchical=0&feed=RSS'); ?></ul> <h2><?php _e('All Blog Posts', 'evolve'); ?></h2> <ul><?php $archive_query = new WP_Query('showposts=1000'); while ($archive_query->have_posts()) : $archive_query->the_post(); ?> <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="PermarLink to <?php the_title(); ?>"><?php the_title(); ?></a> (<?php comments_number('0', '1', '%'); ?>) </li> <?php endwhile; ?> </ul> </div> <?php /* After Content Area --------------------------------------- Hooked: evolve_primary_container_close() - 10 --------------------------------------- */ do_action( 'evolve_after_content_area' ); get_footer();
Thank you
first problem I see you don’t call get_header(); anywhere
yes, I was starting again at 0, I just put it back.
<?php /* Template Name: sitemap */ get_header(); ?> <div id="content"> <h2><?php _e('Pages', 'evolve'); ?></h2> <ul><?php wp_list_pages("title_li=" ); ?></ul> <h2><?php _e('RSS Feeds', 'evolve'); ?></h2> <ul> <li><a title="Full content" href="feed:<?php bloginfo('rss2_url'); ?>"><?php _e('Main RSS' , 'textdomain'); ?></a></li> <li><a title="Comment Feed" href="feed:<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Comment Feed', 'textdomain'); ?></a></li> </ul> <h2><?php _e('Categories', 'evolve'); ?></h2> <ul><?php wp_list_categories('sort_column=name&optioncount=1&hierarchical=0&feed=RSS'); ?></ul> <h2><?php _e('All Blog Posts', 'evolve'); ?></h2> <ul><?php $archive_query = new WP_Query('showposts=1000'); while ($archive_query->have_posts()) : $archive_query->the_post(); ?> <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="PermarLink to <?php the_title(); ?>"><?php the_title(); ?></a> (<?php comments_number('0', '1', '%'); ?>) </li> <?php endwhile; ?> </ul> </div> <?php /* Footer Area --------------------------------------- */ get_footer();
Incredible, several days, it works.
Excuse-me, the code for the attachment.php file, is it correct?
Thank you<?php /* Template Name: sitemap */ get_header(); ?> <?php if ( wp_attachment_is_image() ) : $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); foreach ( $attachments as $k => $attachment ) { if ( $attachment->ID == $post->ID ) break; } $k++; // If there is more than 1 image attachment in a gallery if ( count( $attachments ) > 1 ) { if ( isset( $attachments[ $k ] ) ) // get the URL of the next image attachment $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); else // or get the URL of the first image attachment $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID ); } else { // or, if there's only 1 image attachment, get the URL of the image $next_attachment_url = wp_get_attachment_url(); } ?> <p class="attachment" align="center"><a rel="lightbox" href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" class="single-gallery-image"><?php echo wp_get_attachment_image( $post->ID, $size='large' ); // filterable image width with, essentially, no limit for image height. ?></a></p> <?php else : ?> <a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php echo basename( get_permalink() ); ?></a> <?php endif; ?> <?php /* Footer Area --------------------------------------- */ get_footer();
Hi,
thank you, very much !-
This reply was modified 6 years, 5 months ago by
Anonymous User 12851872.
glad you solved it ??
-
This reply was modified 6 years, 5 months ago by
- The topic ‘Page template ?’ is closed to new replies.