qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
383,360
<p>I have, based on post category, added a password form (shortcode) whereof the purpose is to hide certain HTML code.</p> <p>To do this, I have wrapped certain HTML-tags in a shortcode using the <code>the_content</code> filter.</p> <p>The password itself is added through an array, which would be much better suited as ...
[ { "answer_id": 383485, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 2, "selected": false, "text": "<p>Not exactly sure what you are trying to do and this doesn't look like a WordPress issue, but submitting a html f...
2021/02/14
[ "https://wordpress.stackexchange.com/questions/383360", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/201877/" ]
I have, based on post category, added a password form (shortcode) whereof the purpose is to hide certain HTML code. To do this, I have wrapped certain HTML-tags in a shortcode using the `the_content` filter. The password itself is added through an array, which would be much better suited as an global setting through ...
Not exactly sure what you are trying to do and this doesn't look like a WordPress issue, but submitting a html form will certainly lead to a new page load. So what you want is redirect not to the same page (which happens when you specify no action, leading the page to scroll to the top) but to an anchor on that page. T...
383,498
<p>I have a site that uses a set of 3 images for the header of its subpages. Each page has a different set of images. From what I could find, my best way to accomplish this would be to place an if statement within my <code>header-subpage.php</code>. The following is a snippet of my code.</p> <pre><code>&lt;?php if ( is...
[ { "answer_id": 383363, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>There isn’t a way. You need to create a child theme or a plugin and put the functions there.</p>\n<p>No...
2021/02/16
[ "https://wordpress.stackexchange.com/questions/383498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202028/" ]
I have a site that uses a set of 3 images for the header of its subpages. Each page has a different set of images. From what I could find, my best way to accomplish this would be to place an if statement within my `header-subpage.php`. The following is a snippet of my code. ``` <?php if ( is_page( 'available-homes' ) ...
There isn’t a way. You need to create a child theme or a plugin and put the functions there. Note that there’s nothing special about child themes. The point is to put the code into something that somebody else isn’t going to update. So third party child themes aren’t safe either.
383,511
<p>We have a normal WordPress gallery on a <a href="https://herodevelopment.com.au/allbathroomgear/design-build/bathrooms/" rel="nofollow noreferrer">development webpage</a>.</p> <p><a href="https://i.stack.imgur.com/x4XcK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x4XcK.png" alt="enter image de...
[ { "answer_id": 383363, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>There isn’t a way. You need to create a child theme or a plugin and put the functions there.</p>\n<p>No...
2021/02/17
[ "https://wordpress.stackexchange.com/questions/383511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/201824/" ]
We have a normal WordPress gallery on a [development webpage](https://herodevelopment.com.au/allbathroomgear/design-build/bathrooms/). [![enter image description here](https://i.stack.imgur.com/x4XcK.png)](https://i.stack.imgur.com/x4XcK.png) The page is custom content through Advanced Custom Fields, and we are wrapp...
There isn’t a way. You need to create a child theme or a plugin and put the functions there. Note that there’s nothing special about child themes. The point is to put the code into something that somebody else isn’t going to update. So third party child themes aren’t safe either.
383,539
<p>My aim is to import all XML files from a folder inside the WordPress installation (/data/*.xml)</p> <p>To achieve this, I added action in functions.php:</p> <pre><code>/** * Show 'insert posts' button on backend */ add_action( &quot;admin_notices&quot;, function() { echo &quot;&lt;div class='updated'&gt;&quot;...
[ { "answer_id": 383363, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>There isn’t a way. You need to create a child theme or a plugin and put the functions there.</p>\n<p>No...
2021/02/17
[ "https://wordpress.stackexchange.com/questions/383539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112604/" ]
My aim is to import all XML files from a folder inside the WordPress installation (/data/\*.xml) To achieve this, I added action in functions.php: ``` /** * Show 'insert posts' button on backend */ add_action( "admin_notices", function() { echo "<div class='updated'>"; echo "<p>"; echo "To insert the po...
There isn’t a way. You need to create a child theme or a plugin and put the functions there. Note that there’s nothing special about child themes. The point is to put the code into something that somebody else isn’t going to update. So third party child themes aren’t safe either.
383,632
<p>I struggle with columns block in my plugin. I try to filter all blocks of the type &quot;heading&quot;:</p> <pre><code>$post = get_post(); $blocks = parse_blocks($post-&gt;post_content); $headings = array_values(array_filter($blocks, function ($block) { return $block['blockName'] === 'core/heading'; })); </code>...
[ { "answer_id": 383639, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 2, "selected": true, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/parse_blocks/\" rel=\"nofollow noreferrer\"><...
2021/02/18
[ "https://wordpress.stackexchange.com/questions/383632", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33797/" ]
I struggle with columns block in my plugin. I try to filter all blocks of the type "heading": ``` $post = get_post(); $blocks = parse_blocks($post->post_content); $headings = array_values(array_filter($blocks, function ($block) { return $block['blockName'] === 'core/heading'; })); ``` This returns an array of al...
[`parse_blocks()`](https://developer.wordpress.org/reference/functions/parse_blocks/) simply returns all blocks found in the post content, so for what you're trying to get, you could use a function which calls itself recursively like so: ```php function my_find_heading_blocks( $blocks ) { $list = array(); for...
383,658
<p>I am trying to understand some fundamentals of php with regards to adding new functions to actions. I found a tutorial where he adds a new function to the <code>save_post</code> action…</p> <pre><code>add_action('save_post', 'log_when_saved'); function log_when_saved($post_id){ do something with $post_id }; </code...
[ { "answer_id": 383662, "author": "Buttered_Toast", "author_id": 192133, "author_profile": "https://wordpress.stackexchange.com/users/192133", "pm_score": 3, "selected": false, "text": "<p>For this example lets say we have the following</p>\n<pre><code>do_action('bt_custom_action', get_th...
2021/02/19
[ "https://wordpress.stackexchange.com/questions/383658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202161/" ]
I am trying to understand some fundamentals of php with regards to adding new functions to actions. I found a tutorial where he adds a new function to the `save_post` action… ``` add_action('save_post', 'log_when_saved'); function log_when_saved($post_id){ do something with $post_id }; ``` Is my understanding corr...
For this example lets say we have the following ``` do_action('bt_custom_action', get_the_ID(), get_the_title(), get_the_content()); ``` The arguments that will be passed to `add_action` would be in this order 1. the post id 2. the post title 3. the post content By default if we hook into our `do_action` without a...
383,684
<p>I created a loop for my Custom Posts Type <code>workshop</code> with two custom taxonomies <code>group</code> and <code>teacher</code> on the same page. The Ajax filter works perfectly thanks to the solution provided <a href="https://wordpress.stackexchange.com/questions/383666/ajax-filter-with-custom-taxonomies">he...
[ { "answer_id": 383685, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 0, "selected": false, "text": "<p>The issue is using <code>isset()</code> for the conditions:</p>\n<pre><code>isset($_POST['categoryfilte...
2021/02/19
[ "https://wordpress.stackexchange.com/questions/383684", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/110282/" ]
I created a loop for my Custom Posts Type `workshop` with two custom taxonomies `group` and `teacher` on the same page. The Ajax filter works perfectly thanks to the solution provided [here](https://wordpress.stackexchange.com/questions/383666/ajax-filter-with-custom-taxonomies). The user can select one taxonomy or bot...
Going by what @JacobPeattie said, that they are still set but empty you need to change the conditional login to check for empty. In our previous discussion I wrote this conditions ``` if ((isset($_POST['categoryfilter1']) && !empty($_POST['categoryfilter1'])) && (isset($_POST['categoryfilter2']) && !empty($_POST['cat...
383,690
<p>So i need to get and echo current users last post date.</p> <p>What i have researched and tested.</p> <p>Red article here: <a href="https://developer.wordpress.org/reference/functions/get_most_recent_post_of_user/" rel="nofollow noreferrer">https://developer.wordpress.org/reference/functions/get_most_recent_post_of_...
[ { "answer_id": 383685, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 0, "selected": false, "text": "<p>The issue is using <code>isset()</code> for the conditions:</p>\n<pre><code>isset($_POST['categoryfilte...
2021/02/19
[ "https://wordpress.stackexchange.com/questions/383690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138704/" ]
So i need to get and echo current users last post date. What i have researched and tested. Red article here: <https://developer.wordpress.org/reference/functions/get_most_recent_post_of_user/> Red this thread here but none of the codes worked: [Get how many days since last post of the current user](https://wordpress...
Going by what @JacobPeattie said, that they are still set but empty you need to change the conditional login to check for empty. In our previous discussion I wrote this conditions ``` if ((isset($_POST['categoryfilter1']) && !empty($_POST['categoryfilter1'])) && (isset($_POST['categoryfilter2']) && !empty($_POST['cat...
383,794
<p>WordPress has a cron named &quot;<code>delete_expired_transients</code>&quot; as seen in the image below.</p> <p><a href="https://i.stack.imgur.com/901Ap.png" rel="noreferrer"><img src="https://i.stack.imgur.com/901Ap.png" alt="enter image description here" /></a></p> <p>In this way, does it clean expired <strong>tr...
[ { "answer_id": 383796, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 4, "selected": true, "text": "<p>Yes, <code>delete_expired_transients</code> is a cron event that runs once per day and the function <code>d...
2021/02/21
[ "https://wordpress.stackexchange.com/questions/383794", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162608/" ]
WordPress has a cron named "`delete_expired_transients`" as seen in the image below. [![enter image description here](https://i.stack.imgur.com/901Ap.png)](https://i.stack.imgur.com/901Ap.png) In this way, does it clean expired **transients** daily? --- **Or is it just giving us action?** Should we clean it oursel...
Yes, `delete_expired_transients` is a cron event that runs once per day and the function `delete_expired_transients()` is automatically called when the cron event runs — see [*wp-includes/default-filters.php*](https://core.trac.wordpress.org/browser/tags/5.6.1/src/wp-includes/default-filters.php#L387). So you do not ne...
383,824
<p>I am desperately attempting to find a way to get an alert when a specific article on my WordPress is visited (and no, I will not be flooded by emails, the code will be used temporarely) Being new to php, I used this code, but the site gets a critical error if I put it into the functions.php?</p> <pre><code> function...
[ { "answer_id": 383829, "author": "Rup", "author_id": 3276, "author_profile": "https://wordpress.stackexchange.com/users/3276", "pm_score": 1, "selected": false, "text": "<p>There's no <code>is_article</code>. I assume you guessed there would be analogously to is_page, but I don't think a...
2021/02/22
[ "https://wordpress.stackexchange.com/questions/383824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202302/" ]
I am desperately attempting to find a way to get an alert when a specific article on my WordPress is visited (and no, I will not be flooded by emails, the code will be used temporarely) Being new to php, I used this code, but the site gets a critical error if I put it into the functions.php? ``` function email_alert(...
here we go, this is the code that works, triggering an email-alert when a specific article is viewed ``` function email_alert() { global $post; if( $post->ID == 1234) { wp_mail( 'aprilia@example.net', 'Alert', 'This Site was Visited!' ); } } add_action( 'wp', 'email_alert' ); ```
383,894
<p>I have a single page site with all content on it. The only other page I have is a &quot;thanks for submitting the contact form&quot; page. In this &quot;thankssubmit.php&quot; page I have my PHP form submission code.</p> <p>I'm new to wordpress so I may be doing this totally wrong but I've created a custom page temp...
[ { "answer_id": 383829, "author": "Rup", "author_id": 3276, "author_profile": "https://wordpress.stackexchange.com/users/3276", "pm_score": 1, "selected": false, "text": "<p>There's no <code>is_article</code>. I assume you guessed there would be analogously to is_page, but I don't think a...
2021/02/23
[ "https://wordpress.stackexchange.com/questions/383894", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202384/" ]
I have a single page site with all content on it. The only other page I have is a "thanks for submitting the contact form" page. In this "thankssubmit.php" page I have my PHP form submission code. I'm new to wordpress so I may be doing this totally wrong but I've created a custom page template for this "thankssubmit.p...
here we go, this is the code that works, triggering an email-alert when a specific article is viewed ``` function email_alert() { global $post; if( $post->ID == 1234) { wp_mail( 'aprilia@example.net', 'Alert', 'This Site was Visited!' ); } } add_action( 'wp', 'email_alert' ); ```
384,038
<p>I'm using the following code to set my Open Graph meta data in functions.php</p> <p>It works great for selecting the featured image, however I would like to set it to use the product gallery image instead (which is better for social media marketing). Here's a screen grab to be more specific: <a href="https://snipboa...
[ { "answer_id": 383829, "author": "Rup", "author_id": 3276, "author_profile": "https://wordpress.stackexchange.com/users/3276", "pm_score": 1, "selected": false, "text": "<p>There's no <code>is_article</code>. I assume you guessed there would be analogously to is_page, but I don't think a...
2021/02/25
[ "https://wordpress.stackexchange.com/questions/384038", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73776/" ]
I'm using the following code to set my Open Graph meta data in functions.php It works great for selecting the featured image, however I would like to set it to use the product gallery image instead (which is better for social media marketing). Here's a screen grab to be more specific: <https://snipboard.io/buvHfk.jpg>...
here we go, this is the code that works, triggering an email-alert when a specific article is viewed ``` function email_alert() { global $post; if( $post->ID == 1234) { wp_mail( 'aprilia@example.net', 'Alert', 'This Site was Visited!' ); } } add_action( 'wp', 'email_alert' ); ```
384,040
<p>I have custom post type.</p> <p>How it is possible to loop through the page created in this custom post type please ?</p> <p>Thanks.</p>
[ { "answer_id": 383829, "author": "Rup", "author_id": 3276, "author_profile": "https://wordpress.stackexchange.com/users/3276", "pm_score": 1, "selected": false, "text": "<p>There's no <code>is_article</code>. I assume you guessed there would be analogously to is_page, but I don't think a...
2021/02/25
[ "https://wordpress.stackexchange.com/questions/384040", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202291/" ]
I have custom post type. How it is possible to loop through the page created in this custom post type please ? Thanks.
here we go, this is the code that works, triggering an email-alert when a specific article is viewed ``` function email_alert() { global $post; if( $post->ID == 1234) { wp_mail( 'aprilia@example.net', 'Alert', 'This Site was Visited!' ); } } add_action( 'wp', 'email_alert' ); ```
384,067
<p>Let´s say a user signs up to multiple memberships, each on a different date.</p> <p>User signs up to:</p> <ul> <li>Membership A on 05.03.2021</li> <li>Membership B on 17.05.2021</li> <li>Membership C on 29.07.2021</li> </ul> <p>I would like the dates for that user to be saved with the same meta_key. Each saved value...
[ { "answer_id": 383829, "author": "Rup", "author_id": 3276, "author_profile": "https://wordpress.stackexchange.com/users/3276", "pm_score": 1, "selected": false, "text": "<p>There's no <code>is_article</code>. I assume you guessed there would be analogously to is_page, but I don't think a...
2021/02/25
[ "https://wordpress.stackexchange.com/questions/384067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202502/" ]
Let´s say a user signs up to multiple memberships, each on a different date. User signs up to: * Membership A on 05.03.2021 * Membership B on 17.05.2021 * Membership C on 29.07.2021 I would like the dates for that user to be saved with the same meta\_key. Each saved value/date should be linked to the specific member...
here we go, this is the code that works, triggering an email-alert when a specific article is viewed ``` function email_alert() { global $post; if( $post->ID == 1234) { wp_mail( 'aprilia@example.net', 'Alert', 'This Site was Visited!' ); } } add_action( 'wp', 'email_alert' ); ```
384,072
<p>I have a situation where I have a function hooked to more than one custom hooks. How to check in the callback function which custom hook triggered the call?</p> <p>Or the question in code will be</p> <pre><code>add_action('my_test_hook_1','my_test_callback_function'); add_action('my_test_hook_2','my_test_callback_fu...
[ { "answer_id": 384075, "author": "Coder At Heart", "author_id": 170574, "author_profile": "https://wordpress.stackexchange.com/users/170574", "pm_score": 0, "selected": false, "text": "<p>The solution will be to add a parameter to <code>do_action</code> and then pick that up in your <cod...
2021/02/25
[ "https://wordpress.stackexchange.com/questions/384072", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202503/" ]
I have a situation where I have a function hooked to more than one custom hooks. How to check in the callback function which custom hook triggered the call? Or the question in code will be ``` add_action('my_test_hook_1','my_test_callback_function'); add_action('my_test_hook_2','my_test_callback_function'); add_actio...
I found the magic code you need. Use `current_filter()`. This function will return name of the current filter or action. ``` add_action('my_test_hook_1','my_test_callback_function'); add_action('my_test_hook_2','my_test_callback_function'); add_action('my_test_hook_3','my_test_callback_function'); add_action('my_test...
384,093
<p>Im using local by flywheel, Here are the steps i have taken so far:</p> <ol> <li>Installed local by flywheel and created a site called stage</li> <li>Downloaded the website from CPanel and also the SQL database</li> <li>Imported the database in admirer (but the links are all the same, How can i change them?)</li> <l...
[ { "answer_id": 384075, "author": "Coder At Heart", "author_id": 170574, "author_profile": "https://wordpress.stackexchange.com/users/170574", "pm_score": 0, "selected": false, "text": "<p>The solution will be to add a parameter to <code>do_action</code> and then pick that up in your <cod...
2021/02/25
[ "https://wordpress.stackexchange.com/questions/384093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202528/" ]
Im using local by flywheel, Here are the steps i have taken so far: 1. Installed local by flywheel and created a site called stage 2. Downloaded the website from CPanel and also the SQL database 3. Imported the database in admirer (but the links are all the same, How can i change them?) 4. Deleted the 'wp\_content' fo...
I found the magic code you need. Use `current_filter()`. This function will return name of the current filter or action. ``` add_action('my_test_hook_1','my_test_callback_function'); add_action('my_test_hook_2','my_test_callback_function'); add_action('my_test_hook_3','my_test_callback_function'); add_action('my_test...
384,100
<p>I just did a major update in my WordPress environment tonight to the latest version, and got an internal server error on the site. I then did a full inspection to see where the issue was coming from. I think I found the culprit...When I commented out the following line in my .htaccess file, the site came back...</...
[ { "answer_id": 384119, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 2, "selected": true, "text": "<blockquote>\n<pre><code>Header unset Vary\n</code></pre>\n</blockquote>\n<p>This is probably a workaround for a su...
2021/02/26
[ "https://wordpress.stackexchange.com/questions/384100", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98671/" ]
I just did a major update in my WordPress environment tonight to the latest version, and got an internal server error on the site. I then did a full inspection to see where the issue was coming from. I think I found the culprit...When I commented out the following line in my .htaccess file, the site came back... ```js...
> > > ``` > Header unset Vary > > ``` > > This is probably a workaround for a supposed [bug in Apache](https://www.jeffgeerling.com/blog/2017/stripping-vary-host-header-apache-response-using-varnish) ([#58231](https://bz.apache.org/bugzilla/show_bug.cgi?id=58231))**\*1** that could prevent certain caching proxies...
384,131
<p>I am working on generating a JWT token for the users who log in to my site using a plugin <a href="https://wordpress.org/plugins/jwt-auth/" rel="nofollow noreferrer">JWT Auth</a> and that token will be used for a external dashboard.</p> <p>The issue that I am facing is that for generating a JWT token you need to pas...
[ { "answer_id": 384179, "author": "FaISalBLiNK", "author_id": 68212, "author_profile": "https://wordpress.stackexchange.com/users/68212", "pm_score": 2, "selected": true, "text": "<p>For the developers who are facing the similar issue here is what I have done to achieve the desired result...
2021/02/26
[ "https://wordpress.stackexchange.com/questions/384131", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68212/" ]
I am working on generating a JWT token for the users who log in to my site using a plugin [JWT Auth](https://wordpress.org/plugins/jwt-auth/) and that token will be used for a external dashboard. The issue that I am facing is that for generating a JWT token you need to pass `username` and `password` as `form-data` to ...
For the developers who are facing the similar issue here is what I have done to achieve the desired results. The best way would be to develop the functionality from scratch but due to a tight deadline I opted to modify the [JWT Auth Plugin](https://wordpress.org/plugins/jwt-auth/) I have modified the method `get_toke...
384,135
<p>I want my WordPress website to load with https + non-www and without trailing slashes. I put the following code in <code>.htaccess</code> file:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On # Remove trailing slash from non-filepath urls RewriteCond %{REQUEST_URI} /(.+)/$ RewriteCond %{REQUEST_FI...
[ { "answer_id": 384145, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 3, "selected": true, "text": "<p>To reduce multiple slashes at the start of the URL-path (or in fact <em>anywhere</em> in the URL-path) to a sing...
2021/02/26
[ "https://wordpress.stackexchange.com/questions/384135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202546/" ]
I want my WordPress website to load with https + non-www and without trailing slashes. I put the following code in `.htaccess` file: ``` <IfModule mod_rewrite.c> RewriteEngine On # Remove trailing slash from non-filepath urls RewriteCond %{REQUEST_URI} /(.+)/$ RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ htt...
To reduce multiple slashes at the start of the URL-path (or in fact *anywhere* in the URL-path) to a single slash (there is always at least 1 slash at the start of the URL-path, even if you can't see this is the browser's address bar) then you can use a directive like the following: ``` # Reduce multiple slashes to si...
384,140
<p>I have a WordPress project im doing, pretty much I need to add 4 individual blog posts with background images behind the specific posts. This is the code i found and used, the only issue is they blog posts aren't clickable, not even the title. I am not sure where to go from here to make each link clickable.</p> <pr...
[ { "answer_id": 384145, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 3, "selected": true, "text": "<p>To reduce multiple slashes at the start of the URL-path (or in fact <em>anywhere</em> in the URL-path) to a sing...
2021/02/26
[ "https://wordpress.stackexchange.com/questions/384140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202557/" ]
I have a WordPress project im doing, pretty much I need to add 4 individual blog posts with background images behind the specific posts. This is the code i found and used, the only issue is they blog posts aren't clickable, not even the title. I am not sure where to go from here to make each link clickable. ``` By <?p...
To reduce multiple slashes at the start of the URL-path (or in fact *anywhere* in the URL-path) to a single slash (there is always at least 1 slash at the start of the URL-path, even if you can't see this is the browser's address bar) then you can use a directive like the following: ``` # Reduce multiple slashes to si...
384,168
<p>I want to count authors post count in a specific category. How do i do that? I have red this thread here but still can't fiure it out.</p> <p><a href="https://wordpress.stackexchange.com/questions/261302/count-number-of-posts-by-author-in-a-category">Count number of posts by author in a category</a></p> <p>Edit: Thi...
[ { "answer_id": 384145, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 3, "selected": true, "text": "<p>To reduce multiple slashes at the start of the URL-path (or in fact <em>anywhere</em> in the URL-path) to a sing...
2021/02/27
[ "https://wordpress.stackexchange.com/questions/384168", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138704/" ]
I want to count authors post count in a specific category. How do i do that? I have red this thread here but still can't fiure it out. [Count number of posts by author in a category](https://wordpress.stackexchange.com/questions/261302/count-number-of-posts-by-author-in-a-category) Edit: This is what i got and tried ...
To reduce multiple slashes at the start of the URL-path (or in fact *anywhere* in the URL-path) to a single slash (there is always at least 1 slash at the start of the URL-path, even if you can't see this is the browser's address bar) then you can use a directive like the following: ``` # Reduce multiple slashes to si...
384,186
<p>I have just installed WordPress locally in my computer and run the website successfully. I want to achieve following: when logged-in user tries to access wp-login.php or register page, it should be automatically redirected to home page.</p> <p>I have spent several hours on web, but could no come up with solution nei...
[ { "answer_id": 384145, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 3, "selected": true, "text": "<p>To reduce multiple slashes at the start of the URL-path (or in fact <em>anywhere</em> in the URL-path) to a sing...
2021/02/27
[ "https://wordpress.stackexchange.com/questions/384186", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202589/" ]
I have just installed WordPress locally in my computer and run the website successfully. I want to achieve following: when logged-in user tries to access wp-login.php or register page, it should be automatically redirected to home page. I have spent several hours on web, but could no come up with solution neither was ...
To reduce multiple slashes at the start of the URL-path (or in fact *anywhere* in the URL-path) to a single slash (there is always at least 1 slash at the start of the URL-path, even if you can't see this is the browser's address bar) then you can use a directive like the following: ``` # Reduce multiple slashes to si...
384,212
<p>I've been looking for this method for weeks, but still can't find it. There are so many sites that discuss how to create a custom login page, but they don't cover how to block a specific id like the one I was looking for.</p> <p>The algorithm is as below:</p> <p>first I will determine the user id number that I will ...
[ { "answer_id": 384145, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 3, "selected": true, "text": "<p>To reduce multiple slashes at the start of the URL-path (or in fact <em>anywhere</em> in the URL-path) to a sing...
2021/02/28
[ "https://wordpress.stackexchange.com/questions/384212", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202647/" ]
I've been looking for this method for weeks, but still can't find it. There are so many sites that discuss how to create a custom login page, but they don't cover how to block a specific id like the one I was looking for. The algorithm is as below: first I will determine the user id number that I will block via code ...
To reduce multiple slashes at the start of the URL-path (or in fact *anywhere* in the URL-path) to a single slash (there is always at least 1 slash at the start of the URL-path, even if you can't see this is the browser's address bar) then you can use a directive like the following: ``` # Reduce multiple slashes to si...
384,337
<p>I'm using social sign up buttons on my Wordpress site to register/sign in using Google, FB, TW...</p> <p>When they are logged in, this notice appear on the top of the Wordpress dashboard:</p> <blockquote> <p>Notice: You’re using the auto-generated password for your account. Would you like to change it?</p> </blockq...
[ { "answer_id": 384342, "author": "robert0", "author_id": 202740, "author_profile": "https://wordpress.stackexchange.com/users/202740", "pm_score": -1, "selected": false, "text": "<p>Found the solution.</p>\n<p>This will remove all the notices for your registered WordPress users, except a...
2021/03/02
[ "https://wordpress.stackexchange.com/questions/384337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202740/" ]
I'm using social sign up buttons on my Wordpress site to register/sign in using Google, FB, TW... When they are logged in, this notice appear on the top of the Wordpress dashboard: > > Notice: You’re using the auto-generated password for your account. Would you like to change it? > > > Is it possible to remove t...
Similar to @robert0's answer, you can unhook the nag from happening: ```php remove_action( 'profile_update', 'default_password_nag_edit_user', 10 ); ``` Just put that in your theme's `functions.php` and that should take care of it.
384,344
<p>I have a custom page template <code>products</code>, so i get the url <code>site.com/products</code>. I want to add a parameter (for example <code>product</code>) to this url, so that I can access this page using url <code>site.com/products/product-1</code> or <code>site.com/products/product-2</code> etc.</p> <p>How...
[ { "answer_id": 384342, "author": "robert0", "author_id": 202740, "author_profile": "https://wordpress.stackexchange.com/users/202740", "pm_score": -1, "selected": false, "text": "<p>Found the solution.</p>\n<p>This will remove all the notices for your registered WordPress users, except a...
2021/03/02
[ "https://wordpress.stackexchange.com/questions/384344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202743/" ]
I have a custom page template `products`, so i get the url `site.com/products`. I want to add a parameter (for example `product`) to this url, so that I can access this page using url `site.com/products/product-1` or `site.com/products/product-2` etc. How can I add this parameter and make that url accessible?
Similar to @robert0's answer, you can unhook the nag from happening: ```php remove_action( 'profile_update', 'default_password_nag_edit_user', 10 ); ``` Just put that in your theme's `functions.php` and that should take care of it.
384,372
<p>this is my code:</p> <pre><code>$terms = wp_get_post_terms( $listing_id,'job_listing_category' ); if(!empty($terms)){ $sql_terms.=&quot; AND (&quot;; foreach($terms as $term){ $sql_terms.=&quot; category LIKE '%&quot;.$term-&gt;slug.&quot;%' OR&quot;; } ...
[ { "answer_id": 384342, "author": "robert0", "author_id": 202740, "author_profile": "https://wordpress.stackexchange.com/users/202740", "pm_score": -1, "selected": false, "text": "<p>Found the solution.</p>\n<p>This will remove all the notices for your registered WordPress users, except a...
2021/03/03
[ "https://wordpress.stackexchange.com/questions/384372", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/164443/" ]
this is my code: ``` $terms = wp_get_post_terms( $listing_id,'job_listing_category' ); if(!empty($terms)){ $sql_terms.=" AND ("; foreach($terms as $term){ $sql_terms.=" category LIKE '%".$term->slug."%' OR"; } $sql_terms.=" category IS NULL OR category=''...
Similar to @robert0's answer, you can unhook the nag from happening: ```php remove_action( 'profile_update', 'default_password_nag_edit_user', 10 ); ``` Just put that in your theme's `functions.php` and that should take care of it.
384,401
<p>I've been having this weird issue on a site for a few weeks now, tried everything I found by searching but still not being able to find a clue of the issue.</p> <p>Whenever I add some items to the Menu (Appearance &gt; Menus), a few items become empty. And then gets removed when I click the Save button again. Simila...
[ { "answer_id": 384342, "author": "robert0", "author_id": 202740, "author_profile": "https://wordpress.stackexchange.com/users/202740", "pm_score": -1, "selected": false, "text": "<p>Found the solution.</p>\n<p>This will remove all the notices for your registered WordPress users, except a...
2021/03/03
[ "https://wordpress.stackexchange.com/questions/384401", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31449/" ]
I've been having this weird issue on a site for a few weeks now, tried everything I found by searching but still not being able to find a clue of the issue. Whenever I add some items to the Menu (Appearance > Menus), a few items become empty. And then gets removed when I click the Save button again. Similarly, if I ed...
Similar to @robert0's answer, you can unhook the nag from happening: ```php remove_action( 'profile_update', 'default_password_nag_edit_user', 10 ); ``` Just put that in your theme's `functions.php` and that should take care of it.
384,445
<p>I am trying to add a class to a checkout page if the checkout contains a subscription renewal. Woocommerce provides <a href="https://github.com/wp-premium/woocommerce-subscriptions/blob/master/includes/wcs-renewal-functions.php#L71" rel="nofollow noreferrer"><code>wcs_cart_contains_renewal()</code></a> to check. I a...
[ { "answer_id": 384454, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>The <code>body_class</code> filter is called inside the <a href=\"https://developer.wordpress.org/reference/func...
2021/03/04
[ "https://wordpress.stackexchange.com/questions/384445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104225/" ]
I am trying to add a class to a checkout page if the checkout contains a subscription renewal. Woocommerce provides [`wcs_cart_contains_renewal()`](https://github.com/wp-premium/woocommerce-subscriptions/blob/master/includes/wcs-renewal-functions.php#L71) to check. I am using this code but obviously missing something a...
As @cjbj noted in a comment, this is probably a timing issue. This means that instead of directly adding the code to `functions.php` you need to wrap it inside a callback function and attach it to a later firing action. WordPress, themes and plugins too, [loads](https://wordpress.stackexchange.com/questions/71406/is-th...
384,453
<p>I understand my question may be a bit broad, or even easy to answer. I have been building custom blocks using the <code>--es5</code> flag of <code>@wordpress/create-block</code> (<a href="https://developer.wordpress.org/block-editor/packages/packages-create-block/" rel="nofollow noreferrer">https://developer.wordpre...
[ { "answer_id": 384463, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>Whatever issues you had that caused a block to be &quot;killed&quot; after editing was entirely unrelat...
2021/03/04
[ "https://wordpress.stackexchange.com/questions/384453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114814/" ]
I understand my question may be a bit broad, or even easy to answer. I have been building custom blocks using the `--es5` flag of `@wordpress/create-block` (<https://developer.wordpress.org/block-editor/packages/packages-create-block/>), which has been fairly successful on projects. The reason for using this method is...
Whatever issues you had that caused a block to be "killed" after editing was entirely unrelated to the two different methods of writing the block that you have outlined. > > Building a custom block using the following method > (<https://github.com/WordPress/gutenberg-examples/blob/master/03-editable/block.js>) > of a...
384,485
<p>I would like to hide the image title tag when hovering an image as they aren't needed on my website. I have tried this code below and added it above the closing <code>&lt;/head&gt;</code> in header.php but it doesn't work.</p> <p>I don't have to download a plugin to achieve this. The title tag doesn't have an impact...
[ { "answer_id": 384463, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>Whatever issues you had that caused a block to be &quot;killed&quot; after editing was entirely unrelat...
2021/03/04
[ "https://wordpress.stackexchange.com/questions/384485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/192974/" ]
I would like to hide the image title tag when hovering an image as they aren't needed on my website. I have tried this code below and added it above the closing `</head>` in header.php but it doesn't work. I don't have to download a plugin to achieve this. The title tag doesn't have an impact on SEO so there shouldn't...
Whatever issues you had that caused a block to be "killed" after editing was entirely unrelated to the two different methods of writing the block that you have outlined. > > Building a custom block using the following method > (<https://github.com/WordPress/gutenberg-examples/blob/master/03-editable/block.js>) > of a...
384,506
<p>I'm just having trouble figuring out why I'm getting an error at the &quot;}&quot; after the &quot;$attachment_image&quot; line, just before &quot;&quot;. I'm probably just too tired to see it.</p> <pre><code>&lt;?php if($term) { $args = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'i...
[ { "answer_id": 384508, "author": "Patriot", "author_id": 202596, "author_profile": "https://wordpress.stackexchange.com/users/202596", "pm_score": 1, "selected": false, "text": "<p><strong>UPDATE:</strong> Ah, there's a little more to it. I didn't see the <code>endwhile</code> further on...
2021/03/04
[ "https://wordpress.stackexchange.com/questions/384506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88351/" ]
I'm just having trouble figuring out why I'm getting an error at the "}" after the "$attachment\_image" line, just before "". I'm probably just too tired to see it. ``` <?php if($term) { $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'posts_per_page' => 1, 'tax_quer...
You've wrapped the opening and closing of the `while` in separate `if` statements. This is the structure of your code. ``` if( $term ) { // etc. while ( $loop->have_posts() ) : } // etc. if( $term ) { endwhile; } ``` This is not valid PHP. You need to structure it like this: ``` if( $term ) { // etc...
384,513
<p>In a custom shortcode function, I'm grabbing the featured image URL:</p> <pre><code>$text_slider_testimonial_img = get_the_post_thumbnail_url($single-&gt;ID); </code></pre> <p>If I echo <code>$text_slider_testimonial_img</code> immediately I see the correct image URL: <code>//localhost:3000/wp-content/uploads/2021/0...
[ { "answer_id": 384508, "author": "Patriot", "author_id": 202596, "author_profile": "https://wordpress.stackexchange.com/users/202596", "pm_score": 1, "selected": false, "text": "<p><strong>UPDATE:</strong> Ah, there's a little more to it. I didn't see the <code>endwhile</code> further on...
2021/03/04
[ "https://wordpress.stackexchange.com/questions/384513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/201824/" ]
In a custom shortcode function, I'm grabbing the featured image URL: ``` $text_slider_testimonial_img = get_the_post_thumbnail_url($single->ID); ``` If I echo `$text_slider_testimonial_img` immediately I see the correct image URL: `//localhost:3000/wp-content/uploads/2021/03/splitbanner1.jpg` When I pass this varia...
You've wrapped the opening and closing of the `while` in separate `if` statements. This is the structure of your code. ``` if( $term ) { // etc. while ( $loop->have_posts() ) : } // etc. if( $term ) { endwhile; } ``` This is not valid PHP. You need to structure it like this: ``` if( $term ) { // etc...
384,522
<p>I'm looking for a way to insert &quot;THIS ARTICLE MAY CONTAIN COMPENSATED LINKS. PLEASE READ DISCLAIMER FOR MORE INFO.&quot; after the H1 in all my blog posts (not pages).</p> <p>Is there a way to do it without plugins?</p> <p>Thanks</p>
[ { "answer_id": 384508, "author": "Patriot", "author_id": 202596, "author_profile": "https://wordpress.stackexchange.com/users/202596", "pm_score": 1, "selected": false, "text": "<p><strong>UPDATE:</strong> Ah, there's a little more to it. I didn't see the <code>endwhile</code> further on...
2021/03/05
[ "https://wordpress.stackexchange.com/questions/384522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202870/" ]
I'm looking for a way to insert "THIS ARTICLE MAY CONTAIN COMPENSATED LINKS. PLEASE READ DISCLAIMER FOR MORE INFO." after the H1 in all my blog posts (not pages). Is there a way to do it without plugins? Thanks
You've wrapped the opening and closing of the `while` in separate `if` statements. This is the structure of your code. ``` if( $term ) { // etc. while ( $loop->have_posts() ) : } // etc. if( $term ) { endwhile; } ``` This is not valid PHP. You need to structure it like this: ``` if( $term ) { // etc...
384,526
<p>I using plugin advanced custom fields to show recommended posts in my sidebar (posts that authors select as recommended using radio buttons (yes or no)). And it is all working well.</p> <p>Now, i will need to show that same recommended posts in my mobile application via json.</p> <p>I found this amazing plugin: <a h...
[ { "answer_id": 384541, "author": "Stevo", "author_id": 202881, "author_profile": "https://wordpress.stackexchange.com/users/202881", "pm_score": 0, "selected": false, "text": "<p>Maybe try amending the query to something like this (i havent test this but cant hurt to try) maybe get rid o...
2021/03/05
[ "https://wordpress.stackexchange.com/questions/384526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138487/" ]
I using plugin advanced custom fields to show recommended posts in my sidebar (posts that authors select as recommended using radio buttons (yes or no)). And it is all working well. Now, i will need to show that same recommended posts in my mobile application via json. I found this amazing plugin: <https://wordpress....
TL;DR - ACF now has support for the WP REST API Hey all, Iain the Product Manager for Advanced Custom Fields here As part of the [ACF 5.11](https://www.advancedcustomfields.com/blog/acf-5-11-release-rest-api/) release we added native support for ACF fields in the WordPress REST API. Read more about that [here](https...
384,570
<p>I want to set WordPress Transient via Variable Value.</p> <p>This is an example code with what I'm trying to achieve.</p> <pre><code>&lt;?php if ( false === get_transient( 'special_query_results' ) ) { $ExpiryInterval = &quot;24 * HOUR_IN_SECONDS&quot;; // &lt;--- Storing in Variable $...
[ { "answer_id": 384573, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 1, "selected": false, "text": "<p><code>HOUR_IN_SECONDS</code> is a <a href=\"https://codex.wordpress.org/Easier_Expression_of_Time_Constants\...
2021/03/05
[ "https://wordpress.stackexchange.com/questions/384570", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195903/" ]
I want to set WordPress Transient via Variable Value. This is an example code with what I'm trying to achieve. ``` <?php if ( false === get_transient( 'special_query_results' ) ) { $ExpiryInterval = "24 * HOUR_IN_SECONDS"; // <--- Storing in Variable $RandPostQuery = new WP_Query(array('post_ty...
```php $ExpiryInterval = "24 * HOUR_IN_SECONDS"; ``` `$ExpiryInterval` is being assigned a string, but you need a number. Consider this example: ```php $foo = 5 * 10; $bar = "5 * 10"; ``` The value of `$foo` is `50`. The value of `$bar` is `"5 * 10"`. `set_transient` expects a number, not a string, `"24 * HOUR_IN...
384,614
<p>I've been playing a little bit with the woocommerce storefront theme and woocommerce, and I wanted to display the &quot;Add to basket&quot; and &quot;Read more&quot; at the same time on the shop page for each product when possible. <strong>I came out with a solution, but I wonder if there is a different way to do th...
[ { "answer_id": 384573, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 1, "selected": false, "text": "<p><code>HOUR_IN_SECONDS</code> is a <a href=\"https://codex.wordpress.org/Easier_Expression_of_Time_Constants\...
2021/03/06
[ "https://wordpress.stackexchange.com/questions/384614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128713/" ]
I've been playing a little bit with the woocommerce storefront theme and woocommerce, and I wanted to display the "Add to basket" and "Read more" at the same time on the shop page for each product when possible. **I came out with a solution, but I wonder if there is a different way to do this** so I don't have to use C...
```php $ExpiryInterval = "24 * HOUR_IN_SECONDS"; ``` `$ExpiryInterval` is being assigned a string, but you need a number. Consider this example: ```php $foo = 5 * 10; $bar = "5 * 10"; ``` The value of `$foo` is `50`. The value of `$bar` is `"5 * 10"`. `set_transient` expects a number, not a string, `"24 * HOUR_IN...
384,680
<p>I am using WordPress and I have to show the related blog by category. I have created a custom-type post. I tried the below code but the code is displaying the last category of the post.</p> <p>Would you help me out with this issue?</p> <pre><code>function relatedBlogPost($atts){ global $post; $custom_terms = get_ter...
[ { "answer_id": 384573, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 1, "selected": false, "text": "<p><code>HOUR_IN_SECONDS</code> is a <a href=\"https://codex.wordpress.org/Easier_Expression_of_Time_Constants\...
2021/03/08
[ "https://wordpress.stackexchange.com/questions/384680", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/177715/" ]
I am using WordPress and I have to show the related blog by category. I have created a custom-type post. I tried the below code but the code is displaying the last category of the post. Would you help me out with this issue? ``` function relatedBlogPost($atts){ global $post; $custom_terms = get_terms('blogs_cat'); fo...
```php $ExpiryInterval = "24 * HOUR_IN_SECONDS"; ``` `$ExpiryInterval` is being assigned a string, but you need a number. Consider this example: ```php $foo = 5 * 10; $bar = "5 * 10"; ``` The value of `$foo` is `50`. The value of `$bar` is `"5 * 10"`. `set_transient` expects a number, not a string, `"24 * HOUR_IN...
384,917
<p>i want to get a post embedded images but the only methods i see over the internet are</p> <pre><code> $attachments = get_posts(array( 'post_parent' =&gt; get_the_ID(), 'post_type' =&gt; 'attachment', 'posts_per_page' =&gt; $n, 'post_mime_type' =...
[ { "answer_id": 384928, "author": "Álvaro García", "author_id": 201928, "author_profile": "https://wordpress.stackexchange.com/users/201928", "pm_score": 0, "selected": false, "text": "<p>You can use DOMDocument to get every image from any page:</p>\n<pre><code>function testingdom(){\n\n ...
2021/03/11
[ "https://wordpress.stackexchange.com/questions/384917", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/201279/" ]
i want to get a post embedded images but the only methods i see over the internet are ``` $attachments = get_posts(array( 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'posts_per_page' => $n, 'post_mime_type' => 'image' )); ...
i think if WordPress doesn't provide such a function then this is the shortest way ``` function my_get_embeded_media() { $content = apply_filters('the_content', get_the_content()); $arr = preg_match_all("/<img[^>]* src=\"([^\"]*)\"[^>]*>/", $content, $matches); return $arr ? $matches[1] : array(); } ```...
384,980
<p>im about to install wordpress trought my cpanel, and it asks me do I want to install it on HTTP or https, I checked, and my domain has valid SSL certificate? what should I do? install It on https or HTTP?</p>
[ { "answer_id": 384928, "author": "Álvaro García", "author_id": 201928, "author_profile": "https://wordpress.stackexchange.com/users/201928", "pm_score": 0, "selected": false, "text": "<p>You can use DOMDocument to get every image from any page:</p>\n<pre><code>function testingdom(){\n\n ...
2021/03/12
[ "https://wordpress.stackexchange.com/questions/384980", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203265/" ]
im about to install wordpress trought my cpanel, and it asks me do I want to install it on HTTP or https, I checked, and my domain has valid SSL certificate? what should I do? install It on https or HTTP?
i think if WordPress doesn't provide such a function then this is the shortest way ``` function my_get_embeded_media() { $content = apply_filters('the_content', get_the_content()); $arr = preg_match_all("/<img[^>]* src=\"([^\"]*)\"[^>]*>/", $content, $matches); return $arr ? $matches[1] : array(); } ```...
385,007
<p>I want to create a shortcode that pulls value from a custom field of a post and parses that value on Post title, post content.</p> <p>So if the custom field value is <strong>Icecream</strong> for Post 1.</p> <p>On the admin side the post title will be <strong>Favorite [geo_name]</strong>, it will be displayed as <st...
[ { "answer_id": 384928, "author": "Álvaro García", "author_id": 201928, "author_profile": "https://wordpress.stackexchange.com/users/201928", "pm_score": 0, "selected": false, "text": "<p>You can use DOMDocument to get every image from any page:</p>\n<pre><code>function testingdom(){\n\n ...
2021/03/12
[ "https://wordpress.stackexchange.com/questions/385007", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/164186/" ]
I want to create a shortcode that pulls value from a custom field of a post and parses that value on Post title, post content. So if the custom field value is **Icecream** for Post 1. On the admin side the post title will be **Favorite [geo\_name]**, it will be displayed as **Favorite Icecream**. Here is my code so ...
i think if WordPress doesn't provide such a function then this is the shortest way ``` function my_get_embeded_media() { $content = apply_filters('the_content', get_the_content()); $arr = preg_match_all("/<img[^>]* src=\"([^\"]*)\"[^>]*>/", $content, $matches); return $arr ? $matches[1] : array(); } ```...
385,029
<p>I hope everyone is well!</p> <p>I am looking for a possibility to load different galleries, background images etc for the phone and desktop. For example, I set my hero background image like this:</p> <pre><code> &lt;section class=&quot;hero&quot; style=&quot;background-image: url(&lt;?php echo esc_url(wp_get_att...
[ { "answer_id": 385058, "author": "Matthew Brown aka Lord Matt", "author_id": 109240, "author_profile": "https://wordpress.stackexchange.com/users/109240", "pm_score": 0, "selected": false, "text": "<p>It sounds like you are after the srcset feature of HTML. IT allows you to define differ...
2021/03/13
[ "https://wordpress.stackexchange.com/questions/385029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203297/" ]
I hope everyone is well! I am looking for a possibility to load different galleries, background images etc for the phone and desktop. For example, I set my hero background image like this: ``` <section class="hero" style="background-image: url(<?php echo esc_url(wp_get_attachment_image_src(get_field('advanced_cu...
You can display the selected image when using the `Image ID` return type `<?php $image = get_field('image'); $size = 'full'; // (thumbnail, medium, large, full or custom size) if( $image ) { echo wp_get_attachment_image( $image, $size ); }` This function also generates the srcset attribute allowing for **responsive ...
385,054
<p>Can a non-javascript person fix this error? any advice? thank you for help?</p> <p>console shows:</p> <p><a href="https://i.stack.imgur.com/pEdmj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pEdmj.jpg" alt="Uncaught ReferenceError: jQuery is not defined" /></a></p> <p>code is:</p> <pre><code> ...
[ { "answer_id": 385060, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>It's a very bad idea to deregister jQuery and re-register it to a CDN, and it does not improve performance. ...
2021/03/14
[ "https://wordpress.stackexchange.com/questions/385054", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202302/" ]
Can a non-javascript person fix this error? any advice? thank you for help? console shows: [![Uncaught ReferenceError: jQuery is not defined](https://i.stack.imgur.com/pEdmj.jpg)](https://i.stack.imgur.com/pEdmj.jpg) code is: ``` <script async src="https://cdn.filmpuls.info/jquery/jquery.min...
thanks to the inputs of two great members of this community, I could solve the matter without touching any code, applying the follow fixes: * exclude jquery.min.js from "CDN Enabler" plugin * exclude jquery.min.js in plugin "Async JavaScript" * exclude jquery.min.js in plugin "Autoptimize" in the section JavaScript-op...
385,059
<p>In Ubuntu 20.04 wp-env is giving me error once i have installed it and while trying to start it with <code>wp-env start</code> .The error showing is <code>mysqlcheck: Got error: 1130: Host '172.29.0.5' is not allowed to connect to this MariaDB server when trying to connect</code>.</p> <p>I have tried....... <code>CR...
[ { "answer_id": 385079, "author": "Greys", "author_id": 194559, "author_profile": "https://wordpress.stackexchange.com/users/194559", "pm_score": 2, "selected": false, "text": "<p>Step 1: Find the name of your wp-env container</p>\n<p>First, you need to locate the name of the container cr...
2021/03/14
[ "https://wordpress.stackexchange.com/questions/385059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9673/" ]
In Ubuntu 20.04 wp-env is giving me error once i have installed it and while trying to start it with `wp-env start` .The error showing is `mysqlcheck: Got error: 1130: Host '172.29.0.5' is not allowed to connect to this MariaDB server when trying to connect`. I have tried....... `CREATE USER 'wp'@'%' IDENTIFIED BY 'ne...
Step 1: Find the name of your wp-env container First, you need to locate the name of the container created by wp-env. To do this, in the directory of your project containing .wp-env.json, you must run the following command: ``` docker ps ``` This should give you a list of containers. In the Names column, you’ll see...
385,084
<h1>How to change taxonomy urls in wordpress?</h1> <p>Following along with <a href="https://wordpress.stackexchange.com/questions/296510/divi-change-project-slug-based-on-category">this question</a> and <a href="https://wordpress.stackexchange.com/questions/212455/change-the-url-of-projects-in-divi-theme">this one</a><...
[ { "answer_id": 386592, "author": "jasmines", "author_id": 173126, "author_profile": "https://wordpress.stackexchange.com/users/173126", "pm_score": 3, "selected": true, "text": "<pre><code>add_filter( 'register_taxonomy_args', 'change_taxonomies_slug', 10, 2 );\nfunction change_taxonomie...
2021/03/15
[ "https://wordpress.stackexchange.com/questions/385084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/192994/" ]
How to change taxonomy urls in wordpress? ========================================= Following along with [this question](https://wordpress.stackexchange.com/questions/296510/divi-change-project-slug-based-on-category) and [this one](https://wordpress.stackexchange.com/questions/212455/change-the-url-of-projects-in-div...
``` add_filter( 'register_taxonomy_args', 'change_taxonomies_slug', 10, 2 ); function change_taxonomies_slug( $args, $taxonomy ) { if ( 'project_category' === $taxonomy ) { $args['rewrite']['slug'] = 'stainless-steel-products'; } return $args; } ```
385,186
<p>I would like to show an archive of posts that have two taxonomy terms in common. So for example, I'd like to show all posts that have <em>both</em> the terms &quot;sauce&quot; and &quot;cheese&quot; in the custom <code>food</code> taxonomy.</p> <p>The trick is that I'd like to do this using the url. The closest I've...
[ { "answer_id": 385251, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 2, "selected": false, "text": "<p>Looks like you can define the <code>AND</code> logical operator with the URL parameters, specifically adding ...
2021/03/16
[ "https://wordpress.stackexchange.com/questions/385186", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2044/" ]
I would like to show an archive of posts that have two taxonomy terms in common. So for example, I'd like to show all posts that have *both* the terms "sauce" and "cheese" in the custom `food` taxonomy. The trick is that I'd like to do this using the url. The closest I've come is with: ``` example.com?food[]=sauce&fo...
When I registered my taxonomy, I left out the argument for 'rewrite', which then defaulted to `true`. So by default, WordPress wanted to rewrite the url as `/food/whatever/`. The tricky thing was that it *did* accept the format `?food=whatever` , but wouldn't accept two different terms in that format when joined with a...
385,209
<p>I am trying to let a user change their password via the API. What it looks like here is that I can send a POST request to the users endpoint with their user ID at the end, sending the new password in the request body as JSON. So,</p> <p>POST to : <code>https://example.com/wp-json/wp/v2/users/123</code></p> <p>And in...
[ { "answer_id": 385251, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 2, "selected": false, "text": "<p>Looks like you can define the <code>AND</code> logical operator with the URL parameters, specifically adding ...
2021/03/17
[ "https://wordpress.stackexchange.com/questions/385209", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/140276/" ]
I am trying to let a user change their password via the API. What it looks like here is that I can send a POST request to the users endpoint with their user ID at the end, sending the new password in the request body as JSON. So, POST to : `https://example.com/wp-json/wp/v2/users/123` And in the body: ``` { "pas...
When I registered my taxonomy, I left out the argument for 'rewrite', which then defaulted to `true`. So by default, WordPress wanted to rewrite the url as `/food/whatever/`. The tricky thing was that it *did* accept the format `?food=whatever` , but wouldn't accept two different terms in that format when joined with a...
385,245
<p>I am trying to redirect user roles to a specific page. If their role is <strong>contributor</strong> and is trying to access the <strong>Users Admin Page</strong> they should be redirected. Not sure if I am doing this correctly as it isn't working. Please help</p> <pre><code>function mwd_redirect_if_on_page() { $...
[ { "answer_id": 385251, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 2, "selected": false, "text": "<p>Looks like you can define the <code>AND</code> logical operator with the URL parameters, specifically adding ...
2021/03/17
[ "https://wordpress.stackexchange.com/questions/385245", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96830/" ]
I am trying to redirect user roles to a specific page. If their role is **contributor** and is trying to access the **Users Admin Page** they should be redirected. Not sure if I am doing this correctly as it isn't working. Please help ``` function mwd_redirect_if_on_page() { $mwd_current_user = wp_get_current_user(...
When I registered my taxonomy, I left out the argument for 'rewrite', which then defaulted to `true`. So by default, WordPress wanted to rewrite the url as `/food/whatever/`. The tricky thing was that it *did* accept the format `?food=whatever` , but wouldn't accept two different terms in that format when joined with a...
385,266
<p>Using WordPress PHP code, how to bulk delete ONLY 100 subscribers at a time from thousands of users?</p> <p>(The following code tries to delete all 50k users at once and my server hangs. If I can delete only 100 users at a time then I can use a Cron job every 5 minutes.)</p> <pre><code>&lt;?php $blogusers = get_user...
[ { "answer_id": 385251, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 2, "selected": false, "text": "<p>Looks like you can define the <code>AND</code> logical operator with the URL parameters, specifically adding ...
2021/03/18
[ "https://wordpress.stackexchange.com/questions/385266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203522/" ]
Using WordPress PHP code, how to bulk delete ONLY 100 subscribers at a time from thousands of users? (The following code tries to delete all 50k users at once and my server hangs. If I can delete only 100 users at a time then I can use a Cron job every 5 minutes.) ``` <?php $blogusers = get_users( ‘role=subscriber’ )...
When I registered my taxonomy, I left out the argument for 'rewrite', which then defaulted to `true`. So by default, WordPress wanted to rewrite the url as `/food/whatever/`. The tricky thing was that it *did* accept the format `?food=whatever` , but wouldn't accept two different terms in that format when joined with a...
385,303
<p>I want to create a button on the front end and when user click, the value &quot;user-meta&quot; change 'validate'</p> <pre><code>function func_change_validate() { if (is_user_logged_in()) { $current_user = wp_get_current_user(); $new_value = 'validate'; $updated = update_user_meta( $use...
[ { "answer_id": 385306, "author": "Nour Edin Al-Habal", "author_id": 97257, "author_profile": "https://wordpress.stackexchange.com/users/97257", "pm_score": 3, "selected": true, "text": "<p>Basically, you can't show the button and update the meta at the same moment. This has to be done in...
2021/03/18
[ "https://wordpress.stackexchange.com/questions/385303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/192355/" ]
I want to create a button on the front end and when user click, the value "user-meta" change 'validate' ``` function func_change_validate() { if (is_user_logged_in()) { $current_user = wp_get_current_user(); $new_value = 'validate'; $updated = update_user_meta( $user_id, 'User_meta_change...
Basically, you can't show the button and update the meta at the same moment. This has to be done in two separate requests as follows: 1. Show the button whereever you want. It needs to be a form that submits to the same page (or an ajax call to another URL, but let's keep it simple for now). 2. Read the value posted f...
385,333
<p>I'm looking for a way to prevent the automatic login after registration (i.e. by logging him out after registration) <strong>and</strong> redirect him to a custom URL. So far I'm only able to do both of them individually, but the combination of it is not working. For redirect after registration I'm using the followi...
[ { "answer_id": 385365, "author": "Kirtan", "author_id": 203555, "author_profile": "https://wordpress.stackexchange.com/users/203555", "pm_score": 2, "selected": false, "text": "<p>Try this, It may helpful.</p>\n<pre><code>function wc_custom_registration_redirect() {\n wp_logout();\n ...
2021/03/18
[ "https://wordpress.stackexchange.com/questions/385333", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/176724/" ]
I'm looking for a way to prevent the automatic login after registration (i.e. by logging him out after registration) **and** redirect him to a custom URL. So far I'm only able to do both of them individually, but the combination of it is not working. For redirect after registration I'm using the following: ``` add...
Whoever has also the same question as I had: This is how I got it to work: ``` add_filter('woocommerce_registration_redirect', 'custom_redirection_after_registration', 1); function custom_redirection_after_registration( $redirection_url ){ // Change the redirection Url add_action('wp_logout','only_redirect_un...
385,334
<p>I want to show a popup to the first time visitor of a Wordpress site. I tried to check the visit state using <code>$_SESSION</code>. Something like this in the <em>footer.php</em>:</p> <pre><code>&lt;?php if(!isset($_SESSION['pxpop'])) $_SESSION['pxpop']= true; if(($_SESSION['pxpop']) &amp;&amp; (!is_user_logged...
[ { "answer_id": 385365, "author": "Kirtan", "author_id": 203555, "author_profile": "https://wordpress.stackexchange.com/users/203555", "pm_score": 2, "selected": false, "text": "<p>Try this, It may helpful.</p>\n<pre><code>function wc_custom_registration_redirect() {\n wp_logout();\n ...
2021/03/18
[ "https://wordpress.stackexchange.com/questions/385334", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92425/" ]
I want to show a popup to the first time visitor of a Wordpress site. I tried to check the visit state using `$_SESSION`. Something like this in the *footer.php*: ``` <?php if(!isset($_SESSION['pxpop'])) $_SESSION['pxpop']= true; if(($_SESSION['pxpop']) && (!is_user_logged_in())) { ?> <div class="open_initpop"> <?...
Whoever has also the same question as I had: This is how I got it to work: ``` add_filter('woocommerce_registration_redirect', 'custom_redirection_after_registration', 1); function custom_redirection_after_registration( $redirection_url ){ // Change the redirection Url add_action('wp_logout','only_redirect_un...
385,377
<p>Here's the situation:</p> <p>I've created a child theme that enhances a popular parent theme. The enhancements include CSS, JS, and php. I want to use this child theme on multiple sites, and I want to allow for additional customization on each site without editing the child theme I created.</p> <p>A few requirements...
[ { "answer_id": 385379, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 2, "selected": false, "text": "<p>Firstly, I would ensure that your child theme is well equipped with hooks to accommodate the potential custo...
2021/03/19
[ "https://wordpress.stackexchange.com/questions/385377", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203510/" ]
Here's the situation: I've created a child theme that enhances a popular parent theme. The enhancements include CSS, JS, and php. I want to use this child theme on multiple sites, and I want to allow for additional customization on each site without editing the child theme I created. A few requirements: * Each site ...
> > My current solution is to create a directory outside the child theme that includes the CSS, JS, and php files for customizations > > > This is a plugin, a folder containing PHP/JS/CSS, with a comment at the top of one of the PHP files that has `/** Plugin Name: XYZ` at the top of the file. ```php <?php /** *...
385,447
<p><code>get_queried_object</code> returns <code>NULL</code> inside a function hooked to <code>wp_enqueue_scripts</code> action hook when going to an nonexistent category URL on my website. If the category exists, the error is not shown and I think it does not exist.</p> <p>I need it to conditionally load a CSS file fo...
[ { "answer_id": 385449, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": false, "text": "<p>According to the documentation, <code>get_queried_object()</code> is a wrapper for <a href=\"https://developer....
2021/03/21
[ "https://wordpress.stackexchange.com/questions/385447", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/182585/" ]
`get_queried_object` returns `NULL` inside a function hooked to `wp_enqueue_scripts` action hook when going to an nonexistent category URL on my website. If the category exists, the error is not shown and I think it does not exist. I need it to conditionally load a CSS file for better modularization, not in the admin ...
I agreed with [@PatJ](https://wordpress.stackexchange.com/users/16121/pat-j) — you should check if [`get_queried_object()`](https://developer.wordpress.org/reference/functions/get_queried_object/) returns an object or not. But you could *simplify* your code by simply using [`is_category()`](https://developer.wordpress...
385,458
<p>I'm trying to register a GET REST API route with multiple parameters with the following code:</p> <pre><code>register_rest_route( 'myplugin/v1', '/posts/?number=(?P&lt;number&gt;[\d]+)&amp;amp;offset=(?P&lt;offset&gt;[\d]+)&amp;amp;total=(?P&lt;total&gt;[\d]+)', array( 'methods' =&gt; 'GET', 'cal...
[ { "answer_id": 385459, "author": "rexkogitans", "author_id": 196282, "author_profile": "https://wordpress.stackexchange.com/users/196282", "pm_score": 0, "selected": false, "text": "<p>The request should be a regular expression, but not HTML encoded. So, instead of <code>&amp;amp;</code...
2021/03/21
[ "https://wordpress.stackexchange.com/questions/385458", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33049/" ]
I'm trying to register a GET REST API route with multiple parameters with the following code: ``` register_rest_route( 'myplugin/v1', '/posts/?number=(?P<number>[\d]+)&amp;offset=(?P<offset>[\d]+)&amp;total=(?P<total>[\d]+)', array( 'methods' => 'GET', 'callback' => 'my_rest_function', ...
You don't need to include query parameters in the endpoint. Just the path: ``` register_rest_route( 'myplugin/v1', '/posts', array( 'methods' => 'GET', 'callback' => 'my_rest_function', 'permission_callback' => '__return_true', 'args' => array( 'number' => ...
385,490
<p>I have a line of code in my template I would like to add the css class &quot;has-video&quot; to if the post is within a certain category.</p> <p>I am trying to do this inline with <code>' . ( if (in_category(42)) echo 'has-video') ? '</code> but I get a syntax error, unexpected 'if' (T_IF)</p> <p>I'm not great with ...
[ { "answer_id": 385495, "author": "Kirtan", "author_id": 203555, "author_profile": "https://wordpress.stackexchange.com/users/203555", "pm_score": 1, "selected": false, "text": "<p>It may helpful to you...</p>\n<pre><code>$video = (in_category ( 42 )) ? 'has-video' : '';\n\necho '&lt;sect...
2021/03/22
[ "https://wordpress.stackexchange.com/questions/385490", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196309/" ]
I have a line of code in my template I would like to add the css class "has-video" to if the post is within a certain category. I am trying to do this inline with `' . ( if (in_category(42)) echo 'has-video') ? '` but I get a syntax error, unexpected 'if' (T\_IF) I'm not great with my PHP and know this is close but n...
It may helpful to you... ``` $video = (in_category ( 42 )) ? 'has-video' : ''; echo '<section id="cooked-recipe-list-' . $list_id_counter . '" class="cooked-clearfix cooked-recipe-' . $list_style . ' cooked-recipe-loader' . ( in_array( $list_style, $masonry_layouts ) ? ' cooked-masonry' : '' ) . ( isset($atts['column...
385,544
<p>I am currently developing my first WordPress plugin and am currently a bit confused on how to change a record in a database.</p> <p>So far I have solved it using the $wpdb::update() function:</p> <pre><code>public function toggle_status() { global $wpdb; $id = (int) $_POST[&quot;id&quot;]; $active = (int...
[ { "answer_id": 385495, "author": "Kirtan", "author_id": 203555, "author_profile": "https://wordpress.stackexchange.com/users/203555", "pm_score": 1, "selected": false, "text": "<p>It may helpful to you...</p>\n<pre><code>$video = (in_category ( 42 )) ? 'has-video' : '';\n\necho '&lt;sect...
2021/03/23
[ "https://wordpress.stackexchange.com/questions/385544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103972/" ]
I am currently developing my first WordPress plugin and am currently a bit confused on how to change a record in a database. So far I have solved it using the $wpdb::update() function: ``` public function toggle_status() { global $wpdb; $id = (int) $_POST["id"]; $active = (int) $_POST["active"]; $tabl...
It may helpful to you... ``` $video = (in_category ( 42 )) ? 'has-video' : ''; echo '<section id="cooked-recipe-list-' . $list_id_counter . '" class="cooked-clearfix cooked-recipe-' . $list_style . ' cooked-recipe-loader' . ( in_array( $list_style, $masonry_layouts ) ? ' cooked-masonry' : '' ) . ( isset($atts['column...
385,617
<p>I'm using the <code>rest_photo_query</code> filter to manipulate the arguments of <code>WP_Query</code> through the use of my own <code>GET</code> parameters. It's working perfectly and fast, with one exception.</p> <p>I can adjust the <code>orderby</code> parameter using <code>rest_sht_photo_collection_params</code...
[ { "answer_id": 385495, "author": "Kirtan", "author_id": 203555, "author_profile": "https://wordpress.stackexchange.com/users/203555", "pm_score": 1, "selected": false, "text": "<p>It may helpful to you...</p>\n<pre><code>$video = (in_category ( 42 )) ? 'has-video' : '';\n\necho '&lt;sect...
2021/03/24
[ "https://wordpress.stackexchange.com/questions/385617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83412/" ]
I'm using the `rest_photo_query` filter to manipulate the arguments of `WP_Query` through the use of my own `GET` parameters. It's working perfectly and fast, with one exception. I can adjust the `orderby` parameter using `rest_sht_photo_collection_params`, and it's easy to sort the results by `meta_value`. The **pho...
It may helpful to you... ``` $video = (in_category ( 42 )) ? 'has-video' : ''; echo '<section id="cooked-recipe-list-' . $list_id_counter . '" class="cooked-clearfix cooked-recipe-' . $list_style . ' cooked-recipe-loader' . ( in_array( $list_style, $masonry_layouts ) ? ' cooked-masonry' : '' ) . ( isset($atts['column...
385,643
<p>So sorry if this have been answered - but in that case, I surely do not know what to ask.</p> <p>Anyway, I have built an image slider which changes the image and the description of the image on click of a button. Point be, I dynamically change the source of the img tag using javascript. But the images do not actuall...
[ { "answer_id": 385668, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>The problem is that you are trying to use PHP inside a javascript file. <strong>PHP only works inside <code>...
2021/03/24
[ "https://wordpress.stackexchange.com/questions/385643", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203890/" ]
So sorry if this have been answered - but in that case, I surely do not know what to ask. Anyway, I have built an image slider which changes the image and the description of the image on click of a button. Point be, I dynamically change the source of the img tag using javascript. But the images do not actually appear ...
The problem is that you are trying to use PHP inside a javascript file. **PHP only works inside `.php` files.** If you want to pass information to your javascript file from PHP, use `wp_localize_script` to store it in a variable, e.g. in a PHP file: ```php $values = array( 'foo' => 'bar', ); wp_localize_script( '...
385,646
<p>I'm using the following code to add a panel to the admin menu screen, so the users are able to add a Cart link to their menus:</p> <pre><code>function my_add_meta_box() { add_meta_box( 'custom-meta-box', __( 'Cart' ), 'my_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); } add_action( 'admin_init',...
[ { "answer_id": 385655, "author": "Bhautik", "author_id": 127648, "author_profile": "https://wordpress.stackexchange.com/users/127648", "pm_score": 1, "selected": false, "text": "<p>You can <a href=\"https://developer.wordpress.org/reference/hooks/wp_nav_menu_objects/\" rel=\"nofollow nor...
2021/03/24
[ "https://wordpress.stackexchange.com/questions/385646", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33049/" ]
I'm using the following code to add a panel to the admin menu screen, so the users are able to add a Cart link to their menus: ``` function my_add_meta_box() { add_meta_box( 'custom-meta-box', __( 'Cart' ), 'my_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); } add_action( 'admin_init', 'my_add_meta...
Based on Bhautik answer, I've found a solution to identify the cart menu link using the `woocommerce_cart_page_id` option: ``` function modify_cart_label_in_nav_menu_objects( $items, $args ) { foreach ( $items as $key => $item ) { if ( $item->object_id == (int) get_option( 'woocommerce_cart_page_id' ) ) { ...
385,666
<p>I've been tasked with managing a WordPress site that was developed and configured by some other team. During a basic security scan, I've realized that the following end-point <code>https://www.mywordpress.com/wp-json</code> does not restrict the Origin for some reason.</p> <pre><code>curl -H &quot;Origin: https://ww...
[ { "answer_id": 385687, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 3, "selected": true, "text": "<p>First of all, this is intentional behaviour, as relayed in a Slack discussion described in <a href=\"htt...
2021/03/25
[ "https://wordpress.stackexchange.com/questions/385666", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24635/" ]
I've been tasked with managing a WordPress site that was developed and configured by some other team. During a basic security scan, I've realized that the following end-point `https://www.mywordpress.com/wp-json` does not restrict the Origin for some reason. ``` curl -H "Origin: https://www.thewrongorigin.com" -I http...
First of all, this is intentional behaviour, as relayed in a Slack discussion described in [this ticket](https://core.trac.wordpress.org/ticket/45477) (this has likely been discussed in other places, but that's the first I found): > > tl;dr: CORS is built for CSRF protection, but WordPress already has a > system for ...
385,681
<p>I created a query with arguments see blow. On the page I see an error in a loop</p> <ul> <li><p>Notice undefined offset 1</p> </li> <li><p>Notice undefined offset 2</p> </li> <li><p>Notice undefined offset 3 and so on...</p> <pre><code>$args = array ( 'post_type' =&gt; 'catalog', 'post_status' =&gt; 'publi...
[ { "answer_id": 385682, "author": "Kaif Ahmad", "author_id": 203686, "author_profile": "https://wordpress.stackexchange.com/users/203686", "pm_score": -1, "selected": false, "text": "<p>There are five default Post Types readily available to users or internally used by the WordPress instal...
2021/03/25
[ "https://wordpress.stackexchange.com/questions/385681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203763/" ]
I created a query with arguments see blow. On the page I see an error in a loop * Notice undefined offset 1 * Notice undefined offset 2 * Notice undefined offset 3 and so on... ``` $args = array ( 'post_type' => 'catalog', 'post_status' => 'publish', ); $loop = new WP_Query( $args ); if ( $loop->have_pos...
There might be other causes to the issue in question, but one issue I noticed in your code is that because you are looping through a custom `WP_Query` instance, i.e. `$loop`, then you need to use `$loop->the_post()` instead of just `the_post()`: ```php while ( $loop->have_posts() ) { $loop->the_post(); the_tit...
385,691
<p>I'm using this function right now</p> <pre><code>wp_link_pages( array('before' =&gt; '&lt;div class=&quot;page-links&quot;&gt;','after' =&gt; '&lt;/div&gt;',) ); </code></pre> <p>The post pagination is showing like this:</p> <blockquote> <p>1 2 3 4 5 6 7 8 9 10 11</p> </blockquote> <p>But I want it to be like this ...
[ { "answer_id": 385682, "author": "Kaif Ahmad", "author_id": 203686, "author_profile": "https://wordpress.stackexchange.com/users/203686", "pm_score": -1, "selected": false, "text": "<p>There are five default Post Types readily available to users or internally used by the WordPress instal...
2021/03/25
[ "https://wordpress.stackexchange.com/questions/385691", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203936/" ]
I'm using this function right now ``` wp_link_pages( array('before' => '<div class="page-links">','after' => '</div>',) ); ``` The post pagination is showing like this: > > 1 2 3 4 5 6 7 8 9 10 11 > > > But I want it to be like this in that there's too many pages > > 1 2 3 ..9 10 11 > > > However, There...
There might be other causes to the issue in question, but one issue I noticed in your code is that because you are looping through a custom `WP_Query` instance, i.e. `$loop`, then you need to use `$loop->the_post()` instead of just `the_post()`: ```php while ( $loop->have_posts() ) { $loop->the_post(); the_tit...
385,705
<p>I could not get to work. When published the content the attribute innerContent didn't save. Here is what I tried.</p> <p><strong>block.js</strong></p> <pre><code>// Import CSS. import './style.scss'; import './editor.scss'; const { __ } = wp.i18n; const { registerBlockType } = wp.blocks; const { RichText } = wp.ed...
[ { "answer_id": 385682, "author": "Kaif Ahmad", "author_id": 203686, "author_profile": "https://wordpress.stackexchange.com/users/203686", "pm_score": -1, "selected": false, "text": "<p>There are five default Post Types readily available to users or internally used by the WordPress instal...
2021/03/25
[ "https://wordpress.stackexchange.com/questions/385705", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/198218/" ]
I could not get to work. When published the content the attribute innerContent didn't save. Here is what I tried. **block.js** ``` // Import CSS. import './style.scss'; import './editor.scss'; const { __ } = wp.i18n; const { registerBlockType } = wp.blocks; const { RichText } = wp.editor; registerBlockType( 'hall/...
There might be other causes to the issue in question, but one issue I noticed in your code is that because you are looping through a custom `WP_Query` instance, i.e. `$loop`, then you need to use `$loop->the_post()` instead of just `the_post()`: ```php while ( $loop->have_posts() ) { $loop->the_post(); the_tit...
385,716
<p>I think I'm missing obvious here, but here's the issue:</p> <p>I used the current @wordpress/create-block to create a block plugin.</p> <p>I'm looking to create three blocks in this plugin, so I setup the first one and it's working great in the editor and saving. The block details are all coming from the block.json,...
[ { "answer_id": 385757, "author": "llysa ", "author_id": 152943, "author_profile": "https://wordpress.stackexchange.com/users/152943", "pm_score": 3, "selected": false, "text": "<p>Figured it out, in the block.json script needs a new relative location to the build directory, so new code:<...
2021/03/25
[ "https://wordpress.stackexchange.com/questions/385716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/152943/" ]
I think I'm missing obvious here, but here's the issue: I used the current @wordpress/create-block to create a block plugin. I'm looking to create three blocks in this plugin, so I setup the first one and it's working great in the editor and saving. The block details are all coming from the block.json, as it's setup ...
Figured it out, in the block.json script needs a new relative location to the build directory, so new code: ``` "editorScript": "file:../../build/index.js", "editorStyle": "file:../../build/index.css", "style": "file:../../build/style-index.css" ```
385,752
<p>as a matter of performance for the entire system, how to do it correctly, if there is a way, to make the code of my plugin read or interpreted only when the user will login, as it is only and exclusively to work when the user is logged in.</p> <p>In this way, I decrease the load on the site, not having to run or rea...
[ { "answer_id": 385753, "author": "PVee Marketing", "author_id": 203744, "author_profile": "https://wordpress.stackexchange.com/users/203744", "pm_score": 0, "selected": false, "text": "<p>is_user_logged_in() Would do it. So let's assume you're loading scripts only when the user is logged...
2021/03/26
[ "https://wordpress.stackexchange.com/questions/385752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/201813/" ]
as a matter of performance for the entire system, how to do it correctly, if there is a way, to make the code of my plugin read or interpreted only when the user will login, as it is only and exclusively to work when the user is logged in. In this way, I decrease the load on the site, not having to run or read everyth...
When I create custom plugins I tend to add a single init function, which includes other plugin files, attached functions from these files to actions and hooks, etc. This way I have centralized place where the plugin is bootstrapped. This init function is then hooked to the `plugins_loaded` action in case I need to do s...
385,763
<p>I am trying to enqueue a hover function in my functios.php of my child theme, so that when hovering over a title, a div with a text will be visible. The code I am using is this:</p> <pre><code>&lt;?php add_action( 'wp_enqueue_scripts', 'home_game', 20); function home_game(){ ?&gt; &lt;script&gt; let title1 = ...
[ { "answer_id": 385753, "author": "PVee Marketing", "author_id": 203744, "author_profile": "https://wordpress.stackexchange.com/users/203744", "pm_score": 0, "selected": false, "text": "<p>is_user_logged_in() Would do it. So let's assume you're loading scripts only when the user is logged...
2021/03/26
[ "https://wordpress.stackexchange.com/questions/385763", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203994/" ]
I am trying to enqueue a hover function in my functios.php of my child theme, so that when hovering over a title, a div with a text will be visible. The code I am using is this: ``` <?php add_action( 'wp_enqueue_scripts', 'home_game', 20); function home_game(){ ?> <script> let title1 = document.getElementById("...
When I create custom plugins I tend to add a single init function, which includes other plugin files, attached functions from these files to actions and hooks, etc. This way I have centralized place where the plugin is bootstrapped. This init function is then hooked to the `plugins_loaded` action in case I need to do s...
385,812
<p>I am using Modula Plugin to speedup the galleries creation process. It works wonderfully but I don't understand how to render it correctly on the ajax call. I read through the available posts on rendering shortcodes via ajax, but so far I struggle to implement it in my code. Here is the code I use:</p> <pre><code>ad...
[ { "answer_id": 385753, "author": "PVee Marketing", "author_id": 203744, "author_profile": "https://wordpress.stackexchange.com/users/203744", "pm_score": 0, "selected": false, "text": "<p>is_user_logged_in() Would do it. So let's assume you're loading scripts only when the user is logged...
2021/03/28
[ "https://wordpress.stackexchange.com/questions/385812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203297/" ]
I am using Modula Plugin to speedup the galleries creation process. It works wonderfully but I don't understand how to render it correctly on the ajax call. I read through the available posts on rendering shortcodes via ajax, but so far I struggle to implement it in my code. Here is the code I use: ``` add_action('wp_...
When I create custom plugins I tend to add a single init function, which includes other plugin files, attached functions from these files to actions and hooks, etc. This way I have centralized place where the plugin is bootstrapped. This init function is then hooked to the `plugins_loaded` action in case I need to do s...
385,827
<p>I have a nav menu in footer. I just want to display it side by a <code>&lt;p&gt;</code> tag, I mean something like this</p> <pre><code>&lt;ul&gt; &lt;li&gt; &lt;p&gt;copyright C 2021&lt;/p&gt; &lt;/li&gt; &lt;li&gt; contact &lt;/li&gt; &lt;li&gt; blog &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>this is my menu function...
[ { "answer_id": 385829, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": false, "text": "<p>You can filter the HTML output with the <a href=\"https://developer.wordpress.org/reference/hooks/wp_nav_menu/\...
2021/03/28
[ "https://wordpress.stackexchange.com/questions/385827", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113723/" ]
I have a nav menu in footer. I just want to display it side by a `<p>` tag, I mean something like this ``` <ul> <li> <p>copyright C 2021</p> </li> <li> contact </li> <li> blog </li> </ul> ``` this is my menu function ``` if ( function_exists( 'register_nav_menus' ) ) { register_nav_menus( array( ...
When using `wp_nav_menu()` you can exclude the `<ul>` tag by setting the `items_wrap` to only include the list items (`%3$s`), then you can add your own `<li>` before or after that, and wrap it with `<ul>` yourself: ``` <ul class="footer-links"> <li> <p>copyright C 2021</p> </li> <?php wp_nav_...
385,849
<p>I have configured the <code>upload_max_filesize</code> directive to <strong>64 MB</strong> in my localhost <code>php.ini</code> and have my Apache restarted.</p> <p>But why the Media section in my WordPress still showing 2 MB below?</p> <pre><code>Maximum upload file size: 2 MB. </code></pre> <p>So any file is more ...
[ { "answer_id": 385829, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": false, "text": "<p>You can filter the HTML output with the <a href=\"https://developer.wordpress.org/reference/hooks/wp_nav_menu/\...
2021/03/29
[ "https://wordpress.stackexchange.com/questions/385849", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/89898/" ]
I have configured the `upload_max_filesize` directive to **64 MB** in my localhost `php.ini` and have my Apache restarted. But why the Media section in my WordPress still showing 2 MB below? ``` Maximum upload file size: 2 MB. ``` So any file is more than 2 MB, I get this error below: > > The uploaded file exceed...
When using `wp_nav_menu()` you can exclude the `<ul>` tag by setting the `items_wrap` to only include the list items (`%3$s`), then you can add your own `<li>` before or after that, and wrap it with `<ul>` yourself: ``` <ul class="footer-links"> <li> <p>copyright C 2021</p> </li> <?php wp_nav_...
385,852
<p>I want to display a page with ID=1149 in a particular place on another page. For that I've tried with this:</p> <pre><code> &lt;div class=&quot;col-md-4 sidebarl&quot;&gt; &lt;?php $args = array( 'post_type' =&gt; 'page', 'post__in' =&gt; array(1149) ); $query = new WP...
[ { "answer_id": 385858, "author": "Dejan Dozet", "author_id": 134358, "author_profile": "https://wordpress.stackexchange.com/users/134358", "pm_score": 0, "selected": false, "text": "<p>I am not sure if this is the correct answer, but I did it this way:</p>\n<pre><code> &lt;div class=&...
2021/03/29
[ "https://wordpress.stackexchange.com/questions/385852", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134358/" ]
I want to display a page with ID=1149 in a particular place on another page. For that I've tried with this: ``` <div class="col-md-4 sidebarl"> <?php $args = array( 'post_type' => 'page', 'post__in' => array(1149) ); $query = new WP_Query($args); while ($query->ha...
> > I am not getting anything, an empty page. Am I missing something? > > > Yes, you are. [`$query->the_post()`](https://developer.wordpress.org/reference/classes/wp_query/the_post/) does *not* display anything — it just moves the pointer/key in the posts array (`$query->posts`) to the next one, and setups the gl...
385,982
<p>I'm programming the integration with external API (real estate). I have one CRON job which is planned for at 1 o'clock am. It's running very well because I'm using server CRON initialize instead WP CRON standard so It's running at the right time.</p> <p>It's my scheduled job function:</p> <pre><code>function wcs_cro...
[ { "answer_id": 385983, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 0, "selected": false, "text": "<blockquote>\n<p>Question: is it the correct way to do it? maybe I should do it another way? how?</p>\n</blockq...
2021/03/31
[ "https://wordpress.stackexchange.com/questions/385982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/204224/" ]
I'm programming the integration with external API (real estate). I have one CRON job which is planned for at 1 o'clock am. It's running very well because I'm using server CRON initialize instead WP CRON standard so It's running at the right time. It's my scheduled job function: ``` function wcs_cron_system_update() {...
> > I can't schedule (I don't know how I should do it) separately CRON jobs because I had a few situations when some function was run before I have necessary data > > > The key to doing this is scheduling the first job to run daily at the required time, and have that event create all of the other ones after it is ...
385,988
<p>I am wondering how to add meta box in WordPress specific page admin, I mean when I create meta_box with code snippet below provided from source tutorial is really perfect and effective but one thing that I need to control is display that meta_box only in specific page for instance: pretend I have two page in my Word...
[ { "answer_id": 385991, "author": "Kirtan", "author_id": 203555, "author_profile": "https://wordpress.stackexchange.com/users/203555", "pm_score": 1, "selected": false, "text": "<pre><code>**check via post ID for a specific page or post**\n\n\n$post_id = $_GET['post'] ? $_GET['post'] : $_...
2021/04/01
[ "https://wordpress.stackexchange.com/questions/385988", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171613/" ]
I am wondering how to add meta box in WordPress specific page admin, I mean when I create meta\_box with code snippet below provided from source tutorial is really perfect and effective but one thing that I need to control is display that meta\_box only in specific page for instance: pretend I have two page in my WordP...
``` /* Add meta boxs for particular pages */ function meta_set_particular_page() { $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID']; $current_page_title = get_the_title($post_id); if ($current_page_title == 'home') { add_meta_box('Home_page', 'Home Name:', 'only_home', 'page', 'side', ...
386,039
<p>As the title, I would like to save the post with the specific image as the featured image, when it is new published. Also I would like to save different images which is filtered by categories.</p> <p>I have wrote the code below, it does not work as I wish to.</p> <pre><code>add_action('save_post', 'wp_force_featured...
[ { "answer_id": 386067, "author": "drdogbot7", "author_id": 105124, "author_profile": "https://wordpress.stackexchange.com/users/105124", "pm_score": 0, "selected": false, "text": "<p>If you're building a custom theme and you just want to have some fallback images, an easier approach migh...
2021/04/01
[ "https://wordpress.stackexchange.com/questions/386039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/204287/" ]
As the title, I would like to save the post with the specific image as the featured image, when it is new published. Also I would like to save different images which is filtered by categories. I have wrote the code below, it does not work as I wish to. ``` add_action('save_post', 'wp_force_featured_image', 20, 2); f...
Your conditional is in trouble. `get_the_category()` returns an **object**, use foreach to find the specific category. In addition, you assigned a value to the `$categories` variable, to compare you must use the [**comparison operators**](https://www.php.net/manual/en/language.operators.comparison.php) ( Ex: == or ==...
386,059
<p>I try to use the hook wp_head on a template page but this does not work</p> <pre><code>add_action('wp_head', 'to_head'); function to_head(){ //do stuff } </code></pre> <p>I placed this code on a template part what is called by <code>get_template_part( 'temp-parts/content/pages/catalog' );</code></p> <p>Can you ...
[ { "answer_id": 386067, "author": "drdogbot7", "author_id": 105124, "author_profile": "https://wordpress.stackexchange.com/users/105124", "pm_score": 0, "selected": false, "text": "<p>If you're building a custom theme and you just want to have some fallback images, an easier approach migh...
2021/04/02
[ "https://wordpress.stackexchange.com/questions/386059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162095/" ]
I try to use the hook wp\_head on a template page but this does not work ``` add_action('wp_head', 'to_head'); function to_head(){ //do stuff } ``` I placed this code on a template part what is called by `get_template_part( 'temp-parts/content/pages/catalog' );` Can you use the hook only on the functions.php o...
Your conditional is in trouble. `get_the_category()` returns an **object**, use foreach to find the specific category. In addition, you assigned a value to the `$categories` variable, to compare you must use the [**comparison operators**](https://www.php.net/manual/en/language.operators.comparison.php) ( Ex: == or ==...
386,069
<p>I wrote a WordPress theme for a non-profit where I use templates to style individual pages. I select the template for an individual page in the editor on the right:</p> <p><a href="https://i.stack.imgur.com/znMdl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/znMdl.png" alt="Template selection in editor" ...
[ { "answer_id": 386215, "author": "Trisha", "author_id": 56458, "author_profile": "https://wordpress.stackexchange.com/users/56458", "pm_score": 1, "selected": false, "text": "<p>welcome to this forum. :-)</p>\n<p>I'm not an expert, BUT I did do something similar by following the instruct...
2021/04/02
[ "https://wordpress.stackexchange.com/questions/386069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/198618/" ]
I wrote a WordPress theme for a non-profit where I use templates to style individual pages. I select the template for an individual page in the editor on the right: [![Template selection in editor](https://i.stack.imgur.com/znMdl.png)](https://i.stack.imgur.com/znMdl.png) For styling of a template page, I simply add ...
welcome to this forum. :-) I'm not an expert, BUT I did do something similar by following the instructions and tutorials I found at these links below, hopefully these will help guide you. In a nutshell, you have to go beyond just enabling the stylesheet in the editor, you have actually add a stylesheet specifically f...
386,140
<p>I used the snippet below to lock out all administrators and editors except myself</p> <pre><code>if ( is_user_logged_in() ){ $current_user = wp_get_current_user() ; if ( in_array( 'administrator', (array) $current_user-&gt;roles ) || in_array( 'editor', (array) $current_user-&gt;roles )) { if ($curre...
[ { "answer_id": 386215, "author": "Trisha", "author_id": 56458, "author_profile": "https://wordpress.stackexchange.com/users/56458", "pm_score": 1, "selected": false, "text": "<p>welcome to this forum. :-)</p>\n<p>I'm not an expert, BUT I did do something similar by following the instruct...
2021/04/04
[ "https://wordpress.stackexchange.com/questions/386140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106290/" ]
I used the snippet below to lock out all administrators and editors except myself ``` if ( is_user_logged_in() ){ $current_user = wp_get_current_user() ; if ( in_array( 'administrator', (array) $current_user->roles ) || in_array( 'editor', (array) $current_user->roles )) { if ($current_user->user_login...
welcome to this forum. :-) I'm not an expert, BUT I did do something similar by following the instructions and tutorials I found at these links below, hopefully these will help guide you. In a nutshell, you have to go beyond just enabling the stylesheet in the editor, you have actually add a stylesheet specifically f...
386,280
<p>I need some guidance on making a wordpress posts query responsive to user meta data, and whether it’s possible to do what I want within the query itself, or if further work is needed in the database first?</p> <p>Every user on my site has a meta field with the meta key <strong>language_level</strong>. These broadly ...
[ { "answer_id": 386193, "author": "Daniel Loureiro", "author_id": 149505, "author_profile": "https://wordpress.stackexchange.com/users/149505", "pm_score": 1, "selected": false, "text": "<p>The HTML of a WordPress page is a mix of many sources. Parts of it come from plugins, other parts f...
2021/04/07
[ "https://wordpress.stackexchange.com/questions/386280", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/204530/" ]
I need some guidance on making a wordpress posts query responsive to user meta data, and whether it’s possible to do what I want within the query itself, or if further work is needed in the database first? Every user on my site has a meta field with the meta key **language\_level**. These broadly correspond to beginne...
The HTML of a WordPress page is a mix of many sources. Parts of it come from plugins, other parts from the main template, others from the database, others from the core. They can also come from widgets, template options, and so on. Unfortunately, WordPress pages are not on specific files that you can open and edit the...
386,514
<p>I've written a custom plugin, <code>ta-intentclicks</code> which is used as a shortcode:</p> <pre><code>[ta-intentclicks count=&quot;3&quot; category=&quot;SEC-EDR&quot;...] </code></pre> <p>Within this shortcode I'd like to use another shortcode that I can use as a helper. For example; in one of the PHP templates w...
[ { "answer_id": 386700, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 1, "selected": false, "text": "<p>If I understand it correctly, inside the <em>shortcode template</em>, you could do something like this:</p...
2021/04/12
[ "https://wordpress.stackexchange.com/questions/386514", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/185653/" ]
I've written a custom plugin, `ta-intentclicks` which is used as a shortcode: ``` [ta-intentclicks count="3" category="SEC-EDR"...] ``` Within this shortcode I'd like to use another shortcode that I can use as a helper. For example; in one of the PHP templates within my plugin. ``` [ta-intentclicks-link url="$list_...
If I understand it correctly, inside the *shortcode template*, you could do something like this: ```php echo do_shortcode( '[ta-intentclicks-link url="' . esc_url( $list_item['link'] ) . '"]Visit website[/ta-intentclicks-link]' ); ``` But then, **instead of having to use [`do_shortcode()`](https://developer.wordpres...
386,665
<p>Ok, so I have been using <code>wp plugin update --all</code> in the past with a tee command. There has been no problem in the past, but after I ran an update on my system, everytime I run the command through a pipe, the formatting is messed up. So this is the gist of the command used: <code>wp plugin update --all|aw...
[ { "answer_id": 386667, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": true, "text": "<p>WP CLI needs to know some things about the terminal it's running in to format the table, aka the TTY.</p>\n<p...
2021/04/15
[ "https://wordpress.stackexchange.com/questions/386665", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/204949/" ]
Ok, so I have been using `wp plugin update --all` in the past with a tee command. There has been no problem in the past, but after I ran an update on my system, everytime I run the command through a pipe, the formatting is messed up. So this is the gist of the command used: `wp plugin update --all|awk '/Success/,EOF'| ...
WP CLI needs to know some things about the terminal it's running in to format the table, aka the TTY. But when you pipe, there is no TTY! But you can trick it into thinking there is if you use this bash function: ```sh faketty() { 0</dev/null script --quiet --flush --return --command "$(pr...
386,689
<p>I need to show history of post changes (post revisions) at the end of post content.</p> <p>I saw tips about &quot;Last modified by/date&quot; feature but I need to <strong>show the table of all changes (revisions) done on post (Date/author/content- if possible).</strong></p> <p>It's formally required for public inst...
[ { "answer_id": 386707, "author": "Dave White", "author_id": 175096, "author_profile": "https://wordpress.stackexchange.com/users/175096", "pm_score": 0, "selected": false, "text": "<p>WordPress does not natively do that. You may want to try plugins such as Simple History.</p>\n<p>Check t...
2021/04/15
[ "https://wordpress.stackexchange.com/questions/386689", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/204978/" ]
I need to show history of post changes (post revisions) at the end of post content. I saw tips about "Last modified by/date" feature but I need to **show the table of all changes (revisions) done on post (Date/author/content- if possible).** It's formally required for public institutions and I'm bit surprised there a...
There are many ways to do it, without third party plugins: Shortcode --------- **Cons**: shortcode has to be created, and added to all posts. Child theme template -------------------- **Cons**: theme dependent, and right template has to be modified. Child theme functions.php ------------------------- **Cons**: th...
386,757
<p>I try to create and run a custom hook on my Wordpress site.</p> <p>In the header.php file I used</p> <pre><code>do_action('somestuff'); </code></pre> <p>On my home.php and page.php I does the add_action like</p> <pre><code>add_action('somestuff', 'testfunc'); function testfunc(){ echo 'hello'; } </code></pre> <...
[ { "answer_id": 386758, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>The problem is the order of execution. <strong>The order things run matters.</strong></p>\n<p>For your code ...
2021/04/16
[ "https://wordpress.stackexchange.com/questions/386757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/201091/" ]
I try to create and run a custom hook on my Wordpress site. In the header.php file I used ``` do_action('somestuff'); ``` On my home.php and page.php I does the add\_action like ``` add_action('somestuff', 'testfunc'); function testfunc(){ echo 'hello'; } ``` But the text is not showing? What I am doing wro...
The problem is the order of execution. **The order things run matters.** For your code to function, it would require either `add_action` to implement time travel several microseconds into the past so that it can add the hook before it ran, or it would require `do_action` to implement precognition so that it knows abou...
386,966
<p>1st post on this forum so sorry if not enough detail passed.</p> <p>I am trying to use WP_Query to gather CPT that have an Advanced Custom Field (WP Plugin) of &quot;End Date&quot;, the field is a date picker. I want the Query to return all posts that are before their individual &quot;End Date&quot; and all posts th...
[ { "answer_id": 386758, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>The problem is the order of execution. <strong>The order things run matters.</strong></p>\n<p>For your code ...
2021/04/21
[ "https://wordpress.stackexchange.com/questions/386966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205247/" ]
1st post on this forum so sorry if not enough detail passed. I am trying to use WP\_Query to gather CPT that have an Advanced Custom Field (WP Plugin) of "End Date", the field is a date picker. I want the Query to return all posts that are before their individual "End Date" and all posts that don't have an "End Date" ...
The problem is the order of execution. **The order things run matters.** For your code to function, it would require either `add_action` to implement time travel several microseconds into the past so that it can add the hook before it ran, or it would require `do_action` to implement precognition so that it knows abou...
386,994
<p>In order to have two blogs on one website, I was able to put in the menu two categories: DOCUMENTATION and ACTUALITES. My problem is in the header. The titles are displayed well however for both categories, the titles correspond to the title of the last article of the page... You can see an example in the picture (Y...
[ { "answer_id": 386758, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>The problem is the order of execution. <strong>The order things run matters.</strong></p>\n<p>For your code ...
2021/04/22
[ "https://wordpress.stackexchange.com/questions/386994", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205282/" ]
In order to have two blogs on one website, I was able to put in the menu two categories: DOCUMENTATION and ACTUALITES. My problem is in the header. The titles are displayed well however for both categories, the titles correspond to the title of the last article of the page... You can see an example in the picture (You ...
The problem is the order of execution. **The order things run matters.** For your code to function, it would require either `add_action` to implement time travel several microseconds into the past so that it can add the hook before it ran, or it would require `do_action` to implement precognition so that it knows abou...
387,040
<p>how to get all capabilities regardless of user roles? so far I am only seeing tutorial of how to get capabilities per user. I want to list all available capabilities in one page.</p>
[ { "answer_id": 387046, "author": "Frank P. Walentynowicz", "author_id": 32851, "author_profile": "https://wordpress.stackexchange.com/users/32851", "pm_score": 1, "selected": true, "text": "<p>First, create <code>[all-capabilities]</code> shortcode. Put this code in your theme's <code>fu...
2021/04/22
[ "https://wordpress.stackexchange.com/questions/387040", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205278/" ]
how to get all capabilities regardless of user roles? so far I am only seeing tutorial of how to get capabilities per user. I want to list all available capabilities in one page.
First, create `[all-capabilities]` shortcode. Put this code in your theme's `functions.php`: ``` function wpse_all_capabilities() { $out = '<style> .flex-columns { column-count: 4; column-gap: 3em; column-rule: 1px solid #000; } </style>'; $out .= '<p class="flex-columns">'; $users = ge...
387,041
<p>I bought woocommerce compare plugin. Unfortunately I can't understand how to apply some filters.</p> <p>For example I want to increase compare limit tom 10. How ı can use below filte?</p> <p>apply_filters( ‘woocommerce_products_compare_max_products’, int ) – sets how many products can be compared at one time. Defaul...
[ { "answer_id": 387042, "author": "cameronjonesweb", "author_id": 65582, "author_profile": "https://wordpress.stackexchange.com/users/65582", "pm_score": 2, "selected": false, "text": "<p>You need to return the value in the function for it to be accessible outside that function</p>\n<pre>...
2021/04/22
[ "https://wordpress.stackexchange.com/questions/387041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205323/" ]
I bought woocommerce compare plugin. Unfortunately I can't understand how to apply some filters. For example I want to increase compare limit tom 10. How ı can use below filte? apply\_filters( ‘woocommerce\_products\_compare\_max\_products’, int ) – sets how many products can be compared at one time. Default is 5. W...
You need to return the value in the function for it to be accessible outside that function ``` function comparelimit( $location ) { $location = 10; return $location; } add_filter( 'woocommerce_products_compare_max_products', 'comparelimit' ); ```
387,288
<p>I have this function in my theme's functions.php file:</p> <pre><code>remove_theme_support( 'core-block-patterns' ); </code></pre> <p>which works great but does not remove the Query patterns. How can I include those to be removed in this function?</p> <p><a href="https://i.stack.imgur.com/TgEoa.png" rel="nofollow n...
[ { "answer_id": 387856, "author": "divided", "author_id": 191673, "author_profile": "https://wordpress.stackexchange.com/users/191673", "pm_score": -1, "selected": true, "text": "<p>My fix for this issue is editing the Gutenberg plugin and removing the blocks there. I have not found a wa...
2021/04/27
[ "https://wordpress.stackexchange.com/questions/387288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/191673/" ]
I have this function in my theme's functions.php file: ``` remove_theme_support( 'core-block-patterns' ); ``` which works great but does not remove the Query patterns. How can I include those to be removed in this function? [![enter image description here](https://i.stack.imgur.com/TgEoa.png)](https://i.stack.imgur...
My fix for this issue is editing the Gutenberg plugin and removing the blocks there. I have not found a way to cleanly remove them through functions.php.
387,297
<h2>Update:</h2> <p>I got this working with a different hook <code>user_register</code>. It looks like <code>wpmu_activate_user</code> was never triggering.</p> <p><strong>I would still like to have this happen after the user verifies and sets a password though. Can anyone help?</strong></p> <p><strong>Current Code:</s...
[ { "answer_id": 387856, "author": "divided", "author_id": 191673, "author_profile": "https://wordpress.stackexchange.com/users/191673", "pm_score": -1, "selected": true, "text": "<p>My fix for this issue is editing the Gutenberg plugin and removing the blocks there. I have not found a wa...
2021/04/27
[ "https://wordpress.stackexchange.com/questions/387297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205549/" ]
Update: ------- I got this working with a different hook `user_register`. It looks like `wpmu_activate_user` was never triggering. **I would still like to have this happen after the user verifies and sets a password though. Can anyone help?** **Current Code:** > > > ``` > function xxx_whmcs_signup($user_id) { > ...
My fix for this issue is editing the Gutenberg plugin and removing the blocks there. I have not found a way to cleanly remove them through functions.php.
387,414
<p>I am looking for a way not to show the site logo in my homepage (but on all other pages). I can manage to do this only in the nasty way, using css and display none - however, I would like to avoid that the logo is not loaded on the homepage? functions.php?</p> <p>best, Aprilia</p>
[ { "answer_id": 387438, "author": "Aprilia Parrino", "author_id": 202302, "author_profile": "https://wordpress.stackexchange.com/users/202302", "pm_score": 1, "selected": false, "text": "<p>solved it like this, it works, but seems not very elegant?</p>\n<pre><code>function change_logo_on_...
2021/04/29
[ "https://wordpress.stackexchange.com/questions/387414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202302/" ]
I am looking for a way not to show the site logo in my homepage (but on all other pages). I can manage to do this only in the nasty way, using css and display none - however, I would like to avoid that the logo is not loaded on the homepage? functions.php? best, Aprilia
I had a quick look at the [site-branding template part](https://themes.trac.wordpress.org/browser/twentytwentyone/1.3/template-parts/header/site-branding.php) which handles the rendering of the custom logo on the site header. There's a conditional check on two lines against `has_custom_logo()`, along show title theme m...
387,496
<p>Is it possible to programmatically change the plugin descriptions otherwise provided by the plugin author? The text I've highlighted below is what I'm talking about wanting to change: <a href="https://i.stack.imgur.com/UndMY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UndMY.png" alt="Plugin de...
[ { "answer_id": 387498, "author": "Eigirdas Skruolis", "author_id": 183717, "author_profile": "https://wordpress.stackexchange.com/users/183717", "pm_score": -1, "selected": false, "text": "<p>It is possible by opening plugin directory , in there find file name <em>plugin-name</em>.php , ...
2021/05/01
[ "https://wordpress.stackexchange.com/questions/387496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/198566/" ]
Is it possible to programmatically change the plugin descriptions otherwise provided by the plugin author? The text I've highlighted below is what I'm talking about wanting to change: [![Plugin description](https://i.stack.imgur.com/UndMY.png)](https://i.stack.imgur.com/UndMY.png) I often find most plugins have fairly...
Yes, there is a filter you can use — [`all_plugins`](https://developer.wordpress.org/reference/hooks/all_plugins/): > > `apply_filters( 'all_plugins', array $all_plugins )` > > > Filters the full array of plugins to list in the Plugins list table. > > > And here's an example which changes the description of the...
387,501
<p>I moved <code>get_sidebar();</code> from <code>header.php</code> to <code>footer.php</code> but it <s>simply does not appear</s> is being placed after the last post in the page body instead of after the footer. There are no errors displayed. What do I need to do to get this working?</p> <p>functions.php</p> <pre><co...
[ { "answer_id": 387515, "author": "Pixelsmith", "author_id": 66368, "author_profile": "https://wordpress.stackexchange.com/users/66368", "pm_score": 0, "selected": false, "text": "<p>If you want it in the footer, just put it in the footer.</p>\n<pre><code> &lt;/main&gt;\n ...
2021/05/01
[ "https://wordpress.stackexchange.com/questions/387501", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/148991/" ]
I moved `get_sidebar();` from `header.php` to `footer.php` but it ~~simply does not appear~~ is being placed after the last post in the page body instead of after the footer. There are no errors displayed. What do I need to do to get this working? functions.php ``` /** * Register widget area. * * @link https://dev...
You need to read the documentation, [`get_sidebar()`](https://developer.wordpress.org/reference/functions/get_sidebar/): > > Includes the sidebar template for a theme or if a name is specified then a specialised sidebar will be included. > > > Its purpose is to load `sidebar.php`. It does not output widgets. To o...
387,599
<p>First, is it even <em>possible</em> to change the page title from a plugin (specifically, from a shortcode defined in a plugin)? <a href="https://wordpress.stackexchange.com/questions/46921/filter-title-from-shortcode">This answer</a> says no, but there are certainly reasonable use cases for it. Like, say, my use ca...
[ { "answer_id": 397904, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 3, "selected": true, "text": "<p>You can do it like so:</p>\n<pre><code>function filterDocumentTitle(string $title): string\n{\n // don't cha...
2021/05/03
[ "https://wordpress.stackexchange.com/questions/387599", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91121/" ]
First, is it even *possible* to change the page title from a plugin (specifically, from a shortcode defined in a plugin)? [This answer](https://wordpress.stackexchange.com/questions/46921/filter-title-from-shortcode) says no, but there are certainly reasonable use cases for it. Like, say, my use case (the shortcode dis...
You can do it like so: ``` function filterDocumentTitle(string $title): string { // don't change title on admin pages or when global $post is not loaded if (is_admin() || get_the_ID() === false) { return $title; } // don't change title if shortcode is not present in content if (!has_shortc...
387,651
<p>I have about 2000 titles. How can I automatically delete posts with these titles?</p> <p>For example</p> <p><a href="https://i.stack.imgur.com/bwVZ1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bwVZ1.png" alt="My list" /></a></p>
[ { "answer_id": 397904, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 3, "selected": true, "text": "<p>You can do it like so:</p>\n<pre><code>function filterDocumentTitle(string $title): string\n{\n // don't cha...
2021/05/04
[ "https://wordpress.stackexchange.com/questions/387651", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/160866/" ]
I have about 2000 titles. How can I automatically delete posts with these titles? For example [![My list](https://i.stack.imgur.com/bwVZ1.png)](https://i.stack.imgur.com/bwVZ1.png)
You can do it like so: ``` function filterDocumentTitle(string $title): string { // don't change title on admin pages or when global $post is not loaded if (is_admin() || get_the_ID() === false) { return $title; } // don't change title if shortcode is not present in content if (!has_shortc...
387,658
<p>This is a very straight-forward question, but it's important and I can't find anything definitive in the docs.</p> <p><a href="https://wordpress.stackexchange.com/questions/63664/do-i-need-to-sanitize-wordpress-search-query">This question</a> asks a similar question for the <code>'s'</code> parameter, specifically. ...
[ { "answer_id": 387924, "author": "Cas Dekkers", "author_id": 153884, "author_profile": "https://wordpress.stackexchange.com/users/153884", "pm_score": 0, "selected": false, "text": "<blockquote>\n<p>I want to know if I have to sanitize user input for <strong>any</strong> of the other par...
2021/05/04
[ "https://wordpress.stackexchange.com/questions/387658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11363/" ]
This is a very straight-forward question, but it's important and I can't find anything definitive in the docs. [This question](https://wordpress.stackexchange.com/questions/63664/do-i-need-to-sanitize-wordpress-search-query) asks a similar question for the `'s'` parameter, specifically. I want to know if WordPress val...
It's actually a good question. Of course user input cannot be trusted, but also sanitizing the same value twice "just in case" isn't the best solution for a problem. The only real answer to this question can be given by looking at the code and following what goes on. And after reading it for a few hours, here is what...
387,683
<p>Anyone know how to sanitize the $_POST for wordpress?</p> <pre><code>$args = array( 's' =&gt; esc_attr( $_POST['keyword'] ), ); </code></pre>
[ { "answer_id": 387924, "author": "Cas Dekkers", "author_id": 153884, "author_profile": "https://wordpress.stackexchange.com/users/153884", "pm_score": 0, "selected": false, "text": "<blockquote>\n<p>I want to know if I have to sanitize user input for <strong>any</strong> of the other par...
2021/05/05
[ "https://wordpress.stackexchange.com/questions/387683", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205932/" ]
Anyone know how to sanitize the $\_POST for wordpress? ``` $args = array( 's' => esc_attr( $_POST['keyword'] ), ); ```
It's actually a good question. Of course user input cannot be trusted, but also sanitizing the same value twice "just in case" isn't the best solution for a problem. The only real answer to this question can be given by looking at the code and following what goes on. And after reading it for a few hours, here is what...
387,722
<p>i have to create a specifif form ta register data into the database and send a mail without refreshing the page</p> <p>so i create a script.js file :</p> <pre><code> (function ($) { $(document).ready(function () { jQuery('form[name=&quot;form_result&quot;]').on('submit', function() { var ...
[ { "answer_id": 387724, "author": "Rajilesh Panoli", "author_id": 68892, "author_profile": "https://wordpress.stackexchange.com/users/68892", "pm_score": 0, "selected": false, "text": "<pre><code>check_ajax_referer( 'secure-nonce-name', 'security' );\n</code></pre>\n<p>Try this instead a...
2021/05/05
[ "https://wordpress.stackexchange.com/questions/387722", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153966/" ]
i have to create a specifif form ta register data into the database and send a mail without refreshing the page so i create a script.js file : ``` (function ($) { $(document).ready(function () { jQuery('form[name="form_result"]').on('submit', function() { var form_data = jQuery(this).seri...
**Short answer — how can you solve the problem:** When you call [`check_ajax_referer()`](https://developer.wordpress.org/reference/functions/check_ajax_referer/), use `secure_nonce_name` as the first parameter, i.e. `check_ajax_referer( 'secure_nonce_name', 'security' )`. A Longer Answer --------------- The first par...
387,743
<p>I'm trying to create a custom shortcode that will allow me to input custom order field data into an auto generated outbound email template via the <a href="https://www.tychesoftwares.com/store/premium-plugins/custom-order-status-woocommerce/" rel="nofollow noreferrer">Custom Order Status for WooCommerce</a> plugin.<...
[ { "answer_id": 387724, "author": "Rajilesh Panoli", "author_id": 68892, "author_profile": "https://wordpress.stackexchange.com/users/68892", "pm_score": 0, "selected": false, "text": "<pre><code>check_ajax_referer( 'secure-nonce-name', 'security' );\n</code></pre>\n<p>Try this instead a...
2021/05/06
[ "https://wordpress.stackexchange.com/questions/387743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205994/" ]
I'm trying to create a custom shortcode that will allow me to input custom order field data into an auto generated outbound email template via the [Custom Order Status for WooCommerce](https://www.tychesoftwares.com/store/premium-plugins/custom-order-status-woocommerce/) plugin. My understanding of PHP is limited at b...
**Short answer — how can you solve the problem:** When you call [`check_ajax_referer()`](https://developer.wordpress.org/reference/functions/check_ajax_referer/), use `secure_nonce_name` as the first parameter, i.e. `check_ajax_referer( 'secure_nonce_name', 'security' )`. A Longer Answer --------------- The first par...
387,767
<p>I am using get_users() to return a list of users with specified roles. The purpose of this is to generate a dropdown on the front end to mention other users in comments, very similar to the functionality of <a href="https://wordpress.org/plugins/comment-mention/" rel="nofollow noreferrer">https://wordpress.org/plugi...
[ { "answer_id": 387724, "author": "Rajilesh Panoli", "author_id": 68892, "author_profile": "https://wordpress.stackexchange.com/users/68892", "pm_score": 0, "selected": false, "text": "<pre><code>check_ajax_referer( 'secure-nonce-name', 'security' );\n</code></pre>\n<p>Try this instead a...
2021/05/06
[ "https://wordpress.stackexchange.com/questions/387767", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120722/" ]
I am using get\_users() to return a list of users with specified roles. The purpose of this is to generate a dropdown on the front end to mention other users in comments, very similar to the functionality of <https://wordpress.org/plugins/comment-mention/>. The problem is that if the current user is in a lower role, s...
**Short answer — how can you solve the problem:** When you call [`check_ajax_referer()`](https://developer.wordpress.org/reference/functions/check_ajax_referer/), use `secure_nonce_name` as the first parameter, i.e. `check_ajax_referer( 'secure_nonce_name', 'security' )`. A Longer Answer --------------- The first par...
387,793
<p>I have looked at a couple of different ways to check when a user, of a particular role, has logged out. The call is made within a plugin.</p> <p>In the main loop I have the following:</p> <pre><code>add_action( 'wp_logout', mmd_JudgeLogoutCheck, 10,0); function mmd_JudgeLogoutCheck() { $current_user = wp_get_curr...
[ { "answer_id": 387796, "author": "Debbie Kurth", "author_id": 119560, "author_profile": "https://wordpress.stackexchange.com/users/119560", "pm_score": -1, "selected": false, "text": "<p>Would you not know it, the minute I wrote the question, I thought of another idea and it worked. Her...
2021/05/06
[ "https://wordpress.stackexchange.com/questions/387793", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119560/" ]
I have looked at a couple of different ways to check when a user, of a particular role, has logged out. The call is made within a plugin. In the main loop I have the following: ``` add_action( 'wp_logout', mmd_JudgeLogoutCheck, 10,0); function mmd_JudgeLogoutCheck() { $current_user = wp_get_current_user(); if ( in...
**wp\_get\_current\_user()** will never work in this hook, because, `wp_logout` action fires after user is logged out: session destroyed, cookies cleared and current user is set to 0. But `wp_logout` action recieves $user\_id. I will give you a working example, because I do not familiar with your custom functions. ``...
387,818
<p>I've been struggling to find a solution for this and I don't know if it's the Gutenberg editor or if it's the hook <code>publish_post</code>.</p> <p>Hook:</p> <pre class="lang-php prettyprint-override"><code>function api_method($post_id) { // If this is just a revision, don't send request if ( wp_is_post_rev...
[ { "answer_id": 387850, "author": "anton", "author_id": 97934, "author_profile": "https://wordpress.stackexchange.com/users/97934", "pm_score": 0, "selected": false, "text": "<p><code>{$new_status}_{$post-&gt;post_type}</code> hook or <code>publish_post</code> fires when a post is transit...
2021/05/07
[ "https://wordpress.stackexchange.com/questions/387818", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54323/" ]
I've been struggling to find a solution for this and I don't know if it's the Gutenberg editor or if it's the hook `publish_post`. Hook: ```php function api_method($post_id) { // If this is just a revision, don't send request if ( wp_is_post_revision( $post_id ) ) { return; } // Get Post Obje...
> > I don't know if it's the Gutenberg editor or if it's the hook > `publish_post` > > > The hook itself works, and if you used the old WordPress post editor, then the issue in question would **not** happen. So you can say that it's the Gutenberg/block editor. > > why it's not returning the meta and featured im...
387,840
<p>I'm trying to add pagination through function.php. No Output! What I'm missing?</p> <pre><code>function simpleblog() { $query = 'posts_per_page=6'; $queryObject = new WP_Query($query); // The Loop... if ($queryObject-&gt;have_posts()) { while ($queryObject-&gt;have_posts()) { $que...
[ { "answer_id": 387850, "author": "anton", "author_id": 97934, "author_profile": "https://wordpress.stackexchange.com/users/97934", "pm_score": 0, "selected": false, "text": "<p><code>{$new_status}_{$post-&gt;post_type}</code> hook or <code>publish_post</code> fires when a post is transit...
2021/05/07
[ "https://wordpress.stackexchange.com/questions/387840", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60272/" ]
I'm trying to add pagination through function.php. No Output! What I'm missing? ``` function simpleblog() { $query = 'posts_per_page=6'; $queryObject = new WP_Query($query); // The Loop... if ($queryObject->have_posts()) { while ($queryObject->have_posts()) { $queryObject->the_post(...
> > I don't know if it's the Gutenberg editor or if it's the hook > `publish_post` > > > The hook itself works, and if you used the old WordPress post editor, then the issue in question would **not** happen. So you can say that it's the Gutenberg/block editor. > > why it's not returning the meta and featured im...