在home/index上运行Wordpress插件快捷代码


Run Wordpress plugin shortcode on home/index

我们发现了一个wordpress插件,经过一些修改后效果良好。所有的东西都在一个页面上工作,但我们想把插件的短代码移到主页上。当我们这样做时,会显示快捷代码,而不是插件输出。我读到插件何时可以执行有限制(即,不在侧边栏中),并且有一些代码被认为允许短代码工作,但不管怎样,我们在索引上看到的是短代码,而不是插件输出。

有人有任何经验让插件快捷代码在wordpress安装的主页/索引页上工作吗?

谢谢,

更新:下面是我认为生成主页的index.php。我们对这个文件进行了更改以更新主页,这是我在标准HTML中放置快捷代码的地方(这可能不是正确的方法)。

<?php get_header();?>
<div id="content">
    <h1 class="hidden">Haute Inhabit</h1>
    <div class="wrapper clear">
        <div class="main section" id="main" role="main">
            <div class="widget Blog" id="Blog1">
                <div class="blog-posts hfeed">
                    <!-- google_ad_section_start(name=default) -->
                    <?php 
                    $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                    $query = new WP_Query( array( 'paged' => $paged, 'cat'=>'-460' ) ); 
                    //$query = new WP_Query( 'cat=-460&posts_per_page=5' );
                    if ( $query->have_posts() ):
                         /*$tmp = $wp_query;
                         $wp_query = null;
                         $wp_query = new WP_Query('showposts=3');*/
                               //$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                        //$my_query = new WP_Query('showposts=3&paged=' . $paged);
                        while ($query->have_posts() ) : $query->the_post(); ?>

                            <div class="post hentry">
                                <a id="6576135133677080233" name=
                                "6576135133677080233"></a>
                                <h3 class="date-header"><span><?php echo get_the_date(); ?></span></h3>
                                <h2 class="post-title entry-title"><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
                                <div class="post-lead entry-content">
                                    <?php echo get_first_paragraph() ?>
                                </div>
                                <div class="post-image">
                                    <a href="<?php the_permalink();?>">
                                    <?php 
                                    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                                        the_post_thumbnail('full');
                                    } else {
                                    ?>
                                        <img src="<?php echo catch_that_image() ?>">
                                    <?php } ?>
                                    </a>
                                </div>
                                <div class="post-utility">
                                    <div class="inner clear">
                                        <a href="<?php the_permalink();?>" class="view">View More</a>
                                        <div class="comments">
                                            <?php if ( comments_open() ) : ?><span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Comment', 'hautein' ) . '</span>', __( '<em>1</em> Comment', 'hautein' ), __( '<em>%</em> Comments', 'hautein' ) ); ?></span>
                                            <?php endif; // End if comments_open() ?>
                                        </div>
                                        <a href="#" class="share"><span>Share</span></a>
                                    </div>
                                    <?php include('inc/social.php'); ?>
                                </div>      
                            </div>
                        <?php endwhile;?>
                        <?php
                            // $wp_query=$tmp;
                            //hautein_content_nav( 'nav-below' );
                        endif;?>
                        <div class="pagination clear">
                        <?php
                            global $wp_query;
                            $big = 999999999; // need an unlikely integer
                            echo paginate_links( array(
                                'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
                                'format' => '?paged=%#%',
                                'current' => max( 1, get_query_var('paged') ),
                                'total' => $wp_query->max_num_pages,
                                'prev_text' => 'Prev',
                                'next_text' => 'Next'
                            ) );
                        ?>
                        </div>
                </div>
                <script type="text/javascript">
                    window.___gcfg = {'lang': 'en'};
                </script>
            </div>
        </div>
        <?php get_sidebar();?>
    </div>
</div>
<?php get_footer();?>

您可以使用一个插件来转换小部件中的短代码

https://wordpress.org/plugins/shortcode-widget/

或使用此短代码

https://wordpress.org/plugins/shortcodes-ultimate/

不应该有任何问题,比如短代码没有出现。。。

除非你的索引提取了你帖子的摘录,否则shortcode可能不会按预期工作。

为了更好地解决您的问题,您确实需要知道哪个文件正在显示您的索引页,并在此处向我们显示代码。