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
- Missing sidebar parameter “fix” – before_content
- Automatically add custom CSS to new posts using a category template
- Hide wordpress field if data is empty in post!
- How to get the POST TITLE using the POST ID?
- How can I use wp_query to show all product data using just the products ID?
- Query all posts of a custom taxonomy term
- Retrieving Author ID in wp-admin area
- HTML tags in bloginfo description
- ACF page while loop breaks footer while loop
- Add a class to the anchor tag on HTML5 gallery
- Trying to add attribute to my posts’ featured image
- Transferring working local PHP site to wordpress – with database (MySQL)
- Displaying the last post on static homepage
- how to remove metadata from the posts of my blog?
- Can’t get wp_insert_post to work
- Why not yield/iterable in posts interface?
- Load a page into a div with Ajax
- My form action url is being prepended with a directory that does not exists
- Best practice for migration friendly images in posts/pages?
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Converting HTML Template to WordPress Theme
- Multiple options not staying selected after saving
- How to show part of the_content?
- Using the echo command adds unwanted br tags to source
- custom fields wordpress
- Why the JavaScript code is ignored from wp editor?
- Populate dropdown with Child Pages based on Parent Page chosen
- Unreadable pagination
- 200 Rewrite blog post links
- How to store data from multiple forms using ajax and php
- How to set a min number of words for a blog post
- search and replace preword from author
- Embed html in php code
- Loop through categories and display posts title under each dropdown
- Get post id in a function when edit/add a post
- how do I get a specific post from a post with a subcategory in WP
- Automatically create child pages and grandchild pages when saving a (parent) page
- WP grandchild categories in nested ul li
- Use DOMDocument with ob_start breaks my HTML code
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Second transition_post_status hook fired instead of the first
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to store post ID’s in cookie or session to display the same posts later
- Which hook/action will help me solve my problem?
- How can I add extra word in permalink when someone click download button?
- selected option if current category is the value
- Post + form + action + results on the same page
- Open post-content in archive page in a Modal box with bootstrap
- How to remove ?wp-mce-4103-20162941
- Customize position of social icons in upme plugin [closed]
- Why Won’t My Inputs in a form with a Get method work together?
- parts of url disappear when using # inside href=”” [closed]
- Settings API callback function inserts html quotes from nowhere
- Input data from email form not going to JSON file
- How to get the value of input hidden html from text editor to custom page template?
- remove post that has no content
- Different post styles depending on category
- How create a Shortcode with hover and complex options
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- Dot is not added at the end of href
- WordPress Multiple Navigation bars
- Position banner to right of logo in header – messed up my header file
- 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
- Custom posts in different columns style
- Get children post mime type using parent post_ID wp_post
- How to separate HTML and WordPress files
- Add .htm extention to a custom taxonomy
- How to show only subcategories in parent category not parent category?
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- 404 error when I acess the second page of post-type
- How do I add a custom css to all posts without affecting homepage css? [closed]
- Make PHP work with HTML tags
- Noscript not working as it should in wordpress site
- Show latest posts in a plain HTML website custom widget [closed]
- Which PHP page is the Default Posts Page
- How to convert select to HTML with PHP tags inside of it [closed]
- Is this spyware on my site or a real Java update?
- Syntax error when I try to insert my loop into an unordered list? [closed]
- retrieve post data and insert it in seperate static html page without WordPress
- How to make modifications only to certain elements of an HTML string on the server-side?
- WP Insert Post and then go to post
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Returning data instead of echoing/printing
- Wrapping a Sidebar within
- Display related posts without a plugin
- Search WordPress using static html page
- Hide HTML element (by class or ID) with PHP
- Counting Search results, and displaying the offset per page