Php 静态wordpress页面链接到帖子
嗨,我想让我的静态wordpress页面在这里看到 链接到显示的帖子。但是,它们只是链接到浏览器中的文件目录,而不是帖子 以前它只会链接到wordpress主题中的帖子,但现在它根本不起作用 我已经有一个星期没碰代码了,我把它放在上面提到的状态,在那里它会链接到wordpress主题 下面是我用来从wordpress获取静态页面信息的代码-Php 静态wordpress页面链接到帖子,php,html,wordpress,Php,Html,Wordpress,嗨,我想让我的静态wordpress页面在这里看到 链接到显示的帖子。但是,它们只是链接到浏览器中的文件目录,而不是帖子 以前它只会链接到wordpress主题中的帖子,但现在它根本不起作用 我已经有一个星期没碰代码了,我把它放在上面提到的状态,在那里它会链接到wordpress主题 下面是我用来从wordpress获取静态页面信息的代码- <?php // set up or arguments for our custom query $paged = ( get_query_
<?php
// set up or arguments for our custom query
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$query_args = array(
'post_type' => 'post',
'paged' => $paged
);
// create a new instance of WP_Query
$the_query = new WP_Query( $query_args );
?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // run the loop ?>
<article>
<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<?php the_content(); ?>
</div>
<small><?php the_time('F jS, Y'); ?> by <?php the_author_posts_link(); ?></small>
<hr>
</article>
<?php endwhile; ?>
<?php if ($the_query->max_num_pages > 1) { // check if the max number of pages is greater than 1 ?>
<nav class="prev-next-posts">
<div class="prev-posts-link">
<?php echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages ); // display older posts link ?>
</div>
<div class="next-posts-link">
<?php echo get_previous_posts_link( 'Newer Entries' ); // display newer posts link ?>
</div>
</nav>
<?php } ?>
<?php else: ?>
<article>
<h1>Sorry...</h1>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</article>
<?php endif; ?>
通过
如果你想要的只是工作链接
http://auroraservers.org/MainSite/?p=38 ---fails
http://auroraservers.org/MainSite/wordpress/?p=38 ---works
这是可行的,可以在permalinks自定义区域进行调整。如果您希望该URL不同,则需要处理htaccess更改
虽然不美观,但您可以替换_permalink()代码>带有
$id = get_the_ID();
$url = 'http://auroraservers.org/MainSite/wordpress/?p='.$id;
如果你想要的只是工作的链接
http://auroraservers.org/MainSite/?p=38 ---fails
http://auroraservers.org/MainSite/wordpress/?p=38 ---works
这是可行的,可以在permalinks自定义区域进行调整。如果您希望该URL不同,则需要处理htaccess更改
虽然不美观,但您可以替换_permalink()代码>带有
$id = get_the_ID();
$url = 'http://auroraservers.org/MainSite/wordpress/?p='.$id;
尝试将Index.php
重命名为Index.php
。Wordpress似乎找不到index.php作为帖子的模板,因此系统会将您重定向到文件目录,因为它找不到任何可能的模板文件
另外:由于您的“Index.php”似乎没有包含用于显示单篇文章的代码,因此您可能需要设置一个文件“single.php”作为单篇文章的模板。但是无论如何,Wordpress会在很多情况下尝试使用index.php
——总是在找不到特定帖子类型的实际模板文件时使用,比如archive.php
,page.php
和其他许多情况
因此,创建一个“常规”的、通用的index.php
,将静态页面重命名为其他页面,例如front page.php
,并将t定义为起始页面可能是一个好主意。尝试将index.php
重命名为index.php
。Wordpress似乎找不到index.php作为帖子的模板,因此系统会将您重定向到文件目录,因为它找不到任何可能的模板文件
另外:由于您的“Index.php”似乎没有包含用于显示单篇文章的代码,因此您可能需要设置一个文件“single.php”作为单篇文章的模板。但是无论如何,Wordpress会在很多情况下尝试使用index.php
——总是在找不到特定帖子类型的实际模板文件时使用,比如archive.php
,page.php
和其他许多情况
因此,创建一个“常规”的、通用的index.php
,将静态页面重命名为其他页面,例如front page.php
,并将t定义为起始页面可能是一个好主意。我似乎已经解决了我一直遇到的问题。谢谢你的回复
万一有人需要知道我做了什么
我进入mysql,删除了数据库并重新创建了它。一定是因为某种原因被损坏了。我似乎已经解决了我一直存在的问题。谢谢你的回复
万一有人需要知道我做了什么
我进入mysql,删除了数据库并重新创建了它。一定是被破坏了。在子目录中安装wordpress可能会很痛苦。我建议改为使用子域。例如mainsite.auroraservers.org。如果不可能,那么按照说明在子目录中安装wordpress可能会很痛苦。我建议改为使用子域。例如mainsite.auroraservers.org。如果不可能,请按照说明进行操作嗨,谢谢你的回复,我已将其更改为/wordpress/%post\u id%,但现在出现了一个404未找到错误,我想这会让你http://auroraservers.org/MainSite/wordpress/38
而不是您需要的。我会将其返回到普通永久链接,然后将其编码到您的模板中。您好,感谢您的回复,我已将其更改为/wordpress/%post_id%,但现在出现了一个404 Not Found Error,我想这会让您http://auroraservers.org/MainSite/wordpress/38
而不是您需要的。我会将其返回到普通永久链接,然后将其编码到您的模板中。