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
393,266
<p>I've searched online and have not been able to find any answers to this one. I am in the middle of developing a new website and have started trying to work with the new theme.json feature in WordPress 5.8.</p> <p>I've had no problems setting the layout width and defining a color pallette, however, when it then comes...
[ { "answer_id": 393459, "author": "Xavi", "author_id": 210356, "author_profile": "https://wordpress.stackexchange.com/users/210356", "pm_score": 3, "selected": false, "text": "<p>I had the same problem and I find out how to solve it:</p>\n<p>For each &quot;fontFamily&quot; inside &quot;fo...
2021/08/13
[ "https://wordpress.stackexchange.com/questions/393266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104675/" ]
I've searched online and have not been able to find any answers to this one. I am in the middle of developing a new website and have started trying to work with the new theme.json feature in WordPress 5.8. I've had no problems setting the layout width and defining a color pallette, however, when it then comes to setti...
I had the same problem and I find out how to solve it: For each "fontFamily" inside "fontFamilies" array, you get a custom variable. From your example You can use both variables on your stylesheet or in theme.json: ``` --wp--preset--font-family--helvetica-arial --wp--preset--font-family--ubuntu-sansserif ``` And th...
393,309
<p>I am getting an error on my WordPress website after changing the server. it's working on cPanel but not working on the AWS server.</p> <p>I haven't change anything in this file.</p> <p><a href="https://i.stack.imgur.com/qgniX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qgniX.png" alt="enter im...
[ { "answer_id": 393459, "author": "Xavi", "author_id": 210356, "author_profile": "https://wordpress.stackexchange.com/users/210356", "pm_score": 3, "selected": false, "text": "<p>I had the same problem and I find out how to solve it:</p>\n<p>For each &quot;fontFamily&quot; inside &quot;fo...
2021/08/14
[ "https://wordpress.stackexchange.com/questions/393309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/192859/" ]
I am getting an error on my WordPress website after changing the server. it's working on cPanel but not working on the AWS server. I haven't change anything in this file. [![enter image description here](https://i.stack.imgur.com/qgniX.png)](https://i.stack.imgur.com/qgniX.png) [![enter image description here](https...
I had the same problem and I find out how to solve it: For each "fontFamily" inside "fontFamilies" array, you get a custom variable. From your example You can use both variables on your stylesheet or in theme.json: ``` --wp--preset--font-family--helvetica-arial --wp--preset--font-family--ubuntu-sansserif ``` And th...
393,323
<p>I have a 7-page static site I built with a page builder theme, child theme and some plugins. I would like to override all CSS (theme AND plugins) with custom CSS stylesheets on a page-by-page basis.</p> <p>How can I do this? Can I accomplish this with functions.php and my child theme? Please be explicit in your answ...
[ { "answer_id": 393459, "author": "Xavi", "author_id": 210356, "author_profile": "https://wordpress.stackexchange.com/users/210356", "pm_score": 3, "selected": false, "text": "<p>I had the same problem and I find out how to solve it:</p>\n<p>For each &quot;fontFamily&quot; inside &quot;fo...
2021/08/15
[ "https://wordpress.stackexchange.com/questions/393323", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210224/" ]
I have a 7-page static site I built with a page builder theme, child theme and some plugins. I would like to override all CSS (theme AND plugins) with custom CSS stylesheets on a page-by-page basis. How can I do this? Can I accomplish this with functions.php and my child theme? Please be explicit in your answer -- I'm...
I had the same problem and I find out how to solve it: For each "fontFamily" inside "fontFamilies" array, you get a custom variable. From your example You can use both variables on your stylesheet or in theme.json: ``` --wp--preset--font-family--helvetica-arial --wp--preset--font-family--ubuntu-sansserif ``` And th...
393,352
<p>I have a site that I am working on and I noticed that I get this error in my browser console:</p> <p>Failed to load resource: the server responded with a status of 404 ()</p> <p>It was trying to load a image file called 'bg-10-free-img.jpg'</p> <p>Now I did look in the console and <a href="https://i.stack.imgur.com/...
[ { "answer_id": 393459, "author": "Xavi", "author_id": 210356, "author_profile": "https://wordpress.stackexchange.com/users/210356", "pm_score": 3, "selected": false, "text": "<p>I had the same problem and I find out how to solve it:</p>\n<p>For each &quot;fontFamily&quot; inside &quot;fo...
2021/08/16
[ "https://wordpress.stackexchange.com/questions/393352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210265/" ]
I have a site that I am working on and I noticed that I get this error in my browser console: Failed to load resource: the server responded with a status of 404 () It was trying to load a image file called 'bg-10-free-img.jpg' Now I did look in the console and [I did see this Image file in the console](https://i.sta...
I had the same problem and I find out how to solve it: For each "fontFamily" inside "fontFamilies" array, you get a custom variable. From your example You can use both variables on your stylesheet or in theme.json: ``` --wp--preset--font-family--helvetica-arial --wp--preset--font-family--ubuntu-sansserif ``` And th...
393,511
<p>i am currently trying to remove the draft(action) from the custom post type dropdown menu. I am sharing a screenshot it will help you to understand my question. I have no idea how to achieve this, is there any hook or method. Kindly help me out. Thank you in advance.</p> <p><a href="https://i.stack.imgur.com/5rlIW.p...
[ { "answer_id": 393516, "author": "Dipendra Pancholi", "author_id": 182923, "author_profile": "https://wordpress.stackexchange.com/users/182923", "pm_score": 2, "selected": false, "text": "<p>You can use the below code for this. You just need to change the &quot;posttype&quot; in the acti...
2021/08/19
[ "https://wordpress.stackexchange.com/questions/393511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/206959/" ]
i am currently trying to remove the draft(action) from the custom post type dropdown menu. I am sharing a screenshot it will help you to understand my question. I have no idea how to achieve this, is there any hook or method. Kindly help me out. Thank you in advance. [![enter image description here](https://i.stack.im...
You can use the below code for this. You just need to change the "posttype" in the action name, for which you want to remove draft from the bulk action. ``` function remove_draft_from_bulk_actions( $actions ) { if( isset( $actions[ 'draft' ] ) ) { unset( $actions[ 'draft' ] ); } return $actions; ...
393,595
<p>I'm making a shortcode function that collects data from WordPress media library</p> <pre><code>function byn_recent_resources_shortcode($atts, $content = null) { global $post; extract(shortcode_atts(array( 'group' =&gt; 'public', 'num' =&gt; '1', 'orderby' =&gt; 'post_date', ...
[ { "answer_id": 393516, "author": "Dipendra Pancholi", "author_id": 182923, "author_profile": "https://wordpress.stackexchange.com/users/182923", "pm_score": 2, "selected": false, "text": "<p>You can use the below code for this. You just need to change the &quot;posttype&quot; in the acti...
2021/08/21
[ "https://wordpress.stackexchange.com/questions/393595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64468/" ]
I'm making a shortcode function that collects data from WordPress media library ``` function byn_recent_resources_shortcode($atts, $content = null) { global $post; extract(shortcode_atts(array( 'group' => 'public', 'num' => '1', 'orderby' => 'post_date', ), $atts)); $arg...
You can use the below code for this. You just need to change the "posttype" in the action name, for which you want to remove draft from the bulk action. ``` function remove_draft_from_bulk_actions( $actions ) { if( isset( $actions[ 'draft' ] ) ) { unset( $actions[ 'draft' ] ); } return $actions; ...
393,689
<p>I'm trying to add a Button, which generates a random URL every time it's clicked.</p> <p>I found :</p> <pre><code>&lt;a href=&quot;&lt;?php echo ( &quot;http://meet.jit.si/&quot; . rand(1000, 9000) )?&gt;&quot; target=&quot;_blank&quot;&gt; click here &lt;/a&gt; </code></pre> <p>But I have no idea where to post this...
[ { "answer_id": 393695, "author": "MarkPraschan", "author_id": 129862, "author_profile": "https://wordpress.stackexchange.com/users/129862", "pm_score": 2, "selected": false, "text": "<p>It looks like your code works as written.</p>\n<p>Alternatively, you can generate an alphanumeric stri...
2021/08/24
[ "https://wordpress.stackexchange.com/questions/393689", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210595/" ]
I'm trying to add a Button, which generates a random URL every time it's clicked. I found : ``` <a href="<?php echo ( "http://meet.jit.si/" . rand(1000, 9000) )?>" target="_blank"> click here </a> ``` But I have no idea where to post this into.
It looks like your code works as written. Alternatively, you can generate an alphanumeric string using [`uniqid()`](https://www.php.net/manual/en/function.uniqid.php)... ``` <a href="http://meet.jit.si/<?php echo uniqid()?>" target="_blank"> click here </a> ``` --- **EDIT:** Modified code based on additional infor...
393,717
<p>due to debugging and error hunting in a plugin, I have a quick question.</p> <p>What does $wpdb-&gt;get_row() return in case there are no results? The documentation says:</p> <pre><code>(array|object|null|void) Database query result in format specified by $output or null on failure. </code></pre> <p>But when looking...
[ { "answer_id": 393718, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 1, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/reference/classes/wpdb/#select-a-row\" rel=\"nofollow noreferrer\">...
2021/08/24
[ "https://wordpress.stackexchange.com/questions/393717", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153053/" ]
due to debugging and error hunting in a plugin, I have a quick question. What does $wpdb->get\_row() return in case there are no results? The documentation says: ``` (array|object|null|void) Database query result in format specified by $output or null on failure. ``` But when looking at the source code, it rather s...
[From the docs](https://developer.wordpress.org/reference/classes/wpdb/#select-a-row): *Returns **null** if no result is found...*
393,728
<p>I'm making a button shortcode that requires to attach extra HTML element to <code>wp_foot</code> for each shortcode added.</p> <pre><code>function action_button_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'title' =&gt; 'Title', 'color' =&gt; 'blue', // blue, green 'u...
[ { "answer_id": 393718, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 1, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/reference/classes/wpdb/#select-a-row\" rel=\"nofollow noreferrer\">...
2021/08/25
[ "https://wordpress.stackexchange.com/questions/393728", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64468/" ]
I'm making a button shortcode that requires to attach extra HTML element to `wp_foot` for each shortcode added. ``` function action_button_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'title' => 'Title', 'color' => 'blue', // blue, green 'url' => 'url', 'icon' => ...
[From the docs](https://developer.wordpress.org/reference/classes/wpdb/#select-a-row): *Returns **null** if no result is found...*
393,746
<p>We have our blog posts on a custom page with a custom pagination. For example a blog post name is url.de/postname instead of url.de/blog/postname.</p> <p>Therefore we have a page /blog/ which has the pagination on it. The links from the pagination module like /blog/2/ lead to a 404 error page, because the /page/ par...
[ { "answer_id": 393749, "author": "Pierre R", "author_id": 134512, "author_profile": "https://wordpress.stackexchange.com/users/134512", "pm_score": -1, "selected": false, "text": "<p>You should keep the slug page in your URL.\nIt is way more easier and better to read.</p>\n<p>Here is som...
2021/08/25
[ "https://wordpress.stackexchange.com/questions/393746", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17691/" ]
We have our blog posts on a custom page with a custom pagination. For example a blog post name is url.de/postname instead of url.de/blog/postname. Therefore we have a page /blog/ which has the pagination on it. The links from the pagination module like /blog/2/ lead to a 404 error page, because the /page/ part is miss...
I'll add another answer because the rule is only a part of the problem. Here is what I have tested and is working : ``` <?php class BadRewritesRules { public function __construct() { add_action('init', [$this, 'custom_post_types_rewrite_rules']); remove_filter('template_redirect', 'redirect_canon...
393,786
<p>I'm using ACF to add categories color. I display them in the articles loop.</p> <p>I would like to retrieve the parent category color if the child color is empty. If the parent is also empty, get the primary color.</p> <p>Here is what I have:</p> <pre><code>$terms = get_the_terms( get_the_ID(), 'category' ); if ( $t...
[ { "answer_id": 393749, "author": "Pierre R", "author_id": 134512, "author_profile": "https://wordpress.stackexchange.com/users/134512", "pm_score": -1, "selected": false, "text": "<p>You should keep the slug page in your URL.\nIt is way more easier and better to read.</p>\n<p>Here is som...
2021/08/26
[ "https://wordpress.stackexchange.com/questions/393786", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210698/" ]
I'm using ACF to add categories color. I display them in the articles loop. I would like to retrieve the parent category color if the child color is empty. If the parent is also empty, get the primary color. Here is what I have: ``` $terms = get_the_terms( get_the_ID(), 'category' ); if ( $terms ) { foreach ( $ter...
I'll add another answer because the rule is only a part of the problem. Here is what I have tested and is working : ``` <?php class BadRewritesRules { public function __construct() { add_action('init', [$this, 'custom_post_types_rewrite_rules']); remove_filter('template_redirect', 'redirect_canon...
393,799
<h3>Goal</h3> <p>Every time an admin clicks on the &quot;Trash&quot; button below a comment, refresh the page. If the comment was trashed while the admin was in the &quot;All&quot; category, he should be in the &quot;All&quot; category again after the refresh. If he was in the &quot;Pending&quot; category, he should be...
[ { "answer_id": 393749, "author": "Pierre R", "author_id": 134512, "author_profile": "https://wordpress.stackexchange.com/users/134512", "pm_score": -1, "selected": false, "text": "<p>You should keep the slug page in your URL.\nIt is way more easier and better to read.</p>\n<p>Here is som...
2021/08/26
[ "https://wordpress.stackexchange.com/questions/393799", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210026/" ]
### Goal Every time an admin clicks on the "Trash" button below a comment, refresh the page. If the comment was trashed while the admin was in the "All" category, he should be in the "All" category again after the refresh. If he was in the "Pending" category, he should be there again after the refresh. ### Why I'm d...
I'll add another answer because the rule is only a part of the problem. Here is what I have tested and is working : ``` <?php class BadRewritesRules { public function __construct() { add_action('init', [$this, 'custom_post_types_rewrite_rules']); remove_filter('template_redirect', 'redirect_canon...
393,801
<p>I've created a Custom Post Type called 'Item' and added a multi-upload file/image/video field type but I'm not able to figure out how to register that custom field with WPGraphQL. Here's how I registered my CPT with WPGraphQL:</p> <pre class="lang-php prettyprint-override"><code> add_filter( 'register_post_type_arg...
[ { "answer_id": 393749, "author": "Pierre R", "author_id": 134512, "author_profile": "https://wordpress.stackexchange.com/users/134512", "pm_score": -1, "selected": false, "text": "<p>You should keep the slug page in your URL.\nIt is way more easier and better to read.</p>\n<p>Here is som...
2021/08/26
[ "https://wordpress.stackexchange.com/questions/393801", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210715/" ]
I've created a Custom Post Type called 'Item' and added a multi-upload file/image/video field type but I'm not able to figure out how to register that custom field with WPGraphQL. Here's how I registered my CPT with WPGraphQL: ```php add_filter( 'register_post_type_args', function( $args, $post_type ) { if ( 'i...
I'll add another answer because the rule is only a part of the problem. Here is what I have tested and is working : ``` <?php class BadRewritesRules { public function __construct() { add_action('init', [$this, 'custom_post_types_rewrite_rules']); remove_filter('template_redirect', 'redirect_canon...
393,829
<p>I want to add custom overlay search to my WordPress site using add action. Somehow, it is not triggering the javascripts to show the overlay html. However, it is working in a browser when I test simply in browser by saving as html, <a href="https://js.do/code/overlayworkingcode" rel="nofollow noreferrer">can be chec...
[ { "answer_id": 393749, "author": "Pierre R", "author_id": 134512, "author_profile": "https://wordpress.stackexchange.com/users/134512", "pm_score": -1, "selected": false, "text": "<p>You should keep the slug page in your URL.\nIt is way more easier and better to read.</p>\n<p>Here is som...
2021/08/26
[ "https://wordpress.stackexchange.com/questions/393829", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/201013/" ]
I want to add custom overlay search to my WordPress site using add action. Somehow, it is not triggering the javascripts to show the overlay html. However, it is working in a browser when I test simply in browser by saving as html, [can be checked here](https://js.do/code/overlayworkingcode). How can I properly add the...
I'll add another answer because the rule is only a part of the problem. Here is what I have tested and is working : ``` <?php class BadRewritesRules { public function __construct() { add_action('init', [$this, 'custom_post_types_rewrite_rules']); remove_filter('template_redirect', 'redirect_canon...
393,836
<p>I have successfully changed the name of a specific page using this code in my functions.php file:</p> <pre><code>add_filter('pre_get_document_title', 'change_my_property_title'); function change_my_property_title($title) { if ( is_page('property') ) { return 'Property'; } return $title; } </co...
[ { "answer_id": 393749, "author": "Pierre R", "author_id": 134512, "author_profile": "https://wordpress.stackexchange.com/users/134512", "pm_score": -1, "selected": false, "text": "<p>You should keep the slug page in your URL.\nIt is way more easier and better to read.</p>\n<p>Here is som...
2021/08/27
[ "https://wordpress.stackexchange.com/questions/393836", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210568/" ]
I have successfully changed the name of a specific page using this code in my functions.php file: ``` add_filter('pre_get_document_title', 'change_my_property_title'); function change_my_property_title($title) { if ( is_page('property') ) { return 'Property'; } return $title; } ``` My problem ...
I'll add another answer because the rule is only a part of the problem. Here is what I have tested and is working : ``` <?php class BadRewritesRules { public function __construct() { add_action('init', [$this, 'custom_post_types_rewrite_rules']); remove_filter('template_redirect', 'redirect_canon...
393,858
<p>This is my Shortcode: <code>[mbv name=”product-info”]</code></p> <p>And i want to display this shortcode's content after <a href="https://github.com/woocommerce/woocommerce/blob/b19500728b4b292562afb65eb3a0c0f50d5859de/templates/single-product/short-description.php#L24" rel="nofollow noreferrer">WooCommerce Short P...
[ { "answer_id": 393749, "author": "Pierre R", "author_id": 134512, "author_profile": "https://wordpress.stackexchange.com/users/134512", "pm_score": -1, "selected": false, "text": "<p>You should keep the slug page in your URL.\nIt is way more easier and better to read.</p>\n<p>Here is som...
2021/08/27
[ "https://wordpress.stackexchange.com/questions/393858", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210558/" ]
This is my Shortcode: `[mbv name=”product-info”]` And i want to display this shortcode's content after [WooCommerce Short Product Description](https://github.com/woocommerce/woocommerce/blob/b19500728b4b292562afb65eb3a0c0f50d5859de/templates/single-product/short-description.php#L24) How can i do it?
I'll add another answer because the rule is only a part of the problem. Here is what I have tested and is working : ``` <?php class BadRewritesRules { public function __construct() { add_action('init', [$this, 'custom_post_types_rewrite_rules']); remove_filter('template_redirect', 'redirect_canon...
393,877
<p>Hope someone can help me with this.</p> <p>This is my code:</p> <pre><code>function swh_woocommerce_store_credit_shortcode() { $store_credits = swh_woocommerce_get_store_credits(); echo &quot;&lt;span style= 'display: inline;'&gt;Remaining Credit:&lt;/span&gt;&quot;; return wc_price($store_credits); ...
[ { "answer_id": 393749, "author": "Pierre R", "author_id": 134512, "author_profile": "https://wordpress.stackexchange.com/users/134512", "pm_score": -1, "selected": false, "text": "<p>You should keep the slug page in your URL.\nIt is way more easier and better to read.</p>\n<p>Here is som...
2021/08/27
[ "https://wordpress.stackexchange.com/questions/393877", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210770/" ]
Hope someone can help me with this. This is my code: ``` function swh_woocommerce_store_credit_shortcode() { $store_credits = swh_woocommerce_get_store_credits(); echo "<span style= 'display: inline;'>Remaining Credit:</span>"; return wc_price($store_credits); } add_shortcode( 'swh_store_credit_total_val...
I'll add another answer because the rule is only a part of the problem. Here is what I have tested and is working : ``` <?php class BadRewritesRules { public function __construct() { add_action('init', [$this, 'custom_post_types_rewrite_rules']); remove_filter('template_redirect', 'redirect_canon...
394,020
<p>I recently noticed a new feature in the Gutenberg editor (I'm guessing introduced in Wordpress 5.8) that seemingly allows any user to post as any other user:</p> <p><a href="https://i.stack.imgur.com/nIo3m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nIo3m.png" alt="enter image description here...
[ { "answer_id": 394027, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>This has been present since before the block editor, and even the classic editor, and can be seen in WordPres...
2021/08/31
[ "https://wordpress.stackexchange.com/questions/394020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/167562/" ]
I recently noticed a new feature in the Gutenberg editor (I'm guessing introduced in Wordpress 5.8) that seemingly allows any user to post as any other user: [![enter image description here](https://i.stack.imgur.com/nIo3m.png)](https://i.stack.imgur.com/nIo3m.png) I confirmed that using this new option, a user belon...
This has been present since before the block editor, and even the classic editor, and can be seen in WordPress 2.0. It even predates proper metaboxes! In the block editor, the presence of the author field depends on wether the user has the action `wp:action-assign-author`, but there is no direct capability that determ...
394,032
<p>I wonder if this is possible on wordpress. In my application I will have a contact form, in this contact form, when filling in the fields, there must be a field that will generate an ID. This ID the customer will be able to write down and save. I will also receive this ID along with the details this person has fille...
[ { "answer_id": 394027, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>This has been present since before the block editor, and even the classic editor, and can be seen in WordPres...
2021/08/31
[ "https://wordpress.stackexchange.com/questions/394032", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203043/" ]
I wonder if this is possible on wordpress. In my application I will have a contact form, in this contact form, when filling in the fields, there must be a field that will generate an ID. This ID the customer will be able to write down and save. I will also receive this ID along with the details this person has filled i...
This has been present since before the block editor, and even the classic editor, and can be seen in WordPress 2.0. It even predates proper metaboxes! In the block editor, the presence of the author field depends on wether the user has the action `wp:action-assign-author`, but there is no direct capability that determ...
394,086
<p>I have created a form and the table in the database I want submissions to be sent to. From my research I've found that this code should send it to the database:</p> <pre><code>&lt;?php /* PHP code that processes form */ if(isset($_POST['submit'])){ global $wpdb; $tablename = Form_Submiss...
[ { "answer_id": 394027, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>This has been present since before the block editor, and even the classic editor, and can be seen in WordPres...
2021/09/01
[ "https://wordpress.stackexchange.com/questions/394086", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210914/" ]
I have created a form and the table in the database I want submissions to be sent to. From my research I've found that this code should send it to the database: ``` <?php /* PHP code that processes form */ if(isset($_POST['submit'])){ global $wpdb; $tablename = Form_Submissions; $data=arr...
This has been present since before the block editor, and even the classic editor, and can be seen in WordPress 2.0. It even predates proper metaboxes! In the block editor, the presence of the author field depends on wether the user has the action `wp:action-assign-author`, but there is no direct capability that determ...
395,152
<p>I use wordpress for my Social Media site. WordPress Pings allow other blog posts to appear in comments when they link to us.</p> <p>I want to limit it to only blog posts created on my own site. Basically I only want SELF-PINGS/Trackbacks.</p> <p>If Other site tries to send ping reject it then and their, but if my ow...
[ { "answer_id": 395178, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": 1, "selected": false, "text": "<p>If you don't make any other use of XMLRPC service in WordPress than the pingbacks/trackbacks, you could try limitin...
2021/09/03
[ "https://wordpress.stackexchange.com/questions/395152", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/166927/" ]
I use wordpress for my Social Media site. WordPress Pings allow other blog posts to appear in comments when they link to us. I want to limit it to only blog posts created on my own site. Basically I only want SELF-PINGS/Trackbacks. If Other site tries to send ping reject it then and their, but if my own site https://...
If you want to receive only linkbacks from your own WordPress site, then try both of these: But if you want to allow all that were sent as *trackbacks* (where the comment type is `trackback`), then just ignore the second snippet below, which I added because in default/core themes like Twenty Twenty-One, both pingbacks...
395,169
<p>I have a huge problem! I am in the middle of migrating a drupal based online database to wordpress. In the old database every object (post) had downloadable qr code. Because the database is used for scientific purposes and users where allowed to use the downloaded qr code in their own publications for reference purp...
[ { "answer_id": 395178, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": 1, "selected": false, "text": "<p>If you don't make any other use of XMLRPC service in WordPress than the pingbacks/trackbacks, you could try limitin...
2021/09/03
[ "https://wordpress.stackexchange.com/questions/395169", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212032/" ]
I have a huge problem! I am in the middle of migrating a drupal based online database to wordpress. In the old database every object (post) had downloadable qr code. Because the database is used for scientific purposes and users where allowed to use the downloaded qr code in their own publications for reference purpose...
If you want to receive only linkbacks from your own WordPress site, then try both of these: But if you want to allow all that were sent as *trackbacks* (where the comment type is `trackback`), then just ignore the second snippet below, which I added because in default/core themes like Twenty Twenty-One, both pingbacks...
395,184
<p>In my current case, the system try to find a page and show 404 if it does not find. I would like with the same url... like <a href="https://example.com/%7B%7Bslug%7D%7D/" rel="nofollow noreferrer">https://example.com/{{slug}}/</a></p> <ol> <li>Check if a page with this slug exists : <ol> <li> <ul> <li>Yes - show the...
[ { "answer_id": 395178, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": 1, "selected": false, "text": "<p>If you don't make any other use of XMLRPC service in WordPress than the pingbacks/trackbacks, you could try limitin...
2021/09/03
[ "https://wordpress.stackexchange.com/questions/395184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128094/" ]
In my current case, the system try to find a page and show 404 if it does not find. I would like with the same url... like [https://example.com/{{slug}}/](https://example.com/%7B%7Bslug%7D%7D/) 1. Check if a page with this slug exists : 1. * Yes - show the page 2. * No - switch to the category page (with same slug) ...
If you want to receive only linkbacks from your own WordPress site, then try both of these: But if you want to allow all that were sent as *trackbacks* (where the comment type is `trackback`), then just ignore the second snippet below, which I added because in default/core themes like Twenty Twenty-One, both pingbacks...
395,222
<p>I have little problem how implement deleting data from database using row actions. I have my custom list which includes data from database table. <a href="https://i.stack.imgur.com/v8EuB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v8EuB.png" alt="List" /></a></p> <pre><code> function column_na...
[ { "answer_id": 395224, "author": "Mafnah", "author_id": 104860, "author_profile": "https://wordpress.stackexchange.com/users/104860", "pm_score": 2, "selected": false, "text": "<p>I think it's better to use the <a href=\"https://developer.wordpress.org/reference/classes/wpdb/delete/\" re...
2021/09/04
[ "https://wordpress.stackexchange.com/questions/395222", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212087/" ]
I have little problem how implement deleting data from database using row actions. I have my custom list which includes data from database table. [![List](https://i.stack.imgur.com/v8EuB.png)](https://i.stack.imgur.com/v8EuB.png) ``` function column_name( $item ) { $delete_nonce = wp_create_nonce(); $title = ...
The ["admin\_action\_{$\_REQUEST['action']}" hook](https://developer.wordpress.org/reference/hooks/admin_action__requestaction/) does not pass any arguments. You would need to get the article\_id from the $\_REQUEST array. There are also a few other concerns such as: 1. You're not assigning an action when you call `wp...
395,419
<p>I have a load of data as JSON that I am trying to save into a fresh install of WordPress.</p> <p>I am using <a href="https://github.com/puppeteer/puppeteer" rel="nofollow noreferrer">puppeteer</a> to log into and create each page, and <code>wp.blocks.createBlock</code> to programmatically create the blocks.</p> <pre...
[ { "answer_id": 395467, "author": "dgwyer", "author_id": 8961, "author_profile": "https://wordpress.stackexchange.com/users/8961", "pm_score": 0, "selected": false, "text": "<p>Have you tried using <code>savePost</code>?</p>\n<p><a href=\"https://developer.wordpress.org/block-editor/refer...
2021/09/09
[ "https://wordpress.stackexchange.com/questions/395419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27866/" ]
I have a load of data as JSON that I am trying to save into a fresh install of WordPress. I am using [puppeteer](https://github.com/puppeteer/puppeteer) to log into and create each page, and `wp.blocks.createBlock` to programmatically create the blocks. ``` // Input the page title const headingInput = document.q...
You can do this with: ``` wp.data.dispatch( 'core/editor' ).savePost() ```
395,431
<p>I'm building a webshop with Wordpress and Woocommerce. On the productoverview (archive) of a productcategories I want to show a label if the product has the category 'New'. The following code works on the product-single, but it won't show on the productcategory-page if I add the action in content-product.php.</p> <p...
[ { "answer_id": 395467, "author": "dgwyer", "author_id": 8961, "author_profile": "https://wordpress.stackexchange.com/users/8961", "pm_score": 0, "selected": false, "text": "<p>Have you tried using <code>savePost</code>?</p>\n<p><a href=\"https://developer.wordpress.org/block-editor/refer...
2021/09/09
[ "https://wordpress.stackexchange.com/questions/395431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/209621/" ]
I'm building a webshop with Wordpress and Woocommerce. On the productoverview (archive) of a productcategories I want to show a label if the product has the category 'New'. The following code works on the product-single, but it won't show on the productcategory-page if I add the action in content-product.php. I used t...
You can do this with: ``` wp.data.dispatch( 'core/editor' ).savePost() ```
395,551
<p>I have a function in a theme:</p> <pre><code>$category = isset($_GET['category']) ? wp_unslash($_GET['category']) : ''; </code></pre> <p>The problem is that it outputs my categories like this:</p> <p>&quot;test-category&quot;</p> <p>I want, however, to show: <strong>&quot;Test Category&quot;</strong>, just like it's...
[ { "answer_id": 395467, "author": "dgwyer", "author_id": 8961, "author_profile": "https://wordpress.stackexchange.com/users/8961", "pm_score": 0, "selected": false, "text": "<p>Have you tried using <code>savePost</code>?</p>\n<p><a href=\"https://developer.wordpress.org/block-editor/refer...
2021/09/13
[ "https://wordpress.stackexchange.com/questions/395551", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34977/" ]
I have a function in a theme: ``` $category = isset($_GET['category']) ? wp_unslash($_GET['category']) : ''; ``` The problem is that it outputs my categories like this: "test-category" I want, however, to show: **"Test Category"**, just like it's saved in the backend, without the dashes and the smaller letters. I...
You can do this with: ``` wp.data.dispatch( 'core/editor' ).savePost() ```
395,602
<p>I'm beginning in PHP and I'm building a little shop with WooCommerce. I'm trying to display the top level parent category of a product in the body class.</p> <p>This code works well :</p> <pre><code>function woo_custom_taxonomy_in_body_class( $classes ){ $custom_terms = get_the_terms(0, 'product_cat'); if ($custom_t...
[ { "answer_id": 395467, "author": "dgwyer", "author_id": 8961, "author_profile": "https://wordpress.stackexchange.com/users/8961", "pm_score": 0, "selected": false, "text": "<p>Have you tried using <code>savePost</code>?</p>\n<p><a href=\"https://developer.wordpress.org/block-editor/refer...
2021/09/14
[ "https://wordpress.stackexchange.com/questions/395602", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212456/" ]
I'm beginning in PHP and I'm building a little shop with WooCommerce. I'm trying to display the top level parent category of a product in the body class. This code works well : ``` function woo_custom_taxonomy_in_body_class( $classes ){ $custom_terms = get_the_terms(0, 'product_cat'); if ($custom_terms) { foreach (...
You can do this with: ``` wp.data.dispatch( 'core/editor' ).savePost() ```
395,697
<p>How can I totally disable the wordpress auto-resizing when uploading images, but only for images that have a certain string in its filename.</p> <p>Eg. disable auto-resizing on images in which its filenames contains the string &quot;HD&quot;.</p> <p>image_xyz.jpeg &gt;&gt; auto-resizing function enabled <br>imageHD...
[ { "answer_id": 395467, "author": "dgwyer", "author_id": 8961, "author_profile": "https://wordpress.stackexchange.com/users/8961", "pm_score": 0, "selected": false, "text": "<p>Have you tried using <code>savePost</code>?</p>\n<p><a href=\"https://developer.wordpress.org/block-editor/refer...
2021/09/16
[ "https://wordpress.stackexchange.com/questions/395697", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212522/" ]
How can I totally disable the wordpress auto-resizing when uploading images, but only for images that have a certain string in its filename. Eg. disable auto-resizing on images in which its filenames contains the string "HD". image\_xyz.jpeg >> auto-resizing function enabled imageHD\_xyz.jpeg >> auto-resizing functi...
You can do this with: ``` wp.data.dispatch( 'core/editor' ).savePost() ```
395,709
<p>Ok so basically I have this kind of situation.</p> <p>My first step is to filter out the posts using an array, let's say using this:</p> <pre><code>$posts = get_posts(array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; 99999999, 'meta_query' =&gt; array( array( ...
[ { "answer_id": 395728, "author": "Ahmad Ahmad", "author_id": 212539, "author_profile": "https://wordpress.stackexchange.com/users/212539", "pm_score": 2, "selected": true, "text": "<p>I think a plugin did update ( if they are set to be auto-updated ), then this plugin may have crushed th...
2021/09/16
[ "https://wordpress.stackexchange.com/questions/395709", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202740/" ]
Ok so basically I have this kind of situation. My first step is to filter out the posts using an array, let's say using this: ``` $posts = get_posts(array( 'post_type' => 'post', 'posts_per_page' => 99999999, 'meta_query' => array( array( 'key' => 'status', ...
I think a plugin did update ( if they are set to be auto-updated ), then this plugin may have crushed the dashboard. so you can try to test "[manually disable plugins Wordpress](https://kinsta.com/knowledgebase/disable-wordpress-plugins/)"
395,714
<p>I have a need to capture data in a WordPress plugin and append it into some sort of log.</p> <p>The data I want happens to be slow SQL queries from $wpdb-&gt;queries. I'm hoping to present useful &quot;dirty dozen&quot; SQL queries to my users to help them with optimizations. It's a companion plugin, or maybe a fea...
[ { "answer_id": 395728, "author": "Ahmad Ahmad", "author_id": 212539, "author_profile": "https://wordpress.stackexchange.com/users/212539", "pm_score": 2, "selected": true, "text": "<p>I think a plugin did update ( if they are set to be auto-updated ), then this plugin may have crushed th...
2021/09/16
[ "https://wordpress.stackexchange.com/questions/395714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13596/" ]
I have a need to capture data in a WordPress plugin and append it into some sort of log. The data I want happens to be slow SQL queries from $wpdb->queries. I'm hoping to present useful "dirty dozen" SQL queries to my users to help them with optimizations. It's a companion plugin, or maybe a feature set, for [this plu...
I think a plugin did update ( if they are set to be auto-updated ), then this plugin may have crushed the dashboard. so you can try to test "[manually disable plugins Wordpress](https://kinsta.com/knowledgebase/disable-wordpress-plugins/)"
395,795
<p>I have been told that using this in the array:</p> <pre><code>'orderby' =&gt; 'rand' </code></pre> <p>will cause this:</p> <blockquote> <p>Ordering by random is extremely expensive to query, involving creating temporary database tables, and scans, as it has to copy the entire posts table, then randomly re-order the...
[ { "answer_id": 395728, "author": "Ahmad Ahmad", "author_id": 212539, "author_profile": "https://wordpress.stackexchange.com/users/212539", "pm_score": 2, "selected": true, "text": "<p>I think a plugin did update ( if they are set to be auto-updated ), then this plugin may have crushed th...
2021/09/18
[ "https://wordpress.stackexchange.com/questions/395795", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/202740/" ]
I have been told that using this in the array: ``` 'orderby' => 'rand' ``` will cause this: > > Ordering by random is extremely expensive to query, involving creating > temporary database tables, and scans, as it has to copy the entire > posts table, then randomly re-order the posts, then finally do the > actual ...
I think a plugin did update ( if they are set to be auto-updated ), then this plugin may have crushed the dashboard. so you can try to test "[manually disable plugins Wordpress](https://kinsta.com/knowledgebase/disable-wordpress-plugins/)"
395,841
<p>It's really hilarious but my <code>the_date()</code> and <code>the_time()</code> functions show the current date and time instead of the post's publication time, therefore at each refresh of the page, the time changes according to the actual time and date. I am using these functions in a single template for a custom...
[ { "answer_id": 395728, "author": "Ahmad Ahmad", "author_id": 212539, "author_profile": "https://wordpress.stackexchange.com/users/212539", "pm_score": 2, "selected": true, "text": "<p>I think a plugin did update ( if they are set to be auto-updated ), then this plugin may have crushed th...
2021/09/19
[ "https://wordpress.stackexchange.com/questions/395841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210079/" ]
It's really hilarious but my `the_date()` and `the_time()` functions show the current date and time instead of the post's publication time, therefore at each refresh of the page, the time changes according to the actual time and date. I am using these functions in a single template for a custom post in the loop, like s...
I think a plugin did update ( if they are set to be auto-updated ), then this plugin may have crushed the dashboard. so you can try to test "[manually disable plugins Wordpress](https://kinsta.com/knowledgebase/disable-wordpress-plugins/)"
395,953
<p>I have registered some styles and scripts that should be loaded if a template part is loaded in a template file. For ex:</p> <p>in home.php</p> <pre><code>&lt;?php get_template_part( 'template-parts/external_links'); ?&gt; </code></pre> <p>(this template-part is loaded across different template files) therefore, I w...
[ { "answer_id": 396106, "author": "Pixelsmith", "author_id": 66368, "author_profile": "https://wordpress.stackexchange.com/users/66368", "pm_score": 0, "selected": false, "text": "<p>A question very similar to this has already been <a href=\"https://stackoverflow.com/questions/28332354/ho...
2021/09/21
[ "https://wordpress.stackexchange.com/questions/395953", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/206371/" ]
I have registered some styles and scripts that should be loaded if a template part is loaded in a template file. For ex: in home.php ``` <?php get_template_part( 'template-parts/external_links'); ?> ``` (this template-part is loaded across different template files) therefore, I want to enqueue (a previously registe...
You can use the `get_template_part_{$slug}` hook, which fires before a template part is loaded. You can find the reference [here](https://wp-kama.com/hook/get_template_part_(slug)), which I find more useful than the official reference. So, I tested it in the twentytwentyone theme (yes I modified the theme directly but...
396,005
<p>I made a config.php file where I store some arrays for configuration like LDAP and other things. I need to call it on different templates but I also need to require it into function.php.</p> <p>When I do this this, I have warning and all my tables become Undefined.</p> <p><strong>EDIT</strong></p> <p>I found this so...
[ { "answer_id": 396106, "author": "Pixelsmith", "author_id": 66368, "author_profile": "https://wordpress.stackexchange.com/users/66368", "pm_score": 0, "selected": false, "text": "<p>A question very similar to this has already been <a href=\"https://stackoverflow.com/questions/28332354/ho...
2021/09/22
[ "https://wordpress.stackexchange.com/questions/396005", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194938/" ]
I made a config.php file where I store some arrays for configuration like LDAP and other things. I need to call it on different templates but I also need to require it into function.php. When I do this this, I have warning and all my tables become Undefined. **EDIT** I found this solution : call my config.php into f...
You can use the `get_template_part_{$slug}` hook, which fires before a template part is loaded. You can find the reference [here](https://wp-kama.com/hook/get_template_part_(slug)), which I find more useful than the official reference. So, I tested it in the twentytwentyone theme (yes I modified the theme directly but...
396,013
<p>I'm trying to save post id and keyword (Yoast Focus Keyword) to a custom table when post is created or updated via <code>save_post</code> action. It saves everything fine on Publish (first-time) but when I update the post, it gets old value for focus keyword from database and doesn't save the new value.</p> <p>for e...
[ { "answer_id": 396045, "author": "kovshenin", "author_id": 1316, "author_profile": "https://wordpress.stackexchange.com/users/1316", "pm_score": 0, "selected": false, "text": "<p>It really depends on when <code>_yoast_wpseo_focuskw</code> is actually written/updated in the plugin you're ...
2021/09/22
[ "https://wordpress.stackexchange.com/questions/396013", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161037/" ]
I'm trying to save post id and keyword (Yoast Focus Keyword) to a custom table when post is created or updated via `save_post` action. It saves everything fine on Publish (first-time) but when I update the post, it gets old value for focus keyword from database and doesn't save the new value. for example Focus Keyword...
WordPress fires the [updated\_{$meta\_type}\_meta](https://developer.wordpress.org/reference/hooks/updated_meta_type_meta/) hook which fires after the metadata is updated. In your case, the hook would be `updated_post_meta` and you could have your function run on that hook instead of the `save_post` hook.
396,024
<p>Here's my meta query:</p> <pre><code>$taxonomy_term = 1494; $args['meta_query'] = array( 'relation' =&gt; 'OR', 'mp_exists' =&gt; array( 'key' =&gt; 'tdlrm_mp_'.$taxonomy_term, 'type' =&gt; 'NUMERIC', ), 'mp_not_exists' =&gt; array( 'key' =&gt; 'tdl...
[ { "answer_id": 396045, "author": "kovshenin", "author_id": 1316, "author_profile": "https://wordpress.stackexchange.com/users/1316", "pm_score": 0, "selected": false, "text": "<p>It really depends on when <code>_yoast_wpseo_focuskw</code> is actually written/updated in the plugin you're ...
2021/09/23
[ "https://wordpress.stackexchange.com/questions/396024", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/190417/" ]
Here's my meta query: ``` $taxonomy_term = 1494; $args['meta_query'] = array( 'relation' => 'OR', 'mp_exists' => array( 'key' => 'tdlrm_mp_'.$taxonomy_term, 'type' => 'NUMERIC', ), 'mp_not_exists' => array( 'key' => 'tdlrm_mp_'.$taxonomy_term, ...
WordPress fires the [updated\_{$meta\_type}\_meta](https://developer.wordpress.org/reference/hooks/updated_meta_type_meta/) hook which fires after the metadata is updated. In your case, the hook would be `updated_post_meta` and you could have your function run on that hook instead of the `save_post` hook.
396,039
<p>I try tu run wp form with ajax but console return Wordpress admin-ajax.php 400 bad request.</p> <pre><code> jQuery(function ($) { $(document).ready(function () { jQuery('#form_add_to_cart').on('submit', function () { jQuery.ajax({ url...
[ { "answer_id": 396045, "author": "kovshenin", "author_id": 1316, "author_profile": "https://wordpress.stackexchange.com/users/1316", "pm_score": 0, "selected": false, "text": "<p>It really depends on when <code>_yoast_wpseo_focuskw</code> is actually written/updated in the plugin you're ...
2021/09/23
[ "https://wordpress.stackexchange.com/questions/396039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212803/" ]
I try tu run wp form with ajax but console return Wordpress admin-ajax.php 400 bad request. ``` jQuery(function ($) { $(document).ready(function () { jQuery('#form_add_to_cart').on('submit', function () { jQuery.ajax({ url: 'https://domain.com/wp-admin/admin-a...
WordPress fires the [updated\_{$meta\_type}\_meta](https://developer.wordpress.org/reference/hooks/updated_meta_type_meta/) hook which fires after the metadata is updated. In your case, the hook would be `updated_post_meta` and you could have your function run on that hook instead of the `save_post` hook.
396,105
<p>I would like to use the rest API to take a username and a password sent in a request and use it in wp_authenticate() then send back if the credentials were correct. How would I do this.</p>
[ { "answer_id": 396119, "author": "Aurovrata", "author_id": 52120, "author_profile": "https://wordpress.stackexchange.com/users/52120", "pm_score": 1, "selected": false, "text": "<p>There are 3 ways to authenticate a user using a REST api end-point request,</p>\n<p>1- using cookies, which...
2021/09/24
[ "https://wordpress.stackexchange.com/questions/396105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212716/" ]
I would like to use the rest API to take a username and a password sent in a request and use it in wp\_authenticate() then send back if the credentials were correct. How would I do this.
There are 3 ways to authenticate a user using a REST api end-point request, 1- using cookies, which is the way WordPress keeps track of authenticated users in POST requests. You pass the authentication details in your REST request, use the `wp_signon()` [function](https://developer.wordpress.org/reference/functions/wp...
396,171
<p>How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help</p> <p>I give you a piece of code. Thanks to this code I am able to display the total number of re...
[ { "answer_id": 396189, "author": "Joe", "author_id": 34273, "author_profile": "https://wordpress.stackexchange.com/users/34273", "pm_score": 1, "selected": true, "text": "<p>If you have access to user IDs, you can use the <a href=\"https://developer.wordpress.org/reference/functions/coun...
2021/09/27
[ "https://wordpress.stackexchange.com/questions/396171", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212622/" ]
How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help I give you a piece of code. Thanks to this code I am able to display the total number of recipes, bu...
If you have access to user IDs, you can use the [count\_user\_posts()](https://developer.wordpress.org/reference/functions/count_user_posts/) function. You would get the number of posts by a user like this: ``` //Assume the variable $thisUser is equal to a valid user ID $ThisUserCount = count_user_posts($thisUser, 'r...
396,277
<p>I am trying to use a tax query in my <code>pre_get_posts</code> function. All is working but not when the array has multiple IDs. Let's say my URL looks like: ?listing_cat[]=1&amp;listing_cat[]=2</p> <p>Now I am trying to filter out posts that are in those 2 categories. But my filter only gets the posts from the fir...
[ { "answer_id": 396314, "author": "Den Isahac", "author_id": 113233, "author_profile": "https://wordpress.stackexchange.com/users/113233", "pm_score": 2, "selected": true, "text": "<p>Just use:</p>\n<p><code>'terms' =&gt; $rt_cat_id</code></p>\n<p>I'll work for both array and single-based...
2021/09/29
[ "https://wordpress.stackexchange.com/questions/396277", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/124244/" ]
I am trying to use a tax query in my `pre_get_posts` function. All is working but not when the array has multiple IDs. Let's say my URL looks like: ?listing\_cat[]=1&listing\_cat[]=2 Now I am trying to filter out posts that are in those 2 categories. But my filter only gets the posts from the first category ID. I gues...
Just use: `'terms' => $rt_cat_id` I'll work for both array and single-based values. Or you can simplify your code as follows: ```php if( isset( $_GET[ 'listing_cat' ] ) ) { $tax_query[] = array( 'taxonomy' => 'listing_category', 'field' => 'id', 'terms' => $_GET[ 'listing_cat' ] ); } ```
396,282
<p>My website has a few .PNG images animated at the very start of my Contact page. Those images are a bit heavy (because they have transparent background), so the animation starts with some of them loading during the animation, looking pretty bad.</p> <p>So, to fix it, I must add this line <code>&lt;link rel=&quot;prel...
[ { "answer_id": 396314, "author": "Den Isahac", "author_id": 113233, "author_profile": "https://wordpress.stackexchange.com/users/113233", "pm_score": 2, "selected": true, "text": "<p>Just use:</p>\n<p><code>'terms' =&gt; $rt_cat_id</code></p>\n<p>I'll work for both array and single-based...
2021/09/29
[ "https://wordpress.stackexchange.com/questions/396282", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/203472/" ]
My website has a few .PNG images animated at the very start of my Contact page. Those images are a bit heavy (because they have transparent background), so the animation starts with some of them loading during the animation, looking pretty bad. So, to fix it, I must add this line `<link rel="preload" as="image" href="...
Just use: `'terms' => $rt_cat_id` I'll work for both array and single-based values. Or you can simplify your code as follows: ```php if( isset( $_GET[ 'listing_cat' ] ) ) { $tax_query[] = array( 'taxonomy' => 'listing_category', 'field' => 'id', 'terms' => $_GET[ 'listing_cat' ] ); } ```
396,286
<p>Is it possible to show ONLY the first 300 words (or even 50 lines) of every blog post for anonymous users? Instead of show the whole article on the page? And after registration all the post would show.</p> <p>Thanks!!!</p>
[ { "answer_id": 396293, "author": "Pixelsmith", "author_id": 66368, "author_profile": "https://wordpress.stackexchange.com/users/66368", "pm_score": 1, "selected": false, "text": "<p>It wasn't quite as easy as @Pat J made it sound, especially if you want <code>HTML</code> formatting with ...
2021/09/29
[ "https://wordpress.stackexchange.com/questions/396286", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213060/" ]
Is it possible to show ONLY the first 300 words (or even 50 lines) of every blog post for anonymous users? Instead of show the whole article on the page? And after registration all the post would show. Thanks!!!
It wasn't quite as easy as @Pat J made it sound, especially if you want `HTML` formatting with your copy. I cribbed from [this answer](https://stackoverflow.com/questions/36078264/i-want-to-allow-html-tag-when-use-the-wp-trim-words) and came up with the following code for you. I've tested it and it works: ``` // I...
396,304
<p>At the moment I'm using Postman to hit the endpoints and I have a successful Basic Authentication but so far I'm unable to get all the registered users. My request:</p> <pre><code>https://example.com/wp-json/wp/v2/users </code></pre> <p>returns only users that have posts even though I have inserted:</p> <pre><code>a...
[ { "answer_id": 396306, "author": "billybadass", "author_id": 194672, "author_profile": "https://wordpress.stackexchange.com/users/194672", "pm_score": 0, "selected": false, "text": "<p>WP has nice build in tools to work with db, my suggestion would be to register your endpoint and use fo...
2021/09/30
[ "https://wordpress.stackexchange.com/questions/396304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213074/" ]
At the moment I'm using Postman to hit the endpoints and I have a successful Basic Authentication but so far I'm unable to get all the registered users. My request: ``` https://example.com/wp-json/wp/v2/users ``` returns only users that have posts even though I have inserted: ``` add_filter( 'rest_user_query' , 'cu...
**The problem may be pagination** The API only returns 10 results per page, and needs follow up requests to fetch the rest. WP includes a HTTP header that tells you how many total results and the number of pages. It has a hard limit of 100 per page maximum, if you request 200, you will be capped to 100. So your missi...
396,325
<p>I tried hooking the <code>upload_mimes</code> hook in order to add support for ttf files to be uploaded, however this didn't immediately work (.ttf files were still blocked).</p> <p>The reason isn't entirely clear to me but I assume Wordpress's calculated MIME type for the file I'm trying to upload and the MIME type...
[ { "answer_id": 396326, "author": "mozboz", "author_id": 176814, "author_profile": "https://wordpress.stackexchange.com/users/176814", "pm_score": 3, "selected": true, "text": "<p>This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension <em>...
2021/09/30
[ "https://wordpress.stackexchange.com/questions/396325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/176814/" ]
I tried hooking the `upload_mimes` hook in order to add support for ttf files to be uploaded, however this didn't immediately work (.ttf files were still blocked). The reason isn't entirely clear to me but I assume Wordpress's calculated MIME type for the file I'm trying to upload and the MIME type I'm adding to the `...
This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension *and* then hooks `upload_mimes` for exactly our specified MIME type. Part of this answer taken from <https://diviengine.com/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/> First massage the ...
396,337
<p>How do I allow a specific user or a specific role to view drafts and previews, but not allow them to edit posts or have any other admin capabilities? I can add a custom capability to a role, but don't know the logic for allowing them to view drafts and previews. Any thoughts?</p>
[ { "answer_id": 396326, "author": "mozboz", "author_id": 176814, "author_profile": "https://wordpress.stackexchange.com/users/176814", "pm_score": 3, "selected": true, "text": "<p>This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension <em>...
2021/09/30
[ "https://wordpress.stackexchange.com/questions/396337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/42925/" ]
How do I allow a specific user or a specific role to view drafts and previews, but not allow them to edit posts or have any other admin capabilities? I can add a custom capability to a role, but don't know the logic for allowing them to view drafts and previews. Any thoughts?
This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension *and* then hooks `upload_mimes` for exactly our specified MIME type. Part of this answer taken from <https://diviengine.com/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/> First massage the ...
396,397
<p>Very new to PHP and I'm trying to do the following through a snippets plugin but keep getting critical errors:</p> <ul> <li>Restrict all non-logged in users to home, about and pricing pages. If attempting to access other pages, redirect to &quot;no-permission&quot; message page.</li> <li>If user is logged in, allow ...
[ { "answer_id": 396326, "author": "mozboz", "author_id": 176814, "author_profile": "https://wordpress.stackexchange.com/users/176814", "pm_score": 3, "selected": true, "text": "<p>This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension <em>...
2021/10/02
[ "https://wordpress.stackexchange.com/questions/396397", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213142/" ]
Very new to PHP and I'm trying to do the following through a snippets plugin but keep getting critical errors: * Restrict all non-logged in users to home, about and pricing pages. If attempting to access other pages, redirect to "no-permission" message page. * If user is logged in, allow them to only view posts on the...
This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension *and* then hooks `upload_mimes` for exactly our specified MIME type. Part of this answer taken from <https://diviengine.com/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/> First massage the ...
396,411
<p>I am currently using the wp-members wordpress plugin. I just learned that they have no functionality to redirect the user to the last page viewed after login or registration .. which has a solution thank you</p>
[ { "answer_id": 396326, "author": "mozboz", "author_id": 176814, "author_profile": "https://wordpress.stackexchange.com/users/176814", "pm_score": 3, "selected": true, "text": "<p>This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension <em>...
2021/10/02
[ "https://wordpress.stackexchange.com/questions/396411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212622/" ]
I am currently using the wp-members wordpress plugin. I just learned that they have no functionality to redirect the user to the last page viewed after login or registration .. which has a solution thank you
This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension *and* then hooks `upload_mimes` for exactly our specified MIME type. Part of this answer taken from <https://diviengine.com/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/> First massage the ...
396,416
<p>I have a website with several custom fields, however when using the following code to search for a post, it only searches for the title or for the content, excluding the custom fields associated with the post or entry.</p> <pre><code>&lt;form method=&quot;get&quot; id=&quot;searchform&quot; action=&quot;&lt;?php blo...
[ { "answer_id": 396326, "author": "mozboz", "author_id": 176814, "author_profile": "https://wordpress.stackexchange.com/users/176814", "pm_score": 3, "selected": true, "text": "<p>This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension <em>...
2021/10/03
[ "https://wordpress.stackexchange.com/questions/396416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162329/" ]
I have a website with several custom fields, however when using the following code to search for a post, it only searches for the title or for the content, excluding the custom fields associated with the post or entry. ``` <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/"> <input type="text" val...
This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension *and* then hooks `upload_mimes` for exactly our specified MIME type. Part of this answer taken from <https://diviengine.com/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/> First massage the ...
396,485
<p>I am writing a custom (bespoke, for 1 client, not for publication and general consumption) plugin, that needs to access custom tables.</p> <p>In general with WP,I follow the principle of using the higher level APIs where possible, so rarely have to work with \wpdb. Now that i do have a need, i am discovering how arc...
[ { "answer_id": 396326, "author": "mozboz", "author_id": 176814, "author_profile": "https://wordpress.stackexchange.com/users/176814", "pm_score": 3, "selected": true, "text": "<p>This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension <em>...
2021/10/05
[ "https://wordpress.stackexchange.com/questions/396485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120700/" ]
I am writing a custom (bespoke, for 1 client, not for publication and general consumption) plugin, that needs to access custom tables. In general with WP,I follow the principle of using the higher level APIs where possible, so rarely have to work with \wpdb. Now that i do have a need, i am discovering how archaic it i...
This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension *and* then hooks `upload_mimes` for exactly our specified MIME type. Part of this answer taken from <https://diviengine.com/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/> First massage the ...
396,517
<p>I am following the official WordPress &quot;Create a Block Tutorial&quot; located here: <a href="https://developer.wordpress.org/block-editor/handbook/tutorials/create-block/" rel="nofollow noreferrer">https://developer.wordpress.org/block-editor/handbook/tutorials/create-block/</a></p> <p>I used this as a starting ...
[ { "answer_id": 396326, "author": "mozboz", "author_id": 176814, "author_profile": "https://wordpress.stackexchange.com/users/176814", "pm_score": 3, "selected": true, "text": "<p>This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension <em>...
2021/10/05
[ "https://wordpress.stackexchange.com/questions/396517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213256/" ]
I am following the official WordPress "Create a Block Tutorial" located here: <https://developer.wordpress.org/block-editor/handbook/tutorials/create-block/> I used this as a starting point for the plugin: `npx @wordpress/create-block` I am using it in conjunction with Local by Flywheel for my dev environment. Mostly...
This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension *and* then hooks `upload_mimes` for exactly our specified MIME type. Part of this answer taken from <https://diviengine.com/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/> First massage the ...
396,518
<p>Is there a way to check which files are part of vanilla Wordpress? I am working on a custom Wordpress project that has a lot of added parts to it and I was wondering if there was an easy way to check which files were added.</p> <p>Inside of root there's a folder website.com, among other things, and inside website.co...
[ { "answer_id": 396326, "author": "mozboz", "author_id": 176814, "author_profile": "https://wordpress.stackexchange.com/users/176814", "pm_score": 3, "selected": true, "text": "<p>This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension <em>...
2021/10/05
[ "https://wordpress.stackexchange.com/questions/396518", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212733/" ]
Is there a way to check which files are part of vanilla Wordpress? I am working on a custom Wordpress project that has a lot of added parts to it and I was wondering if there was an easy way to check which files were added. Inside of root there's a folder website.com, among other things, and inside website.com there's...
This is an imperfect solution which forces the way Wordpress detects TTF files to use the file extension *and* then hooks `upload_mimes` for exactly our specified MIME type. Part of this answer taken from <https://diviengine.com/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/> First massage the ...
396,540
<p>On button click, I want user to download a file which is an apk file. On that same click, at the same time, I want to scroll to a div.</p> <p>Is it possible to add two actions in a button? Note: I'm using elementor.</p>
[ { "answer_id": 396543, "author": "Praveen", "author_id": 97802, "author_profile": "https://wordpress.stackexchange.com/users/97802", "pm_score": 0, "selected": false, "text": "<p>Try this code</p>\n<pre><code>$('.download-btn').click(function(){\n $('html, body').animate({scrollTop : $(...
2021/10/06
[ "https://wordpress.stackexchange.com/questions/396540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/182718/" ]
On button click, I want user to download a file which is an apk file. On that same click, at the same time, I want to scroll to a div. Is it possible to add two actions in a button? Note: I'm using elementor.
Demo: <https://codepen.io/livehelp/pen/MWoNPqX?editors=1010> Just use an HTML or Code element in Elementor to paste in the code instead of a Button element. ``` <h2><a href="#smooth" onclick="window.open('https://downloads.wordpress.org/plugin/apk-downloader.zip')";>Click to Download + Smooth Scroll</a></h2> <p>Inse...
396,542
<pre><code>&lt;?php the_post_thumbnail( 'medium-thumbnail', array( 'loading' =&gt; false ), [ 'alt' =&gt; esc_html ( get_the_title() ) ] ); ?&gt; </code></pre> <p>Get Diagnostics info on pagespeed</p> <p>Largest Contentful Paint image was not lazily loaded</p> <p>what I wrong?</p>
[ { "answer_id": 396543, "author": "Praveen", "author_id": 97802, "author_profile": "https://wordpress.stackexchange.com/users/97802", "pm_score": 0, "selected": false, "text": "<p>Try this code</p>\n<pre><code>$('.download-btn').click(function(){\n $('html, body').animate({scrollTop : $(...
2021/10/06
[ "https://wordpress.stackexchange.com/questions/396542", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194551/" ]
``` <?php the_post_thumbnail( 'medium-thumbnail', array( 'loading' => false ), [ 'alt' => esc_html ( get_the_title() ) ] ); ?> ``` Get Diagnostics info on pagespeed Largest Contentful Paint image was not lazily loaded what I wrong?
Demo: <https://codepen.io/livehelp/pen/MWoNPqX?editors=1010> Just use an HTML or Code element in Elementor to paste in the code instead of a Button element. ``` <h2><a href="#smooth" onclick="window.open('https://downloads.wordpress.org/plugin/apk-downloader.zip')";>Click to Download + Smooth Scroll</a></h2> <p>Inse...
396,598
<p>One of my sites is used as a personal diary with &gt;5000 videos uploaded within the media library.</p> <p>Each post uses the following shortcode, disabling pre-load and assigning a manual poster. This reduces server load and speed for the default preload='metadata', should the post contain lots of videos. The poste...
[ { "answer_id": 396543, "author": "Praveen", "author_id": 97802, "author_profile": "https://wordpress.stackexchange.com/users/97802", "pm_score": 0, "selected": false, "text": "<p>Try this code</p>\n<pre><code>$('.download-btn').click(function(){\n $('html, body').animate({scrollTop : $(...
2021/10/07
[ "https://wordpress.stackexchange.com/questions/396598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213345/" ]
One of my sites is used as a personal diary with >5000 videos uploaded within the media library. Each post uses the following shortcode, disabling pre-load and assigning a manual poster. This reduces server load and speed for the default preload='metadata', should the post contain lots of videos. The posters are manua...
Demo: <https://codepen.io/livehelp/pen/MWoNPqX?editors=1010> Just use an HTML or Code element in Elementor to paste in the code instead of a Button element. ``` <h2><a href="#smooth" onclick="window.open('https://downloads.wordpress.org/plugin/apk-downloader.zip')";>Click to Download + Smooth Scroll</a></h2> <p>Inse...
396,661
<br> <p><strong>Targets : Show Locations (sub-districts &amp; cities) on the customized shop page &amp; on tab additional information - Show on line 5</strong></p> <p>I'm building a property site using wordpress and woocommerce.</p> <p>In my country has 7 islands, 34 provinces, 514 Cities, 7041 Districts, 82194 Sub-di...
[ { "answer_id": 396543, "author": "Praveen", "author_id": 97802, "author_profile": "https://wordpress.stackexchange.com/users/97802", "pm_score": 0, "selected": false, "text": "<p>Try this code</p>\n<pre><code>$('.download-btn').click(function(){\n $('html, body').animate({scrollTop : $(...
2021/10/09
[ "https://wordpress.stackexchange.com/questions/396661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/210665/" ]
**Targets : Show Locations (sub-districts & cities) on the customized shop page & on tab additional information - Show on line 5** I'm building a property site using wordpress and woocommerce. In my country has 7 islands, 34 provinces, 514 Cities, 7041 Districts, 82194 Sub-districts. Then I grouped the data and adde...
Demo: <https://codepen.io/livehelp/pen/MWoNPqX?editors=1010> Just use an HTML or Code element in Elementor to paste in the code instead of a Button element. ``` <h2><a href="#smooth" onclick="window.open('https://downloads.wordpress.org/plugin/apk-downloader.zip')";>Click to Download + Smooth Scroll</a></h2> <p>Inse...
396,663
<p>Everything worked fine a week ago. Lets Encrypt certificate on the site is valid. I am currently getting the following error while creating a product:</p> <pre><code>{&quot;code&quot;:&quot;woocommerce_product_image_upload_error&quot;,&quot;message&quot;:&quot;Error getting remote image https:\/\/mysite.com\/wp-cont...
[ { "answer_id": 396543, "author": "Praveen", "author_id": 97802, "author_profile": "https://wordpress.stackexchange.com/users/97802", "pm_score": 0, "selected": false, "text": "<p>Try this code</p>\n<pre><code>$('.download-btn').click(function(){\n $('html, body').animate({scrollTop : $(...
2021/10/09
[ "https://wordpress.stackexchange.com/questions/396663", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/89603/" ]
Everything worked fine a week ago. Lets Encrypt certificate on the site is valid. I am currently getting the following error while creating a product: ``` {"code":"woocommerce_product_image_upload_error","message":"Error getting remote image https:\/\/mysite.com\/wp-content\/uploads\/2021\/10\/60c739fd1-1.jpg. Error: ...
Demo: <https://codepen.io/livehelp/pen/MWoNPqX?editors=1010> Just use an HTML or Code element in Elementor to paste in the code instead of a Button element. ``` <h2><a href="#smooth" onclick="window.open('https://downloads.wordpress.org/plugin/apk-downloader.zip')";>Click to Download + Smooth Scroll</a></h2> <p>Inse...
396,768
<p>I registered a custom post type called <code>wasb_message</code> with <code>show_in_rest</code> set to <code>true</code> and <code>rest_base</code> set to <code>'messages'</code> so the resource is reachable at endpoint <em>https://mydomain/wp-json/wp/v2/messages</em> (using the <code>WP_REST_Posts_Controller</code>...
[ { "answer_id": 396769, "author": "Tami", "author_id": 181119, "author_profile": "https://wordpress.stackexchange.com/users/181119", "pm_score": 0, "selected": false, "text": "<p>As per the reply by Haris it should be something like this:</p>\n<pre><code>function wasb_rest_parameter($args...
2021/10/12
[ "https://wordpress.stackexchange.com/questions/396768", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/178523/" ]
I registered a custom post type called `wasb_message` with `show_in_rest` set to `true` and `rest_base` set to `'messages'` so the resource is reachable at endpoint *https://mydomain/wp-json/wp/v2/messages* (using the `WP_REST_Posts_Controller` class). The custom post type has a custom meta field called `wasb_status` w...
I solved following [this answer](https://wordpress.stackexchange.com/questions/300316/how-to-add-a-custom-parameter-to-a-wp-api-default-route) and writing: ``` public function query_wasb_messages_by_status( $args, $request ) { if ( ! is_null( $request->get_param( 'message_status' ) ) ) { $args['me...
396,902
<p>I try to <code>require_once()</code> a file, if the condition of a specific tag is met, on a woocommerce single product page.</p> <p>I've added following to my <code>functions.php</code></p> <pre><code>if(has_term('xyz', 'product_tag')){ require_once WP_CONTENT_DIR . '/path/file.php'; } </code></pre> <p>It doesn...
[ { "answer_id": 396904, "author": "tiago calado", "author_id": 198152, "author_profile": "https://wordpress.stackexchange.com/users/198152", "pm_score": 0, "selected": false, "text": "<p>require_once is a function, try this way.</p>\n<pre class=\"lang-php prettyprint-override\"><code>if(h...
2021/10/14
[ "https://wordpress.stackexchange.com/questions/396902", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213621/" ]
I try to `require_once()` a file, if the condition of a specific tag is met, on a woocommerce single product page. I've added following to my `functions.php` ``` if(has_term('xyz', 'product_tag')){ require_once WP_CONTENT_DIR . '/path/file.php'; } ``` It doesn't load my file, but if I take it out of my conditio...
`has_term()` is a template function therefore it does not work if you use it straight in functions.php which is loaded well before knowing if the current object is a product page. So if you use it in `functions.php` you could do: ``` add_action('template_redirect','my_inclusion_function'); function my_inclusion_functi...
396,908
<p>Unless I type the URL of my site as example.com/wp-login.php, with URL typed as example.com, the front page is automatically directed to the following unknown site:</p> <pre><code>https://elementonfor.live/?utm_campaign=pEv9cTd8QNHYzqqr5UNFx2COHvnp_JE3r8uVIhm3Qww1&amp;t=main9 </code></pre> <p>The above website is un...
[ { "answer_id": 396911, "author": "tiago calado", "author_id": 198152, "author_profile": "https://wordpress.stackexchange.com/users/198152", "pm_score": 0, "selected": false, "text": "<p>have you installed any new plugin recently. that can be a cause.\nif so try to deactivate them and che...
2021/10/14
[ "https://wordpress.stackexchange.com/questions/396908", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170049/" ]
Unless I type the URL of my site as example.com/wp-login.php, with URL typed as example.com, the front page is automatically directed to the following unknown site: ``` https://elementonfor.live/?utm_campaign=pEv9cTd8QNHYzqqr5UNFx2COHvnp_JE3r8uVIhm3Qww1&t=main9 ``` The above website is unknown, and it is not clear w...
Finally, I had to contact my web host. They cleared the server cache and everything is back to normal. Thanks to @tiago-calado and @Rup for their response.
396,944
<p>hi i am newbie with SQL data base so forgive my dumbness i have installed KK Star rating plugin on my wp site which noticed its recording lot of entries and my db size is over 280 MB and 188MB is wp_postmeta table. uninstalled the plugin and i want to run sql query to delete all postmeta with kkstar recorcs. the met...
[ { "answer_id": 396945, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>First, make sure you back up your database. :)</p>\n<p>If you're wanting to run a SQL command directly - ...
2021/10/15
[ "https://wordpress.stackexchange.com/questions/396944", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/175359/" ]
hi i am newbie with SQL data base so forgive my dumbness i have installed KK Star rating plugin on my wp site which noticed its recording lot of entries and my db size is over 280 MB and 188MB is wp\_postmeta table. uninstalled the plugin and i want to run sql query to delete all postmeta with kkstar recorcs. the meta ...
``` DELETE FROM `{PREFIX}post_meta` WHERE meta_key = 'kksr_fingerprint_default' ``` {PREFIX} is the string `$table_prefix` defined in wp-config.php; of course be careful in run SQL DELETE, create a table backup and (maybe) execute first a single line deletion to check the result ``` DELETE FROM `{PREFIX}post_meta` W...
396,962
<p>I'm new to the Wordpress/PHP world. I want my page be able to communicate with an API that I build myself. So for this I have a form on my Wordpress Page using a HTML code widget which looks like this:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;div&gt; &lt;form id=&quot;myform&quot; action=&quot;submit...
[ { "answer_id": 396945, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>First, make sure you back up your database. :)</p>\n<p>If you're wanting to run a SQL command directly - ...
2021/10/15
[ "https://wordpress.stackexchange.com/questions/396962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213571/" ]
I'm new to the Wordpress/PHP world. I want my page be able to communicate with an API that I build myself. So for this I have a form on my Wordpress Page using a HTML code widget which looks like this: ``` <html> <body> <div> <form id="myform" action="submit_shortcode"> <input type="text" id="i...
``` DELETE FROM `{PREFIX}post_meta` WHERE meta_key = 'kksr_fingerprint_default' ``` {PREFIX} is the string `$table_prefix` defined in wp-config.php; of course be careful in run SQL DELETE, create a table backup and (maybe) execute first a single line deletion to check the result ``` DELETE FROM `{PREFIX}post_meta` W...
397,015
<p>I recently migrated the site from a subdomain back to the main domain using WP All-in-One Migration Tool. The migration was successful and I can see the wp-admin panel just fine and even view the site while logged in.</p> <p>But... when logging out the visitors just see the white screen of death. I have tried every ...
[ { "answer_id": 396945, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>First, make sure you back up your database. :)</p>\n<p>If you're wanting to run a SQL command directly - ...
2021/10/18
[ "https://wordpress.stackexchange.com/questions/397015", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213737/" ]
I recently migrated the site from a subdomain back to the main domain using WP All-in-One Migration Tool. The migration was successful and I can see the wp-admin panel just fine and even view the site while logged in. But... when logging out the visitors just see the white screen of death. I have tried every fix in th...
``` DELETE FROM `{PREFIX}post_meta` WHERE meta_key = 'kksr_fingerprint_default' ``` {PREFIX} is the string `$table_prefix` defined in wp-config.php; of course be careful in run SQL DELETE, create a table backup and (maybe) execute first a single line deletion to check the result ``` DELETE FROM `{PREFIX}post_meta` W...
397,120
<p>Checking the <code>editor-blocks.css</code> file found in some themes, I see the following CSS classes added before some of the individual block classes:</p> <pre><code>.edit-post-visual-editor .editor-block-list__layout .editor-block-list__block .block-library-list </code></pre> <p>An example:</p> <pre><code>.edito...
[ { "answer_id": 397155, "author": "Kalimah", "author_id": 35871, "author_profile": "https://wordpress.stackexchange.com/users/35871", "pm_score": 0, "selected": false, "text": "<p>Searching the editor source code: <a href=\"https://github.com/WordPress/gutenberg\" rel=\"nofollow noreferre...
2021/10/20
[ "https://wordpress.stackexchange.com/questions/397120", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33049/" ]
Checking the `editor-blocks.css` file found in some themes, I see the following CSS classes added before some of the individual block classes: ``` .edit-post-visual-editor .editor-block-list__layout .editor-block-list__block .block-library-list ``` An example: ``` .editor-block-list__block .wp-block-latest-comments...
In case anyone is interested, these are the conclusions I reached after studying the block editor for some time. Both `.editor-block-list__layout` and `.editor-block-list__block` classes are deprecated since WordPress 5.4 and have been renamed to `.block-editor-block-list__layout` and `.block-editor-block-list__block`...
397,145
<p>In this project, there are custom posts with a variety of titles. In each post with the title that is the name of a person (first name, last name), there is a custom field (custom_title) that can hold an alternate name (last name, first name).</p> <p>In order to display the names in a useful way in the custom archiv...
[ { "answer_id": 397155, "author": "Kalimah", "author_id": 35871, "author_profile": "https://wordpress.stackexchange.com/users/35871", "pm_score": 0, "selected": false, "text": "<p>Searching the editor source code: <a href=\"https://github.com/WordPress/gutenberg\" rel=\"nofollow noreferre...
2021/10/20
[ "https://wordpress.stackexchange.com/questions/397145", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213871/" ]
In this project, there are custom posts with a variety of titles. In each post with the title that is the name of a person (first name, last name), there is a custom field (custom\_title) that can hold an alternate name (last name, first name). In order to display the names in a useful way in the custom archive page, ...
In case anyone is interested, these are the conclusions I reached after studying the block editor for some time. Both `.editor-block-list__layout` and `.editor-block-list__block` classes are deprecated since WordPress 5.4 and have been renamed to `.block-editor-block-list__layout` and `.block-editor-block-list__block`...
397,316
<p>I want to change WooCommerce pagination links from:</p> <ul> <li>example.com/category/page/3/ to:</li> <li>example.com/category/3/</li> </ul> <p>I found many examples of how to change '/page/' to '/something/' but I want only the number of the current page. I also tried this:</p> <pre class="lang-php prettyprint-ove...
[ { "answer_id": 397155, "author": "Kalimah", "author_id": 35871, "author_profile": "https://wordpress.stackexchange.com/users/35871", "pm_score": 0, "selected": false, "text": "<p>Searching the editor source code: <a href=\"https://github.com/WordPress/gutenberg\" rel=\"nofollow noreferre...
2021/10/25
[ "https://wordpress.stackexchange.com/questions/397316", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/214037/" ]
I want to change WooCommerce pagination links from: * example.com/category/page/3/ to: * example.com/category/3/ I found many examples of how to change '/page/' to '/something/' but I want only the number of the current page. I also tried this: ```php $wp_rewrite->pagination_base = ''; ``` But then my url looks l...
In case anyone is interested, these are the conclusions I reached after studying the block editor for some time. Both `.editor-block-list__layout` and `.editor-block-list__block` classes are deprecated since WordPress 5.4 and have been renamed to `.block-editor-block-list__layout` and `.block-editor-block-list__block`...
397,380
<p>I'm performing an <code>wpdb-&gt;insert()</code>. When a field includes a special the insert is not done and I get the error</p> <blockquote> <p>Error in Wordpress database for query SHOW FULL COLUMNS FROM <code>wp_my_table</code></p> </blockquote> <p>If I don't use special characters the insert is done correctly.</...
[ { "answer_id": 397155, "author": "Kalimah", "author_id": 35871, "author_profile": "https://wordpress.stackexchange.com/users/35871", "pm_score": 0, "selected": false, "text": "<p>Searching the editor source code: <a href=\"https://github.com/WordPress/gutenberg\" rel=\"nofollow noreferre...
2021/10/27
[ "https://wordpress.stackexchange.com/questions/397380", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17141/" ]
I'm performing an `wpdb->insert()`. When a field includes a special the insert is not done and I get the error > > Error in Wordpress database for query SHOW FULL COLUMNS FROM `wp_my_table` > > > If I don't use special characters the insert is done correctly. Apparently, the column collations are correct, but so...
In case anyone is interested, these are the conclusions I reached after studying the block editor for some time. Both `.editor-block-list__layout` and `.editor-block-list__block` classes are deprecated since WordPress 5.4 and have been renamed to `.block-editor-block-list__layout` and `.block-editor-block-list__block`...
397,571
<p>brand new to WordPress and StackExchange so excuse my poor etiquette. I am making a custom WordPress theme for a class, and somewhere along the line made an error so tiny neither me nor my professor could find it, but it's specifically caused my entire CSS page to not load whatsoever. Through troubleshooting, we fig...
[ { "answer_id": 397572, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;\n</code></pre>\n<p><em><strong>Be...
2021/11/01
[ "https://wordpress.stackexchange.com/questions/397571", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/214321/" ]
brand new to WordPress and StackExchange so excuse my poor etiquette. I am making a custom WordPress theme for a class, and somewhere along the line made an error so tiny neither me nor my professor could find it, but it's specifically caused my entire CSS page to not load whatsoever. Through troubleshooting, we figure...
``` <link href="style.css" rel="stylesheet"> ``` ***Because you're using relative URLs.*** When you are on `example.com` it will load `example.com/style.css` When you are on `example.com/test` it will load `example.com/test/style.css` etc etc As you move around the site, it will change where it's looking. None of ...
397,644
<p>I ask if it is possible to wrap a specific sidebar within a <code>&lt;div class=&quot;customdiv&quot;&gt;&lt;/div&gt;</code>. Are there any instructions to add in the function.php file? Thank you.</p> <p>Like this:</p> <pre><code>I've created this sidebar (which contains widgets): // ATTIVITA - widgets ...
[ { "answer_id": 397572, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;\n</code></pre>\n<p><em><strong>Be...
2021/11/03
[ "https://wordpress.stackexchange.com/questions/397644", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/214375/" ]
I ask if it is possible to wrap a specific sidebar within a `<div class="customdiv"></div>`. Are there any instructions to add in the function.php file? Thank you. Like this: ``` I've created this sidebar (which contains widgets): // ATTIVITA - widgets register_sidebar( array ( 'nam...
``` <link href="style.css" rel="stylesheet"> ``` ***Because you're using relative URLs.*** When you are on `example.com` it will load `example.com/style.css` When you are on `example.com/test` it will load `example.com/test/style.css` etc etc As you move around the site, it will change where it's looking. None of ...
397,668
<p>I am having a bit of a weird glitch happening to me and I am not sure how I have produced it or whether it is the norm.</p> <p>I am developing my own plugin and when a football/soccer team is typed into a box it will check if its in the database already or not.</p> <p>Here are my lines of code</p> <pre><code>add_act...
[ { "answer_id": 397572, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;\n</code></pre>\n<p><em><strong>Be...
2021/11/03
[ "https://wordpress.stackexchange.com/questions/397668", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/214284/" ]
I am having a bit of a weird glitch happening to me and I am not sure how I have produced it or whether it is the norm. I am developing my own plugin and when a football/soccer team is typed into a box it will check if its in the database already or not. Here are my lines of code ``` add_action( 'admin_footer', 'fws...
``` <link href="style.css" rel="stylesheet"> ``` ***Because you're using relative URLs.*** When you are on `example.com` it will load `example.com/style.css` When you are on `example.com/test` it will load `example.com/test/style.css` etc etc As you move around the site, it will change where it's looking. None of ...
397,814
<p>I have 4 roles in my platform : administrator, author, editor, external</p> <p>I need to restrict WordPress media library access to the user’s own uploads only for one users role (<strong>external</strong>) on my platform. <strong>The External user role can only see/select his own media</strong>.</p> <p>All others ...
[ { "answer_id": 397572, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;\n</code></pre>\n<p><em><strong>Be...
2021/11/07
[ "https://wordpress.stackexchange.com/questions/397814", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119785/" ]
I have 4 roles in my platform : administrator, author, editor, external I need to restrict WordPress media library access to the user’s own uploads only for one users role (**external**) on my platform. **The External user role can only see/select his own media**. All others roles still have access to all medias in t...
``` <link href="style.css" rel="stylesheet"> ``` ***Because you're using relative URLs.*** When you are on `example.com` it will load `example.com/style.css` When you are on `example.com/test` it will load `example.com/test/style.css` etc etc As you move around the site, it will change where it's looking. None of ...
397,860
<p>Not sure the best way to describe this, but basically I am defining a variable ($cat) which chooses a taxonomy based on a number defined just before the query is called, but as the number is defined AFTER the args I can't figure out how to get it to work. I know I could just duplicate the whole query for each taxono...
[ { "answer_id": 397864, "author": "Peter Petrov", "author_id": 124071, "author_profile": "https://wordpress.stackexchange.com/users/124071", "pm_score": 0, "selected": false, "text": "<p>To reduce code repetition, you could introduce a function. The below code example is a reworked versio...
2021/11/08
[ "https://wordpress.stackexchange.com/questions/397860", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/214570/" ]
Not sure the best way to describe this, but basically I am defining a variable ($cat) which chooses a taxonomy based on a number defined just before the query is called, but as the number is defined AFTER the args I can't figure out how to get it to work. I know I could just duplicate the whole query for each taxonomy ...
Combining Petar's function and Tiago's shortened option syntax, this works: In template: ``` //once, in header: $i = 0; //anytime I want to run the query: $i++; $cat_query = prefix_get_wp_query($i); while ( $cat_query->have_posts() ) { $cat_query->the_post(); get_template_part( 'template-parts/posts/content', g...
397,862
<p>When WordPress is installed, it sends a notification</p> <pre><code>New WordPress Site Your new WordPress site has been successfully set up at: ... </code></pre> <p>I would like to change the text of the e-mail but am not successfull. Here is what I tried:</p> <p>I added the following code to the main file of a plug...
[ { "answer_id": 397988, "author": "tiago calado", "author_id": 198152, "author_profile": "https://wordpress.stackexchange.com/users/198152", "pm_score": 0, "selected": false, "text": "<p>just an opinium, each wordpress plataform is only instaled one time, and each time only the email regi...
2021/11/08
[ "https://wordpress.stackexchange.com/questions/397862", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132518/" ]
When WordPress is installed, it sends a notification ``` New WordPress Site Your new WordPress site has been successfully set up at: ... ``` I would like to change the text of the e-mail but am not successfull. Here is what I tried: I added the following code to the main file of a plugin which I add before the inst...
I found a solution: mu-plugins. My code isn't executed in this early state, but that's what mu-plugins are for. <https://wordpress.org/support/article/must-use-plugins/> This did the trick.
397,873
<p>I'm taking a Udemy class to learn how to make Wordpress plugins and themes. The video I'm on is having me override the default search widget with a custom one via searchform.php. From what I've gathered, this file should automatically be loaded with the rest of the theme as long as I have followed these steps:</p> <...
[ { "answer_id": 397988, "author": "tiago calado", "author_id": 198152, "author_profile": "https://wordpress.stackexchange.com/users/198152", "pm_score": 0, "selected": false, "text": "<p>just an opinium, each wordpress plataform is only instaled one time, and each time only the email regi...
2021/11/08
[ "https://wordpress.stackexchange.com/questions/397873", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/214581/" ]
I'm taking a Udemy class to learn how to make Wordpress plugins and themes. The video I'm on is having me override the default search widget with a custom one via searchform.php. From what I've gathered, this file should automatically be loaded with the rest of the theme as long as I have followed these steps: /theme\...
I found a solution: mu-plugins. My code isn't executed in this early state, but that's what mu-plugins are for. <https://wordpress.org/support/article/must-use-plugins/> This did the trick.
397,957
<p>I have a <code>Quiz</code> block that contains <code>Question</code>s blocks that have <code>Answer</code> blocks. Both <code>Quiz</code> and <code>Question</code> use <code>InnerBlocks</code> to allow questions or answers to be dragged around, edited and saved.</p> <p>When I save the Quiz, how can I get the index o...
[ { "answer_id": 397966, "author": "shadi", "author_id": 124857, "author_profile": "https://wordpress.stackexchange.com/users/124857", "pm_score": 0, "selected": false, "text": "<p>try saving the values in html data attributes. then get them using <code>getAttribute(&quot;data-index&quot;)...
2021/11/10
[ "https://wordpress.stackexchange.com/questions/397957", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27866/" ]
I have a `Quiz` block that contains `Question`s blocks that have `Answer` blocks. Both `Quiz` and `Question` use `InnerBlocks` to allow questions or answers to be dragged around, edited and saved. When I save the Quiz, how can I get the index of each question in `question/save.js` and the index of each question and an...
You may now retrieve the index of a inner block via the `core/block-editor` data module. You may pair it with the `useSelect` hook to keep the indexes up to date on changes. Something like this. *Intentionally verbose for clarity.* ``` import {useSelect} from '@wordpress/data'; const Answer = ( blockProps ) => { ...
397,962
<p>I have a custom field for view counts that are stored as numbers. I added a Views column, and made it sortable, but they are not sorting properly.</p> <p>The results when I click on the Views column are something like this:</p> <pre><code>Views ===== 1900 10992 10004 280 18 4015 ... </code></pre> <p>Here is my code:...
[ { "answer_id": 397999, "author": "ZealousWeb", "author_id": 70780, "author_profile": "https://wordpress.stackexchange.com/users/70780", "pm_score": -1, "selected": false, "text": "<p>Can you please set query as per below code?</p>\n<pre><code>$query-&gt;set('orderby','meta_value meta_val...
2021/11/10
[ "https://wordpress.stackexchange.com/questions/397962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/42925/" ]
I have a custom field for view counts that are stored as numbers. I added a Views column, and made it sortable, but they are not sorting properly. The results when I click on the Views column are something like this: ``` Views ===== 1900 10992 10004 280 18 4015 ... ``` Here is my code: ``` /** * Add view counts t...
I figured it out after adding the same code to a different site I run. It was working fine on that site with the same theme and mostly the same plugins. I narrowed it down to another function I made (thankfully it wasn't another plugin). The other function was sorting something on the front end, so all I had to do was ...
397,974
<p>I have a client who wants to review and revise their Tags and tagging strategy, but they want to start with a spreadsheet of ALL tags, including those that have no posts assigned to them.</p> <p>SO I created a template that outputs the Tags to an HTML Table, that I can then import into Excel and upload to Google She...
[ { "answer_id": 397975, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 0, "selected": false, "text": "<p>Try:</p>\n<pre><code>$args = array( 'hide_empty' =&gt; false );\n$tags = get_tags( $args );\n</code></pre>\n<...
2021/11/10
[ "https://wordpress.stackexchange.com/questions/397974", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56458/" ]
I have a client who wants to review and revise their Tags and tagging strategy, but they want to start with a spreadsheet of ALL tags, including those that have no posts assigned to them. SO I created a template that outputs the Tags to an HTML Table, that I can then import into Excel and upload to Google Sheets so th...
Well this was an odd fix, and one that in theory shouldn't have been necessary, however, what finally worked (to show ALL Tags including those with empty counts) was to specify the taxonomy => 'post\_tag' EVEN THOUGH that is the 'default' parameter and shouldn't need to have been added to $args. Sigh. My final query ...
398,024
<p>I am working on a multisite install where one specific site needs to have access restricted to only users who are logged in AND have a specific user meta set (key=&quot;cr_access&quot;, val=&quot;Yes&quot;). If the user is not logged in, or that meta key is not set to &quot;Yes&quot;, then they should be redirected...
[ { "answer_id": 401005, "author": "Squivo", "author_id": 217626, "author_profile": "https://wordpress.stackexchange.com/users/217626", "pm_score": 0, "selected": false, "text": "<p>Been banging my head against the wall on this one for months. The workaround is to set all the of redirected...
2021/11/11
[ "https://wordpress.stackexchange.com/questions/398024", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/155285/" ]
I am working on a multisite install where one specific site needs to have access restricted to only users who are logged in AND have a specific user meta set (key="cr\_access", val="Yes"). If the user is not logged in, or that meta key is not set to "Yes", then they should be redirected to the specified url. The redir...
You should try adding `nocache_headers()` before you `wp_redirect()`. It's meant for this exact thing. [From the docs](https://developer.wordpress.org/reference/functions/nocache_headers/): > > Set the headers to prevent caching for the different browsers. > > > Your scenario was mentioned and addressed in a [use...
398,071
<p>I have a plugin with import</p> <pre><code>import { __experimentalUseInnerBlocksProps as useInnerBlocksProps } from '@wordpress/block-editor'; </code></pre> <p>but it's not working with newest Gutenberg plugin 11.9, because this <code>useInnerBlocksProps</code> is no longer <em>experimental</em></p> <p>so I can use<...
[ { "answer_id": 398086, "author": "KubiQ", "author_id": 128483, "author_profile": "https://wordpress.stackexchange.com/users/128483", "pm_score": 2, "selected": true, "text": "<p>Ok, this is probably the easiest workaround I was able to find, but if someone has better idea, then feel free...
2021/11/12
[ "https://wordpress.stackexchange.com/questions/398071", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128483/" ]
I have a plugin with import ``` import { __experimentalUseInnerBlocksProps as useInnerBlocksProps } from '@wordpress/block-editor'; ``` but it's not working with newest Gutenberg plugin 11.9, because this `useInnerBlocksProps` is no longer *experimental* so I can use ``` import { useInnerBlocksProps } from '@wordp...
Ok, this is probably the easiest workaround I was able to find, but if someone has better idea, then feel free to post it here ;) ``` import { __experimentalUseInnerBlocksProps, useInnerBlocksProps, } from '@wordpress/block-editor'; if( typeof useInnerBlocksProps == 'undefined' ){ var compatibleUseInnerBl...
398,210
<p>As referenced in this issue ( <a href="https://github.com/WordPress/gutenberg/issues/33374" rel="nofollow noreferrer">https://github.com/WordPress/gutenberg/issues/33374</a>) I want my custom block's innerblocks to have the default layout and alignment controls Like the layout toggle for the Group block, but baked i...
[ { "answer_id": 398252, "author": "stokesman", "author_id": 214758, "author_profile": "https://wordpress.stackexchange.com/users/214758", "pm_score": 2, "selected": false, "text": "<p>You're pretty close. Specifying layout details in block.json should nest inside a <code>&quot;default&quo...
2021/11/16
[ "https://wordpress.stackexchange.com/questions/398210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120585/" ]
As referenced in this issue ( <https://github.com/WordPress/gutenberg/issues/33374>) I want my custom block's innerblocks to have the default layout and alignment controls Like the layout toggle for the Group block, but baked in. It was answered, but I can't figure out the code: > > you can do it by providing a layo...
You're pretty close. Specifying layout details in block.json should nest inside a `"default"` property. Doing so will have the Layout panel display accordingly but there's more to it than that. If you want the default layout for the block, there is no need to add `contentSize` or `wideSize`. Here is the layout config ...
398,340
<p>I have some legacy meta fields in my post that I would like to display in my block. I found a documentation for settings meta fields but not how to display them. So I tried this:</p> <pre><code>export default function save( { attributes } ) { const blockProps = useBlockProps.save(); const postType = useSel...
[ { "answer_id": 398361, "author": "stokesman", "author_id": 214758, "author_profile": "https://wordpress.stackexchange.com/users/214758", "pm_score": 3, "selected": true, "text": "<p>From the docs:\n<a href=\"https://developer.wordpress.org/block-editor/reference-guides/block-api/block-ed...
2021/11/19
[ "https://wordpress.stackexchange.com/questions/398340", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33797/" ]
I have some legacy meta fields in my post that I would like to display in my block. I found a documentation for settings meta fields but not how to display them. So I tried this: ``` export default function save( { attributes } ) { const blockProps = useBlockProps.save(); const postType = useSelect( ...
From the docs: <https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#save> > > Note: The save function should be a pure function that depends only on the attributes used to invoke it. > It can not have any side effect or retrieve information from another source, e.g. it is not poss...
398,364
<p>I have for example this posts in WP:</p> <pre><code>Name ID Date JohnA 6 01012020 JohnB 7 01022020 KateA 7 05052021 SamA 4 01022020 SamA 4 01022022 </code></pre> <p>How I can order by date, but also put posts with ID before others for every user logged in (also ordered by date ) ? Other words - how ...
[ { "answer_id": 398361, "author": "stokesman", "author_id": 214758, "author_profile": "https://wordpress.stackexchange.com/users/214758", "pm_score": 3, "selected": true, "text": "<p>From the docs:\n<a href=\"https://developer.wordpress.org/block-editor/reference-guides/block-api/block-ed...
2021/11/20
[ "https://wordpress.stackexchange.com/questions/398364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81810/" ]
I have for example this posts in WP: ``` Name ID Date JohnA 6 01012020 JohnB 7 01022020 KateA 7 05052021 SamA 4 01022020 SamA 4 01022022 ``` How I can order by date, but also put posts with ID before others for every user logged in (also ordered by date ) ? Other words - how to sort with conditional ...
From the docs: <https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#save> > > Note: The save function should be a pure function that depends only on the attributes used to invoke it. > It can not have any side effect or retrieve information from another source, e.g. it is not poss...
398,461
<p>I have a specific requirement that my referral link be as simple as possible to type in manually (customer base is very low skilled) while simultaneously referring to an employee number who was responsible for the referral.</p> <p>So, the referral links need to look like:</p> <pre><code>www.domain.com/referral/1555 ...
[ { "answer_id": 398844, "author": "keepkalm", "author_id": 26744, "author_profile": "https://wordpress.stackexchange.com/users/26744", "pm_score": 0, "selected": false, "text": "<p>You just need the <a href=\"https://wordpress.org/plugins/redirection/\" rel=\"nofollow noreferrer\">Redirec...
2021/11/23
[ "https://wordpress.stackexchange.com/questions/398461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/215164/" ]
I have a specific requirement that my referral link be as simple as possible to type in manually (customer base is very low skilled) while simultaneously referring to an employee number who was responsible for the referral. So, the referral links need to look like: ``` www.domain.com/referral/1555 ``` Where "1555" ...
Supposing you have a ***page created with the slug "referral"***, you can add another segment to the page URL containing the employee ref number like this: 1- Register a new query variable e.g "employee\_ref" ``` add_filter('query_vars', function ($query_vars){ $query_vars[] = 'employee_ref'; return $query_va...
398,497
<p>This is an unusual one (I think).</p> <p>We run a news site, and sometimes when editing posts (using the classic editor, not the new block one) we find that a paragraph in the post we are editing has somehow become wrapped in a bunch of spans containing bootstrap css classes.</p> <p>i.e. the paragraph becomes this</...
[ { "answer_id": 398808, "author": "Lovor", "author_id": 135704, "author_profile": "https://wordpress.stackexchange.com/users/135704", "pm_score": 0, "selected": false, "text": "<ol>\n<li>In developer tools, find if bootstrap css is added. Look in list of loaded css files. Copy the name of...
2021/11/24
[ "https://wordpress.stackexchange.com/questions/398497", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/213900/" ]
This is an unusual one (I think). We run a news site, and sometimes when editing posts (using the classic editor, not the new block one) we find that a paragraph in the post we are editing has somehow become wrapped in a bunch of spans containing bootstrap css classes. i.e. the paragraph becomes this ``` <p><span st...
Without checking your install it's a bit of a guessing game, but I'd say your TinyMCE editor has a bootstrap plugin installed (there are several). Perhaps the developer tried to remove it, but only removed the buttons in the editor. Any case, it might be active without you noticing, with the plugin's jquery interfering...
398,602
<p>I created my first WordPress website using Elementor and an all-in-one theme called Webify.</p> <p>Since I am new to WordPress and to website design, I've imported a demo website that comes with the Webify theme and I am editing based on that import.</p> <p>I noticed that some pages on my site have this top 'stripe'...
[ { "answer_id": 398605, "author": "SavPhill", "author_id": 202754, "author_profile": "https://wordpress.stackexchange.com/users/202754", "pm_score": 1, "selected": false, "text": "<p>If the element you are seeing can not be edited in Elementor, then this is part of the theme template. You...
2021/11/27
[ "https://wordpress.stackexchange.com/questions/398602", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/215262/" ]
I created my first WordPress website using Elementor and an all-in-one theme called Webify. Since I am new to WordPress and to website design, I've imported a demo website that comes with the Webify theme and I am editing based on that import. I noticed that some pages on my site have this top 'stripe' with a backgro...
If the element you are seeing can not be edited in Elementor, then this is part of the theme template. You should consider looking directly at the theme page template you are using on this page to solve. Nether the less, as per your question you can remove this globally using css. In your browser you can Inspect Eleme...
398,898
<p>I use this to display all categories:</p> <pre><code>&lt;?php $args = array( 'child_of' =&gt; 0, 'current_category' =&gt; 0, 'depth' =&gt; 0, 'echo' =&gt; 1, 'exclude' =&gt; '', 'exclude_tree' =&gt; '', 'feed' =&...
[ { "answer_id": 398605, "author": "SavPhill", "author_id": 202754, "author_profile": "https://wordpress.stackexchange.com/users/202754", "pm_score": 1, "selected": false, "text": "<p>If the element you are seeing can not be edited in Elementor, then this is part of the theme template. You...
2021/12/05
[ "https://wordpress.stackexchange.com/questions/398898", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/137495/" ]
I use this to display all categories: ``` <?php $args = array( 'child_of' => 0, 'current_category' => 0, 'depth' => 0, 'echo' => 1, 'exclude' => '', 'exclude_tree' => '', 'feed' => '', 'feed_image' => ...
If the element you are seeing can not be edited in Elementor, then this is part of the theme template. You should consider looking directly at the theme page template you are using on this page to solve. Nether the less, as per your question you can remove this globally using css. In your browser you can Inspect Eleme...
398,964
<p>I would like to have an svg downloaded from my site as a png. Searching I found this code and I must say that everything works. The site is a project that will only be viewed from mobile <a href="https://7c81b.wineqrcode.com/" rel="nofollow noreferrer">https://7c81b.wineqrcode.com/</a> and I would like you to change...
[ { "answer_id": 398605, "author": "SavPhill", "author_id": 202754, "author_profile": "https://wordpress.stackexchange.com/users/202754", "pm_score": 1, "selected": false, "text": "<p>If the element you are seeing can not be edited in Elementor, then this is part of the theme template. You...
2021/12/07
[ "https://wordpress.stackexchange.com/questions/398964", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/204509/" ]
I would like to have an svg downloaded from my site as a png. Searching I found this code and I must say that everything works. The site is a project that will only be viewed from mobile <https://7c81b.wineqrcode.com/> and I would like you to change the size of the downloaded image. Currently the photo is generated bas...
If the element you are seeing can not be edited in Elementor, then this is part of the theme template. You should consider looking directly at the theme page template you are using on this page to solve. Nether the less, as per your question you can remove this globally using css. In your browser you can Inspect Eleme...
399,000
<p>Let say I want to insert different inline formatting texts. I can do that by opening the HTML mode, but is there a way to do it directly in the visual mode? For example, if I type <code>span.a</code> in a paragraph block then it will insert <code>&lt;span class=&quot;a&quot;&gt;&lt;/span&gt;</code> in HTML, similarl...
[ { "answer_id": 398605, "author": "SavPhill", "author_id": 202754, "author_profile": "https://wordpress.stackexchange.com/users/202754", "pm_score": 1, "selected": false, "text": "<p>If the element you are seeing can not be edited in Elementor, then this is part of the theme template. You...
2021/12/08
[ "https://wordpress.stackexchange.com/questions/399000", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64282/" ]
Let say I want to insert different inline formatting texts. I can do that by opening the HTML mode, but is there a way to do it directly in the visual mode? For example, if I type `span.a` in a paragraph block then it will insert `<span class="a"></span>` in HTML, similarly how the formatting buttons like bold or itali...
If the element you are seeing can not be edited in Elementor, then this is part of the theme template. You should consider looking directly at the theme page template you are using on this page to solve. Nether the less, as per your question you can remove this globally using css. In your browser you can Inspect Eleme...
399,225
<p>I would like to ask about the wp_redirect(); function. Before I ask this question, everything was working on both local and test servers. But right now, for some unknown reason, on my local wp_redirect is not working.</p> <p>My current structure is this:</p> <pre><code>get_header(); ... wp_redirect($url); exit(); ...
[ { "answer_id": 399227, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p><code>wp_redirect()</code> works by sending a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HT...
2021/12/14
[ "https://wordpress.stackexchange.com/questions/399225", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/214554/" ]
I would like to ask about the wp\_redirect(); function. Before I ask this question, everything was working on both local and test servers. But right now, for some unknown reason, on my local wp\_redirect is not working. My current structure is this: ``` get_header(); ... wp_redirect($url); exit(); ``` This was al...
`wp_redirect()` works by sending a [Location header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location). Headers cannot be sent after output has been sent to the browser. So you cannot output any HTML before calling `wp_redirect()`. Using `wp_redirect()` after `get_header()` never would have worked, w...
399,237
<p>I searched the whole net and stackexchange for a reason and a solution, but couldn't find any. There are many questions (and answers) related to own plugins and the code how to create tables on activation. But this applies not here, because I have this problem with well known and maintained plugins from the wordpres...
[ { "answer_id": 399302, "author": "Christin Löhner", "author_id": 215861, "author_profile": "https://wordpress.stackexchange.com/users/215861", "pm_score": 3, "selected": true, "text": "<p>Like <a href=\"https://wordpress.stackexchange.com/users/108180/kero\">kero</a> already has mentione...
2021/12/14
[ "https://wordpress.stackexchange.com/questions/399237", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/215861/" ]
I searched the whole net and stackexchange for a reason and a solution, but couldn't find any. There are many questions (and answers) related to own plugins and the code how to create tables on activation. But this applies not here, because I have this problem with well known and maintained plugins from the wordpress p...
Like [kero](https://wordpress.stackexchange.com/users/108180/kero) already has mentioned, I've now tested the activation of plugins with other PHP versions. And what should I say.... Simply switching from docker image php:8-fpm (8.1) to php:7.4-fpm fixed the issue for me. **Update** I've tested this now with different...
399,279
<p>I have my custom Wordpress+Woocommerce theme created that I want to show on my github page as a reference.</p> <p>The theme does not contain any login data. Of course it contains server-side php code that shows how the client page is created. I always tried to structure the logic according to other themes/according ...
[ { "answer_id": 399302, "author": "Christin Löhner", "author_id": 215861, "author_profile": "https://wordpress.stackexchange.com/users/215861", "pm_score": 3, "selected": true, "text": "<p>Like <a href=\"https://wordpress.stackexchange.com/users/108180/kero\">kero</a> already has mentione...
2021/12/15
[ "https://wordpress.stackexchange.com/questions/399279", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/215899/" ]
I have my custom Wordpress+Woocommerce theme created that I want to show on my github page as a reference. The theme does not contain any login data. Of course it contains server-side php code that shows how the client page is created. I always tried to structure the logic according to other themes/according to how co...
Like [kero](https://wordpress.stackexchange.com/users/108180/kero) already has mentioned, I've now tested the activation of plugins with other PHP versions. And what should I say.... Simply switching from docker image php:8-fpm (8.1) to php:7.4-fpm fixed the issue for me. **Update** I've tested this now with different...
400,336
<p>I'm studying someone else's code (a custom search widget based on Elementor) and there's one thing I just don't understand.</p> <pre><code>$type_term = get_term_by('slug', get_query_var($taxonomy), $taxonomy); $type = (!empty($type_term) &amp;&amp; !empty($type_term-&gt;slug)) ? $type_term-&gt;slug : 0; </code></pre...
[ { "answer_id": 399302, "author": "Christin Löhner", "author_id": 215861, "author_profile": "https://wordpress.stackexchange.com/users/215861", "pm_score": 3, "selected": true, "text": "<p>Like <a href=\"https://wordpress.stackexchange.com/users/108180/kero\">kero</a> already has mentione...
2021/12/16
[ "https://wordpress.stackexchange.com/questions/400336", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/215929/" ]
I'm studying someone else's code (a custom search widget based on Elementor) and there's one thing I just don't understand. ``` $type_term = get_term_by('slug', get_query_var($taxonomy), $taxonomy); $type = (!empty($type_term) && !empty($type_term->slug)) ? $type_term->slug : 0; ``` ``` wp_dropdown_categories(array(...
Like [kero](https://wordpress.stackexchange.com/users/108180/kero) already has mentioned, I've now tested the activation of plugins with other PHP versions. And what should I say.... Simply switching from docker image php:8-fpm (8.1) to php:7.4-fpm fixed the issue for me. **Update** I've tested this now with different...
400,397
<p>I am creating a custom theme. In it I am trying to add salon booking plugin. This plugin creates default booking page. When I am viewing the booking page I cannot see the booking form. I have tried installing the salon booking plugin in WordPress default theme twenty twenty-one and it is working fine in this theme. ...
[ { "answer_id": 400400, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Your theme does not contain a main post loop, so there is no place for the plugin to do its work</p>\n<pre c...
2021/12/17
[ "https://wordpress.stackexchange.com/questions/400397", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/216993/" ]
I am creating a custom theme. In it I am trying to add salon booking plugin. This plugin creates default booking page. When I am viewing the booking page I cannot see the booking form. I have tried installing the salon booking plugin in WordPress default theme twenty twenty-one and it is working fine in this theme. Not...
Your theme does not contain a main post loop, so there is no place for the plugin to do its work ```php if ( have_posts() ) { while ( have_posts() ) { the_post(); // // Post Content here // the_content(); } // end while } // end if ``` <https://codex.wordpress.org/The...
400,444
<p>my javascript code isn't working. I put the js folder next to the other folders, the astra-child folder, astra folder and other themes. Is this correct. Then in the js folder, I created custom_script.js file and put the javascript in there. And in functions.php file enqueued it.</p> <pre class="lang-php prettyprint-...
[ { "answer_id": 400400, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Your theme does not contain a main post loop, so there is no place for the plugin to do its work</p>\n<pre c...
2021/12/19
[ "https://wordpress.stackexchange.com/questions/400444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205788/" ]
my javascript code isn't working. I put the js folder next to the other folders, the astra-child folder, astra folder and other themes. Is this correct. Then in the js folder, I created custom\_script.js file and put the javascript in there. And in functions.php file enqueued it. ```php <?php /** * Astra Child Theme ...
Your theme does not contain a main post loop, so there is no place for the plugin to do its work ```php if ( have_posts() ) { while ( have_posts() ) { the_post(); // // Post Content here // the_content(); } // end while } // end if ``` <https://codex.wordpress.org/The...
400,480
<p>WordPress supports storing multiple post meta values for a single post using the same meta key. For example one post can have multiple instances of meta_key 'pet' with meta_value 'cat', 'dog', and/or 'fish'. This is super useful when using get_post_meta because you can get an array of all values for the pet meta key...
[ { "answer_id": 400400, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Your theme does not contain a main post loop, so there is no place for the plugin to do its work</p>\n<pre c...
2021/12/20
[ "https://wordpress.stackexchange.com/questions/400480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28924/" ]
WordPress supports storing multiple post meta values for a single post using the same meta key. For example one post can have multiple instances of meta\_key 'pet' with meta\_value 'cat', 'dog', and/or 'fish'. This is super useful when using get\_post\_meta because you can get an array of all values for the pet meta ke...
Your theme does not contain a main post loop, so there is no place for the plugin to do its work ```php if ( have_posts() ) { while ( have_posts() ) { the_post(); // // Post Content here // the_content(); } // end while } // end if ``` <https://codex.wordpress.org/The...
400,507
<p>I uploaded a child theme from Astra, but the css or javascript does not display, but I was told to look if it is activated. I have looked in developer tools, and I do not see anything about a child theme there. Would anybody know, how I could activate it, if that is the problem. Thanks</p>
[ { "answer_id": 400400, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Your theme does not contain a main post loop, so there is no place for the plugin to do its work</p>\n<pre c...
2021/12/21
[ "https://wordpress.stackexchange.com/questions/400507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/205788/" ]
I uploaded a child theme from Astra, but the css or javascript does not display, but I was told to look if it is activated. I have looked in developer tools, and I do not see anything about a child theme there. Would anybody know, how I could activate it, if that is the problem. Thanks
Your theme does not contain a main post loop, so there is no place for the plugin to do its work ```php if ( have_posts() ) { while ( have_posts() ) { the_post(); // // Post Content here // the_content(); } // end while } // end if ``` <https://codex.wordpress.org/The...
400,598
<p>I am very new to HTML and PHP and have spent hours trying to find the right questions to ask. I would like to create a simple webform on a page and add a button that will generate text (on the same page) based on the variables answered in the webform. I don't need to/want to capture the data from the form. I <em>do ...
[ { "answer_id": 400400, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Your theme does not contain a main post loop, so there is no place for the plugin to do its work</p>\n<pre c...
2021/12/23
[ "https://wordpress.stackexchange.com/questions/400598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/217202/" ]
I am very new to HTML and PHP and have spent hours trying to find the right questions to ask. I would like to create a simple webform on a page and add a button that will generate text (on the same page) based on the variables answered in the webform. I don't need to/want to capture the data from the form. I *do not* w...
Your theme does not contain a main post loop, so there is no place for the plugin to do its work ```php if ( have_posts() ) { while ( have_posts() ) { the_post(); // // Post Content here // the_content(); } // end while } // end if ``` <https://codex.wordpress.org/The...
400,712
<p>I am trying to change the classes for the &quot;View cart&quot; button after adding an item to the cart. What I tried to do is to hook into the &quot;woocommerce_ajax_added_to_cart&quot; action and insert my Javascript as below but this Breaks the AJAX call. I honestly don't know if I am using the correct hook:</p> ...
[ { "answer_id": 400400, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Your theme does not contain a main post loop, so there is no place for the plugin to do its work</p>\n<pre c...
2021/12/28
[ "https://wordpress.stackexchange.com/questions/400712", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/217352/" ]
I am trying to change the classes for the "View cart" button after adding an item to the cart. What I tried to do is to hook into the "woocommerce\_ajax\_added\_to\_cart" action and insert my Javascript as below but this Breaks the AJAX call. I honestly don't know if I am using the correct hook: ``` function set_butto...
Your theme does not contain a main post loop, so there is no place for the plugin to do its work ```php if ( have_posts() ) { while ( have_posts() ) { the_post(); // // Post Content here // the_content(); } // end while } // end if ``` <https://codex.wordpress.org/The...
400,820
<p>I have a snippet that redirects all users to a maintenance page. How can I tweak it to All users except admin users?</p> <pre><code>&lt;?php add_action( 'template_redirect', function() { if ( is_page( 4848 ) ) { return; } wp_redirect( esc_url_raw( home_url( 'maintenance/' ) ) ); //wp_redirec...
[ { "answer_id": 400821, "author": "Maytha8", "author_id": 200755, "author_profile": "https://wordpress.stackexchange.com/users/200755", "pm_score": 0, "selected": false, "text": "<p>Use <code>user_can( wp_get_current_user(), 'administrator' )</code> to determine if the user is logged in a...
2022/01/01
[ "https://wordpress.stackexchange.com/questions/400820", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/179876/" ]
I have a snippet that redirects all users to a maintenance page. How can I tweak it to All users except admin users? ``` <?php add_action( 'template_redirect', function() { if ( is_page( 4848 ) ) { return; } wp_redirect( esc_url_raw( home_url( 'maintenance/' ) ) ); //wp_redirect( esc_url_raw( ...
I would advise againt using anonymous functions for callback (when ever you can) as you can't use a targeted `remove_action` on it. What Maythan8 answered will work but it can be done with fewer functions. ```php add_action('template_redirect', 'bt_maintenance_redirect'); function bt_maintenance_redirect () { i...
400,831
<p>I am moving a site from a Genesis theme to Colorlib theme. The genesis theme includes <code>add_action( 'genesis_before_while', 'custom function' );</code> in a custom archive page, which loads restricted content from a template part. Is there a standard WP hook equivalent? or a work-around?</p>
[ { "answer_id": 400821, "author": "Maytha8", "author_id": 200755, "author_profile": "https://wordpress.stackexchange.com/users/200755", "pm_score": 0, "selected": false, "text": "<p>Use <code>user_can( wp_get_current_user(), 'administrator' )</code> to determine if the user is logged in a...
2022/01/02
[ "https://wordpress.stackexchange.com/questions/400831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/212424/" ]
I am moving a site from a Genesis theme to Colorlib theme. The genesis theme includes `add_action( 'genesis_before_while', 'custom function' );` in a custom archive page, which loads restricted content from a template part. Is there a standard WP hook equivalent? or a work-around?
I would advise againt using anonymous functions for callback (when ever you can) as you can't use a targeted `remove_action` on it. What Maythan8 answered will work but it can be done with fewer functions. ```php add_action('template_redirect', 'bt_maintenance_redirect'); function bt_maintenance_redirect () { i...