2017-09-15 7 views
-1

私はページテンプレート-ViewAllを使用しているDisplayAllという名前のWordPressページのデータベースからすべてのレコードを表示するためにPage Template-ViewAllを持っています。私のコードはHere.Nowで編集して削除したいと思います。 Wordpressの両方でカスタムページテンプレートを渡すことによってWordpressでそれを?どのようにIDを渡すことによってWordpressで編集し、削除するには?

<?php 
/** 
* Template Name:ViewAll 
* The template for displaying all pages 
* 
* This is the template that displays all pages by default. 
* Please note that this is the WordPress construct of pages 
* and that other 'pages' on your WordPress site may use a 
* different template. 
* 
* @link https://codex.wordpress.org/Template_Hierarchy 
* 
* @package WordPress 
* @subpackage Twenty_Seventeen 
* @since 1.0 
* @version 1.0 

*/ 

get_header(); ?> 

<div class="wrap"> 
    <div id="primary" class="content-area"> 
     <main id="main" class="site-main" role="main"> 

      <?php 
      $newdb=new wpdb('root','','wpdemo1','localhost'); 



      $rows=$newdb->get_results("Select * From wp_student"); 
      if($rows) 
      { 
       foreach ($rows as $obj) 
       { 
        //$path = 'admin.php?page=EditStud&id='.$obj->roll; 
        //$url = admin_url($path); 
        //$id=$obj->roll; 
        ?> 
        <table> 

        <tr> 
        <td><?php echo $obj->roll;?></td> 
        <td><?php echo $obj->name;?></td> 
        <td><?php echo $obj->dept;?></td> 

        <td><a href=""> Delete </a></td> 
        <!--<td><a href="<?php //admin_url('/wp-admin/admin.php?page=editstud&edit-id=' . $obj->roll); ?>">Edit</a></td>--> 
        <td><a href="">Edit</a></td> 

        <!--<td><a href="http://localhost/wptest1/index.php/editstud/?id=<?php //echo $obj->roll;?>"> Edit </a></td>--> 
        </tr> 
        </table> 
        <?php 
       } 
      } 
      /*while (have_posts()) : the_post(); 

       get_template_part('template-parts/page/content', 'page'); 

       // If comments are open or we have at least one comment, load up the comment template. 
       if (comments_open() || get_comments_number()) : 
        comments_template(); 
       endif; 

      endwhile; */// End of the loop. 
      ?> 

     </main><!-- #main --> 
    </div><!-- #primary --> 
</div><!-- .wrap --> 

<?php get_footer(); 
+1

スクリーンショットの代わりにコードを貼り付けてください。 – Regolith

答えて

0

あなたはこれを求めていますか?

<a href = "<?php echo get_template_directory_uri(); ?>/editstud.php?edit-id=<?php echo $obj->roll;?> ">Edit </a> 

テーマのメインディレクトリにカスタムページを作成すると機能します。

+0

brother私はViewAllのカスタムページテンプレートでIDを渡す方法を尋ねたいと思います。このIDを取得するページのタグと私のコードを見て、空白にはEditを記入してください。そこに書くには - ワードプレスのページ名や編集/削除のためのカスタムページテンプレート? –

+0

okありがとう弟 –

+0

しかし、それはページテンプレートeditstud.phpに適用されます私はあなたが示唆したように編集リンクをクリックすると、このeditstud.phpカスタムページテンプレートを使用したワードプレスの編集ページに移動できますか? –

関連する問題