English 中文(简体)
说 明: 在用点击SEND输入数字形式的输入时如何改用该网页?
原标题:Wordpress: How to be redirected to the page when inserting it s page ID into numeric form input with click button SEND?
  • 时间:2010-03-23 00:00:14
  •  标签:
  • wordpress

I would like to know if there s exists some simple code to get to the page i know its ID , I would like to create small input (no matter where in templates)from where the people can easily get to the page if they know it s page ID (4numeric ID is better to remember - permalink name you can mistake . I have the girls portfolio in wordpress - portfolio=pages x jobs in clubs offers=posts , I would like the girls portfolios to be easily findable by ID(s) , if possible the same for the posts=jobs in clubs The best solution little 4-5numeric input and send=go button in sidebar.php - index.php etc

问题回答

i 在此,请见source。 或许可以提供帮助,尽管我不知道它的工作是否可行。

......

function baka_show_form_redirect() {
      $form_search =’<form action="" method="post" name="redirect_to_post_id" class="description" style="color:#fff;font-size:10px;text-align:left;position:fixed;top:40px;">
      <h4>Theme Feature</h4>
      <ol>
          <li><label for="post_id" title="Put numerical value of existing post ID">Redirect to ID (numerical) : </label>
          <input name="post_id" type="text" maxlength="4" class="description"
              style="width:30px;display:inline;border:none;color:#000" /></li>
      </ol>
        <input name="_redirect_to" type="hidden" value="’ . get_permalink() . ‘" />
      </form>’;

  echo $form_search;

iii

function baka_validasi_post_id() { if( $_POST[ post_id ] && $_POST[ post_id ] != ” ) { $post_id = $_POST[ post_id ]; if (absint($post_id)) { //must be integer and not negative

          $url = get_permalink($post_id);

          if ($url) {
              wp_redirect($url); echo "&nbsp;";
          iii else {
              $_redirect_to = $_POST[  _redirect_to  ];
              wp_die("ID can not be found … &lt;a href =’" . $_redirect_to . "’&gt;Back&lt;/a&gt;");
          iii
    iii

iii iii

add_action(‘wp_head’, ‘baka_show_form_redirect’); add_action(‘init’, ‘baka_validasi_post_id’); ?>

......

! 这部法律的作者帮助我从上述网站链接上运行,因此,他们的工作是完美的。 感谢两人的很多! 感谢守则的真正作者和回答第一个问题的编辑。

<?php
}

function baka_show_form_redirect() {
      $form_search = <form action="" method="post" name="redirect_to_post_id">
      <h4>Theme Feature</h4>
      <ol>
          <li><label for="post_id" title="Put numerical value of existing post ID">Redirect to ID (numerical) : </label>
          <input name="post_id" type="text" maxlength="4" class="description"
              style="width:30px;display:inline;border:none;color:#000" /></li>
      </ol>
        <input name="_redirect_to" type="hidden" value="  . get_permalink() .  " />
      </form> ;

      echo $form_search;
}

function baka_validasi_post_id() {
    if( $_POST[  post_id  ] && $_POST[  post_id  ] !=    ) {
          $post_id = $_POST[  post_id  ];
          if (absint($post_id)) { //must be integer and not negative

              $url = get_permalink($post_id);

              if ($url) {
                  wp_redirect($url); echo "&nbsp;";
              } else {
                  $_redirect_to = $_POST[  _redirect_to  ];
                  wp_die("ID can not be found … <a href = " . $_redirect_to . " >Back</a>");
              }
        }
  }
}

add_action( wp_head ,  baka_show_form_redirect );
add_action( init ,  baka_validasi_post_id ); 
?>

? http://www.bakawan.com/log/howto-wordpress-redirect-based-on-post-id/comment-page-1/#comment-6654 法典撰写人网站

我不知道这是否是你要求的事,但你能够利用id获得永久联系。 如果你有网页,你可以产生像样的永久链接,<?php呼应_permalink(page_or_post_id);?>。 每当你获得一页或一页的美元贴后,你可以转头或显示与该页/邮局的联系。





相关问题
Wrap stray text in <p> tags

Wordpress issue.. how do I wrap stray text in P tags? Example: Before- <div class = "content"> <img src = "hello.jpg"/> <h1>Introduction</h1> Hello! this is ...

Using jQuery Plugins with Wordpress

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must ...

WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Why can t I properly style a blockquote in Wordpress?

On the design I just created for my website, I have a blockquote styled with two quote images using the span technique in css: blockquote { background-image: url(images/openquote.jpg); background-...

How does the WordPress <!--nextpage--> tag actually work?

What happens? I m guessing that somehow the post or page is parsed before displaying, and then just split into two methods? I can t seem to find any documentation on how the underlying <?php ...

Wordpress Plug-ins: How-to add custom URL Handles

I m trying to write a Wordpress Plug-in but can t seem to figure out how you would modify how a URL gets handled, so for example: any requests made for: <url>/?myplugin=<pageID> will ...

热门标签