小编Adr*_*ian的帖子

如何将wordpress循环的内容作为一个外部循环变量回显

我在wordpress的php模板文件中使用短代码,因为短代码打开和关闭我需要将其中的整个内容作为一个变量获取.在这种情况下,内容是wordpress循环.

到目前为止,我只显示了循环的最后一个帖子.我理解为什么,因为这是变量的最终值.我想知道有人可以帮我把整个内容(即所有三个帖子)都变成一个变量,而不是最后的帖子.

谢谢

<?php 
                $news_title .= '';
                $news_single_post .= '';

            if ( have_posts() ) :
            $the_query = new WP_Query( array ( 'posts_per_page' => 3, 'cat' => 1 ) ); /*  */
             while ($the_query->have_posts() ) : $the_query->the_post(); ?>
            <?php 
                $news_title = get_the_title();
                $news_excerpt = get_the_excerpt();
                $news_single_post = '<div class="home-content-news-title">'.$news_title.'</div><div class="home-content-news-excerpt">'.$news_excerpt.'</div>';

                endwhile;
                wp_reset_postdata();

                endif; 



                $news_tab_title_string = 'News';
                $news_tab_title_shortcode = do_shortcode('[wptabtitle]'.$news_tab_title_string.'[/wptabtitle]');
                $news_tab_content_shortcode = do_shortcode('[wptabcontent]'.$news_single_post.'[/wptabcontent]');
                $news_tab = $news_tab_title_shortcode.$news_tab_content_shortcode;
                echo do_shortcode('[wptabs]'.$news_tab.'[/wptabs]');

         ?>
Run Code Online (Sandbox Code Playgroud)

php wordpress loops

1
推荐指数
1
解决办法
1542
查看次数

notepad ++无法使用SFTP连接 - 身份验证期间出错:无效的私钥文件

嗨我使用puttygen创建了私钥,我使用putty成功连接,并使用Filezilla.

但我似乎无法使用Notepad ++

我越来越...

接受主机密钥,然后......

身份验证期间出错:无效的私钥文件.

我已经通过IP插入,

选择22作为港口,

我选择了SFTP

我用密码空白输入我的用户名

在授权下,我选择了"尝试私钥文件授权",其中私有密钥文件已经用于其他人,因为它在下面的字段中指向的那个

但尽管所有这一切我仍然得到错误,可能有一些愚蠢,我失踪了吗?

sftp notepad++ private-key

1
推荐指数
1
解决办法
5846
查看次数

php调用未定义的函数(类上的初学者)

我有2个文件index.php和class_lib.php.

这是index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    <title>OOP in PHP</title>
    <?php include("class_lib.php"); ?>
</head>
<body>
        <?php
            $adrian = new person();
            $jimmy = new person;

            $adrian = set_name('adrian de cleir');
            $jimmy = set_name('jimmy darmady');

            echo $adrian->get_name();

    ?>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

和类的文件

<?php
    class person {

    var $name;
           function set_name($new_name) {
                      $this->name = $new_name;
                   }
           function get_name() {
                      return $this->name;
                    }



    }
?>
Run Code Online (Sandbox Code Playgroud)

当我加载页面时,我得到致命错误:在第15行的/var/www/php_learning_testing/index.php中调用未定义的函数set_name()

谢谢你的帮助,它确实是愚蠢的.

php

0
推荐指数
1
解决办法
2300
查看次数

验证插件不适用于一个字段

我有一个非常简单的形式,我想要一个字段.

但是当我提交一个空白字段时,什么也没发生:它仍然提交.

$(document).ready(function() {
    jQuery("#commentForm").validate({
        rules:{
            message_name:{
                required:true
            }
        },
        messages:{
            message_name:{
                required:"Name Required"
            }
        }
    });
});

<form id="case-study-form" action="<?php get_option("siteurl");?>/case-study-downloads/"  method="post"  >
    <p><label class="modal-label" for="name">Name: <span>*</span></label> <input type="text" name="message_name" id="message_name" class="required" value=""></p>
    <p><input type="submit" value="Submit" ></p>
</form>
Run Code Online (Sandbox Code Playgroud)

jquery jquery-validate

0
推荐指数
1
解决办法
56
查看次数

标签 统计

php ×2

jquery ×1

jquery-validate ×1

loops ×1

notepad++ ×1

private-key ×1

sftp ×1

wordpress ×1