最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - How do I open a post in a custom page in wordpress?

programmeradmin0浏览0评论

I'm new to coding wordpresst themes. I made a whale loop on the index.php page, by clicking on the link I want the post to open on another page.php. Do I need to change anything to Permalink or?

The example below is index.php, and the page.php (page.php example does not have an excerpt).

index.php

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
    <head>
        <meta charset="<?php bloginfo("charset"); ?>">
        <meta name="viewport" content="width=device-width">
        <title><?php bloginfo("name"); ?></title>
        <?php wp_head(); ?>
        <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(). "/style.css" ?>">
    </head>
    
<body <?php body_class(); ?>>
<div id="loop" class="loop" >
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
     <div id="loop-con" class="loop-con">
         <div id="thm" >
         <?php if ( has_post_thumbnail() ) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php the_post_thumbnail('medium'); ?> </a> <?php endif; ?>
         </div>
         <div id="ex" >
             <div id="ext" ><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
             <div id="exe" class="child7947810000"><?php the_excerpt(); ?></div>
         </div>
    </div>
<?php endwhile; else : echo '<p>No content found</p>'; endif; ?>
</div>
<?php wp_footer(); ?>
</body>
</html>

page.php

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
    <head>
        <meta charset="<?php bloginfo("charset"); ?>">
        <meta name="viewport" content="width=device-width">
        <title><?php bloginfo("name"); ?></title>
        <?php wp_head(); ?>
        <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(). "/style.css" ?>">
    </head>
    
<body <?php body_class(); ?>>
<div id="loop" class="loop" >
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
     <div id="loop-con" class="loop-con">
         <div id="thm" >
         <?php if ( has_post_thumbnail() ) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php the_post_thumbnail('medium'); ?> </a> <?php endif; ?>
         </div>
         <div id="ex" >
             <div id="ext" ><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
         </div>
    </div>
<?php endwhile; else : echo '<p>No content found</p>'; endif; ?>
</div>
<?php wp_footer(); ?>
</body>
</html>
发布评论

评论列表(0)

  1. 暂无评论