You can do it in different ways:
Json Encode
This is my favorite way of passing data/settings/etc to the front-end.
PHP
$obj=array(
'content' => $post->post_content,
'title' => esc_html( get_the_title() )
);
Now the button output will be like this:
HTML
<button class="btn btn-primary tag_cnt get_button_more_info" type="button" value="<?=json_encode($obj)?>"></button>
Javascript
(function($) {
$('.get_button_more_info').on('click',function() {
var obj = $(this).val();
obj = JSON.parse(obj);
$("#myModal .modal-body").html(obj.content)
$("#myModal .modal-title").html(obj.title)
$("#myModal").modal();
});
})( jQuery );
Related Posts:
- How Display Posts on category
- Need help removing […] after excerpt
- WordPress Post Block Element not properly parsed with the_content filter
- How to center all text body in single.php at once?
- PHP tag in post content makes wordpress go crazy
- Automatically create a loop for post ID
- How to customize posts in WordPress by using HTML and CSS?
- Add multiple HTML attributes to an Elementor button
- start_lvl Ignored in Custom walker_nav_menu
- What exactly does “Posts page” do in WordPress?
- Adding a search form inside a div
- Load custom field value into div with AJAX
- Blank on static home page?
- How to use a frontend URL with a Plugin
- Insert code when users come from an specific referer
- How to display related posts from parent category
- How to display blog images using wordpress in existing project
- How to display a value from a radio button in the options menu in wordpress
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- Get_the_author doesn’t return author name
- Custom image upload
- How to display recent posts on home page with custom HTML
- WordPress automatically adds tags when pasting code, how to stop it?
- Slide in Panel WordPress Post
- Upload Image in a WordPress page using PHP
- How can I use wp_query to show all product data using just the products ID?
- HTML tags in bloginfo description
- Trying to add attribute to my posts’ featured image
- Transferring working local PHP site to wordpress – with database (MySQL)
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Using the echo command adds unwanted br tags to source
- Get post id in a function when edit/add a post
- Post + form + action + results on the same page
- Commenting out unwated CSS/scripts in HTML with PHP
- Loading index.php contents which located outside blog folder for post single page
- get post content of particular post by url
- Post repeating with infinite scroll
- Path for php file for inserting data through html form
- Widget back end radio button issue
- Count posts on multisite with blog id
- Making (and edit existing) posts with ID included
- Parsing Menu Items and Blog Posts
- Add shortcode in my div
- How to show an entire post content and not also the excerpt?
- PHP contact form not redirecting [closed]
- Increment paged on WP_Query
- Add new post in existing categories using wp_insert_post
- How do I add more options to the post-new.php page?
- Modify main query before it run without pre_get_post
- .html end of URl affected to SEO?
- Four posts per row [closed]
- Update if post with specific title exists
- Shortcode displaying at the top of the page [duplicate]
- Is it possible to isolate and use WordPress functions outside of wordpress
- Advanced Query posts
- My Custom Post Type AJAX Query is Returning no posts – why?
- Search bar for wp menu
- Executing php on button press
- Shortcode in Shortcode/HTML Graphics and Pictures
- How to get post image caption by index
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- Is there anyway I can call the year once?
- WP Website is shown in HTML
- Don’t update modified post date when user add a product review or comment?
- Mysterious letters appearing at the top of a few pages
- Current WordPress Page Title as Search Parameter into A Tag
- Limit the number of characters/words in an excerpt for a related posts section
- If user has clicked link add class and store using PHP/WordPress
- How to allow users to save list of posts in wordpress?
- HTML Formatting “single_term_title()”?
- How to Protect a private folder inside uploads folder, if User is not Logged In?
- Closing Comments conditionally in comments.php
- sessionStorage saves input value in browser but it is not loaded in the form field
- Having trouble with customizing blog posts on the home page
- Related Posts: if there is no category use tags
- Changable favicon
- How do if all posts has this category ID then do this
- Use PHP to inject HTML into before page renders?
- Get current_post in reverse order with pagination
- How to make a parent page for author.php?
- Getting error in sql query
- Multisite – Display different header content based on which site is accessed
- html to posts, jpg to featured image, zip file contains jpg and html
- Insert div after every three posts in home.php [duplicate]
- How do you change the tag font size in the repeater-template.php [closed]
- Unable to get Post Category Name and URL
- Dynamically Create Posts Via XML File
- How to only fetch certain Tag ID’s
- Where to find the html for WordPress site? [closed]
- Basic PHP question (displaying post title over thumbnail) [closed]
- insert thumbnail image from php script
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Pagination for div’s
- Post from front end form to post_meta
- media_handle_sideload() returned post_id being incremented
- How Can I Center the Logo in the Navigation Menu? [closed]
- Trying to see if page is category or single and displaying title with appropriate heading tag
- HTML in PHP problem [closed]
- Header location [closed]
- How to create different templates for woocommerce single-product.php?