AJAXing一个WordPress自定义主题(AJAXing a WordPress custom

2019-10-19 21:51发布

我试图让我的女朋友的烹饪和烘焙博客自定义主题。 我想让这个有被点击的博客文章缩略图的链接时,没有页面刷新。 相反,我想动态加载的博客文章的内容与阿贾克斯与ID =“主要内容”的home.php里的文章,我也想使单个帖子深层链接。 下面是该网站会有点像(还没有完成): http://natalija.co.nf/每个类别都有其内部3页缩略图的链接信息将会显示一个滑块,并与文章的板块内该帖将在页面底部显示,仅仅前躯应加载。 这里是我的home.php和single.php中页面的代码:

home.php

<?php get_header(); ?>
<?php
$args = array(
    'orderby' => 'id',
    'order' => 'ASC',
    'hide_empty' => '0',
    'exclude' => '1'
);
$categories = get_categories($args);
foreach($categories as $category) {
    ?>

    <section id="<?php echo $category->slug; ?>" data-stellar-background-ratio="0.5">
        <article class="<?php echo $category->slug; ?>" data-stellar-ratio="1.5">
            <h1><?php echo $category->name; ?></h1>
            <div class="wrapper">
                <ul class="slider">

                <?php
                    $args = array (
                        'post_status' => 'publish',
                        'category_name' => $category->slug,
                        'nopaging' => true,
                    );
                    $custom_query = new WP_Query( $args );

                    if ( $custom_query->have_posts() ) {
                        while ( $custom_query->have_posts() ) {
                            $custom_query->the_post();

                                // begin your slider loops in here
                                ?>

                                    <li class="slide">
                                        <a href="<?php echo get_permalink(); ?>">
                                            <?php the_post_thumbnail(); ?>
                                            <div class="bubble">
                                                <h5><?php echo get_the_title(); ?></h5>
                                            </div>
                                        </a>
                                    </li>

                    <?php } // end $custom_query loop

                    } else {
                        // no posts found
                    }

                    // reset the postdata
                    wp_reset_postdata();
                ?>

                </ul>
                <img class="previous" src="wp-content/themes/Natalija/images/arrow-transparent.png" alt="random" data-stellar-ratio="1.7">
                <img class="next" src="wp-content/themes/Natalija/images/arrow-transparent.png" alt="random" data-stellar-ratio="1.7">
            </div>
        </article>
    </section>
<?php
} // end $categories loop
?>
<section>
            <article id="main-content">

            </article>
        </section>
<?php get_footer(); ?>

single.php中

    <div class="post-wrap">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">

        <h1><?php the_title(); ?></h1>

        <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>

        <div class="entry">

            <?php the_content(); ?>

            <?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>

            <?php the_tags( 'Tags: ', ', ', ''); ?>

        </div>

        <?php edit_post_link('Edit this entry','','.'); ?>

    </div>

<?php comments_template(); ?>

<?php endwhile; endif; ?>
</div>

我想下面就AJAX几个在线教程,但我不能把它关闭。 谁能帮我这个?

文章来源: AJAXing a WordPress custom theme