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 |
|---|---|---|---|---|---|---|
367,853 | <p>Please i want to ensure only male or female is selected in the dropdown if not fail the form but my validation keeps returning false even if male or female is selected. </p>
<p>Html</p>
<pre class="lang-html prettyprint-override"><code><select name="gender">
<option value="Male">Male</option>... | [
{
"answer_id": 367892,
"author": "Himad",
"author_id": 158512,
"author_profile": "https://wordpress.stackexchange.com/users/158512",
"pm_score": -1,
"selected": false,
"text": "<p>I came across this some time ago, I'll try to find time to correctly debug the origin of the issue but in th... | 2020/05/29 | [
"https://wordpress.stackexchange.com/questions/367853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152456/"
] | Please i want to ensure only male or female is selected in the dropdown if not fail the form but my validation keeps returning false even if male or female is selected.
Html
```html
<select name="gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Nonesense" ... | The problem is that when the special subscriber tries to **Add New** a sub-cpt post, it is denied permission. However, when the CPT menu is a top-admin-menu, then everything works out fine. The issue is related to the placement of the CPT's UI menu in the back-end: if it's top-level (`show_in_menu=TRUE`), all is well; ... |
367,886 | <p>I using the InnerBlocks tag to allow for nested blocks, within my custom block. I am trying to use the 'allowedBlocks' argument to restrict the blocks allowed to only specific ones. However, if I put anything inside the InnerBlocks tag, the block does not load and just spins.</p>
<p>I am using acf_register_block fo... | [
{
"answer_id": 367901,
"author": "Garrett ",
"author_id": 189094,
"author_profile": "https://wordpress.stackexchange.com/users/189094",
"pm_score": 0,
"selected": false,
"text": "<p>Is <code>acf</code> the correct namespace? if so, this should work in your edit function.</p>\n\n<pre><cod... | 2020/05/29 | [
"https://wordpress.stackexchange.com/questions/367886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/168656/"
] | I using the InnerBlocks tag to allow for nested blocks, within my custom block. I am trying to use the 'allowedBlocks' argument to restrict the blocks allowed to only specific ones. However, if I put anything inside the InnerBlocks tag, the block does not load and just spins.
I am using acf\_register\_block for my blo... | A late reply but I thought I would include a snippet that worked for me.
Update `$allowed_inner_blocks` with your own "block\_types" and place the following code inside the parent block template;
```
<?php $allowed_inner_blocks = ['acf/logos']; ?>
<InnerBlocks allowedBlocks="<?php echo esc_attr(wp_json_encode($allowe... |
367,904 | <p>My previous blog author using his font-family and size on every sentence of blog post. I want apply new css rule to post but it cant overide these in-line styles.</p>
<p>I tried searching around and found this one:</p>
<pre><code>add_filter( 'the_content', function( $content ){
return str_replace( ' style="', ' ... | [
{
"answer_id": 367906,
"author": "Sabry Suleiman",
"author_id": 174580,
"author_profile": "https://wordpress.stackexchange.com/users/174580",
"pm_score": 1,
"selected": false,
"text": "<p>You can try this code it works better</p>\n\n<pre><code>add_filter('the_content', function( $content... | 2020/05/30 | [
"https://wordpress.stackexchange.com/questions/367904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/153513/"
] | My previous blog author using his font-family and size on every sentence of blog post. I want apply new css rule to post but it cant overide these in-line styles.
I tried searching around and found this one:
```
add_filter( 'the_content', function( $content ){
return str_replace( ' style="', ' data-style="', $conte... | You want to remove the style from single post. And the "single post" term is confusing.
Whether you need it for a single post or the single post template.
In either case you have to use your code with conditional and your code may look like this.
***If you want to remove from all posts(not pages but including custo... |
367,932 | <p>The documentation for InnerBlock has a prop <a href="https://github.com/WordPress/gutenberg/tree/master/packages/block-editor/src/components/inner-blocks#example-usage" rel="nofollow noreferrer">renderAppender</a> which can be used to add a custom button. In the example:</p>
<pre><code>// Fully custom
<InnerBloc... | [
{
"answer_id": 368098,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 2,
"selected": false,
"text": "<p>Custom <code>renderAppenders</code> require that you create all of the functionality of inserting blocks your... | 2020/05/30 | [
"https://wordpress.stackexchange.com/questions/367932",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67538/"
] | The documentation for InnerBlock has a prop [renderAppender](https://github.com/WordPress/gutenberg/tree/master/packages/block-editor/src/components/inner-blocks#example-usage) which can be used to add a custom button. In the example:
```
// Fully custom
<InnerBlocks
renderAppender={ () => (
<button classN... | So I'm answering the following: **How to open the *block picker menu* via a *custom button*.** I.e. Without using `InnerBlocks.ButtonBlockAppender`. :)
>
> How can I open the Block Picker Menu on click of the custom button?
>
>
>
There's no (as of writing) "standard" function (like `alert()`) that you can simply ... |
367,934 | <p>I have a list of emails I have fetched from the Wordpress database. </p>
<p>I would like to programmatically send emails to these emails using the contact form 7.</p>
<p>this is my code</p>
<pre><code>function benson_call_before_form_submit( $wpcf7 ){
$submission = WPCF7_Submission::get_instance();
if (... | [
{
"answer_id": 372158,
"author": "Aurovrata",
"author_id": 52120,
"author_profile": "https://wordpress.stackexchange.com/users/52120",
"pm_score": 1,
"selected": false,
"text": "<p>There is 2 way to achieve this, either</p>\n<p>1 use the 'wpcf7_mail_components' hook, to modify the email ... | 2020/05/30 | [
"https://wordpress.stackexchange.com/questions/367934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/153444/"
] | I have a list of emails I have fetched from the Wordpress database.
I would like to programmatically send emails to these emails using the contact form 7.
this is my code
```
function benson_call_before_form_submit( $wpcf7 ){
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$po... | You can manipulate recipients just before sending out the emails with the hook wpcf7\_before\_send\_mail.
Here is a simple script that adds an extra recipient:
```
add_action( 'wpcf7_before_send_mail', 'add_my_second_recipient', 10, 1 );
function add_my_second_recipient($instance) {
$properites = $instance->get_... |
368,016 | <p>I am conditionally showing menu items. All is fine but want to remove parent item if returning no child items. </p>
<p>For example if I have a parent menu (it will always be a custom link with #) called <strong>More</strong> and it has multiple child items (mostly one level). Now if I am hiding child items based on... | [
{
"answer_id": 368153,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": true,
"text": "<p>If you want to use the <code>wp_get_nav_menu_items</code> hook, then try the function below which should be... | 2020/06/01 | [
"https://wordpress.stackexchange.com/questions/368016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9821/"
] | I am conditionally showing menu items. All is fine but want to remove parent item if returning no child items.
For example if I have a parent menu (it will always be a custom link with #) called **More** and it has multiple child items (mostly one level). Now if I am hiding child items based on user roles and for som... | If you want to use the `wp_get_nav_menu_items` hook, then try the function below which should be hooked *after* the `exclude_menu_items` function:
```php
// Example when NOT using a class: (you already defined the exclude_menu_items function)
add_filter( 'wp_get_nav_menu_items', 'exclude_menu_items', 10, 3 );
add_filt... |
368,033 | <p>I am creating a plugin to redirect all sign in attempts to a dedicated page rather than using the builting wordpress page<br>
so i created this hook action for the admin_init with the highest priority over other callbacks </p>
<pre><code>add_action( 'admin_init', 'redirect_callback', 1)
</code></pre>
<p>the callb... | [
{
"answer_id": 368153,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": true,
"text": "<p>If you want to use the <code>wp_get_nav_menu_items</code> hook, then try the function below which should be... | 2020/06/01 | [
"https://wordpress.stackexchange.com/questions/368033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am creating a plugin to redirect all sign in attempts to a dedicated page rather than using the builting wordpress page
so i created this hook action for the admin\_init with the highest priority over other callbacks
```
add_action( 'admin_init', 'redirect_callback', 1)
```
the callback function will then make... | If you want to use the `wp_get_nav_menu_items` hook, then try the function below which should be hooked *after* the `exclude_menu_items` function:
```php
// Example when NOT using a class: (you already defined the exclude_menu_items function)
add_filter( 'wp_get_nav_menu_items', 'exclude_menu_items', 10, 3 );
add_filt... |
368,122 | <p>I'm tryng without success to create a custom backend based on user ID, if user id is different the 1 or different then 2 show custom backend.</p>
<p>This is my code but it doesn't work, any help would be very appreciate it.</p>
<pre><code>if ($current_user_id != 1 || $current_user_id != 2){ show custom backend
</c... | [
{
"answer_id": 368123,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<p>Use: <code>get_current_user_id()</code></p>\n\n<pre><code>$current_user_id = get_current_user_id();\nif ($cur... | 2020/06/02 | [
"https://wordpress.stackexchange.com/questions/368122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107630/"
] | I'm tryng without success to create a custom backend based on user ID, if user id is different the 1 or different then 2 show custom backend.
This is my code but it doesn't work, any help would be very appreciate it.
```
if ($current_user_id != 1 || $current_user_id != 2){ show custom backend
```
Thank you | You do not want an OR, you want an AND.
Follow it through and substitute the values. If we are user 1, then it's true because we are not user 2, and true OR false resolves to true. Only one of them needs to be true for an OR to be true. If we are user 2, then it's true because we are not user 1, and false OR true also... |
368,169 | <p>Please i need assistance in converting objects that is returned from $wpdb->get_results into arrays so that i can call them values like $query['username'] instead of using $Query->username <br><br> because my method of doing it is not flexible enough and it makes me write many codes by manually creating those colum... | [
{
"answer_id": 368170,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"https://developer.wordpress.org/reference/classes/wpdb/get_results/\" rel=\"nofollow noreferrer\"><code>$wpd... | 2020/06/03 | [
"https://wordpress.stackexchange.com/questions/368169",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152456/"
] | Please i need assistance in converting objects that is returned from $wpdb->get\_results into arrays so that i can call them values like $query['username'] instead of using $Query->username
because my method of doing it is not flexible enough and it makes me write many codes by manually creating those column as ar... | [`$wpdb->get_results`](https://developer.wordpress.org/reference/classes/wpdb/get_results/) has a second parameter that lets you specify what kind of return value you want:
For example:
```
$data = $wpdb->get_results( $query, ARRAY_A );
```
Here you get an associative array back. |
368,194 | <p>Having a perplexing issue... ...for a custom post-type called 'Resources' I used the 'Featured Image' or 'thumbnail' function within WordPress to allow users to attach documents to 'Resources'. The process itself works exactly as expected and anticipated.</p>
<p>However, setting the site up, someone made a mistake... | [
{
"answer_id": 368759,
"author": "Ahmad Wael",
"author_id": 115635,
"author_profile": "https://wordpress.stackexchange.com/users/115635",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried this plugin <a href=\"https://wordpress.org/plugins/pdf-thumbnails/\" rel=\"nofollow nore... | 2020/06/03 | [
"https://wordpress.stackexchange.com/questions/368194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60844/"
] | Having a perplexing issue... ...for a custom post-type called 'Resources' I used the 'Featured Image' or 'thumbnail' function within WordPress to allow users to attach documents to 'Resources'. The process itself works exactly as expected and anticipated.
However, setting the site up, someone made a mistake and upload... | So this may be hacky..
======================
I mean, compared to [overriding the default Featured Image panel/component in the Gutenberg block editor](https://github.com/WordPress/gutenberg/tree/master/packages/editor/src/components/post-featured-image), which is not exactly hard, but this one is much simpler and bas... |
368,247 | <p>I am using WooCommerce for the eCommerce part of my WordPress site. </p>
<p>When using the <code>add_to_cart</code> button I want it to say "read more" on a specific webpage only.</p>
<p>So far I have found the code to change the button text: </p>
<pre><code>add_filter('woocommerce_product_single_add_to_cart_text... | [
{
"answer_id": 368759,
"author": "Ahmad Wael",
"author_id": 115635,
"author_profile": "https://wordpress.stackexchange.com/users/115635",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried this plugin <a href=\"https://wordpress.org/plugins/pdf-thumbnails/\" rel=\"nofollow nore... | 2020/06/04 | [
"https://wordpress.stackexchange.com/questions/368247",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189372/"
] | I am using WooCommerce for the eCommerce part of my WordPress site.
When using the `add_to_cart` button I want it to say "read more" on a specific webpage only.
So far I have found the code to change the button text:
```
add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text');
fun... | So this may be hacky..
======================
I mean, compared to [overriding the default Featured Image panel/component in the Gutenberg block editor](https://github.com/WordPress/gutenberg/tree/master/packages/editor/src/components/post-featured-image), which is not exactly hard, but this one is much simpler and bas... |
368,291 | <p>In custom post type book I have several books published
I just want to show data obtained from metabox field but I have not been able to help me the code that I am showing does not work</p>
<pre><code> <?php $book=get_post_meta( get_the_ID(), 'name_ebook', true ); ?> return name ebook Paintree
... | [
{
"answer_id": 368759,
"author": "Ahmad Wael",
"author_id": 115635,
"author_profile": "https://wordpress.stackexchange.com/users/115635",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried this plugin <a href=\"https://wordpress.org/plugins/pdf-thumbnails/\" rel=\"nofollow nore... | 2020/06/04 | [
"https://wordpress.stackexchange.com/questions/368291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189413/"
] | In custom post type book I have several books published
I just want to show data obtained from metabox field but I have not been able to help me the code that I am showing does not work
```
<?php $book=get_post_meta( get_the_ID(), 'name_ebook', true ); ?> return name ebook Paintree
<?php
... | So this may be hacky..
======================
I mean, compared to [overriding the default Featured Image panel/component in the Gutenberg block editor](https://github.com/WordPress/gutenberg/tree/master/packages/editor/src/components/post-featured-image), which is not exactly hard, but this one is much simpler and bas... |
368,293 | <p>I want <code>testFunction()</code> to call <code>check()</code> that i created in my plugin php when i click <strong>My Button</strong>. How do i make it work ?</p>
<pre><code><?php
function createButton()
{
echo '<button onclick="testFunction()">My Button</button>';
}
function check()
{
ale... | [
{
"answer_id": 368759,
"author": "Ahmad Wael",
"author_id": 115635,
"author_profile": "https://wordpress.stackexchange.com/users/115635",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried this plugin <a href=\"https://wordpress.org/plugins/pdf-thumbnails/\" rel=\"nofollow nore... | 2020/06/05 | [
"https://wordpress.stackexchange.com/questions/368293",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189146/"
] | I want `testFunction()` to call `check()` that i created in my plugin php when i click **My Button**. How do i make it work ?
```
<?php
function createButton()
{
echo '<button onclick="testFunction()">My Button</button>';
}
function check()
{
alert("Works");
}
function my_php_function()
{
echo '<script>
... | So this may be hacky..
======================
I mean, compared to [overriding the default Featured Image panel/component in the Gutenberg block editor](https://github.com/WordPress/gutenberg/tree/master/packages/editor/src/components/post-featured-image), which is not exactly hard, but this one is much simpler and bas... |
368,299 | <p>I have two custom post types </p>
<ol>
<li>case</li>
<li>client </li>
</ol>
<p>In case post type I have a ACF custom field to choose a client, so each case have a single client.</p>
<p>Now what is working:
I am displaying all cases on a page and able to filter them using a client Id.</p>
<p>Whats I want:
I want ... | [
{
"answer_id": 368301,
"author": "Baikare Sandeep",
"author_id": 99404,
"author_profile": "https://wordpress.stackexchange.com/users/99404",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the <code>order</code> and <code>orderby</code> param in <code>WP_Query</code> argument ... | 2020/06/05 | [
"https://wordpress.stackexchange.com/questions/368299",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149954/"
] | I have two custom post types
1. case
2. client
In case post type I have a ACF custom field to choose a client, so each case have a single client.
Now what is working:
I am displaying all cases on a page and able to filter them using a client Id.
Whats I want:
I want to get a list of cases (of all clients) and the ... | You can use the `order` and `orderby` param in `WP_Query` argument like below:
```
$args = array(
'post_type' => 'case',
'post_status' => 'publish',
'meta_key' => 'client',
'posts_per_page' => 9,
'orderby' => 'title',
'order' => 'ASC',
);
$query = new WP_Query( $args ... |
368,327 | <p>I'm having a heck of a time with the ServerSideRender component for a Gutenberg block I'm developing. I'm seeing this error in the (non-)rendered block: <code>Error loading block: The response is not a valid JSON response.</code>
But where can I see the actual JSON response?</p>
<p>In the Chrome Inspector Tools I s... | [
{
"answer_id": 368418,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>The problem is that your block has a lot of attributes, and when they're turned into a <code>GET</code> url ... | 2020/06/05 | [
"https://wordpress.stackexchange.com/questions/368327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60906/"
] | I'm having a heck of a time with the ServerSideRender component for a Gutenberg block I'm developing. I'm seeing this error in the (non-)rendered block: `Error loading block: The response is not a valid JSON response.`
But where can I see the actual JSON response?
In the Chrome Inspector Tools I see:
>
> Failed to l... | After discovering the exact problem in this case, the request headers being too large because ServerSideRender sending too many attributes in a GET request, I [opened a ticket](https://github.com/WordPress/gutenberg/issues/23004) on the Gutenberg development repository proposing a few possible solutions for this issue.... |
368,332 | <p>when I try to upload a theme I have uploaded on a free host and it is the first time I upload a theme on a host, I got this error failed because
The style.css stylesheet doesn’t contain a valid theme header.</p>
<p>then I put this on my styles.css , but still getting this error , although the theme works very well... | [
{
"answer_id": 368348,
"author": "Sabbir Hasan",
"author_id": 76587,
"author_profile": "https://wordpress.stackexchange.com/users/76587",
"pm_score": 1,
"selected": false,
"text": "<p>Remove the extra space from the header. Try like below:</p>\n<pre><code>/*\nTheme Name: shah\nTheme URI:... | 2020/06/05 | [
"https://wordpress.stackexchange.com/questions/368332",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188733/"
] | when I try to upload a theme I have uploaded on a free host and it is the first time I upload a theme on a host, I got this error failed because
The style.css stylesheet doesn’t contain a valid theme header.
then I put this on my styles.css , but still getting this error , although the theme works very well on the lo... | Remove the extra space from the header. Try like below:
```
/*
Theme Name: shah
Theme URI:
Author: shah
Author URI: http://shah.gq
Description: Wordpress Theme
Version: 1.0
*/
``` |
368,342 | <h1>Context</h1>
<p>I'm developping a plugin showing geolocated posts on a leaflet map. <strong>I want to add a shortcode parameter to show a map with only the current loop posts' markers.</strong> That feature would be great on the search result page for exemple!</p>
<h1>Question</h1>
<p><strong>Is there a way to g... | [
{
"answer_id": 368346,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 1,
"selected": false,
"text": "<p>I believe you can use <code>rewind_posts()</code> to get the posts from the current query, then amend from there:<... | 2020/06/05 | [
"https://wordpress.stackexchange.com/questions/368342",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140435/"
] | Context
=======
I'm developping a plugin showing geolocated posts on a leaflet map. **I want to add a shortcode parameter to show a map with only the current loop posts' markers.** That feature would be great on the search result page for exemple!
Question
========
**Is there a way to get the current page WP\_Query ... | Have you tried using `$wp_query` ?
```
global $wp_query;
var_dump($wp_query->query_vars);
```
For a single variable, you can use [get\_query\_var](https://developer.wordpress.org/reference/functions/get_query_var/)
Or you could try just dumping the `$_POST` , `var_dump( $_POST );`
Or maybe `var_dump( $GLOBALS['pos... |
368,369 | <p>I am looking to use the rest API to use WordPress as a headless CMS, but I am curious as to how best to get a page using the path.</p>
<p>Example, if Wordpress is hosted at cms.example.com and my frontend is at example.com. If I create a page at cms.example.com/services/service-a I would want it accessible on the f... | [
{
"answer_id": 368346,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 1,
"selected": false,
"text": "<p>I believe you can use <code>rewind_posts()</code> to get the posts from the current query, then amend from there:<... | 2020/06/06 | [
"https://wordpress.stackexchange.com/questions/368369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189477/"
] | I am looking to use the rest API to use WordPress as a headless CMS, but I am curious as to how best to get a page using the path.
Example, if Wordpress is hosted at cms.example.com and my frontend is at example.com. If I create a page at cms.example.com/services/service-a I would want it accessible on the frontend at... | Have you tried using `$wp_query` ?
```
global $wp_query;
var_dump($wp_query->query_vars);
```
For a single variable, you can use [get\_query\_var](https://developer.wordpress.org/reference/functions/get_query_var/)
Or you could try just dumping the `$_POST` , `var_dump( $_POST );`
Or maybe `var_dump( $GLOBALS['pos... |
368,389 | <p>I've added the following code to
<strong>remove some checkout fields</strong> in case a <strong>particular shipping method</strong> is chosen and also make it work when you <strong>change the shipping method on the checkout page</strong>. </p>
<pre><code>add_filter( 'woocommerce_checkout_fields', 'xa_remove_billin... | [
{
"answer_id": 368392,
"author": "Falz",
"author_id": 188264,
"author_profile": "https://wordpress.stackexchange.com/users/188264",
"pm_score": 1,
"selected": false,
"text": "<p>Sorry Not really a great answer. However, I haven't got enough Reputation points to add a comment yet :(</p>\n... | 2020/06/06 | [
"https://wordpress.stackexchange.com/questions/368389",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129008/"
] | I've added the following code to
**remove some checkout fields** in case a **particular shipping method** is chosen and also make it work when you **change the shipping method on the checkout page**.
```
add_filter( 'woocommerce_checkout_fields', 'xa_remove_billing_checkout_fields' );
function xa_remove_billing_chec... | I came up with the following code for my problem:
```
/* HIDE "POSTKANTOOR" FIELD WHEN NON-POSTKANTOOR SHIPPING OPTION IS SELECTED */
/* --- */
add_filter( 'woocommerce_checkout_fields', 'remove_billing_checkout_fields' );
function remove_billing_checkout_fields( $fields ) {
// Postkantoor shipping methods
$sh... |
368,427 | <p>In the default wordpress rss feed the element <code><pubDate></code> is </p>
<p><code><pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate></code></p>
<p>and gives a result of <code><pubDate>Tue, 12 May 2020 12:39:03 +0000&... | [
{
"answer_id": 368392,
"author": "Falz",
"author_id": 188264,
"author_profile": "https://wordpress.stackexchange.com/users/188264",
"pm_score": 1,
"selected": false,
"text": "<p>Sorry Not really a great answer. However, I haven't got enough Reputation points to add a comment yet :(</p>\n... | 2020/06/07 | [
"https://wordpress.stackexchange.com/questions/368427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129972/"
] | In the default wordpress rss feed the element `<pubDate>` is
`<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>`
and gives a result of `<pubDate>Tue, 12 May 2020 12:39:03 +0000</pubDate>`
how can i change this line to give a result of `<pubDate>12/05... | I came up with the following code for my problem:
```
/* HIDE "POSTKANTOOR" FIELD WHEN NON-POSTKANTOOR SHIPPING OPTION IS SELECTED */
/* --- */
add_filter( 'woocommerce_checkout_fields', 'remove_billing_checkout_fields' );
function remove_billing_checkout_fields( $fields ) {
// Postkantoor shipping methods
$sh... |
368,489 | <p>I have a site developed by a third party using wordpress however we could not log in the Admin page currently due to change of IP address recently.</p>
<p>The login page <a href="https://domain/wp-admin" rel="nofollow noreferrer">https://domain/wp-admin</a> has directed me to "Forbidden" error page instead.</p>
<p... | [
{
"answer_id": 368491,
"author": "Botond Vajna",
"author_id": 163786,
"author_profile": "https://wordpress.stackexchange.com/users/163786",
"pm_score": 2,
"selected": false,
"text": "<p>You may try changing the site url in wp-config.php with:</p>\n\n<pre><code>define( 'WP_HOME', 'http://... | 2020/06/08 | [
"https://wordpress.stackexchange.com/questions/368489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189570/"
] | I have a site developed by a third party using wordpress however we could not log in the Admin page currently due to change of IP address recently.
The login page <https://domain/wp-admin> has directed me to "Forbidden" error page instead.
I also do not have the database file to do further amendments.
Can anyone hel... | You may try changing the site url in wp-config.php with:
```
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );
```
you may also check if you have http, or https. |
368,498 | <p>I use the Contact Form 7 plugin on my site, now I have a task to send a confirmation email after sending the data. But I can not find in the documentation how to do this without creating an extra field.</p>
<p><strong>My solution:</strong> </p>
<ol>
<li>I created an additional field "Confirm email"</li>
<li>In the... | [
{
"answer_id": 368499,
"author": "Juan Cullen",
"author_id": 189571,
"author_profile": "https://wordpress.stackexchange.com/users/189571",
"pm_score": 0,
"selected": false,
"text": "<p>You could redirect to another URL after the form is submitted. See: <a href=\"https://contactform7.com/... | 2020/06/08 | [
"https://wordpress.stackexchange.com/questions/368498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189574/"
] | I use the Contact Form 7 plugin on my site, now I have a task to send a confirmation email after sending the data. But I can not find in the documentation how to do this without creating an extra field.
**My solution:**
1. I created an additional field "Confirm email"
2. In the plugin settings, turned on Mail (2) an... | Hook into `wpcf7_mail_sent` action, it fires after the mail is successfully sent.
```
function wpse_368498_cf7_mail_sent( $contact_form ) {
//Your confirmation code here
}
add_action( 'wpcf7_mail_sent', 'wpse_368498_cf7_mail_sent' );
``` |
368,511 | <p>Gutenberg is still relative new concept, so I lack experiences (and the Internet lacks good tutorials). My goal it to wrap all heading titles generated by Gutenberg's "Heading" block with the <code><span></code> tag. So instead following code</p>
<pre><code><h2>Tips and trics</h2>
</code></pre>
<... | [
{
"answer_id": 368499,
"author": "Juan Cullen",
"author_id": 189571,
"author_profile": "https://wordpress.stackexchange.com/users/189571",
"pm_score": 0,
"selected": false,
"text": "<p>You could redirect to another URL after the form is submitted. See: <a href=\"https://contactform7.com/... | 2020/06/08 | [
"https://wordpress.stackexchange.com/questions/368511",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50021/"
] | Gutenberg is still relative new concept, so I lack experiences (and the Internet lacks good tutorials). My goal it to wrap all heading titles generated by Gutenberg's "Heading" block with the `<span>` tag. So instead following code
```
<h2>Tips and trics</h2>
```
it renders this way
```
<h2><span>Tips and trics</sp... | Hook into `wpcf7_mail_sent` action, it fires after the mail is successfully sent.
```
function wpse_368498_cf7_mail_sent( $contact_form ) {
//Your confirmation code here
}
add_action( 'wpcf7_mail_sent', 'wpse_368498_cf7_mail_sent' );
``` |
368,535 | <p>I have created two post types, events and registrations and would like to be able to loop through the events and then fetch the registrations for each event, but WP_Query seems not to be working.</p>
<p>The data is setup for 9 events and 3 registrations, two for one event and one for another</p>
<p>It seems to not... | [
{
"answer_id": 368499,
"author": "Juan Cullen",
"author_id": 189571,
"author_profile": "https://wordpress.stackexchange.com/users/189571",
"pm_score": 0,
"selected": false,
"text": "<p>You could redirect to another URL after the form is submitted. See: <a href=\"https://contactform7.com/... | 2020/06/08 | [
"https://wordpress.stackexchange.com/questions/368535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189611/"
] | I have created two post types, events and registrations and would like to be able to loop through the events and then fetch the registrations for each event, but WP\_Query seems not to be working.
The data is setup for 9 events and 3 registrations, two for one event and one for another
It seems to not fetch the regis... | Hook into `wpcf7_mail_sent` action, it fires after the mail is successfully sent.
```
function wpse_368498_cf7_mail_sent( $contact_form ) {
//Your confirmation code here
}
add_action( 'wpcf7_mail_sent', 'wpse_368498_cf7_mail_sent' );
``` |
368,587 | <p>I have a form where users will submit a timecard.<br /><br /><ul><li>All entries to this form will be from users who are logged in (this part I have figured out).</li><li>Users will enter their name, the amount of hours, and select the date for the timecard (week ending).</li><li><strong>The issue I'm encountering</... | [
{
"answer_id": 368499,
"author": "Juan Cullen",
"author_id": 189571,
"author_profile": "https://wordpress.stackexchange.com/users/189571",
"pm_score": 0,
"selected": false,
"text": "<p>You could redirect to another URL after the form is submitted. See: <a href=\"https://contactform7.com/... | 2020/06/09 | [
"https://wordpress.stackexchange.com/questions/368587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189655/"
] | I have a form where users will submit a timecard.
* All entries to this form will be from users who are logged in (this part I have figured out).
* Users will enter their name, the amount of hours, and select the date for the timecard (week ending).
* **The issue I'm encountering** is how to limit the form so that e... | Hook into `wpcf7_mail_sent` action, it fires after the mail is successfully sent.
```
function wpse_368498_cf7_mail_sent( $contact_form ) {
//Your confirmation code here
}
add_action( 'wpcf7_mail_sent', 'wpse_368498_cf7_mail_sent' );
``` |
368,627 | <p>I am having an issue:</p>
<ul>
<li><a href="https://developer.wordpress.org/reference/functions/get_the_author_meta/" rel="nofollow noreferrer">get_the_author_meta()</a> returns the meta</li>
<li><a href="https://developer.wordpress.org/reference/functions/get_user_meta/" rel="nofollow noreferrer">get_user_meta()</... | [
{
"answer_id": 368634,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 2,
"selected": false,
"text": "<p>Your parameter order is wrong for <a href=\"https://developer.wordpress.org/reference/functions/get_user_meta... | 2020/06/09 | [
"https://wordpress.stackexchange.com/questions/368627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/155394/"
] | I am having an issue:
* [get\_the\_author\_meta()](https://developer.wordpress.org/reference/functions/get_the_author_meta/) returns the meta
* [get\_user\_meta()](https://developer.wordpress.org/reference/functions/get_user_meta/) returns *false* for the same meta key
I don't know why this happens.
Regarding user m... | **[`get_the_author_meta`](https://developer.wordpress.org/reference/functions/get_the_author_meta/)**: retrieves the requested data of the author of the current post.
* Parameters: ( string **$field = ''**, int|false **$user\_id = false** )
**[`get_user_meta`](https://developer.wordpress.org/reference/functions/get_u... |
368,696 | <p>Im trying to set a custom post title with a custom field instead of typing the title im setting it with a custom field it works good if I use a type text custom field but once I use a relationship field Im getting nothing I guess because that field return a array, my relationship field is "route_affected_by_thi... | [
{
"answer_id": 368715,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": 1,
"selected": true,
"text": "<p>Updated version...</p>\n<pre><code><?php\n\n/**\n * @param $posts array\n * @return false|string\n */\nf... | 2020/06/10 | [
"https://wordpress.stackexchange.com/questions/368696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/181226/"
] | Im trying to set a custom post title with a custom field instead of typing the title im setting it with a custom field it works good if I use a type text custom field but once I use a relationship field Im getting nothing I guess because that field return a array, my relationship field is "route\_affected\_by\_this\_al... | Updated version...
```
<?php
/**
* @param $posts array
* @return false|string
*/
function create_relationship_title($posts)
{
// set empty net title array
$new_title = [];
// if posts is not an array then return false
if (!is_array($posts)) return false;
// loop through each post
foreach... |
368,805 | <p>I use the wordpress theme Sensible WP. When I do a search this is what appears as the URL:</p>
<p><a href="https://www.example.com/?s=my+search+text" rel="nofollow noreferrer">https://www.example.com/?s=my+search+text</a></p>
<p>I need to modify the CSS for this page only, not all pages, but I can't find how to do... | [
{
"answer_id": 368806,
"author": "Jarod Thornton",
"author_id": 44017,
"author_profile": "https://wordpress.stackexchange.com/users/44017",
"pm_score": -1,
"selected": false,
"text": "<pre><code>if ( is_search() ) {\n echo ‘<style>.class{color:red;}</style>’;\n}\n</code></... | 2020/06/12 | [
"https://wordpress.stackexchange.com/questions/368805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189834/"
] | I use the wordpress theme Sensible WP. When I do a search this is what appears as the URL:
<https://www.example.com/?s=my+search+text>
I need to modify the CSS for this page only, not all pages, but I can't find how to do it. | I was looking for this and found the solution:
Just add
>
> .search-results
>
>
>
to your class. ie:
```
.search-results .title {
color: red;
}
```
Hope this is useful. |
368,872 | <p>I want to display the "ratingValue" and "ratingCount" values generated by the <a href="https://id.wordpress.org/plugins/kk-star-ratings/" rel="nofollow noreferrer">KK Star Ratings plugin</a> (<a href="https://github.com/kamalkhan/kk-star-ratings" rel="nofollow noreferrer">Github</a>).</p>
<p>I made a JSON-LD Soft... | [
{
"answer_id": 368952,
"author": "Sabbir Hasan",
"author_id": 76587,
"author_profile": "https://wordpress.stackexchange.com/users/76587",
"pm_score": 2,
"selected": true,
"text": "<p>Here is what I found that might help you. I did some test by myself and here is snippets for you to use. ... | 2020/06/13 | [
"https://wordpress.stackexchange.com/questions/368872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/159482/"
] | I want to display the "ratingValue" and "ratingCount" values generated by the [KK Star Ratings plugin](https://id.wordpress.org/plugins/kk-star-ratings/) ([Github](https://github.com/kamalkhan/kk-star-ratings)).
I made a JSON-LD SoftwareAplication and here is the code I use in function.php:
```
add_action('wp_head'... | Here is what I found that might help you. I did some test by myself and here is snippets for you to use. Add the following code to functions.php file:
```
//Getter methods
//this will return the base best score like 5 or 10.
function get_best_rating(){
return max((int) get_option('kksr_stars'), 1);
}
//This will... |
368,875 | <p>I've pulling pulling my hair for the last 2 days with this and searching did not result in any solution to the issue I am having. </p>
<p>I wanted to use <strong><serverSideRender /></strong> to load dynamic content in the front-end as well as see the generated content in the Gutenberg editor. I tested it wit... | [
{
"answer_id": 368892,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 0,
"selected": false,
"text": "<p>You’ll have to alias serverSideRender to use it in JSX.</p>\n\n<pre><code>const { serverSiderRender: ServerSi... | 2020/06/13 | [
"https://wordpress.stackexchange.com/questions/368875",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189887/"
] | I've pulling pulling my hair for the last 2 days with this and searching did not result in any solution to the issue I am having.
I wanted to use **<serverSideRender />** to load dynamic content in the front-end as well as see the generated content in the Gutenberg editor. I tested it with the simple example given on... | Ok, after spending the whole day searching and reading I found the solution. It seems that `ServerSideRender` should be de-structured from `wp.components` and **NOT** from `wp.serverSideRender`
After replacing
```
const { serverSiderRender: ServerSideRender } = wp.serverSideRender;
```
with
```
const { ServerSid... |
368,890 | <p>Hi I'm building up a WordPress rest API's custom endpoint on my project. I'm using the following code to get the single response from the website.</p>
<pre><code>function get_single_post( $request ) {
$response = array();
$args = [
'id' => $request['id'],
'post_type' => 'payment',
... | [
{
"answer_id": 368893,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": true,
"text": "<p>You're getting that mismatched values because you're using the wrong argument for the post ID in your <code... | 2020/06/13 | [
"https://wordpress.stackexchange.com/questions/368890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189621/"
] | Hi I'm building up a WordPress rest API's custom endpoint on my project. I'm using the following code to get the single response from the website.
```
function get_single_post( $request ) {
$response = array();
$args = [
'id' => $request['id'],
'post_type' => 'payment',
];
$post = get_... | You're getting that mismatched values because you're using the wrong argument for the post ID in your `$args` array (i.e. the query args for `WP_Query`). And the correct argument is `p` (lowercase `P`) and not `id`:
```php
$args = [
// 'id' => $request['id'], // wrong argument name - 'id'
'p' => $request['id'], ... |
368,897 | <p>I've just started making my own WordPress widgets and don't have a very good understanding of good practices with PHP or HTML. To add html to a widget I have seen two different methods, the first being inside the PHP using <code>echo</code> and the second being closing off the PHP with <code>?></code> , writing s... | [
{
"answer_id": 368910,
"author": "Mort 1305",
"author_id": 188811,
"author_profile": "https://wordpress.stackexchange.com/users/188811",
"pm_score": 2,
"selected": false,
"text": "<p>\"Practice\" is a matter of personal preference. The opening and closing PHP tags (<code><?php</code>... | 2020/06/13 | [
"https://wordpress.stackexchange.com/questions/368897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189907/"
] | I've just started making my own WordPress widgets and don't have a very good understanding of good practices with PHP or HTML. To add html to a widget I have seen two different methods, the first being inside the PHP using `echo` and the second being closing off the PHP with `?>` , writing some HTML then reopening the ... | "Practice" is a matter of personal preference. The opening and closing PHP tags (`<?php` and `?>`) are there as a matter of convenience. Basically, try to write your code in context. In example,
```
// PHP code here
?><a href="<?php the_permalink() ?>"><?php the_title() ?></a><?php
// PHP code here
```
looks (to me... |
368,903 | <p>I have an external api which takes json body as payload. I am trying to send multiple parallel requests. So I am not using <code>wp_remote_post()</code></p>
<p>The wp_remote_post() version of my code works perfectly.</p>
<h1>Sending JSON payload using <code>wp_remote_post()</code></h1>
<p>This works!</p>
<pre><c... | [
{
"answer_id": 368914,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 0,
"selected": false,
"text": "<p>Did you notice that the $registrant variable is spelled differently in the two cases?</p>\n\n<p>If this is n... | 2020/06/13 | [
"https://wordpress.stackexchange.com/questions/368903",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | I have an external api which takes json body as payload. I am trying to send multiple parallel requests. So I am not using `wp_remote_post()`
The wp\_remote\_post() version of my code works perfectly.
Sending JSON payload using `wp_remote_post()`
=============================================
This works!
```
... | **You can't.**
The requests library that comes bundled in WordPress doesn't support this. The reason for this is that the `request_multiple` function only accepts these parameters:
```
* @param array $requests Request data (array of 'url', 'headers', 'data', 'options') as per {@see Requests_Transport::request}
```
... |
368,948 | <p>I want to make the page classes changed dynamic depend on time or anything else to force the type of scraper that depend on my site classes</p>
<p>or the classes like content, entry-content .. etc.</p>
<p>How can I do that? and how I control with the new classes name to get the style from old classes?!</p>
<p><st... | [
{
"answer_id": 368982,
"author": "Tony Djukic",
"author_id": 60844,
"author_profile": "https://wordpress.stackexchange.com/users/60844",
"pm_score": 1,
"selected": false,
"text": "<p>As per my comment, I'm not sure why you'd want to do this, but it is possible.</p>\n\n<p>You would use so... | 2020/06/14 | [
"https://wordpress.stackexchange.com/questions/368948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82877/"
] | I want to make the page classes changed dynamic depend on time or anything else to force the type of scraper that depend on my site classes
or the classes like content, entry-content .. etc.
How can I do that? and how I control with the new classes name to get the style from old classes?!
**Old class**
```
.entry-c... | As per my comment, I'm not sure why you'd want to do this, but it is possible.
You would use something like this for your CSS:
```
[class*='random-']{
color:red;
font-size:12pt;
}
```
That's just your stylesheet targeting any class that starts with `random-`. You could change that to be whatever you want it... |
369,026 | <p>I have a small problem when attempting to query some posts by author.
I have events and registrations. Currently I have 4 registrations, all created by User2 with the wp-admin showing that correctly. If I run the following code with a user logged on it works. User2 shows all and User1 shows none.
However, if no-one ... | [
{
"answer_id": 369028,
"author": "dnwjn",
"author_id": 182963,
"author_profile": "https://wordpress.stackexchange.com/users/182963",
"pm_score": 2,
"selected": false,
"text": "<p>An <code>author</code> value of <code>0</code> results in the query skipping that parameter. See <a href=\"ht... | 2020/06/15 | [
"https://wordpress.stackexchange.com/questions/369026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189611/"
] | I have a small problem when attempting to query some posts by author.
I have events and registrations. Currently I have 4 registrations, all created by User2 with the wp-admin showing that correctly. If I run the following code with a user logged on it works. User2 shows all and User1 shows none.
However, if no-one is ... | Welcome to WPSE. The condition you want to prevent is a ID of 0 so only run the query if it does not.
Also, DRY - don't repeat yourself. Rather than call `get_current_user_id()` multiple times, call it once and store it.
```
$reg_count= 0;
$user_id = get_current_user_id();
if ( 0 !== $user_id ) {
echo "looking ... |
369,094 | <p>I want to show page items in my wordpress theme and this is the code:</p>
<pre><code><section id="two">
<div class="inner">
<?php
$pagesargs = array(
'posts_per_page'=> 2,
'offset'=> 0,
'category' => '',
'... | [
{
"answer_id": 369099,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": -1,
"selected": false,
"text": "<p>Yes, those custom folders and files go inside the theme you're using. Wordpress groups files like HTML and ... | 2020/06/16 | [
"https://wordpress.stackexchange.com/questions/369094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188679/"
] | I want to show page items in my wordpress theme and this is the code:
```
<section id="two">
<div class="inner">
<?php
$pagesargs = array(
'posts_per_page'=> 2,
'offset'=> 0,
'category' => '',
'category_name' => '',
'orderby' => 'post_date... | Taken from [this link](https://themes.artbees.net/blog/add-external-css-or-javascript-to-wordpress/) there are several other options for adding your own CSS, if you don't want to put it in the theme:
1. Use Theme Options and paste in CSS
2. Use a plugin to insert CSS/JS. You could also write your own plugin to 'host' ... |
369,143 | <p>I've looked at the Settings API codex page, <a href="https://codex.wordpress.org/Settings_API" rel="nofollow noreferrer">https://codex.wordpress.org/Settings_API</a>, and I can't find anything related to setting <code>autoload</code> to <code>no</code> for any options using the Settings API.</p>
<p>Is there any way ... | [
{
"answer_id": 369392,
"author": "Mark Barnes",
"author_id": 19528,
"author_profile": "https://wordpress.stackexchange.com/users/19528",
"pm_score": 3,
"selected": true,
"text": "<p>The only way to accomplish this is to add the option to the database yourself before the Settings API does... | 2020/06/16 | [
"https://wordpress.stackexchange.com/questions/369143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190079/"
] | I've looked at the Settings API codex page, <https://codex.wordpress.org/Settings_API>, and I can't find anything related to setting `autoload` to `no` for any options using the Settings API.
Is there any way to achieve this using the Setttings API? Asking because I have many DB table `options` entries that were creat... | The only way to accomplish this is to add the option to the database yourself before the Settings API does so. To do this, add a 'sanitize\_callback' to the register\_settings function:
`register_setting ('my_options', 'my_option_name', array ('type' => 'string', 'sanitize_callback' => 'my_function_name'));`
Then, in... |
369,151 | <p>I have a weird problem with a wordpress site I'm working on, when we share links for it on discord shared link contains my login name and a link to author posts page (index is a page not a blog page) but when I look at the source there is not a single reference to my login name on the page, also facebook and other s... | [
{
"answer_id": 369619,
"author": "John A.",
"author_id": 190483,
"author_profile": "https://wordpress.stackexchange.com/users/190483",
"pm_score": 0,
"selected": false,
"text": "<p>Just ran into this issue myself, you are the author of that page so it shows on a Discord link. The best wo... | 2020/06/16 | [
"https://wordpress.stackexchange.com/questions/369151",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190091/"
] | I have a weird problem with a wordpress site I'm working on, when we share links for it on discord shared link contains my login name and a link to author posts page (index is a page not a blog page) but when I look at the source there is not a single reference to my login name on the page, also facebook and other soci... | This might help you. Add this script to functions.php. It will unset author from oembed preview. Remember Discord might already cached your URL. You may not get immediate result.
```
add_filter( 'oembed_response_data', 'disable_embeds_filter_oembed_response_data_' );
function disable_embeds_filter_oembed_response_data... |
369,187 | <p>I've already saw the question some times here, but sadly nothing helped me out yet.</p>
<p>Right now I've got following code:</p>
<pre><code><h2 class="title_bar">Videos</h2>
<ul class="vlist">
<?php $args = array( 'numberposts' => 60, 'orderby' => 'rand' );
... | [
{
"answer_id": 369184,
"author": "Zayd Bhyat",
"author_id": 93537,
"author_profile": "https://wordpress.stackexchange.com/users/93537",
"pm_score": 2,
"selected": false,
"text": "<p>It seems as though you dont have the required permissions to install this PHP extension. This is often the... | 2020/06/17 | [
"https://wordpress.stackexchange.com/questions/369187",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190116/"
] | I've already saw the question some times here, but sadly nothing helped me out yet.
Right now I've got following code:
```
<h2 class="title_bar">Videos</h2>
<ul class="vlist">
<?php $args = array( 'numberposts' => 60, 'orderby' => 'rand' );
$rand_posts = get_posts( $args );
foreach( $rand_post... | It seems as though you dont have the required permissions to install this PHP extension. This is often the case when youre using shared hosting. The best option is to contact your hosting provider and ask them to install this php extension. However if they provide you with a cpanel dashboard you may be able to do it yo... |
369,211 | <p>I developed a custom plugin with the following structure in my folders:</p>
<pre><code>wp-content
--- plugins
------ my-plugin
--------- languages
------------ po and mo files
--------- my-plugin.php
</code></pre>
<p>I internationalized it, and the translations all worked successfully. Now, I need that plugin to be ... | [
{
"answer_id": 369184,
"author": "Zayd Bhyat",
"author_id": 93537,
"author_profile": "https://wordpress.stackexchange.com/users/93537",
"pm_score": 2,
"selected": false,
"text": "<p>It seems as though you dont have the required permissions to install this PHP extension. This is often the... | 2020/06/17 | [
"https://wordpress.stackexchange.com/questions/369211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188571/"
] | I developed a custom plugin with the following structure in my folders:
```
wp-content
--- plugins
------ my-plugin
--------- languages
------------ po and mo files
--------- my-plugin.php
```
I internationalized it, and the translations all worked successfully. Now, I need that plugin to be a must-use plugin, by us... | It seems as though you dont have the required permissions to install this PHP extension. This is often the case when youre using shared hosting. The best option is to contact your hosting provider and ask them to install this php extension. However if they provide you with a cpanel dashboard you may be able to do it yo... |
369,289 | <p><strong>What I'm NOT trying to do:</strong></p>
<ul>
<li>Remove or hide checkout (billing/shipping) country fields</li>
</ul>
<p><strong>What I'm trying do to:</strong></p>
<ul>
<li>Show only ONE country in checkout (billing/shipping) country fields, depending on geolocation (geolocation is already done)</li>
<li>OR... | [
{
"answer_id": 369437,
"author": "ViralP",
"author_id": 163113,
"author_profile": "https://wordpress.stackexchange.com/users/163113",
"pm_score": 1,
"selected": false,
"text": "<p>If <code>'type' => 'select'</code> works for you then to solve state selection, you can try <code>woocomm... | 2020/06/18 | [
"https://wordpress.stackexchange.com/questions/369289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/180696/"
] | **What I'm NOT trying to do:**
* Remove or hide checkout (billing/shipping) country fields
**What I'm trying do to:**
* Show only ONE country in checkout (billing/shipping) country fields, depending on geolocation (geolocation is already done)
* OR, Remove countries I don't want to show to user from checkout (billin... | If `'type' => 'select'` works for you then to solve state selection, you can try `woocommerce_states` and `woocommerce_countries_allowed_country_states` filter to list states only for the user's country.
Reference : <https://wordpress.stackexchange.com/a/320548/163113> |
369,307 | <p>I have a Wordpress based website that uses gravity forms. I have the gravity form loading in a jquery model window. My issue is the form seems to work except for after submission the form just stays on the screen and I see the below error in the console.</p>
<pre><code>Uncaught DOMException: Failed to set the 'href'... | [
{
"answer_id": 369437,
"author": "ViralP",
"author_id": 163113,
"author_profile": "https://wordpress.stackexchange.com/users/163113",
"pm_score": 1,
"selected": false,
"text": "<p>If <code>'type' => 'select'</code> works for you then to solve state selection, you can try <code>woocomm... | 2020/06/18 | [
"https://wordpress.stackexchange.com/questions/369307",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115581/"
] | I have a Wordpress based website that uses gravity forms. I have the gravity form loading in a jquery model window. My issue is the form seems to work except for after submission the form just stays on the screen and I see the below error in the console.
```
Uncaught DOMException: Failed to set the 'href' property on ... | If `'type' => 'select'` works for you then to solve state selection, you can try `woocommerce_states` and `woocommerce_countries_allowed_country_states` filter to list states only for the user's country.
Reference : <https://wordpress.stackexchange.com/a/320548/163113> |
369,370 | <p>I am trying to find out what impact setting a custom stucture prefix in permalinks has on 404's</p>
<p>I have a custom structure of:</p>
<p><code>/news-opinion/%postname%/</code></p>
<p>This is working as expected if you tried to go to a page: <code>domain.com/news-opinion/non-existing-url</code> I will get a 404 as... | [
{
"answer_id": 383759,
"author": "korkut ozkan",
"author_id": 202249,
"author_profile": "https://wordpress.stackexchange.com/users/202249",
"pm_score": 0,
"selected": false,
"text": "<p>you should install "URL Rewrite" module and restart the server not only iis service. then re... | 2020/06/19 | [
"https://wordpress.stackexchange.com/questions/369370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33236/"
] | I am trying to find out what impact setting a custom stucture prefix in permalinks has on 404's
I have a custom structure of:
`/news-opinion/%postname%/`
This is working as expected if you tried to go to a page: `domain.com/news-opinion/non-existing-url` I will get a 404 as expected.
However if I use: `domain.com/n... | I believe this issue is fixed in more recent WP versions and not sure which it was fixed in. But in older versions of WP the rule name="RULENAME" was always the same. The name must be unique or the IIS mod goes nuts.
You would also run into this if you are copying a complete site for backup or dev. |
369,501 | <p>I have a question.</p>
<p>I use the following code to output the image URLs of a wordpress post. The image URLs are related to the "attached images" of a wordpress post and not the ones that are actually used in the post.</p>
<p>If you added an image to a post 2 years ago, but currently don't use the image... | [
{
"answer_id": 383759,
"author": "korkut ozkan",
"author_id": 202249,
"author_profile": "https://wordpress.stackexchange.com/users/202249",
"pm_score": 0,
"selected": false,
"text": "<p>you should install "URL Rewrite" module and restart the server not only iis service. then re... | 2020/06/22 | [
"https://wordpress.stackexchange.com/questions/369501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190385/"
] | I have a question.
I use the following code to output the image URLs of a wordpress post. The image URLs are related to the "attached images" of a wordpress post and not the ones that are actually used in the post.
If you added an image to a post 2 years ago, but currently don't use the image anymore, the old unused ... | I believe this issue is fixed in more recent WP versions and not sure which it was fixed in. But in older versions of WP the rule name="RULENAME" was always the same. The name must be unique or the IIS mod goes nuts.
You would also run into this if you are copying a complete site for backup or dev. |
369,537 | <p>I can't seem to find an answer/solution to this. If there is one out there, please post a link.</p>
<p>My understanding is that in a <code>wp_query</code>, <code>offset</code> refers to the results of the query. So if I set <code>'offset' => 4</code>, it will ignore the first 4 posts that match the arguments.</p>... | [
{
"answer_id": 369544,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 1,
"selected": false,
"text": "<p>Sure! There are tons of parameters for WP-Query that can probably do what you want.</p>\n<p>Offset is usuall... | 2020/06/22 | [
"https://wordpress.stackexchange.com/questions/369537",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190420/"
] | I can't seem to find an answer/solution to this. If there is one out there, please post a link.
My understanding is that in a `wp_query`, `offset` refers to the results of the query. So if I set `'offset' => 4`, it will ignore the first 4 posts that match the arguments.
What I'm interested in is ignoring the most rec... | Sure! There are tons of parameters for WP-Query that can probably do what you want.
Offset is usually used when your data is ordered. So if you want to ignore the two most recent ones you need to order it by date descending first, then set offset = 2. It doesn't matter if you apply any other query parameters you have ... |
369,547 | <p>I have a shortcode that works to display posts from specific categories, or a single post based on the post slug. I'm having trouble figuring out how to get it to display multiple posts based on their slugs though. I know I need to use explode, but I can't seem to get it right.</p>
<p>Here's the current working code... | [
{
"answer_id": 369551,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 0,
"selected": false,
"text": "<p>This works for me:</p>\n<pre><code>add_shortcode( 'latest_post', 'latest_post_query_shortcode' );\nfunction latest... | 2020/06/22 | [
"https://wordpress.stackexchange.com/questions/369547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186347/"
] | I have a shortcode that works to display posts from specific categories, or a single post based on the post slug. I'm having trouble figuring out how to get it to display multiple posts based on their slugs though. I know I need to use explode, but I can't seem to get it right.
Here's the current working code:
```
ad... | So from the [WP\_Query page](https://developer.wordpress.org/reference/classes/wp_query/), I found this, which is like $args['name'] but for when you want to search for many slugs:
>
> post\_name\_\_in (array) – use post slugs. Specify posts to retrieve. (Will be available in version 4.4)
>
>
>
I think this is ma... |
369,571 | <p>I don't know what's what wrong with my parent menu items. I have two that aren't working on the first click on mobile devices (I've been testing this on my android phone).</p>
<p>To make it look mobile responsive, I added some css:</p>
<pre><code>@media (max-width: 500px) {
&.main-navigation {
.menu-main-m... | [
{
"answer_id": 369551,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 0,
"selected": false,
"text": "<p>This works for me:</p>\n<pre><code>add_shortcode( 'latest_post', 'latest_post_query_shortcode' );\nfunction latest... | 2020/06/23 | [
"https://wordpress.stackexchange.com/questions/369571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/168581/"
] | I don't know what's what wrong with my parent menu items. I have two that aren't working on the first click on mobile devices (I've been testing this on my android phone).
To make it look mobile responsive, I added some css:
```
@media (max-width: 500px) {
&.main-navigation {
.menu-main-menu-container {
d... | So from the [WP\_Query page](https://developer.wordpress.org/reference/classes/wp_query/), I found this, which is like $args['name'] but for when you want to search for many slugs:
>
> post\_name\_\_in (array) – use post slugs. Specify posts to retrieve. (Will be available in version 4.4)
>
>
>
I think this is ma... |
369,771 | <p>I will try to summarize as simply as possible my request.</p>
<p>I have a custom post type (CPT) called “job”.
This custom post type includes 3 fields :</p>
<ul>
<li>The title (the native wordpress title field) / <em>example : Webmaster</em></li>
<li>Secondary title (ACF custom field (type = textfield) called “secon... | [
{
"answer_id": 370380,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": 1,
"selected": false,
"text": "<p>OK so I have had this problem with searching custom fields data.</p>\n<p>The thing is with the native Word... | 2020/06/25 | [
"https://wordpress.stackexchange.com/questions/369771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190605/"
] | I will try to summarize as simply as possible my request.
I have a custom post type (CPT) called “job”.
This custom post type includes 3 fields :
* The title (the native wordpress title field) / *example : Webmaster*
* Secondary title (ACF custom field (type = textfield) called “secondary\_title”.) / *example : Front... | OK so I have had this problem with searching custom fields data.
The thing is with the native Wordpress search, is that is really good, fast and powerful, but it's limitations is that it only searches the `wp_posts` table. It does **not** frickin' query the `wp_postmeta` table!
So to make the most of the native Wordp... |
369,803 | <p>How can I display only the specific category when accessing the posts related to that category? For example, I want to show only CSR Events under Categories When accessing posts related to CSR events. Here's the link to CSR post <a href="https://www.mi-eq.com/blood-donation-compaign/" rel="nofollow noreferrer">https... | [
{
"answer_id": 370380,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": 1,
"selected": false,
"text": "<p>OK so I have had this problem with searching custom fields data.</p>\n<p>The thing is with the native Word... | 2020/06/26 | [
"https://wordpress.stackexchange.com/questions/369803",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190627/"
] | How can I display only the specific category when accessing the posts related to that category? For example, I want to show only CSR Events under Categories When accessing posts related to CSR events. Here's the link to CSR post <https://www.mi-eq.com/blood-donation-compaign/>
Screenshot: <https://i.stack.imgur.com/Yo... | OK so I have had this problem with searching custom fields data.
The thing is with the native Wordpress search, is that is really good, fast and powerful, but it's limitations is that it only searches the `wp_posts` table. It does **not** frickin' query the `wp_postmeta` table!
So to make the most of the native Wordp... |
369,852 | <p>I am using Wordpress for my clients to log into the site, put data in a customized table and save it in a database table.
Through the code “example” that I put in funtions.php theme I can return my email at the top of the screen. Code below.</p>
<pre><code>$ current_user = wp_get_current_user ();
$ logado1 = $ curre... | [
{
"answer_id": 370380,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": 1,
"selected": false,
"text": "<p>OK so I have had this problem with searching custom fields data.</p>\n<p>The thing is with the native Word... | 2020/06/26 | [
"https://wordpress.stackexchange.com/questions/369852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190674/"
] | I am using Wordpress for my clients to log into the site, put data in a customized table and save it in a database table.
Through the code “example” that I put in funtions.php theme I can return my email at the top of the screen. Code below.
```
$ current_user = wp_get_current_user ();
$ logado1 = $ current_user-> use... | OK so I have had this problem with searching custom fields data.
The thing is with the native Wordpress search, is that is really good, fast and powerful, but it's limitations is that it only searches the `wp_posts` table. It does **not** frickin' query the `wp_postmeta` table!
So to make the most of the native Wordp... |
369,860 | <p>I am guessing this is being caused by my nginx configuration, however I can not quite figure out how to troubleshoot in order to resolve.</p>
<p>I am using Ubuntu 20.04 with a LEMP stack to host a wordpress installation. Everything works fine except this quirk, which is that if I type in the site's URL into Chrome, ... | [
{
"answer_id": 370380,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": 1,
"selected": false,
"text": "<p>OK so I have had this problem with searching custom fields data.</p>\n<p>The thing is with the native Word... | 2020/06/26 | [
"https://wordpress.stackexchange.com/questions/369860",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190618/"
] | I am guessing this is being caused by my nginx configuration, however I can not quite figure out how to troubleshoot in order to resolve.
I am using Ubuntu 20.04 with a LEMP stack to host a wordpress installation. Everything works fine except this quirk, which is that if I type in the site's URL into Chrome, the site ... | OK so I have had this problem with searching custom fields data.
The thing is with the native Wordpress search, is that is really good, fast and powerful, but it's limitations is that it only searches the `wp_posts` table. It does **not** frickin' query the `wp_postmeta` table!
So to make the most of the native Wordp... |
369,887 | <p>I'm new to wordpress development.</p>
<p>I'm trying to develop a simple plugin for practice. It involves a form submission from the frontend. The form has an input with the following code.</p>
<pre><code><input type='hidden' name='test' value='{"id": 1}'/>
</code></pre>
<p>When I submit the form, the... | [
{
"answer_id": 370380,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": 1,
"selected": false,
"text": "<p>OK so I have had this problem with searching custom fields data.</p>\n<p>The thing is with the native Word... | 2020/06/27 | [
"https://wordpress.stackexchange.com/questions/369887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190692/"
] | I'm new to wordpress development.
I'm trying to develop a simple plugin for practice. It involves a form submission from the frontend. The form has an input with the following code.
```
<input type='hidden' name='test' value='{"id": 1}'/>
```
When I submit the form, the value of 'test' field gets altered after the ... | OK so I have had this problem with searching custom fields data.
The thing is with the native Wordpress search, is that is really good, fast and powerful, but it's limitations is that it only searches the `wp_posts` table. It does **not** frickin' query the `wp_postmeta` table!
So to make the most of the native Wordp... |
369,902 | <p>I am creating wordpress theme on a single options page. I have customized the default do_settings_fields and do_settings_sections functions. my fields are displaying fine but when i am trying to save it, It won't save.</p>
<pre><code>function amna_theme_options_page () {
wp_enqueue_style( 'theme-options-css', get_te... | [
{
"answer_id": 370011,
"author": "Atif Aqeel",
"author_id": 136891,
"author_profile": "https://wordpress.stackexchange.com/users/136891",
"pm_score": 0,
"selected": false,
"text": "<p>I am posting answer of my own question because of people reference and did not find solution anywhere.</... | 2020/06/27 | [
"https://wordpress.stackexchange.com/questions/369902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136891/"
] | I am creating wordpress theme on a single options page. I have customized the default do\_settings\_fields and do\_settings\_sections functions. my fields are displaying fine but when i am trying to save it, It won't save.
```
function amna_theme_options_page () {
wp_enqueue_style( 'theme-options-css', get_template_di... | So I could understand why you "customized" (i.e. use your own version of) the [`do_settings_sections()`](https://developer.wordpress.org/reference/functions/do_settings_sections/) and [`do_settings_fields()`](https://developer.wordpress.org/reference/functions/do_settings_fields/) functions — because you want to use `d... |
369,941 | <p>How can I add a Notification bubble for <strong>Pending/On Hold/Processing order</strong> on Admin Top Bar?</p>
<p><a href="https://i.stack.imgur.com/oYtZC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oYtZC.png" alt="Like This" /></a></p>
| [
{
"answer_id": 369945,
"author": "Sabbir Hasan",
"author_id": 76587,
"author_profile": "https://wordpress.stackexchange.com/users/76587",
"pm_score": 2,
"selected": true,
"text": "<p>I will get you some idea on how to do this as you didn't mention from where count data will come. Add fol... | 2020/06/28 | [
"https://wordpress.stackexchange.com/questions/369941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189220/"
] | How can I add a Notification bubble for **Pending/On Hold/Processing order** on Admin Top Bar?
[](https://i.stack.imgur.com/oYtZC.png) | I will get you some idea on how to do this as you didn't mention from where count data will come. Add following code to your theme/child-theme `functions.php` file
```
function custom_admin_bar_menu() {
$pending_count = wc_orders_count('pending');
$on_hold_count = wc_orders_count('on-hold');
$processing_co... |
370,057 | <p>Currently I'm writing a WordPress plugin. I would try to re-use variables from a function on different pages. Let's say I would create a function like this:</p>
<pre><code>function test() {
global $hello;
$hello = 'hello world';
}
add_action( 'wp_head', 'test' );
</code></pre>
<p>I can do now on other pages: ... | [
{
"answer_id": 370059,
"author": "DevelJoe",
"author_id": 188571,
"author_profile": "https://wordpress.stackexchange.com/users/188571",
"pm_score": -1,
"selected": false,
"text": "<p>Well if u already use your variable in the global scope, you should also define it in the global scope, n... | 2020/06/30 | [
"https://wordpress.stackexchange.com/questions/370057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/184192/"
] | Currently I'm writing a WordPress plugin. I would try to re-use variables from a function on different pages. Let's say I would create a function like this:
```
function test() {
global $hello;
$hello = 'hello world';
}
add_action( 'wp_head', 'test' );
```
I can do now on other pages: `echo $hello;` This is u... | In general programming, globals are bad practice:
* You can't easily look at the use of a global in one place and see all the other uses, e.g. where it was set or will be read later.
* You have many places to change the use of that variable if e.g. the use or format of it changes.
* This makes it hard to make reliable... |
370,135 | <p>Following is my code which I am using to display comments of posts in a loop (Custom Post Types). I would like to display only latest 3 comments. Kindly help me to limit comments.</p>
<pre><code><?php foreach (get_comments() as $comment): ?>
<div><span class="author-name"><?php ec... | [
{
"answer_id": 370142,
"author": "romand",
"author_id": 190900,
"author_profile": "https://wordpress.stackexchange.com/users/190900",
"pm_score": 1,
"selected": false,
"text": "<p>I don't usually work with comment so my suggestion is untested, but I see that get_comments() receives an ar... | 2020/07/01 | [
"https://wordpress.stackexchange.com/questions/370135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190895/"
] | Following is my code which I am using to display comments of posts in a loop (Custom Post Types). I would like to display only latest 3 comments. Kindly help me to limit comments.
```
<?php foreach (get_comments() as $comment): ?>
<div><span class="author-name"><?php echo $comment->comment_author; ?> said:</span>... | I don't usually work with comment so my suggestion is untested, but I see that get\_comments() receives an array of args.
Try this:
`$comments = get_comments(array("number" => 3))`
and instead of your foreach loop:
`foreach ($comments as $comment):` |
370,182 | <p>i am trying to make a dependend picklist set in a wordpress plugin. Within the plugin i have a javascript with the following method</p>
<pre><code> $('#am_organisation').change(function(){
var val = $(this).val();
$.ajax({
type: 'POST',
url: '/wp-... | [
{
"answer_id": 370142,
"author": "romand",
"author_id": 190900,
"author_profile": "https://wordpress.stackexchange.com/users/190900",
"pm_score": 1,
"selected": false,
"text": "<p>I don't usually work with comment so my suggestion is untested, but I see that get_comments() receives an ar... | 2020/07/01 | [
"https://wordpress.stackexchange.com/questions/370182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190935/"
] | i am trying to make a dependend picklist set in a wordpress plugin. Within the plugin i have a javascript with the following method
```
$('#am_organisation').change(function(){
var val = $(this).val();
$.ajax({
type: 'POST',
url: '/wp-content/plugi... | I don't usually work with comment so my suggestion is untested, but I see that get\_comments() receives an array of args.
Try this:
`$comments = get_comments(array("number" => 3))`
and instead of your foreach loop:
`foreach ($comments as $comment):` |
370,212 | <p>I am trying to check for an excerpt and if it doesn't exist then show the content but trimmed. Currently nothing is showing.</p>
<pre><code><?php if (has_excerpt() ): ?>
<p><?php echo get_the_excerpt(); ?></p>
<?php else: ?>
<p><?php echo wp_trim_words(get_the_content()... | [
{
"answer_id": 370225,
"author": "Ben",
"author_id": 190965,
"author_profile": "https://wordpress.stackexchange.com/users/190965",
"pm_score": 0,
"selected": false,
"text": "<p>Iggy!</p>\n<p>With WP functions, typically speaking the get_ before the function signifies that the call is mad... | 2020/07/02 | [
"https://wordpress.stackexchange.com/questions/370212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64184/"
] | I am trying to check for an excerpt and if it doesn't exist then show the content but trimmed. Currently nothing is showing.
```
<?php if (has_excerpt() ): ?>
<p><?php echo get_the_excerpt(); ?></p>
<?php else: ?>
<p><?php echo wp_trim_words(get_the_content(), 25); ?></p>
<?php endif; ?>
```
However, if I si... | So we already resolved the issue via the comments, but I thought I should explain something:
[`has_excerpt()`](https://developer.wordpress.org/reference/functions/has_excerpt/) returns `! empty( $post->post_excerpt )` if the post has a custom/manual excerpt, so if the function is returning true when it should be false... |
370,229 | <p>What is the reason that $post->ID is not working in <code>metabox_callback</code> after adding a custom query. How can I avoid this? Should I use <code>$post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : false );</code> instead of $post->ID?</p>
<p>Similar que... | [
{
"answer_id": 370241,
"author": "Tetragrammaton",
"author_id": 184192,
"author_profile": "https://wordpress.stackexchange.com/users/184192",
"pm_score": 0,
"selected": false,
"text": "<p>A possible solution is to save the <code>$post</code> variable before the query, like: <code>$origin... | 2020/07/02 | [
"https://wordpress.stackexchange.com/questions/370229",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/184192/"
] | What is the reason that $post->ID is not working in `metabox_callback` after adding a custom query. How can I avoid this? Should I use `$post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : false );` instead of $post->ID?
Similar question/same situation [here](https://w... | That `$query->have_posts()` modifies the global `$post` variable which is also used on the admin side, and on the front-end/public side of the site, you would simply call `wp_reset_postdata()` to restore the global `$post` back to the post before you call the `$query->have_posts()`.
But on the admin side, you need to ... |
370,246 | <p><strong>Hi everyone,</strong></p>
<p>I am starting now to develoo my first wordpress Theme and please, I need your help with code.</p>
<p>With this code I created my post type Team, the problem is to show them, I do not know how to do it.
If it's possible, I wish to create some easy option for users in Bakery page b... | [
{
"answer_id": 370247,
"author": "Sabbir Hasan",
"author_id": 76587,
"author_profile": "https://wordpress.stackexchange.com/users/76587",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>WP_Query</code> or <code>get_posts</code> to achieve the result. Here I'm providing yo... | 2020/07/02 | [
"https://wordpress.stackexchange.com/questions/370246",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190941/"
] | **Hi everyone,**
I am starting now to develoo my first wordpress Theme and please, I need your help with code.
With this code I created my post type Team, the problem is to show them, I do not know how to do it.
If it's possible, I wish to create some easy option for users in Bakery page builder to add it in a row wi... | As you said in a comment that you want to make it dynamic and wants to call anywhere of the website. Then in WP the best option is to use the shortcode. You can create a short code and call it where ever you want. One thing you can update it's design as per your need, I am sharing a way to create a short code for the C... |
370,271 | <p>On functions.php I have the following which works on the homepage :</p>
<pre><code>function load_page_styles() {
if (is_front_page()) {
wp_register_style('home', get_template_directory_uri() . '/css/home.css', array(), 1, 'all');
wp_enqueue_style('home');
wp_register_style('font-awesome... | [
{
"answer_id": 370247,
"author": "Sabbir Hasan",
"author_id": 76587,
"author_profile": "https://wordpress.stackexchange.com/users/76587",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>WP_Query</code> or <code>get_posts</code> to achieve the result. Here I'm providing yo... | 2020/07/03 | [
"https://wordpress.stackexchange.com/questions/370271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191003/"
] | On functions.php I have the following which works on the homepage :
```
function load_page_styles() {
if (is_front_page()) {
wp_register_style('home', get_template_directory_uri() . '/css/home.css', array(), 1, 'all');
wp_enqueue_style('home');
wp_register_style('font-awesome', get_templa... | As you said in a comment that you want to make it dynamic and wants to call anywhere of the website. Then in WP the best option is to use the shortcode. You can create a short code and call it where ever you want. One thing you can update it's design as per your need, I am sharing a way to create a short code for the C... |
370,304 | <p>I want to create a new user when a post is created from the back end. Is there a WP Hook that calls before a post is created. Thanks</p>
| [
{
"answer_id": 370247,
"author": "Sabbir Hasan",
"author_id": 76587,
"author_profile": "https://wordpress.stackexchange.com/users/76587",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>WP_Query</code> or <code>get_posts</code> to achieve the result. Here I'm providing yo... | 2020/07/03 | [
"https://wordpress.stackexchange.com/questions/370304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191027/"
] | I want to create a new user when a post is created from the back end. Is there a WP Hook that calls before a post is created. Thanks | As you said in a comment that you want to make it dynamic and wants to call anywhere of the website. Then in WP the best option is to use the shortcode. You can create a short code and call it where ever you want. One thing you can update it's design as per your need, I am sharing a way to create a short code for the C... |
370,312 | <p>I am trying to write a function that will allow me to add product meta tags as additional order notes. Unfortunately, nothing works. After a few hours I decided to bring the function to the simplest form to see what does not work.</p>
<p>Each time I place an order for two products. I check my order and see two produ... | [
{
"answer_id": 370315,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 0,
"selected": false,
"text": "<p>I found the answer here: <a href=\"https://stackoverflow.com/questions/51014200/wc-order-items-empty\">https... | 2020/07/03 | [
"https://wordpress.stackexchange.com/questions/370312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191029/"
] | I am trying to write a function that will allow me to add product meta tags as additional order notes. Unfortunately, nothing works. After a few hours I decided to bring the function to the simplest form to see what does not work.
Each time I place an order for two products. I check my order and see two products. My f... | The solution that was provided here did not work for me. It seems that the order items are assigned to the order after the `woocommerce_new_order` hook is triggered. I only managed to sort my issues after I changed the hook to `woocommerce_checkout_order_processed` as per below:
```
add_action( 'woocommerce_checkout_o... |
370,354 | <p>I am building the website for my startup, I have limited knowledge of WordPress but managed to build some decent websites using premade themes. I now face this problem I need to build a website that basically holds 4 WordPress websites in one and I don't know where to start with.</p>
<p>The structure would be someth... | [
{
"answer_id": 370315,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 0,
"selected": false,
"text": "<p>I found the answer here: <a href=\"https://stackoverflow.com/questions/51014200/wc-order-items-empty\">https... | 2020/07/04 | [
"https://wordpress.stackexchange.com/questions/370354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191066/"
] | I am building the website for my startup, I have limited knowledge of WordPress but managed to build some decent websites using premade themes. I now face this problem I need to build a website that basically holds 4 WordPress websites in one and I don't know where to start with.
The structure would be something like
... | The solution that was provided here did not work for me. It seems that the order items are assigned to the order after the `woocommerce_new_order` hook is triggered. I only managed to sort my issues after I changed the hook to `woocommerce_checkout_order_processed` as per below:
```
add_action( 'woocommerce_checkout_o... |
370,363 | <p>I'm searching to create a shortcode inside function.php child theme, to show last updated posts with thumbnail.
I have this code that works into page template:</p>
<pre><code> <ol class="list-numbered">
<?php
// Show recently modified posts
$recently_updated_posts = new WP_Query( ar... | [
{
"answer_id": 370315,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 0,
"selected": false,
"text": "<p>I found the answer here: <a href=\"https://stackoverflow.com/questions/51014200/wc-order-items-empty\">https... | 2020/07/04 | [
"https://wordpress.stackexchange.com/questions/370363",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191073/"
] | I'm searching to create a shortcode inside function.php child theme, to show last updated posts with thumbnail.
I have this code that works into page template:
```
<ol class="list-numbered">
<?php
// Show recently modified posts
$recently_updated_posts = new WP_Query( array(
'post_type' =>... | The solution that was provided here did not work for me. It seems that the order items are assigned to the order after the `woocommerce_new_order` hook is triggered. I only managed to sort my issues after I changed the hook to `woocommerce_checkout_order_processed` as per below:
```
add_action( 'woocommerce_checkout_o... |
370,369 | <p>I'm using the PHP <code>file_get_contents()</code> function to retrieve and echo the contents of an SVG-file.</p>
<pre><code><?php echo file_get_contents( get_stylesheet_directory_uri() . '/assets/images/Search_Glyph.svg' ); ?>
</code></pre>
<p>I checked the theme with the <a href="https://wordpress.org/plugin... | [
{
"answer_id": 370376,
"author": "Ejaz UL Haq",
"author_id": 178714,
"author_profile": "https://wordpress.stackexchange.com/users/178714",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Solution 01</strong></p>\n<pre><code>$wp_filesystem = new WP_Filesystem_Direct(null);\n$svg= $w... | 2020/07/04 | [
"https://wordpress.stackexchange.com/questions/370369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/170373/"
] | I'm using the PHP `file_get_contents()` function to retrieve and echo the contents of an SVG-file.
```
<?php echo file_get_contents( get_stylesheet_directory_uri() . '/assets/images/Search_Glyph.svg' ); ?>
```
I checked the theme with the [Wordpress.org theme checker](https://wordpress.org/plugins/theme-check/) and ... | Firstly add this two line to your functions.php file. Sorry I forgot to mention about this earlier.
```
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
```
now you can use `WP_Filesystem_Direct::get_contents($path)` i... |
370,391 | <p>I have been with this for several days to see if you can help me. I need to take the data of the variable $result, which is 6, from the operation function to my shortcode, how can I do this?</p>
<pre>
operation();
function operation(){
$result=5+1;
return $result;
}
function my_function($result){ //
return $all=... | [
{
"answer_id": 370392,
"author": "Will Craig",
"author_id": 16220,
"author_profile": "https://wordpress.stackexchange.com/users/16220",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure what you would need this for but this is how you take the data of the variable $result from the o... | 2020/07/05 | [
"https://wordpress.stackexchange.com/questions/370391",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189413/"
] | I have been with this for several days to see if you can help me. I need to take the data of the variable $result, which is 6, from the operation function to my shortcode, how can I do this?
```
operation();
function operation(){
$result=5+1;
return $result;
}
function my_function($result){ //
return $all=$result+... | Not sure what you would need this for but this is how you take the data of the variable $result from the operation function to your shortcode:
```
operation();
function operation(){
$result=5+1;
return $result;
}
function my_function(){
$result = operation();
return (string)$result;
}
add_shortcode( 'my-shortcode', ... |
370,423 | <p>I'm currently developing an updated version of a live site in a local environment. It's a very large site and the local dev site is using a entirely new theme without many of the live site's plugins or functionality. The live site uses Avada Fusion and almost all content is wrapped in shortcodes forcing me to basica... | [
{
"answer_id": 370392,
"author": "Will Craig",
"author_id": 16220,
"author_profile": "https://wordpress.stackexchange.com/users/16220",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure what you would need this for but this is how you take the data of the variable $result from the o... | 2020/07/05 | [
"https://wordpress.stackexchange.com/questions/370423",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191109/"
] | I'm currently developing an updated version of a live site in a local environment. It's a very large site and the local dev site is using a entirely new theme without many of the live site's plugins or functionality. The live site uses Avada Fusion and almost all content is wrapped in shortcodes forcing me to basically... | Not sure what you would need this for but this is how you take the data of the variable $result from the operation function to your shortcode:
```
operation();
function operation(){
$result=5+1;
return $result;
}
function my_function(){
$result = operation();
return (string)$result;
}
add_shortcode( 'my-shortcode', ... |
370,425 | <p><strong>UPDATE: 2020-07-12</strong> I tried installing on Windows 10 64-bit and it failed to install WordPress with the same database error as on Windows 7. That tells me that <em><strong>either there is a bug in WAMPServer 3.2.0 or there is a bug in WordPress 5.4.2.</strong></em> because the issue occurs on both op... | [
{
"answer_id": 370392,
"author": "Will Craig",
"author_id": 16220,
"author_profile": "https://wordpress.stackexchange.com/users/16220",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure what you would need this for but this is how you take the data of the variable $result from the o... | 2020/07/05 | [
"https://wordpress.stackexchange.com/questions/370425",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49697/"
] | **UPDATE: 2020-07-12** I tried installing on Windows 10 64-bit and it failed to install WordPress with the same database error as on Windows 7. That tells me that ***either there is a bug in WAMPServer 3.2.0 or there is a bug in WordPress 5.4.2.*** because the issue occurs on both operating systems.
---
ISSUE
-----
... | Not sure what you would need this for but this is how you take the data of the variable $result from the operation function to your shortcode:
```
operation();
function operation(){
$result=5+1;
return $result;
}
function my_function(){
$result = operation();
return (string)$result;
}
add_shortcode( 'my-shortcode', ... |
370,452 | <p>I am having trouble getting pagination working for custom taxonomy archive with the custom query. The pagination on the taxonomy archive ends up with a 404 page.</p>
<p>I have to run a query multiple times on many areas, so I have created a method for that.</p>
<h1>Query Method</h1>
<pre><code>/**
* @param bool $p... | [
{
"answer_id": 370462,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 3,
"selected": true,
"text": "<p><em>In short, your code is fine, but the custom query's pagination and the one for the main query, they can... | 2020/07/06 | [
"https://wordpress.stackexchange.com/questions/370452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9821/"
] | I am having trouble getting pagination working for custom taxonomy archive with the custom query. The pagination on the taxonomy archive ends up with a 404 page.
I have to run a query multiple times on many areas, so I have created a method for that.
Query Method
============
```
/**
* @param bool $post_type
* @p... | *In short, your code is fine, but the custom query's pagination and the one for the main query, they can't be using the same `paged` URL query string* (which WordPress reads the value from for the `paged` query arg used in a `WP_Query` request).
Why the error 404?
------------------
So for examples, paginated/paged c... |
370,494 | <p>I'm trying to create shortcodes that will display both avatar and logged in user first name in a text widget. I have managed to create something that displays the avatar, but not the username.</p>
<p>My code is as follows:</p>
<pre><code> <?php
// show user avatar if logged in
function colaborator_avatar($atts... | [
{
"answer_id": 370496,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 0,
"selected": false,
"text": "<p>I searched for 'wordpress get name of logged in user' and the first result gave <a href=\"https://developer.... | 2020/07/06 | [
"https://wordpress.stackexchange.com/questions/370494",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59090/"
] | I'm trying to create shortcodes that will display both avatar and logged in user first name in a text widget. I have managed to create something that displays the avatar, but not the username.
My code is as follows:
```
<?php
// show user avatar if logged in
function colaborator_avatar($atts)
{
if (is_user_lo... | The issue here is that both the functions have the same name - colaborator\_avatar().
Make sure that $new\_user contains the current user. Else use get\_current\_user\_id() like this:
```
get_user_meta( get_current_user_id(), 'first_name', true );
```
Show avatar and first name:
```
// show user avatar if logged i... |
370,564 | <p>Contact form 7 is loading reCaptcha v3 scripts on all the pages of the sites which is making the website slow.<br />
So I was using the script below which was working fine before two weeks from now, but now it stopped working and it's now loading even more scripts. Why could it be?</p>
<p>I don't want to use extra p... | [
{
"answer_id": 370591,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 2,
"selected": false,
"text": "<p>I'd put the dequeue statements inside the 'if', replacing the $loadscripts line. No need to set the fl... | 2020/07/07 | [
"https://wordpress.stackexchange.com/questions/370564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187916/"
] | Contact form 7 is loading reCaptcha v3 scripts on all the pages of the sites which is making the website slow.
So I was using the script below which was working fine before two weeks from now, but now it stopped working and it's now loading even more scripts. Why could it be?
I don't want to use extra plugins.
```... | I'd put the dequeue statements inside the 'if', replacing the $loadscripts line. No need to set the flag and then check the flag to dequeue. That might simplify the code for further debugging.
Edited: suggested code corrections:
```
function contactform_dequeue_scripts() {
if (is_singular()) {
$post = get... |
370,569 | <p>Been trying to re-map the following</p>
<pre class="lang-none prettyprint-override"><code>/test-sale-yacht/comfortably-numb-262749/
/test-sale-yacht/?yacht_name_id=comfortably-numb-262749
</code></pre>
<p>After some testing in a regular expression tester I've put the following command in the init routine of the new ... | [
{
"answer_id": 370572,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 1,
"selected": false,
"text": "<p>You're missing the WP <code>$matches[1]</code> syntax for the regex that gets matched.</p>\n<p>I think you w... | 2020/07/07 | [
"https://wordpress.stackexchange.com/questions/370569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191212/"
] | Been trying to re-map the following
```none
/test-sale-yacht/comfortably-numb-262749/
/test-sale-yacht/?yacht_name_id=comfortably-numb-262749
```
After some testing in a regular expression tester I've put the following command in the init routine of the new plugin
```php
add_rewrite_rule('test-sale-yacht/([^/]*)?',... | You're missing the WP `$matches[1]` syntax for the regex that gets matched.
I think you want `/?` on the end too.
Easiest way I found to test was to temporarily put `flush_rewrite_rules()` in whilst testing, then you don't have to do anything else. I have a similar regex which sends `/foo/catname/` to `index.php?taxo... |
370,571 | <p>My basic titles are something like</p>
<p>Part One: Part Two</p>
<p>And I'm trying to end up with something like this using the colon as what I find in the regex:</p>
<pre><code><span class="one-class">Part One:</span><br><span class="two-class">Part Two</span>
</cod... | [
{
"answer_id": 370572,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 1,
"selected": false,
"text": "<p>You're missing the WP <code>$matches[1]</code> syntax for the regex that gets matched.</p>\n<p>I think you w... | 2020/07/07 | [
"https://wordpress.stackexchange.com/questions/370571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/184735/"
] | My basic titles are something like
Part One: Part Two
And I'm trying to end up with something like this using the colon as what I find in the regex:
```
<span class="one-class">Part One:</span><br><span class="two-class">Part Two</span>
```
This is the original in `entry-header.php` and I want to continue to have ... | You're missing the WP `$matches[1]` syntax for the regex that gets matched.
I think you want `/?` on the end too.
Easiest way I found to test was to temporarily put `flush_rewrite_rules()` in whilst testing, then you don't have to do anything else. I have a similar regex which sends `/foo/catname/` to `index.php?taxo... |
370,621 | <p>When you use the default WordPress search functionality you can only search on Title, so if you type in the title than the posts you search for will appear in the results. I would like to expand this by also being able to search on date, category and author.</p>
<p>I tried to look it up but what I mostly find is to ... | [
{
"answer_id": 370631,
"author": "Az Rieil",
"author_id": 154993,
"author_profile": "https://wordpress.stackexchange.com/users/154993",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n<p>When you use the default WordPress search functionality you can only\nsearch on Title</p>\n<... | 2020/07/08 | [
"https://wordpress.stackexchange.com/questions/370621",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34616/"
] | When you use the default WordPress search functionality you can only search on Title, so if you type in the title than the posts you search for will appear in the results. I would like to expand this by also being able to search on date, category and author.
I tried to look it up but what I mostly find is to search be... | By default, the WordPress search gives an omni-like search facility to WP Posts and Pages that should search any built-in WP content. This can be further extended through a plugin such as Relevanssi.
You can though, if I'm understanding you correctly, create a custom search form where you can dictate the fields availa... |
370,625 | <p>Is possible to assign a default class to the images that are part of a post content? I have a problem with teh layout, this because the attached images insetred inside a post will break my bootstrap layout. I want to assign a default class so the user when add an image into the content will have the class assigned a... | [
{
"answer_id": 370630,
"author": "Az Rieil",
"author_id": 154993,
"author_profile": "https://wordpress.stackexchange.com/users/154993",
"pm_score": -1,
"selected": false,
"text": "<p>I guess you seeking of <a href=\"https://developer.wordpress.org/reference/hooks/get_image_tag_class/\" r... | 2020/07/08 | [
"https://wordpress.stackexchange.com/questions/370625",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191201/"
] | Is possible to assign a default class to the images that are part of a post content? I have a problem with teh layout, this because the attached images insetred inside a post will break my bootstrap layout. I want to assign a default class so the user when add an image into the content will have the class assigned and ... | As you are using bootstrap you can add `img-fluid` helper class to images like this.
```
function example_add_img_class( $class ) {
return $class . ' img-fluid';
}
add_filter( 'get_image_tag_class', 'example_add_img_class' );
```
`get_image_tag_class` filter allows to add custom css class along side WordPress... |
370,665 | <p>I currently have a block that passes some of its <code>attributes</code> down to the nested <code>InnerBlocks</code> using React's Context API (the version of WordPress that I'm on does not yet have the <a href="https://developer.wordpress.org/block-editor/developers/block-api/block-context/" rel="nofollow noreferre... | [
{
"answer_id": 384997,
"author": "PattyOK",
"author_id": 107904,
"author_profile": "https://wordpress.stackexchange.com/users/107904",
"pm_score": 2,
"selected": false,
"text": "<p>You can pass data to a child via the select and dispatch hooks. So you would set up your child block with t... | 2020/07/09 | [
"https://wordpress.stackexchange.com/questions/370665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191311/"
] | I currently have a block that passes some of its `attributes` down to the nested `InnerBlocks` using React's Context API (the version of WordPress that I'm on does not yet have the [Block Context](https://developer.wordpress.org/block-editor/developers/block-api/block-context/) feature. This allows me to successfully a... | You can pass data to a child via the select and dispatch hooks. So you would set up your child block with the inherited attribute and update that when the setting on the parent block changes.
**Parent Block**
Import dependencies
```
import { dispatch, select } from "@wordpress/data";
```
Your edit function might l... |
370,781 | <p>I have a custom post type called products, which I have attached a custom taxonomy called Product Categories.</p>
<p>On each of the Product Categories, I have used Advanced Custom Fields to add fields such as product category colour, logo etc.</p>
<p>Initially, I'm trying to display the Product Category colour as a ... | [
{
"answer_id": 370786,
"author": "Daniel Morell",
"author_id": 142138,
"author_profile": "https://wordpress.stackexchange.com/users/142138",
"pm_score": 2,
"selected": false,
"text": "<p>I would try something like this...</p>\n<pre class=\"lang-php prettyprint-override\"><code>// Assume ... | 2020/07/10 | [
"https://wordpress.stackexchange.com/questions/370781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112099/"
] | I have a custom post type called products, which I have attached a custom taxonomy called Product Categories.
On each of the Product Categories, I have used Advanced Custom Fields to add fields such as product category colour, logo etc.
Initially, I'm trying to display the Product Category colour as a background colo... | I would try something like this...
```php
// Assume there is only one category.
$product_category = get_the_terms($post, 'product-category')[0];
$cat_fields = get_fields("term_$product_category");
$color = $cat_fields['category_colour_primary'];
```
You could also do this...
```php
// Assume there is only one cat... |
370,794 | <p>I'm building theme and using this link in navigation bar to <code>about.php</code> page.</p>
<pre><code><li><a href="<?php echo get_template_directory_uri(); ?>/about.php">אודות</a></li>
</code></pre>
<p>Now I can't understand why but when I enter <code>about.php</code> I get ... | [
{
"answer_id": 370795,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": true,
"text": "<p>Look into <a href=\"https://developer.wordpress.org/themes/basics/template-hierarchy/\" rel=\"nofollow nor... | 2020/07/10 | [
"https://wordpress.stackexchange.com/questions/370794",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191084/"
] | I'm building theme and using this link in navigation bar to `about.php` page.
```
<li><a href="<?php echo get_template_directory_uri(); ?>/about.php">אודות</a></li>
```
Now I can't understand why but when I enter `about.php` I get the following error:
>
> Fatal error: Uncaught Error: Call to undefined function get... | Look into [the theme template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/). There is no "about.php" file and you should not link to any of the theme (PHP) files directly. Instead, you would create a theme file such as "page-about.php" and create its content in wp-admin as a Page with th... |
370,809 | <p>I have a custom WordPress theme I've developed and have included the following lines in my wp-config.php in hopes to automate plugin and core updates:</p>
<pre><code>define( 'WP_AUTO_UPDATE_CORE', true );
add_filter( 'auto_update_plugin', '__return_true' );
add_filter( 'auto_update_theme', '__return_true' );
</code>... | [
{
"answer_id": 370795,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": true,
"text": "<p>Look into <a href=\"https://developer.wordpress.org/themes/basics/template-hierarchy/\" rel=\"nofollow nor... | 2020/07/10 | [
"https://wordpress.stackexchange.com/questions/370809",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191409/"
] | I have a custom WordPress theme I've developed and have included the following lines in my wp-config.php in hopes to automate plugin and core updates:
```
define( 'WP_AUTO_UPDATE_CORE', true );
add_filter( 'auto_update_plugin', '__return_true' );
add_filter( 'auto_update_theme', '__return_true' );
```
I've let it pr... | Look into [the theme template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/). There is no "about.php" file and you should not link to any of the theme (PHP) files directly. Instead, you would create a theme file such as "page-about.php" and create its content in wp-admin as a Page with th... |
370,828 | <p>I basically want to loop through each post I have and get the taxonomy/category id. After that I want to output those id's into a single string (not as a numeric value), separated by a space.</p>
<p>I get this error when I try to echo the string: <strong>"Object of class WP_Term could not be converted to string... | [
{
"answer_id": 370829,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<p><code>$cat</code> is an object, not a string. You are also missing a closing bracket.</p>\n<p>Try: <code>$id... | 2020/07/10 | [
"https://wordpress.stackexchange.com/questions/370828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/180361/"
] | I basically want to loop through each post I have and get the taxonomy/category id. After that I want to output those id's into a single string (not as a numeric value), separated by a space.
I get this error when I try to echo the string: **"Object of class WP\_Term could not be converted to string"**
Here is what i... | According to [the docs for the Term object](https://developer.wordpress.org/reference/classes/wp_term/) the ID is in the property `term_id` So you need:
```
$ids = array();
foreach ($taxonomy as $tax) {
$ids[] = $tax->term_id;
}
$joinedIds = implode(" ", $ids);
// do something with $join... |
370,836 | <p>So I have a function which counts the amount of customer orders.</p>
<p>I want to show a congratulations modal that appears when a customer hits a specific amount of orders.</p>
<p>All of my code is working fine, except when I add this part to the IF statement:</p>
<p><code>|| in_array($count, $the_digits) &&... | [
{
"answer_id": 370829,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<p><code>$cat</code> is an object, not a string. You are also missing a closing bracket.</p>\n<p>Try: <code>$id... | 2020/07/11 | [
"https://wordpress.stackexchange.com/questions/370836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191188/"
] | So I have a function which counts the amount of customer orders.
I want to show a congratulations modal that appears when a customer hits a specific amount of orders.
All of my code is working fine, except when I add this part to the IF statement:
`|| in_array($count, $the_digits) && isset( $_COOKIE['tier_advance'] ... | According to [the docs for the Term object](https://developer.wordpress.org/reference/classes/wp_term/) the ID is in the property `term_id` So you need:
```
$ids = array();
foreach ($taxonomy as $tax) {
$ids[] = $tax->term_id;
}
$joinedIds = implode(" ", $ids);
// do something with $join... |
370,853 | <p>I use TinyMCE advanced on my Wordpress website. My logged-in users have the ability to fill forms with WYSIWYG fields. I don't understand why some styles are not applied on those fields while it applied well on the admin area. Fields are set in up with ACF or formidable forms. In both case I have the same issue.</p>... | [
{
"answer_id": 370829,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<p><code>$cat</code> is an object, not a string. You are also missing a closing bracket.</p>\n<p>Try: <code>$id... | 2020/07/11 | [
"https://wordpress.stackexchange.com/questions/370853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191437/"
] | I use TinyMCE advanced on my Wordpress website. My logged-in users have the ability to fill forms with WYSIWYG fields. I don't understand why some styles are not applied on those fields while it applied well on the admin area. Fields are set in up with ACF or formidable forms. In both case I have the same issue.
On th... | According to [the docs for the Term object](https://developer.wordpress.org/reference/classes/wp_term/) the ID is in the property `term_id` So you need:
```
$ids = array();
foreach ($taxonomy as $tax) {
$ids[] = $tax->term_id;
}
$joinedIds = implode(" ", $ids);
// do something with $join... |
370,859 | <p>In my Wordpress website main directory, I created a folder <code>servers</code>, which contains two files <code>.htaccess</code> & <code>index.php</code>.</p>
<p>In the <code>.htaccess</code> file, I add those lines to redirect all requests to that folder to the <code>index.php</code> file.</p>
<pre><code># Enab... | [
{
"answer_id": 370829,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<p><code>$cat</code> is an object, not a string. You are also missing a closing bracket.</p>\n<p>Try: <code>$id... | 2020/07/11 | [
"https://wordpress.stackexchange.com/questions/370859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86145/"
] | In my Wordpress website main directory, I created a folder `servers`, which contains two files `.htaccess` & `index.php`.
In the `.htaccess` file, I add those lines to redirect all requests to that folder to the `index.php` file.
```
# Enable rewriting.
RewriteEngine on
# Optional: do not allow perusal of directorie... | According to [the docs for the Term object](https://developer.wordpress.org/reference/classes/wp_term/) the ID is in the property `term_id` So you need:
```
$ids = array();
foreach ($taxonomy as $tax) {
$ids[] = $tax->term_id;
}
$joinedIds = implode(" ", $ids);
// do something with $join... |
370,902 | <p>I'm using WordPress to host a few sites. Lately it includes this feature called Site Health Status. This information has in part been valuable, but it also itches me the wrong way somehow that I can't get it to show "green" due to something I'd consider non-issues </p>
<p>Here is how the "critical iss... | [
{
"answer_id": 370906,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 2,
"selected": false,
"text": "<p>I have not tested this, but <a href=\"https://support.cloudways.com/how-to-resolve-wordpress-asking-for-ftp-... | 2020/07/12 | [
"https://wordpress.stackexchange.com/questions/370902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27498/"
] | I'm using WordPress to host a few sites. Lately it includes this feature called Site Health Status. This information has in part been valuable, but it also itches me the wrong way somehow that I can't get it to show "green" due to something I'd consider non-issues
Here is how the "critical issue" looks.
[:
Usage:
```php
add_filter('site_status_tests', function (array $test_type) {
unset($test_type['direct']['theme_version']); ... |
370,916 | <p>I'm using the following PHP code to echo post thumbnails.</p>
<pre><code> <?php
$args = array(
'post_type' => 'post' ,
'orderby' => 'date' ,
'order' => 'DESC' ,
'posts_per_page' => 1,
'category' => '2',
'paged' => get_query_var('paged'),
'post_parent' => $parent
);
... | [
{
"answer_id": 370919,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<pre><code>'posts_per_page' => 1,\n</code></pre>\n<p>Do you really only want a single post to be returned?\nA... | 2020/07/12 | [
"https://wordpress.stackexchange.com/questions/370916",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191084/"
] | I'm using the following PHP code to echo post thumbnails.
```
<?php
$args = array(
'post_type' => 'post' ,
'orderby' => 'date' ,
'order' => 'DESC' ,
'posts_per_page' => 1,
'category' => '2',
'paged' => get_query_var('paged'),
'post_parent' => $parent
);
// The Query
$the_query = new WP_... | Not sure what you're trying to do, but the problem you're having with this specific bit of code is that you're using the wrong function. You want **get\_the\_post\_thumbnail()** instead. The function the\_post\_thumbnail() echoes the result of get\_the\_post\_thumbnail().
```
$args = array(
'post_type' => 'post',
... |
370,986 | <p>I've created a custom post type "testimonials" -- works fine, except I want the url to be "domain.com/results/testimonials" instead of "domain.com/testimonials"</p>
<p>Do I just need to change something in the function that creates the custom post type? Or is there something else I need... | [
{
"answer_id": 370919,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<pre><code>'posts_per_page' => 1,\n</code></pre>\n<p>Do you really only want a single post to be returned?\nA... | 2020/07/13 | [
"https://wordpress.stackexchange.com/questions/370986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57399/"
] | I've created a custom post type "testimonials" -- works fine, except I want the url to be "domain.com/results/testimonials" instead of "domain.com/testimonials"
Do I just need to change something in the function that creates the custom post type? Or is there something else I need to do?
Thanks,
Scott | Not sure what you're trying to do, but the problem you're having with this specific bit of code is that you're using the wrong function. You want **get\_the\_post\_thumbnail()** instead. The function the\_post\_thumbnail() echoes the result of get\_the\_post\_thumbnail().
```
$args = array(
'post_type' => 'post',
... |
370,990 | <p>I have the link of WordPress doc about this function, but there is nothing explaining how to use this. I have a Ajax function, PHP and a HTML input. In this HTML I set the title and content, and I'd like to set the thumbnail too. Maybe I can do that with this function? Is there some example?</p>
<p><a href="https://... | [
{
"answer_id": 370919,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<pre><code>'posts_per_page' => 1,\n</code></pre>\n<p>Do you really only want a single post to be returned?\nA... | 2020/07/13 | [
"https://wordpress.stackexchange.com/questions/370990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186694/"
] | I have the link of WordPress doc about this function, but there is nothing explaining how to use this. I have a Ajax function, PHP and a HTML input. In this HTML I set the title and content, and I'd like to set the thumbnail too. Maybe I can do that with this function? Is there some example?
<https://developer.wordpre... | Not sure what you're trying to do, but the problem you're having with this specific bit of code is that you're using the wrong function. You want **get\_the\_post\_thumbnail()** instead. The function the\_post\_thumbnail() echoes the result of get\_the\_post\_thumbnail().
```
$args = array(
'post_type' => 'post',
... |
371,064 | <p><a href="https://wordpress.stackexchange.com/questions/218824/parent-comments-author-name">Parent comment's author name</a></p>
<p>I found this code and would like to modify it as follows: if someone changes the display_name, the name in the comments should also change.
I was able to achieve this with the follow... | [
{
"answer_id": 370919,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<pre><code>'posts_per_page' => 1,\n</code></pre>\n<p>Do you really only want a single post to be returned?\nA... | 2020/07/14 | [
"https://wordpress.stackexchange.com/questions/371064",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187945/"
] | [Parent comment's author name](https://wordpress.stackexchange.com/questions/218824/parent-comments-author-name)
I found this code and would like to modify it as follows: if someone changes the display\_name, the name in the comments should also change.
I was able to achieve this with the following code in the comment... | Not sure what you're trying to do, but the problem you're having with this specific bit of code is that you're using the wrong function. You want **get\_the\_post\_thumbnail()** instead. The function the\_post\_thumbnail() echoes the result of get\_the\_post\_thumbnail().
```
$args = array(
'post_type' => 'post',
... |
371,065 | <p>I uploaded my first wordpress website on the server, but trying to add new media files, i have got the message "Missing a temporary folder", I tried the solutions on the forum:</p>
<pre><code>define('WP_TEMP_DIR',dirname(__FILE__).'/wp-content/temp/');
</code></pre>
<p>and created a 'temp' folder on 'wp-co... | [
{
"answer_id": 370919,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<pre><code>'posts_per_page' => 1,\n</code></pre>\n<p>Do you really only want a single post to be returned?\nA... | 2020/07/14 | [
"https://wordpress.stackexchange.com/questions/371065",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/184325/"
] | I uploaded my first wordpress website on the server, but trying to add new media files, i have got the message "Missing a temporary folder", I tried the solutions on the forum:
```
define('WP_TEMP_DIR',dirname(__FILE__).'/wp-content/temp/');
```
and created a 'temp' folder on 'wp-content', but the problem still happ... | Not sure what you're trying to do, but the problem you're having with this specific bit of code is that you're using the wrong function. You want **get\_the\_post\_thumbnail()** instead. The function the\_post\_thumbnail() echoes the result of get\_the\_post\_thumbnail().
```
$args = array(
'post_type' => 'post',
... |
371,091 | <p>I'm using a function that changes the front-end and back-end post title for a custom post type according to what you put in certain custom fields.</p>
<pre><code> //Save ACF fields as post_content for back-end
add_action('save_post', 'change_title_cars');
function change_title_cars($post_id) {
global $_POST;... | [
{
"answer_id": 370919,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<pre><code>'posts_per_page' => 1,\n</code></pre>\n<p>Do you really only want a single post to be returned?\nA... | 2020/07/15 | [
"https://wordpress.stackexchange.com/questions/371091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191421/"
] | I'm using a function that changes the front-end and back-end post title for a custom post type according to what you put in certain custom fields.
```
//Save ACF fields as post_content for back-end
add_action('save_post', 'change_title_cars');
function change_title_cars($post_id) {
global $_POST;
if('cars... | Not sure what you're trying to do, but the problem you're having with this specific bit of code is that you're using the wrong function. You want **get\_the\_post\_thumbnail()** instead. The function the\_post\_thumbnail() echoes the result of get\_the\_post\_thumbnail().
```
$args = array(
'post_type' => 'post',
... |
371,136 | <p>I'm looking to force a 403 access denied response for an xml file in a directory outside of the default Wordpress install.</p>
<p>The url I'm trying to force the 403 response on looks like this mydomain.com/autodiscover/autodiscover.xml</p>
<p>I've tried modifying the default Wordpress htaccess file by adding a line... | [
{
"answer_id": 370919,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<pre><code>'posts_per_page' => 1,\n</code></pre>\n<p>Do you really only want a single post to be returned?\nA... | 2020/07/15 | [
"https://wordpress.stackexchange.com/questions/371136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64789/"
] | I'm looking to force a 403 access denied response for an xml file in a directory outside of the default Wordpress install.
The url I'm trying to force the 403 response on looks like this mydomain.com/autodiscover/autodiscover.xml
I've tried modifying the default Wordpress htaccess file by adding a line to ignore the ... | Not sure what you're trying to do, but the problem you're having with this specific bit of code is that you're using the wrong function. You want **get\_the\_post\_thumbnail()** instead. The function the\_post\_thumbnail() echoes the result of get\_the\_post\_thumbnail().
```
$args = array(
'post_type' => 'post',
... |
371,157 | <p>I inherited a website that had a significant number of customized PHP files. I have removed many since, however, this is one of the few that still seemed relevant. The code below displays 1 image at random from a particular post type (gallery) in the website footer.</p>
<p>There was only one post type category prior... | [
{
"answer_id": 381456,
"author": "per.eight",
"author_id": 200313,
"author_profile": "https://wordpress.stackexchange.com/users/200313",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the nl2br PHP function.\nIt means insert line breaks where newlines (\\n) occur in the string... | 2020/07/15 | [
"https://wordpress.stackexchange.com/questions/371157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191689/"
] | I inherited a website that had a significant number of customized PHP files. I have removed many since, however, this is one of the few that still seemed relevant. The code below displays 1 image at random from a particular post type (gallery) in the website footer.
There was only one post type category prior to me wo... | You could use "white-space: pre;" in CSS to display newlines as they are |
371,187 | <p>I need help how to translate the custom post type and taxonomy when using multisite and multi-language.
I am using subdirectory a /en /sv etc.</p>
<p>Are using the plugin (Multisite Language Switcher), but can not change the rewrite settings there. So I am guesing I have to change some rewrite?
Or should I translate... | [
{
"answer_id": 381456,
"author": "per.eight",
"author_id": 200313,
"author_profile": "https://wordpress.stackexchange.com/users/200313",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the nl2br PHP function.\nIt means insert line breaks where newlines (\\n) occur in the string... | 2020/07/16 | [
"https://wordpress.stackexchange.com/questions/371187",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/185742/"
] | I need help how to translate the custom post type and taxonomy when using multisite and multi-language.
I am using subdirectory a /en /sv etc.
Are using the plugin (Multisite Language Switcher), but can not change the rewrite settings there. So I am guesing I have to change some rewrite?
Or should I translate the post... | You could use "white-space: pre;" in CSS to display newlines as they are |
371,189 | <p>I have function which gets menu next and previous item url. I want to get also title for them. How can I do this? This is what i have :</p>
<pre><code> <?php
$menu_name = 'main-menu';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_i... | [
{
"answer_id": 381456,
"author": "per.eight",
"author_id": 200313,
"author_profile": "https://wordpress.stackexchange.com/users/200313",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the nl2br PHP function.\nIt means insert line breaks where newlines (\\n) occur in the string... | 2020/07/16 | [
"https://wordpress.stackexchange.com/questions/371189",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191729/"
] | I have function which gets menu next and previous item url. I want to get also title for them. How can I do this? This is what i have :
```
<?php
$menu_name = 'main-menu';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->ter... | You could use "white-space: pre;" in CSS to display newlines as they are |
371,213 | <p>I have a <code>search form</code> with<code>wp_query</code>argument
There are many <code>checkbox</code> in this form</p>
<p>The problem start here, it takes a long time to load when you <code>select all</code> the options,
this query takes almost a minute to complete. Has anyone had this issue before?</p>
<p>I used... | [
{
"answer_id": 371212,
"author": "mozboz",
"author_id": 176814,
"author_profile": "https://wordpress.stackexchange.com/users/176814",
"pm_score": 2,
"selected": false,
"text": "<p>This is a partially subjective question, so it may get closed on that basis. Answer given here may be somewh... | 2020/07/16 | [
"https://wordpress.stackexchange.com/questions/371213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187881/"
] | I have a `search form` with`wp_query`argument
There are many `checkbox` in this form
The problem start here, it takes a long time to load when you `select all` the options,
this query takes almost a minute to complete. Has anyone had this issue before?
I used these codes
in HTML
```
<form action="<?php echo site_url... | This is a partially subjective question, so it may get closed on that basis. Answer given here may be somewhat subjective but tries to cover the main considerations.
Short Answer
------------
The short answer is you'll definitely have a much easier life running Wordpress on Linux. This is simply due to many more peop... |
371,219 | <p>As the title states <a href="https://developer.wordpress.org/block-editor/data/data-core/#getEntityRecords" rel="nofollow noreferrer">https://developer.wordpress.org/block-editor/data/data-core/#getEntityRecords</a> doesn't allow an array of post types or any sort of delimited types. WP_Query normally accepts 'any' ... | [
{
"answer_id": 391102,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 1,
"selected": false,
"text": "<p>It is not possible to query multiple post types simultaneously using the <code>getEntityRecords()</code> select... | 2020/07/16 | [
"https://wordpress.stackexchange.com/questions/371219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190706/"
] | As the title states <https://developer.wordpress.org/block-editor/data/data-core/#getEntityRecords> doesn't allow an array of post types or any sort of delimited types. WP\_Query normally accepts 'any' but that doesn't work any suggestion for a JSX novice please. Ive checked my local endpoint REST endpoint `/wp/v2/type... | It is not possible to query multiple post types simultaneously using the `getEntityRecords()` selector. This is because the WordPress REST API is not built around the same ideology as the core WordPress back-end.
All data-types being "posts" in the traditional PHP APIs is the product of the somewhat controversial unde... |
371,224 | <p>I am trying to develop a hook when save_post to get the categories but for new posts I don't get any categories and for updated posts I get the categories "before" updating the post. This should be super simple but I can't figure it out. I have been hours trying to find a solution.</p>
<p>This is the minim... | [
{
"answer_id": 371288,
"author": "malago",
"author_id": 191766,
"author_profile": "https://wordpress.stackexchange.com/users/191766",
"pm_score": 1,
"selected": false,
"text": "<p>After doing much more search... it looks like the save_post hook does not run after the post categories are ... | 2020/07/17 | [
"https://wordpress.stackexchange.com/questions/371224",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191766/"
] | I am trying to develop a hook when save\_post to get the categories but for new posts I don't get any categories and for updated posts I get the categories "before" updating the post. This should be super simple but I can't figure it out. I have been hours trying to find a solution.
This is the minimal code that I am ... | After doing much more search... it looks like the save\_post hook does not run after the post categories are updated so it will only show the categories that the post had before the update (or no categories for new posts).
I found that I need to use this hook and then everything inside my function is updated:
```
add... |
371,238 | <p>Let's say my custom post type is 'story'.
I've got 20 stories published on my site.
So each post becomes: 'story 1', 'story 2', ... 'story 20'.
Thus, first post is 'story 1', and last post is 'story 20'.
Now when I open one of these custom posts, I want to see the number. Example, if I open the ninth (published) pos... | [
{
"answer_id": 371288,
"author": "malago",
"author_id": 191766,
"author_profile": "https://wordpress.stackexchange.com/users/191766",
"pm_score": 1,
"selected": false,
"text": "<p>After doing much more search... it looks like the save_post hook does not run after the post categories are ... | 2020/07/17 | [
"https://wordpress.stackexchange.com/questions/371238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/120120/"
] | Let's say my custom post type is 'story'.
I've got 20 stories published on my site.
So each post becomes: 'story 1', 'story 2', ... 'story 20'.
Thus, first post is 'story 1', and last post is 'story 20'.
Now when I open one of these custom posts, I want to see the number. Example, if I open the ninth (published) post I... | After doing much more search... it looks like the save\_post hook does not run after the post categories are updated so it will only show the categories that the post had before the update (or no categories for new posts).
I found that I need to use this hook and then everything inside my function is updated:
```
add... |
371,244 | <p>I’m using Easy Digital Downloads for my Wordpress webshop. After someone buy a item it needs to add data to the SQL database. I got this working by adding PHP code to shortcode-receipt.php. This is working correct but when I reload the receipt via browser or mail the PHP code will fire again.</p>
<p>I figured out th... | [
{
"answer_id": 371288,
"author": "malago",
"author_id": 191766,
"author_profile": "https://wordpress.stackexchange.com/users/191766",
"pm_score": 1,
"selected": false,
"text": "<p>After doing much more search... it looks like the save_post hook does not run after the post categories are ... | 2020/07/17 | [
"https://wordpress.stackexchange.com/questions/371244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/177769/"
] | I’m using Easy Digital Downloads for my Wordpress webshop. After someone buy a item it needs to add data to the SQL database. I got this working by adding PHP code to shortcode-receipt.php. This is working correct but when I reload the receipt via browser or mail the PHP code will fire again.
I figured out that there ... | After doing much more search... it looks like the save\_post hook does not run after the post categories are updated so it will only show the categories that the post had before the update (or no categories for new posts).
I found that I need to use this hook and then everything inside my function is updated:
```
add... |