Sunday, December 11, 2022
HomeWordPress DevelopmentPublish content material in bootstrap modal

Publish content material in bootstrap modal


I attempted to open publish content material in a bootstrap modal window, however one thing just isn’t working accurately. I do not know what the error is and I would love some assist to know.

Publish show:

<?php $args = array(
'p' => $postID, // ID поста
'post_type' => 'any'
);
$current = new WP_Query($args);
whereas ( $recent->have_posts() ) : $recent->the_post();?>

<a data-ajax-param="<?php the_ID(); ?>" data-toggle="modal" data-target="#postModal"><?php the_title() ?></a>

<?php endwhile; ?>

Bootstrap modal:

<div class="modal fade" id="postModal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content ajax">

        </div>
    </div>
</div>

Enabled AJAX help and declared perform in features.php:

add_action('wp_ajax_my_action', 'data_fetch');
add_action('wp_ajax_nopriv_my_action', 'data_fetch');

perform data_fetch($postID){
    $postID=intval( $_POST['param'] );
    
    $args = array(
    'p' => $postID, // ID of a web page, publish, or customized kind
    'post_type' => 'motion pictures'
    );

    $current = new WP_Query($args);

    whereas ( $recent->have_posts() ) : $recent->the_post();?>

        <div class="modal-header">
        <button kind="button" class="shut" data-dismiss="modal" aria-label="Shut"><span aria-hidden="true">&occasions;</span></button>
        <?php the_title( '<h2 class="modal-title text-center">', '</h2>' ); ?>
        </div>

        <div class="row">

            <div class="col-lg-9">
                <?php the_content(); ?>
            </div>
        </div>

    <?php endwhile; ?>
<?php
    die();
}

Jquery scripts for the perform to work, I added in foremost.js:

perform fetch(e){var param = $(e.goal).attr('data-ajax-param');
  $.publish('wp-admin/admin-ajax.php', {'motion':'my_action', 'param':param}, perform(response){
   $('.modal-content.ajax').html(response);
});
}

//-------------

$( '[data-ajax-param]' ).click on(perform (e) {
 fetch(e);
});

The posts is displayed, however when I attempt to open them, nothing occurs.
I wish to perceive what I didn’t enter accurately?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments