New answers tagged

0

The answer was an admin filter on post_link which was building a custom permalink and returning false in some edge-cases, which caused the edit button to be hidden.


0

Use this below code it will work as I have used this and working fine at my end. <?php $querystr = " SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->...


0

Solved. The problem was that mojs has to be included between the <body></body> tags, and the wp_enqueue_script() function that enqueued mojs needed an empty string as argument just before the 'true' parameter (I forgot to specify that there was no required version number of that script). So, changing wp_enqueue_script('mojs', 'https://cdn....


2

Anytime you want to use JavaScript in WordPress, you should enqueue it. Save the JS as a file, ie clickbutton.js inside your theme folder: document.getElementById("defaultOpen").click(); Then in functions.php, enqueue that file: add_action('wp_enqueue_scripts', 'wpse_371294_enqueue_js'); function wpse_371294_enqueue_js() { wp_enqueue_script('...


0

Try following way .................... URL: /wp-json/wp/v2/posts?_embed image: json["_embedded"]["wp:featuredmedia"][0]["source_url"], It's working fine.try


0

I think you should in this case use echo: function print_script() { echo '<script type="text/javascript"> window.onload = function () { var loadTime = window.performance.timing.domContentLoadedEventEnd-window.performance.timing.navigationStart; alert(loadTime); console.log(loadTime); } var var1 = <?php echo json_encode(...


0

If you wrap your booleans in an array, they come out clean: $settings = [ 'booleans' => [ 'foo' => true, 'bar' => false, ], ]; wp_localize_script('my-script-handle', 'mySettings', $settings); will render: <script type='text/javascript'> /* <![CDATA[ */ var mySettings = {"booleans":{"foo":true;"bar":...


0

I used the HTML input to save the image, as you can see below. <form enctype="multipart/form-data"> <input type="text" name="support_title" class="support-title"> <input type="file" id="sortpicture" name="upload"> <input class="save-support" name="...


0

Assuming you're looking at calling this via an AJAX style call from your browser, I'd suggest you look at the new Wordpress REST API. Here's the docs for the endpoint for updating posts. This will allow you to do exactly the same thing with the featured_media parameter, and much more, and is likely much better documented. https://developer.wordpress.org/rest-...


0

Or in case there's no text/javascript : add_filter( 'script_loader_tag', function( $tag, $handle, $src ) { if( 'script_handle' === $handle ) { $tag = str_replace( '<script', '<script type="text/paperscript" ', $tag ); } return $tag; }, 10, 3 );


1

In your GalleryImage const { withSelect } = wp.data; const { compose } = wp.compose; // You should define __ const { __ } = wp.i18n; In your FeaturedGallery You need to return the element, and set a key for the element (which is a list item): ( I also removed the index because it's not being used.. if we define a variable, it should be used. :) ) And ...


0

If you add handler for action with add_action, you should call this with do_action, but I does not see it. Also actions using in AJAX, simple POST/GET request is not need of Simple example of form handling <form method="POST" action="" class="my-form"> <input type="hidden" name="category" value=&...


3

The double NOT operator (!!) It's simply a way to convert/type-cast a non-boolean value to a boolean value, and !! <expression> gives us the opposite of ! <expression>. let foo = 'bar'; // non-empty string console.log( ! foo, !! foo ); // false, true foo = ''; // now it's an empty string console.log( ! foo, !! foo ); // true, false Issues in ...


0

I got an answer. We need to grab the code inside the Event Listener code like this: <script type="text/javascript"> document.addEventListener( 'wpcf7submit', function( event ) { inputs = event.detail.inputs; inputs.forEach( function(el) { if ( el.name == "menu-52" ) { if ( el.value == "Below $10,000" ) { ...


0

The first thing that i am not getting is $exclusive->y ? can you please share custom field settings that you have created? And the second thing that i have found, you must have to put global $post; in the first line of the function : add_filter( 'the_title', 'wpb_new_title', 10, 2 ); function wpb_new_title( $title, $id ) { global $post; if('post' == ...


Top 50 recent answers are included