2016-10-03 37 views
0

你好我試圖讓我在這裏的靜態WordPress的頁面看到靜態頁面WordPress的鏈接到職位

鏈接到所顯示的帖子。但是,它們只是鏈接到瀏覽器中的文件目錄而不是帖子。

這是工作之前,它只會鏈接到wordpress主題的帖子,但現在甚至不工作。

我在一週內沒有碰到代碼,我把它留在上面提到的狀態,它會鏈接到wordpress主題。

下面是我用從WordPress的獲取信息的靜態頁面的代碼 -

<?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; ?> 

基本上,我試圖做的是得到它,所以當我點擊後它需要我到帖子。不是文件目錄。

任何幫助表示讚賞。謝謝。

我正在使用xubuntu 16.04_LTS incase,它與wordpress中的兼容性有關。

我有固定鏈接設置如圖

enter image description here

+1

將wordpress安裝在子目錄中可能會很痛苦。我建議使用子域代替。例如。 mainsite.auroraservers.org。如果這不是possibe然後按照說明[這裏](https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory) – andrew

回答

1

如果你想要的是工作的聯繫。 。 。

http://auroraservers.org/MainSite/?p=38 ---fails 
http://auroraservers.org/MainSite/wordpress/?p=38 ---works 

這樣的作品,可以在永久鏈接自定義區域進行調整。如果你想讓這個URL不同,你正在處理htaccess的變化。

雖然不漂亮,你可以用

$id = get_the_ID(); 
    $url = 'http://auroraservers.org/MainSite/wordpress/?p='.$id; 
+0

嗨,感謝您的答覆,我已經將其更改爲/ wordpress /%post_id%,但現在出現一個404 Not Found錯誤 – Forrest

+1

我認爲這會讓你'http:// auroraservers.org/mainsite/wordpress/38'而不是你所需要的。 我會將它返回到普通永久鏈接,並將其編碼到您的模板中。 –

1

嘗試更換the_permalink();重命名爲Index.phpindex.php。看起來WordPress似乎無法找到index.php作爲帖子的模板,因此係統會將您重定向到文件目錄,因爲它找不到可能的模板文件的任何

此外:由於您的「Index.php」似乎不包含顯示單個帖子的代碼,因此您可能需要爲單個帖子設置一個文件「single.php」作爲模板。但儘管如此,WordPress會嘗試在許多情況下使用index.php - 總是在特定職位類型實際的模板文件無法找到,像archive.phppage.php和許多其他...

因此,它可能是一個很好的創建一個「常規」,通用index.php的想法,重命名您的靜態頁面到其他東西,例如到front-page.php並定義t爲您的起始頁面。

0

我似乎已經解決了我一直有的問題。感謝所有的答覆。

因爲有人需要知道我做了什麼。

我進入mysql並刪除數據庫並重新創建它。不知何故,必須得到損壞。