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 |
|---|---|---|---|---|---|---|
378,842 | <p>I have come across a wonderful portfolio website <a href="https://dogstudio.co/" rel="nofollow noreferrer">https://dogstudio.co/</a> while I was looking for examples of design. Upon exploring the source-code, it was apparent that this was a wordpress website after all.</p>
<p>What I don't understand is how and why d... | [
{
"answer_id": 378875,
"author": "Brian Burton",
"author_id": 158744,
"author_profile": "https://wordpress.stackexchange.com/users/158744",
"pm_score": 0,
"selected": false,
"text": "<p>You can store WordPress static assets anywhere, even on a CDN completely separate from the server host... | 2020/11/26 | [
"https://wordpress.stackexchange.com/questions/378842",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/192517/"
] | I have come across a wonderful portfolio website <https://dogstudio.co/> while I was looking for examples of design. Upon exploring the source-code, it was apparent that this was a wordpress website after all.
What I don't understand is how and why does it not have the typical wordpress directory hierarchy. For exampl... | That site probably uses the Roots Bedrock framework, which moves the theme/plugin folders around into an `app` subfolder. This is mainly due to the preference of that framework though, rather than for any structural benefit.
It's also possible they use standard WordPress but have renamed `wp-content` using constants i... |
378,869 | <p>I have main menu which displays two types of links: CPT and Subcategory.
I create the menu with a custom request: I retrieve the Custom Post Type then the sub-categories of the main category in Alphabetical order :</p>
<pre><code>Category A: - Product a - Product b - sub category a - sub category b ...
</code></pre>... | [
{
"answer_id": 378875,
"author": "Brian Burton",
"author_id": 158744,
"author_profile": "https://wordpress.stackexchange.com/users/158744",
"pm_score": 0,
"selected": false,
"text": "<p>You can store WordPress static assets anywhere, even on a CDN completely separate from the server host... | 2020/11/26 | [
"https://wordpress.stackexchange.com/questions/378869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65465/"
] | I have main menu which displays two types of links: CPT and Subcategory.
I create the menu with a custom request: I retrieve the Custom Post Type then the sub-categories of the main category in Alphabetical order :
```
Category A: - Product a - Product b - sub category a - sub category b ...
```
But, my client wants... | That site probably uses the Roots Bedrock framework, which moves the theme/plugin folders around into an `app` subfolder. This is mainly due to the preference of that framework though, rather than for any structural benefit.
It's also possible they use standard WordPress but have renamed `wp-content` using constants i... |
378,893 | <p>I am trying to use custom HTML in a widget and I can't make an <code>img</code> tag to work because I have no idea where to store the image.</p>
<p>Where does one store an image inside a WordPress website ? And not by "Upload Image", no. By using FTP. Where exactly do I have to store images so that I can l... | [
{
"answer_id": 378875,
"author": "Brian Burton",
"author_id": 158744,
"author_profile": "https://wordpress.stackexchange.com/users/158744",
"pm_score": 0,
"selected": false,
"text": "<p>You can store WordPress static assets anywhere, even on a CDN completely separate from the server host... | 2020/11/26 | [
"https://wordpress.stackexchange.com/questions/378893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198154/"
] | I am trying to use custom HTML in a widget and I can't make an `img` tag to work because I have no idea where to store the image.
Where does one store an image inside a WordPress website ? And not by "Upload Image", no. By using FTP. Where exactly do I have to store images so that I can link them to an `img` tag. | That site probably uses the Roots Bedrock framework, which moves the theme/plugin folders around into an `app` subfolder. This is mainly due to the preference of that framework though, rather than for any structural benefit.
It's also possible they use standard WordPress but have renamed `wp-content` using constants i... |
378,952 | <p>I use norebo theme</p>
<p>I use it when I open a Portfolio the link is in this format</p>
<pre><code>https://www.hshnorm.com/project/fruit-flavored-powder-juice/
</code></pre>
<p>How can I remove the word <code>project</code></p>
<p>To be the link in this format</p>
<pre><code>https://www.hshnorm.com/fruit-flavored-... | [
{
"answer_id": 378875,
"author": "Brian Burton",
"author_id": 158744,
"author_profile": "https://wordpress.stackexchange.com/users/158744",
"pm_score": 0,
"selected": false,
"text": "<p>You can store WordPress static assets anywhere, even on a CDN completely separate from the server host... | 2020/11/27 | [
"https://wordpress.stackexchange.com/questions/378952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198191/"
] | I use norebo theme
I use it when I open a Portfolio the link is in this format
```
https://www.hshnorm.com/project/fruit-flavored-powder-juice/
```
How can I remove the word `project`
To be the link in this format
```
https://www.hshnorm.com/fruit-flavored-powder-juice/
``` | That site probably uses the Roots Bedrock framework, which moves the theme/plugin folders around into an `app` subfolder. This is mainly due to the preference of that framework though, rather than for any structural benefit.
It's also possible they use standard WordPress but have renamed `wp-content` using constants i... |
378,977 | <p>I need to deregister JS scripts everywhere except on one product page, so far this is my code:</p>
<pre><code>add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
if ( !is_product('67688') ) {
wp_deregister_script( 'wc-lottery-jquery-plugin' );
wp_deregister_script( 'wc-lottery-countdown' );
wp_deregis... | [
{
"answer_id": 378875,
"author": "Brian Burton",
"author_id": 158744,
"author_profile": "https://wordpress.stackexchange.com/users/158744",
"pm_score": 0,
"selected": false,
"text": "<p>You can store WordPress static assets anywhere, even on a CDN completely separate from the server host... | 2020/11/28 | [
"https://wordpress.stackexchange.com/questions/378977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/169807/"
] | I need to deregister JS scripts everywhere except on one product page, so far this is my code:
```
add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
if ( !is_product('67688') ) {
wp_deregister_script( 'wc-lottery-jquery-plugin' );
wp_deregister_script( 'wc-lottery-countdown' );
wp_deregister_script( '... | That site probably uses the Roots Bedrock framework, which moves the theme/plugin folders around into an `app` subfolder. This is mainly due to the preference of that framework though, rather than for any structural benefit.
It's also possible they use standard WordPress but have renamed `wp-content` using constants i... |
378,988 | <p>I try to list pages of custom post type in archive.php, and I get this error message:</p>
<p>Invalid argument supplied for foreach()</p>
<pre><code>$post_type = get_post_type( get_the_ID() );
$pages = get_pages(array( 'post_type' => $post_type ) );
foreach ($pages as $page ) {
echo '<div class = &q... | [
{
"answer_id": 378992,
"author": "user3575665",
"author_id": 198226,
"author_profile": "https://wordpress.stackexchange.com/users/198226",
"pm_score": 0,
"selected": false,
"text": "<p>I am assuming your code is not within a wordpress loop,\nsomething like <code>while(have_posts()): the_... | 2020/11/28 | [
"https://wordpress.stackexchange.com/questions/378988",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/163786/"
] | I try to list pages of custom post type in archive.php, and I get this error message:
Invalid argument supplied for foreach()
```
$post_type = get_post_type( get_the_ID() );
$pages = get_pages(array( 'post_type' => $post_type ) );
foreach ($pages as $page ) {
echo '<div class = "prop-sidebar-section">';
... | [`get_pages()`](https://developer.wordpress.org/reference/functions/get_pages/) is intended only for *hierarchical* post types like `page`. For non-hierarchical post types like `post`, `get_pages()` will return a `false`, hence that explains why `get_pages( array( 'post_type' => 'post' ) )` "doesn't work", i.e. the ret... |
379,014 | <p>I used wordfence plugin to clean unwanted files from my site. Post this, my posts page is broken. If i try to load any of my posts page, page will load but without header, footer, css. Homepage looks fine. Posts page works normal if i'm logged in.
here's one of my post url: <a href="https://m.androidestate.com/xiaom... | [
{
"answer_id": 378992,
"author": "user3575665",
"author_id": 198226,
"author_profile": "https://wordpress.stackexchange.com/users/198226",
"pm_score": 0,
"selected": false,
"text": "<p>I am assuming your code is not within a wordpress loop,\nsomething like <code>while(have_posts()): the_... | 2020/11/29 | [
"https://wordpress.stackexchange.com/questions/379014",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198237/"
] | I used wordfence plugin to clean unwanted files from my site. Post this, my posts page is broken. If i try to load any of my posts page, page will load but without header, footer, css. Homepage looks fine. Posts page works normal if i'm logged in.
here's one of my post url: <https://m.androidestate.com/xiaomi-redmi-k20... | [`get_pages()`](https://developer.wordpress.org/reference/functions/get_pages/) is intended only for *hierarchical* post types like `page`. For non-hierarchical post types like `post`, `get_pages()` will return a `false`, hence that explains why `get_pages( array( 'post_type' => 'post' ) )` "doesn't work", i.e. the ret... |
379,023 | <p>I'm having problems with my code. I'm trying to remove a category from a post that's using that category and then adding that same category when saving a post.</p>
<p>For example, if I have a post that's using "First post", when saving any post that is using that category gets removed and the new post that... | [
{
"answer_id": 379024,
"author": "hrsetyono",
"author_id": 33361,
"author_profile": "https://wordpress.stackexchange.com/users/33361",
"pm_score": 0,
"selected": false,
"text": "<p>I don't see you querying for the posts that are using that category,</p>\n<p>Use <code>get_posts</code> lik... | 2020/11/29 | [
"https://wordpress.stackexchange.com/questions/379023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/181902/"
] | I'm having problems with my code. I'm trying to remove a category from a post that's using that category and then adding that same category when saving a post.
For example, if I have a post that's using "First post", when saving any post that is using that category gets removed and the new post that's being saved is a... | Your foreach doesnt have brackets or semicolons, probably thatś why.
and also not very well idented.
Here it is the code properly idented, just one maybe, the foreach closing brackets probably must be after the return like in the code bellow, or maybe right before. if this code doesnt work cut and paste "return;" to ri... |
379,041 | <p>5 WordPress sites (that is all of them) on our server (Apache, Ubuntu) were infected by some malicious code injecting javascript. I have deleted all the wp databases that were full of the injections and reuploaded them back from a backup. Almost all is well now, but one of the WordPress sites from one domain now red... | [
{
"answer_id": 379024,
"author": "hrsetyono",
"author_id": 33361,
"author_profile": "https://wordpress.stackexchange.com/users/33361",
"pm_score": 0,
"selected": false,
"text": "<p>I don't see you querying for the posts that are using that category,</p>\n<p>Use <code>get_posts</code> lik... | 2020/11/29 | [
"https://wordpress.stackexchange.com/questions/379041",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/150082/"
] | 5 WordPress sites (that is all of them) on our server (Apache, Ubuntu) were infected by some malicious code injecting javascript. I have deleted all the wp databases that were full of the injections and reuploaded them back from a backup. Almost all is well now, but one of the WordPress sites from one domain now redire... | Your foreach doesnt have brackets or semicolons, probably thatś why.
and also not very well idented.
Here it is the code properly idented, just one maybe, the foreach closing brackets probably must be after the return like in the code bellow, or maybe right before. if this code doesnt work cut and paste "return;" to ri... |
379,092 | <p>Is it safe to remove</p>
<pre><code>get_footer();
</code></pre>
<p>from the index.php ?</p>
<p>I don't need any footer.</p>
| [
{
"answer_id": 379094,
"author": "user3288647",
"author_id": 198299,
"author_profile": "https://wordpress.stackexchange.com/users/198299",
"pm_score": 3,
"selected": true,
"text": "<p>Its not safe and not recommended. Thats action that read all Javascripts, CSS from other plugins or them... | 2020/11/30 | [
"https://wordpress.stackexchange.com/questions/379092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198297/"
] | Is it safe to remove
```
get_footer();
```
from the index.php ?
I don't need any footer. | Its not safe and not recommended. Thats action that read all Javascripts, CSS from other plugins or theme.
Hide your footer with css or theme option.
```css
#footer,footer{display:none!important}
``` |
379,098 | <p>I'm having font problems, or maybe character encoding on wordpress.</p>
<p>I am building a Thai website, most of the articles are in the correct language and there is no problem.</p>
<p>But there are a number of articles posted when posting errors in the article letters.</p>
<p>Such as:</p>
<p><a href="https://prnt.... | [
{
"answer_id": 379094,
"author": "user3288647",
"author_id": 198299,
"author_profile": "https://wordpress.stackexchange.com/users/198299",
"pm_score": 3,
"selected": true,
"text": "<p>Its not safe and not recommended. Thats action that read all Javascripts, CSS from other plugins or them... | 2020/11/30 | [
"https://wordpress.stackexchange.com/questions/379098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198301/"
] | I'm having font problems, or maybe character encoding on wordpress.
I am building a Thai website, most of the articles are in the correct language and there is no problem.
But there are a number of articles posted when posting errors in the article letters.
Such as:
<https://prnt.sc/vswh8j> or <https://prnt.sc/vswi... | Its not safe and not recommended. Thats action that read all Javascripts, CSS from other plugins or theme.
Hide your footer with css or theme option.
```css
#footer,footer{display:none!important}
``` |
379,122 | <p><strong>Hello everybody</strong>, I need help with my custom wordpress pagination.</p>
<p>I'm looking to get this :</p>
<p><a href="https://i.stack.imgur.com/UUM6d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UUM6d.png" alt="enter image description here" /></a></p>
<p>This is what I did :</p>
<... | [
{
"answer_id": 379984,
"author": "Bunty",
"author_id": 109377,
"author_profile": "https://wordpress.stackexchange.com/users/109377",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of <code>the_posts_pagination( wp_custom_pagination () );</code>, just use this function <code>pagina... | 2020/12/01 | [
"https://wordpress.stackexchange.com/questions/379122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198331/"
] | **Hello everybody**, I need help with my custom wordpress pagination.
I'm looking to get this :
[](https://i.stack.imgur.com/UUM6d.png)
This is what I did :
in the functions.php, I've add this code :
```
function wp_custom_pagination($args = [], $... | Making your Custom Pagination design In Demo According Your Need .
below function Replace Your Function:
```
function wp_custom_pagination($args = [], $class = 'pagination') {
if ($GLOBALS['wp_query']->max_num_pages <= 1) return;
$args = wp_parse_args( $args, [
'mid_size' => 2,
'pr... |
379,153 | <p>I have 2 pages:</p>
<ol>
<li><code>/contact</code></li>
<li><code>/contact-team</code></li>
</ol>
<p>The <code>/contact</code> page has a popup and on user selection, the page must reload but with the contents of <code>/contact-team</code>.</p>
<p>Is there a filter hook which can load a different post altogether aft... | [
{
"answer_id": 379292,
"author": "Awais",
"author_id": 141970,
"author_profile": "https://wordpress.stackexchange.com/users/141970",
"pm_score": 0,
"selected": false,
"text": "<p>You can try <code>the_content</code> filter something like below to load a content from a different post/page... | 2020/12/01 | [
"https://wordpress.stackexchange.com/questions/379153",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67538/"
] | I have 2 pages:
1. `/contact`
2. `/contact-team`
The `/contact` page has a popup and on user selection, the page must reload but with the contents of `/contact-team`.
Is there a filter hook which can load a different post altogether after the URL has been generated?
I have tried the `pre_get_posts` to set the post ... | You can use the `request` hook to change the loaded page for the same URL:
```
add_filter( 'request', function( $request ){
//Replace this with custom logic to determine if the user should see the contact-team page
$load_team_contact = true;
if( $load_team_contact && isset( $request['pagename'] ) && 'cont... |
379,174 | <p>I'm curious that why the get_header() or get_footer() function does not show output if called twice in the same .php file??</p>
<p><a href="https://i.stack.imgur.com/BhaEb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BhaEb.png" alt="enter image description here" /></a></p>
<p><a href="https://i... | [
{
"answer_id": 379178,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 2,
"selected": false,
"text": "<p>The actual templates are loaded with <a href=\"https://www.php.net/manual/en/function.require-once.php\" rel=\"nofo... | 2020/12/01 | [
"https://wordpress.stackexchange.com/questions/379174",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198365/"
] | I'm curious that why the get\_header() or get\_footer() function does not show output if called twice in the same .php file??
[](https://i.stack.imgur.com/BhaEb.png)
[](https://i.sta... | The actual templates are loaded with [`require_once`](https://www.php.net/manual/en/function.require-once.php), so PHP automatically ignores the second attempt to load them. (You will trigger the 'get\_header' hook twice though.)
Here's [the relevant code in get\_header()](https://github.com/WordPress/WordPress/blob/5... |
379,183 | <p>We have a simple plugin to display a tree menu, which includes the parent page, plus the parent page's children (so, the siblings of the current page).</p>
<p>We're using the following <code>get_pages</code> code:</p>
<pre><code>$pages = get_pages( [
'child_of' => $parent,
'sort_order' => 'ASC',
'sort... | [
{
"answer_id": 379184,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>Both the <a href=\"https://developer.wordpress.org/reference/functions/wp_list_pages/\" rel=\"nofollow nore... | 2020/12/02 | [
"https://wordpress.stackexchange.com/questions/379183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | We have a simple plugin to display a tree menu, which includes the parent page, plus the parent page's children (so, the siblings of the current page).
We're using the following `get_pages` code:
```
$pages = get_pages( [
'child_of' => $parent,
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
]);
```
... | When the `child_of` parameter is set, `get_pages()` will use [`get_page_children()`](https://developer.wordpress.org/reference/functions/get_page_children/) to get the child pages, and unfortunately, the `sort_column` will no longer be used, hence the final list will not be sorted by the specified custom sort column, s... |
379,206 | <p>According to the announcement on the <a href="https://make.wordpress.org/core/2020/03/02/general-block-editor-api-updates/" rel="noreferrer">Make WordPress Core blog post</a> it appears that to use post meta on a post things have changed quite a bit.</p>
<p>I'm trying to get a simple block to read and save data from... | [
{
"answer_id": 391761,
"author": "Julio Braña Bouza",
"author_id": 101034,
"author_profile": "https://wordpress.stackexchange.com/users/101034",
"pm_score": 0,
"selected": false,
"text": "<p>I think your onChange function needs to pass the value, like <code>onChange={(value) => update... | 2020/12/02 | [
"https://wordpress.stackexchange.com/questions/379206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62160/"
] | According to the announcement on the [Make WordPress Core blog post](https://make.wordpress.org/core/2020/03/02/general-block-editor-api-updates/) it appears that to use post meta on a post things have changed quite a bit.
I'm trying to get a simple block to read and save data from a custom field, and for some reason ... | I am very late at this, but I think the problem here was that at registration code for your custom post type `ebook` (which you did not show) you were missing `supports` for `custom-fields` in args array:
```php
'supports' => [ 'title', 'editor', 'custom-fields' ]
```
and also
```php
'show_in_rest' ... |
379,213 | <p>I'd love to know how to get back into wp-admin and get my site back online.</p>
<p>I contacted GoDaddy tech support again today and the PHP is supposedly updating.. Wordpress has been complaining about the older version of PHP it had a while back, as of 5 months ago, a GoDaddy rep told me I had to wait for the devs ... | [
{
"answer_id": 391761,
"author": "Julio Braña Bouza",
"author_id": 101034,
"author_profile": "https://wordpress.stackexchange.com/users/101034",
"pm_score": 0,
"selected": false,
"text": "<p>I think your onChange function needs to pass the value, like <code>onChange={(value) => update... | 2020/12/02 | [
"https://wordpress.stackexchange.com/questions/379213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198417/"
] | I'd love to know how to get back into wp-admin and get my site back online.
I contacted GoDaddy tech support again today and the PHP is supposedly updating.. Wordpress has been complaining about the older version of PHP it had a while back, as of 5 months ago, a GoDaddy rep told me I had to wait for the devs to switch... | I am very late at this, but I think the problem here was that at registration code for your custom post type `ebook` (which you did not show) you were missing `supports` for `custom-fields` in args array:
```php
'supports' => [ 'title', 'editor', 'custom-fields' ]
```
and also
```php
'show_in_rest' ... |
379,261 | <p>I have added a page in the admin menu(<em>pxmag-menu</em>) and a submenu(<em>pxmag-plans</em>). There is another page(<em>pxmag-plans-edit</em>) set under the submenu(<em>pxmag-plans</em>) as the parent page.</p>
<pre><code>public function __construct()
{
require('pxMagAdminPlans.class.php');
$this->admPl... | [
{
"answer_id": 379283,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": true,
"text": "<p>If I understand it correctly — you want the "Plans" sub-menu to be highlighted when on the "... | 2020/12/03 | [
"https://wordpress.stackexchange.com/questions/379261",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92425/"
] | I have added a page in the admin menu(*pxmag-menu*) and a submenu(*pxmag-plans*). There is another page(*pxmag-plans-edit*) set under the submenu(*pxmag-plans*) as the parent page.
```
public function __construct()
{
require('pxMagAdminPlans.class.php');
$this->admPlanObj= new pxMagAdminPlans();
add_actio... | If I understand it correctly — you want the "Plans" sub-menu to be highlighted when on the "Add/edit plans" (`pxmag-plans-edit`) page, then you can do it like so:
1. Use the [`add_menu_classes` hook](https://developer.wordpress.org/reference/hooks/add_menu_classes/) to highlight the `pxmag-menu` menu:
```php
function... |
379,306 | <p>I'm trying to hide error messages on a WordPress installation on a shared hosting. I added the following code to my config.</p>
<pre><code>ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
</code></pre>
<p>This is pretty much what I fin... | [
{
"answer_id": 379334,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 2,
"selected": false,
"text": "<p>I believe that this line</p>\n<pre><code>ini_set('error_reporting', E_ALL );\n</code></pre>\n<p>will o... | 2020/12/04 | [
"https://wordpress.stackexchange.com/questions/379306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118091/"
] | I'm trying to hide error messages on a WordPress installation on a shared hosting. I added the following code to my config.
```
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
```
This is pretty much what I find in any article regardi... | I believe that this line
```
ini_set('error_reporting', E_ALL );
```
will override other error settings. Will display all errors, even 'benign' ones, to the screen and error log file. |
379,358 | <p>I'm trying to ensure that all assets are the same size, no matter what resolution they are uploaded in. I'm stuck finding outdated info on the matter, I think.</p>
<p>I've gotten to the following snippet</p>
<pre><code>if( get_the_post_thumbnail_url()){
$image = wp_get_image_editor(get_the_post_thumbnail_url());... | [
{
"answer_id": 379314,
"author": "Marc",
"author_id": 193017,
"author_profile": "https://wordpress.stackexchange.com/users/193017",
"pm_score": 2,
"selected": false,
"text": "<p>By default, that API endpoint is paged and the amount per_page is set to 10. You can see all the defaults for ... | 2020/12/05 | [
"https://wordpress.stackexchange.com/questions/379358",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198566/"
] | I'm trying to ensure that all assets are the same size, no matter what resolution they are uploaded in. I'm stuck finding outdated info on the matter, I think.
I've gotten to the following snippet
```
if( get_the_post_thumbnail_url()){
$image = wp_get_image_editor(get_the_post_thumbnail_url());
if ( !is_wp_er... | By default, that API endpoint is paged and the amount per\_page is set to 10. You can see all the defaults for that endpoint here <https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-orders>
If this endpoint works like WP\_Query then you'll need to set the per\_page parameter to -1. Otherwise you'll need... |
379,400 | <p>I need to execute a portion of code after each: Add / Edit / delete a custom taxonomy .
For creation / edition it works well, but for deletion non :</p>
<pre><code> add_action( 'edited_product_category', array ( $this , 'term_edit_success' ), 10, 2 );
add_action( 'create_product_category', array ( $this , 'te... | [
{
"answer_id": 379314,
"author": "Marc",
"author_id": 193017,
"author_profile": "https://wordpress.stackexchange.com/users/193017",
"pm_score": 2,
"selected": false,
"text": "<p>By default, that API endpoint is paged and the amount per_page is set to 10. You can see all the defaults for ... | 2020/12/06 | [
"https://wordpress.stackexchange.com/questions/379400",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65465/"
] | I need to execute a portion of code after each: Add / Edit / delete a custom taxonomy .
For creation / edition it works well, but for deletion non :
```
add_action( 'edited_product_category', array ( $this , 'term_edit_success' ), 10, 2 );
add_action( 'create_product_category', array ( $this , 'term_create_suc... | By default, that API endpoint is paged and the amount per\_page is set to 10. You can see all the defaults for that endpoint here <https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-orders>
If this endpoint works like WP\_Query then you'll need to set the per\_page parameter to -1. Otherwise you'll need... |
379,424 | <p>How do I get the id of the most recent wordpress audio media upload.
The reason for this is that I want to use audio cover images/ featured images as a post featured image.
Do I need to retrieve the ID of the thumbnail in the audio.</p>
<p>I tried the code below but it returned error</p>
<pre><code> $attachments ... | [
{
"answer_id": 379314,
"author": "Marc",
"author_id": 193017,
"author_profile": "https://wordpress.stackexchange.com/users/193017",
"pm_score": 2,
"selected": false,
"text": "<p>By default, that API endpoint is paged and the amount per_page is set to 10. You can see all the defaults for ... | 2020/12/06 | [
"https://wordpress.stackexchange.com/questions/379424",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/197886/"
] | How do I get the id of the most recent wordpress audio media upload.
The reason for this is that I want to use audio cover images/ featured images as a post featured image.
Do I need to retrieve the ID of the thumbnail in the audio.
I tried the code below but it returned error
```
$attachments = get_posts( array(... | By default, that API endpoint is paged and the amount per\_page is set to 10. You can see all the defaults for that endpoint here <https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-orders>
If this endpoint works like WP\_Query then you'll need to set the per\_page parameter to -1. Otherwise you'll need... |
379,556 | <p>I am missing some feature to prompt the user for input. In Laravel we have <code>$this->ask('What is your age')</code> (<a href="https://laravel.com/docs/8.x/artisan#prompting-for-input" rel="nofollow noreferrer">https://laravel.com/docs/8.x/artisan#prompting-for-input</a>)</p>
<p>I haven't been able to find any ... | [
{
"answer_id": 395107,
"author": "Robert Gres",
"author_id": 146551,
"author_profile": "https://wordpress.stackexchange.com/users/146551",
"pm_score": 1,
"selected": false,
"text": "<p>I didn't find any wp-cli utility either, but <code>readline</code> php function works just fine.</p>\n<... | 2020/12/09 | [
"https://wordpress.stackexchange.com/questions/379556",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50042/"
] | I am missing some feature to prompt the user for input. In Laravel we have `$this->ask('What is your age')` (<https://laravel.com/docs/8.x/artisan#prompting-for-input>)
I haven't been able to find any information on this online | There's the [global parameter](https://make.wordpress.org/cli/handbook/references/config/)
```
--prompt[=<assoc>]
```
>
> Prompt the user to enter values for all command arguments, or a subset
> specified as comma-separated values.
>
>
>
Example - Prompting two arguments
---------------------------------
We ca... |
379,560 | <p>I am using custom php code to perform data insertion, deletion, updating and other tasks. I am able to insert data into a table in two different ways,</p>
<pre><code>$wpdb->insert($table_name, array('id' => NULL, 'name' => '$name', 'email' => '$email', 'city' => '$city'));
</code></pre>
<p>and</p>
<pr... | [
{
"answer_id": 379565,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n<p>Is it a good practice to use wpdb->query() function each time by passing my query to the fu... | 2020/12/09 | [
"https://wordpress.stackexchange.com/questions/379560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198772/"
] | I am using custom php code to perform data insertion, deletion, updating and other tasks. I am able to insert data into a table in two different ways,
```
$wpdb->insert($table_name, array('id' => NULL, 'name' => '$name', 'email' => '$email', 'city' => '$city'));
```
and
```
$sql = "INSERT INTO $table_name VALUES(''... | If you look a bit into the source, you'll see that `$wpdb->insert()` will use [`->query()` under the hood](https://core.trac.wordpress.org/browser/tags/5.6/src/wp-includes/wp-db.php#L2282). So should be the same, right?
Not that simple. It doesn't just use `->query()` but also [`->prepare()`](https://developer.wordpre... |
379,612 | <p>Following up on <a href="https://wordpress.stackexchange.com/q/326959/32946">this question</a>, I want to remove some of the default (core) embed blocks in the WordPress block editor. As of WordPress 5.6, the blocks are no longer available under the <code>core-embed/*</code> namespace.</p>
<p>How can I unregister in... | [
{
"answer_id": 379613,
"author": "Sven",
"author_id": 32946,
"author_profile": "https://wordpress.stackexchange.com/users/32946",
"pm_score": 5,
"selected": true,
"text": "<p>With WordPress 5.6 (<a href=\"https://github.com/WordPress/gutenberg/releases/tag/v8.8.0\" rel=\"nofollow norefer... | 2020/12/10 | [
"https://wordpress.stackexchange.com/questions/379612",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32946/"
] | Following up on [this question](https://wordpress.stackexchange.com/q/326959/32946), I want to remove some of the default (core) embed blocks in the WordPress block editor. As of WordPress 5.6, the blocks are no longer available under the `core-embed/*` namespace.
How can I unregister individual core embed blocks? | With WordPress 5.6 ([Gutenberg v8.8.0](https://github.com/WordPress/gutenberg/releases/tag/v8.8.0)), the implementation of the `core-embed/*` blocks changed (see pull request [#24090](https://github.com/WordPress/gutenberg/pull/24090): Refactor embed block to single block with block variations). There are now 43 blocks... |
379,614 | <p>I want to show users password on the admin profile page. I mean admin can see the other user password. I am using this code. but it shows a password for all user!</p>
<pre class="lang-php prettyprint-override"><code>add_action('show_user_profile', 'extra_user_profile_fields');
add_action('edit_user_profile', 'extra_... | [
{
"answer_id": 379616,
"author": "MMK",
"author_id": 148207,
"author_profile": "https://wordpress.stackexchange.com/users/148207",
"pm_score": 0,
"selected": false,
"text": "<p>I think you cannot get a user password by default as it is stored in a hashed format.\nHowever, you can check t... | 2020/12/10 | [
"https://wordpress.stackexchange.com/questions/379614",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149802/"
] | I want to show users password on the admin profile page. I mean admin can see the other user password. I am using this code. but it shows a password for all user!
```php
add_action('show_user_profile', 'extra_user_profile_fields');
add_action('edit_user_profile', 'extra_user_profile_fields');
function extra_user_... | This cannot be done, it is not possible, and it would be an awful thing to do if it was. Do not attempt or pursue this.
Why It Is Not Possible
----------------------
Passwords are ran through a 1 way hashing function before being stored in the database. This allows us to check if a password matches but we can't undo ... |
379,812 | <p>Heyho,</p>
<p>I've got a problem getting the post_status of a WP_PostObject which is a Woocommerce-Product.
I get all products doing this query:</p>
<pre><code>$onlineShopProducts = get_posts([
'post_type' => ['product', 'product_variation'],
'orderby' => 'post_title',
'orde... | [
{
"answer_id": 379616,
"author": "MMK",
"author_id": 148207,
"author_profile": "https://wordpress.stackexchange.com/users/148207",
"pm_score": 0,
"selected": false,
"text": "<p>I think you cannot get a user password by default as it is stored in a hashed format.\nHowever, you can check t... | 2020/12/14 | [
"https://wordpress.stackexchange.com/questions/379812",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186068/"
] | Heyho,
I've got a problem getting the post\_status of a WP\_PostObject which is a Woocommerce-Product.
I get all products doing this query:
```
$onlineShopProducts = get_posts([
'post_type' => ['product', 'product_variation'],
'orderby' => 'post_title',
'order' => 'ASC',
... | This cannot be done, it is not possible, and it would be an awful thing to do if it was. Do not attempt or pursue this.
Why It Is Not Possible
----------------------
Passwords are ran through a 1 way hashing function before being stored in the database. This allows us to check if a password matches but we can't undo ... |
379,824 | <p>I want to paginate through all users in a WP site in groups of 100. The code below is a simplified version:</p>
<pre><code>for($offset = 0; $offset < 100; $offset++)
$args = ["number" => 100, 'orderby' => 'ID'];
$args['offset'] = ($offset - 1) * (int) $args['number'];
$users = get_u... | [
{
"answer_id": 379825,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Your problem is a basic PHP problem. You're only looping over the even numbers, 0, 2, 4, 6</p>\n<p>This is b... | 2020/12/14 | [
"https://wordpress.stackexchange.com/questions/379824",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112964/"
] | I want to paginate through all users in a WP site in groups of 100. The code below is a simplified version:
```
for($offset = 0; $offset < 100; $offset++)
$args = ["number" => 100, 'orderby' => 'ID'];
$args['offset'] = ($offset - 1) * (int) $args['number'];
$users = get_users($args);
//Do Stuff wit... | Your problem is a basic PHP problem. You're only looping over the even numbers, 0, 2, 4, 6
This is because at the end of every loop `$offset` increases by 1:
```php
for($offset = 0; $offset < 100; $offset++)
```
But then for some reason it also gets incremented before the loop ends:
```php
$offset++;
```
So offs... |
379,856 | <p>we can use</p>
<pre><code>$user = wp_get_current_user();
if ( !in_array( 'administrator', (array) $user->roles ) )
</code></pre>
<p>to get the user role of the viewer. but i want to ignore who views. i want to get who writes the post. need something like</p>
<pre><code>$user = wp_get_post_author();
if ( !... | [
{
"answer_id": 379864,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 1,
"selected": false,
"text": "<p>You can find the author's ID on the post and fetch their user object from that with get_userdata(), e.g.</p>\n<pre ... | 2020/12/15 | [
"https://wordpress.stackexchange.com/questions/379856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198121/"
] | we can use
```
$user = wp_get_current_user();
if ( !in_array( 'administrator', (array) $user->roles ) )
```
to get the user role of the viewer. but i want to ignore who views. i want to get who writes the post. need something like
```
$user = wp_get_post_author();
if ( !in_array( 'administrator', (array) $u... | You can find the author's ID on the post and fetch their user object from that with get\_userdata(), e.g.
```php
$author = get_userdata( get_post()->post_author ) ;
if ( !in_array( 'administrator', (array) $author->roles ) ) { ... }
``` |
379,861 | <p>Do any of you know a way to check if the current page is the permalink admin page?</p>
| [
{
"answer_id": 379865,
"author": "Bunty",
"author_id": 109377,
"author_profile": "https://wordpress.stackexchange.com/users/109377",
"pm_score": 1,
"selected": false,
"text": "<p>Try below lines into your function.</p>\n<pre><code>global $pagenow;\necho $pagenow; // This should give you ... | 2020/12/15 | [
"https://wordpress.stackexchange.com/questions/379861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199010/"
] | Do any of you know a way to check if the current page is the permalink admin page? | ```
<?php
// 'current_screen' action fires after the current screen has been set
add_action( 'current_screen', 'my_check_current_screen' );
// $current_screen is WP_Screen object passed by the 'current_screen' action
function my_check_current_screen( $current_screen ) {
// compare current screen ID to the string ... |
379,870 | <p>I have installed different sites through my admin panel as below screenshot.</p>
<p><a href="https://i.stack.imgur.com/k9XKD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k9XKD.png" alt="enter image description here" /></a></p>
<p>But when I click any of the menus of My Sites it is redirected to... | [
{
"answer_id": 379945,
"author": "phatskat",
"author_id": 20143,
"author_profile": "https://wordpress.stackexchange.com/users/20143",
"pm_score": 0,
"selected": false,
"text": "<p>In your database, check the values of the options in <code>wp_options</code>. I haven't used multisite in a ... | 2020/12/15 | [
"https://wordpress.stackexchange.com/questions/379870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/185810/"
] | I have installed different sites through my admin panel as below screenshot.
[](https://i.stack.imgur.com/k9XKD.png)
But when I click any of the menus of My Sites it is redirected to the wrong URL like,
* `https://www.example.comwp-admin/netowrd` in... | I just hit this issue as well and realised I had:
```
define( 'PATH_CURRENT_SITE', '' );
```
in one of my configs and it should've been:
```
define( 'PATH_CURRENT_SITE', '/' );
``` |
379,894 | <p>I created a Gutenberg block but after saving it and going back into the post I receive this error:</p>
<blockquote>
<p>This block contains unexpected or invalid content</p>
</blockquote>
<p>I couldn't find any inconsistencies and I had a friend also take a look over to see if there was anything amiss. What am I doin... | [
{
"answer_id": 379899,
"author": "Eugene Poluhovich",
"author_id": 197239,
"author_profile": "https://wordpress.stackexchange.com/users/197239",
"pm_score": 1,
"selected": false,
"text": "<p>You can check the WordPress Core file source and try to understand why this error appears, just s... | 2020/12/15 | [
"https://wordpress.stackexchange.com/questions/379894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114269/"
] | I created a Gutenberg block but after saving it and going back into the post I receive this error:
>
> This block contains unexpected or invalid content
>
>
>
I couldn't find any inconsistencies and I had a friend also take a look over to see if there was anything amiss. What am I doing wrong?
```
registerBlockT... | The main issue in your code is with these two attributes which use the exact same selector (the *first* `span` element in your block content):
```js
checkListItemOne: {
type: 'string',
source: 'html',
selector: 'span' // same as below
},
checkListItemTwo: {
type: 'string',
source: 'html',
selec... |
380,062 | <p>Please guys</p>
<p>I need help on how to remove special characters in POST TITLE -</p>
<p>Certain SYMBOLS LIKE < > { }</p>
<p>Please Note: I am a beginner coder, kindly make the solution very simple for me to understand</p>
| [
{
"answer_id": 379899,
"author": "Eugene Poluhovich",
"author_id": 197239,
"author_profile": "https://wordpress.stackexchange.com/users/197239",
"pm_score": 1,
"selected": false,
"text": "<p>You can check the WordPress Core file source and try to understand why this error appears, just s... | 2020/12/18 | [
"https://wordpress.stackexchange.com/questions/380062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/181855/"
] | Please guys
I need help on how to remove special characters in POST TITLE -
Certain SYMBOLS LIKE < > { }
Please Note: I am a beginner coder, kindly make the solution very simple for me to understand | The main issue in your code is with these two attributes which use the exact same selector (the *first* `span` element in your block content):
```js
checkListItemOne: {
type: 'string',
source: 'html',
selector: 'span' // same as below
},
checkListItemTwo: {
type: 'string',
source: 'html',
selec... |
380,078 | <p>I am trying to work on my child theme, but I can't get rid of the <code>filemtime(): stat failed</code> warning, which appeared as soon as I activated my child theme.
After reading other questions, I understand that the filemtime warning is often caused by incorrect use of URLs and paths. However, I think I provided... | [
{
"answer_id": 380080,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": true,
"text": "<p>The problem is in your parent theme. The parent theme is using <code>get_stylesheet_directory()</code> h... | 2020/12/18 | [
"https://wordpress.stackexchange.com/questions/380078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199141/"
] | I am trying to work on my child theme, but I can't get rid of the `filemtime(): stat failed` warning, which appeared as soon as I activated my child theme.
After reading other questions, I understand that the filemtime warning is often caused by incorrect use of URLs and paths. However, I think I provided URLs and path... | The problem is in your parent theme. The parent theme is using `get_stylesheet_directory()` here:
```
filemtime(get_stylesheet_directory() . '/dist/css/custom-style.css'),
```
When the parent theme is active, that's fine, because `get_stylesheet_directory()` will point that file in the parent theme. The problem is t... |
380,083 | <p>How do I get the parent theme's version in a child theme?</p>
<p>I want to use it when loading the parent theme's stylesheet.</p>
<p>Here's how I load the stylesheets in the child theme's <code>functions.php</code> file:</p>
<pre><code>function sometheme_enqueue_styles() {
// Get parent theme version
$parent_th... | [
{
"answer_id": 380087,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 4,
"selected": true,
"text": "<p>In the <a href=\"https://developer.wordpress.org/reference/classes/wp_theme/\" rel=\"noreferrer\">WP_Theme class<... | 2020/12/18 | [
"https://wordpress.stackexchange.com/questions/380083",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105316/"
] | How do I get the parent theme's version in a child theme?
I want to use it when loading the parent theme's stylesheet.
Here's how I load the stylesheets in the child theme's `functions.php` file:
```
function sometheme_enqueue_styles() {
// Get parent theme version
$parent_theme_version = wp_get_theme()->parent... | In the [WP\_Theme class](https://developer.wordpress.org/reference/classes/wp_theme/), the `get` method gives you a sanitized theme header. You cannot use it to extract a property. Actually you don't need to, as you can access it directly like this:
```
// get the parent object
$parent = wp_get_theme()->parent();
/... |
380,086 | <p>I am trying to insert some php code to my WordPress website but it gives security warnings perhaps due to directly accessing <code>$_POST</code> variable.</p>
<p>Instead of <code>$name = $_POST['name'];</code>, I can use <code>$name = filter_input(INPUT_POST, 'name');</code> however I am not able to figure out what ... | [
{
"answer_id": 380091,
"author": "phatskat",
"author_id": 20143,
"author_profile": "https://wordpress.stackexchange.com/users/20143",
"pm_score": 2,
"selected": true,
"text": "<p><code>filter_input</code> is the proper way to go. If it doesn't return anything valid, it will return <code>... | 2020/12/18 | [
"https://wordpress.stackexchange.com/questions/380086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198772/"
] | I am trying to insert some php code to my WordPress website but it gives security warnings perhaps due to directly accessing `$_POST` variable.
Instead of `$name = $_POST['name'];`, I can use `$name = filter_input(INPUT_POST, 'name');` however I am not able to figure out what alternative piece of code I should use ins... | `filter_input` is the proper way to go. If it doesn't return anything valid, it will return `null`:
```php
$myvar = filter_input( INPUT_POST, 'something', FILTER_SANITIZE_STRING );
if ( empty( $myvar ) ) {
// Do whatever you would have done for ! isset( $_POST['something'] )
}
// Use $myvar
```
`filter_input`... |
380,225 | <p>A while back I stumbled across this post from 2015, that showed how to <a href="https://wisdmlabs.com/blog/add-buttons-menu-options-tinymce-wordpress-post-editor/" rel="nofollow noreferrer">add Tiny MCE-buttons</a>.</p>
<p>It has been working for more than a year. But after the latest WordPress update (to version 5.... | [
{
"answer_id": 383577,
"author": "Justin Roy",
"author_id": 202095,
"author_profile": "https://wordpress.stackexchange.com/users/202095",
"pm_score": 1,
"selected": false,
"text": "<p>This exact thing was happening to me after updating. It seems to be an issue with the new version of Wor... | 2020/12/21 | [
"https://wordpress.stackexchange.com/questions/380225",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128304/"
] | A while back I stumbled across this post from 2015, that showed how to [add Tiny MCE-buttons](https://wisdmlabs.com/blog/add-buttons-menu-options-tinymce-wordpress-post-editor/).
It has been working for more than a year. But after the latest WordPress update (to version 5.6) it stopped working (the added dropdown-butt... | This exact thing was happening to me after updating. It seems to be an issue with the new version of WordPress not including jquery-migrate.js by default.
I'm not sure on a permanent solution, but installing this plugin has temporarily fixed the issue for me: <https://wordpress.org/plugins/enable-jquery-migrate-helper... |
380,285 | <p>I have a private custom plugin that I just use on my multiple sites, and since I do a lot of debugging I find it easier to include the wp-config.php file contents in the admin area to ensure I have enabled/disabled debugging properly. Now I am training other designers to help with debugging, so I want to include lin... | [
{
"answer_id": 380289,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps something like:</p>\n<pre class=\"lang-php prettyprint-override\"><code>if ( $wp_config ) { \n... | 2020/12/22 | [
"https://wordpress.stackexchange.com/questions/380285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42925/"
] | I have a private custom plugin that I just use on my multiple sites, and since I do a lot of debugging I find it easier to include the wp-config.php file contents in the admin area to ensure I have enabled/disabled debugging properly. Now I am training other designers to help with debugging, so I want to include line n... | With the help of Q Studio and my own research, I found that exploding with PHP\_EOL worked. Here is my modified code:
```
function eriWpConfig(){
$wp_config = FALSE;
if ( is_readable( ABSPATH . 'wp-config.php' ) )
$wp_config = ABSPATH . 'wp-config.php';
elseif ( is_readable( dirname( ABSPATH ) . '/... |
380,299 | <p>Hello I have create a custom taxonomy for a custom post. I want to get the taxonomy term that is used in the current post. How to get it.</p>
| [
{
"answer_id": 380289,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps something like:</p>\n<pre class=\"lang-php prettyprint-override\"><code>if ( $wp_config ) { \n... | 2020/12/23 | [
"https://wordpress.stackexchange.com/questions/380299",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199341/"
] | Hello I have create a custom taxonomy for a custom post. I want to get the taxonomy term that is used in the current post. How to get it. | With the help of Q Studio and my own research, I found that exploding with PHP\_EOL worked. Here is my modified code:
```
function eriWpConfig(){
$wp_config = FALSE;
if ( is_readable( ABSPATH . 'wp-config.php' ) )
$wp_config = ABSPATH . 'wp-config.php';
elseif ( is_readable( dirname( ABSPATH ) . '/... |
380,346 | <p>I have set up WordPress on my computer, installed in /var/www/localhost/htdocs and eventually got the admin page and entered a username and a password.</p>
<p>This is my wp-config.php (I have taken out the MySQL password and the longer comments):</p>
<pre><code>/** The name of the database for WordPress */
define( '... | [
{
"answer_id": 380289,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps something like:</p>\n<pre class=\"lang-php prettyprint-override\"><code>if ( $wp_config ) { \n... | 2020/12/23 | [
"https://wordpress.stackexchange.com/questions/380346",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199384/"
] | I have set up WordPress on my computer, installed in /var/www/localhost/htdocs and eventually got the admin page and entered a username and a password.
This is my wp-config.php (I have taken out the MySQL password and the longer comments):
```
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpres... | With the help of Q Studio and my own research, I found that exploding with PHP\_EOL worked. Here is my modified code:
```
function eriWpConfig(){
$wp_config = FALSE;
if ( is_readable( ABSPATH . 'wp-config.php' ) )
$wp_config = ABSPATH . 'wp-config.php';
elseif ( is_readable( dirname( ABSPATH ) . '/... |
380,353 | <p>In Wordpress I need to add a filter where user role subscriber just put his email address in form to login, no need for password, just check if the email is for a subscriber and redirect him to a specific page, I tried many solutions but I didn't get it,
Thanks</p>
| [
{
"answer_id": 380358,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 1,
"selected": true,
"text": "<p>Yes, you can add an <a href=\"https://developer.wordpress.org/reference/hooks/authenticate/\" rel=\"nofollow norefer... | 2020/12/23 | [
"https://wordpress.stackexchange.com/questions/380353",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199390/"
] | In Wordpress I need to add a filter where user role subscriber just put his email address in form to login, no need for password, just check if the email is for a subscriber and redirect him to a specific page, I tried many solutions but I didn't get it,
Thanks | Yes, you can add an [authenticate](https://developer.wordpress.org/reference/hooks/authenticate/) filter to handle the email and no password case with a higher priority than the default wp\_authenticate\_email\_password handler. e.g. (untested)
```php
function wpse_380353_authenticate_email_no_password( $user, $email,... |
380,367 | <p>I have a separate page at the root of WordPress, for processing certain data, with the "wp-load.php" file connected to it.</p>
<pre><code><?php
require_once( dirname(__FILE__) . '/wp-load.php' );
require_once( dirname(__FILE__) . '/wp-admin/includes/admin.php' );
add_action( 'wp_ajax_example_aja... | [
{
"answer_id": 380358,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 1,
"selected": true,
"text": "<p>Yes, you can add an <a href=\"https://developer.wordpress.org/reference/hooks/authenticate/\" rel=\"nofollow norefer... | 2020/12/24 | [
"https://wordpress.stackexchange.com/questions/380367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/195858/"
] | I have a separate page at the root of WordPress, for processing certain data, with the "wp-load.php" file connected to it.
```
<?php
require_once( dirname(__FILE__) . '/wp-load.php' );
require_once( dirname(__FILE__) . '/wp-admin/includes/admin.php' );
add_action( 'wp_ajax_example_ajax_request', 'example_ajax_... | Yes, you can add an [authenticate](https://developer.wordpress.org/reference/hooks/authenticate/) filter to handle the email and no password case with a higher priority than the default wp\_authenticate\_email\_password handler. e.g. (untested)
```php
function wpse_380353_authenticate_email_no_password( $user, $email,... |
380,408 | <p>If I try to change my email address, it will say it has sent a confirmation email to the new email address. But, I do not see any email request to that email.</p>
<p>Is there a way to troubleshoot this or understand the error?</p>
| [
{
"answer_id": 380358,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 1,
"selected": true,
"text": "<p>Yes, you can add an <a href=\"https://developer.wordpress.org/reference/hooks/authenticate/\" rel=\"nofollow norefer... | 2020/12/24 | [
"https://wordpress.stackexchange.com/questions/380408",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199437/"
] | If I try to change my email address, it will say it has sent a confirmation email to the new email address. But, I do not see any email request to that email.
Is there a way to troubleshoot this or understand the error? | Yes, you can add an [authenticate](https://developer.wordpress.org/reference/hooks/authenticate/) filter to handle the email and no password case with a higher priority than the default wp\_authenticate\_email\_password handler. e.g. (untested)
```php
function wpse_380353_authenticate_email_no_password( $user, $email,... |
380,430 | <p>Hi all and happy holidays!</p>
<p>I have a page on which I enabled threaded commenting. At present, the comments are ordered new to old by when the thread started:</p>
<pre><code>-Comment 3
-Comment 2
-Comment 5
-Comment 1
-Comment 4
</code></pre>
<p>Actually, I want the last active thread to be the first, in su... | [
{
"answer_id": 380358,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 1,
"selected": true,
"text": "<p>Yes, you can add an <a href=\"https://developer.wordpress.org/reference/hooks/authenticate/\" rel=\"nofollow norefer... | 2020/12/25 | [
"https://wordpress.stackexchange.com/questions/380430",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20349/"
] | Hi all and happy holidays!
I have a page on which I enabled threaded commenting. At present, the comments are ordered new to old by when the thread started:
```
-Comment 3
-Comment 2
-Comment 5
-Comment 1
-Comment 4
```
Actually, I want the last active thread to be the first, in such a way that the listing woul... | Yes, you can add an [authenticate](https://developer.wordpress.org/reference/hooks/authenticate/) filter to handle the email and no password case with a higher priority than the default wp\_authenticate\_email\_password handler. e.g. (untested)
```php
function wpse_380353_authenticate_email_no_password( $user, $email,... |
380,477 | <p>I'm trying to do a super simple block with two rich text areas - description and custom cta button. The button is saved with SVG inside, everything seems ok, but when I refresh the edited post, it sreams following:</p>
<pre><code>Content generated by `save` function:
<div class="wp-block-avmc-cta">&... | [
{
"answer_id": 380479,
"author": "demopix",
"author_id": 174561,
"author_profile": "https://wordpress.stackexchange.com/users/174561",
"pm_score": -1,
"selected": false,
"text": "<p>I think you need thinking about send open and close tag using HTML Entities\n(<code>&lt;</code>) inste... | 2020/12/27 | [
"https://wordpress.stackexchange.com/questions/380477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64771/"
] | I'm trying to do a super simple block with two rich text areas - description and custom cta button. The button is saved with SVG inside, everything seems ok, but when I refresh the edited post, it sreams following:
```
Content generated by `save` function:
<div class="wp-block-avmc-cta"><p class="wp-block-avmc-cta_la... | I was playing around with a couple of more hours it and it seems that type "text" is not equal to inner text, it still grabs innerHTML kind of encoded to entities. I've found that out, but forgot to filter it in the save function, which hasn't had an impact on saving (as expected, since the value was from the input fie... |
380,513 | <p>In the documentation for <a href="https://developer.wordpress.org/rest-api/reference/posts/" rel="nofollow noreferrer">/posts for WordPress REST API</a> it states that I can add a <code>meta</code>-field. But it doesn't say which format that should be in.</p>
<p>I can find <a href="https://stackoverflow.com/a/565089... | [
{
"answer_id": 380479,
"author": "demopix",
"author_id": 174561,
"author_profile": "https://wordpress.stackexchange.com/users/174561",
"pm_score": -1,
"selected": false,
"text": "<p>I think you need thinking about send open and close tag using HTML Entities\n(<code>&lt;</code>) inste... | 2020/12/28 | [
"https://wordpress.stackexchange.com/questions/380513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128304/"
] | In the documentation for [/posts for WordPress REST API](https://developer.wordpress.org/rest-api/reference/posts/) it states that I can add a `meta`-field. But it doesn't say which format that should be in.
I can find [other guides](https://stackoverflow.com/a/56508996/1766219) showing how it should be if using Postm... | I was playing around with a couple of more hours it and it seems that type "text" is not equal to inner text, it still grabs innerHTML kind of encoded to entities. I've found that out, but forgot to filter it in the save function, which hasn't had an impact on saving (as expected, since the value was from the input fie... |
380,527 | <p>i want to disable, hide or remove delete buttons from category page</p>
<p><a href="https://i.stack.imgur.com/DuEcr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DuEcr.png" alt="enter image description here" /></a></p>
<p>I tried editing functions.php with no luck:</p>
<pre><code>add_action('adm... | [
{
"answer_id": 380479,
"author": "demopix",
"author_id": 174561,
"author_profile": "https://wordpress.stackexchange.com/users/174561",
"pm_score": -1,
"selected": false,
"text": "<p>I think you need thinking about send open and close tag using HTML Entities\n(<code>&lt;</code>) inste... | 2020/12/28 | [
"https://wordpress.stackexchange.com/questions/380527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199552/"
] | i want to disable, hide or remove delete buttons from category page
[](https://i.stack.imgur.com/DuEcr.png)
I tried editing functions.php with no luck:
```
add_action('admin_head', 'hide_category_buttons');
function hide_category_buttons() {
echo... | I was playing around with a couple of more hours it and it seems that type "text" is not equal to inner text, it still grabs innerHTML kind of encoded to entities. I've found that out, but forgot to filter it in the save function, which hasn't had an impact on saving (as expected, since the value was from the input fie... |
380,548 | <p>After a malware attack I am trying to replace a malicious call entries. I keep getting syntax errors due to the configuration of the link. Tried all of the various escape characters to now avail. Familiar with normal find and replace but due to unique code in links <code>update _DVB_posts set post_content = replace... | [
{
"answer_id": 380479,
"author": "demopix",
"author_id": 174561,
"author_profile": "https://wordpress.stackexchange.com/users/174561",
"pm_score": -1,
"selected": false,
"text": "<p>I think you need thinking about send open and close tag using HTML Entities\n(<code>&lt;</code>) inste... | 2020/12/29 | [
"https://wordpress.stackexchange.com/questions/380548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199566/"
] | After a malware attack I am trying to replace a malicious call entries. I keep getting syntax errors due to the configuration of the link. Tried all of the various escape characters to now avail. Familiar with normal find and replace but due to unique code in links `update _DVB_posts set post_content = replace(post_con... | I was playing around with a couple of more hours it and it seems that type "text" is not equal to inner text, it still grabs innerHTML kind of encoded to entities. I've found that out, but forgot to filter it in the save function, which hasn't had an impact on saving (as expected, since the value was from the input fie... |
380,568 | <p>I'm trying to match users' data in multiple wordpress applications, so when user created on one app the same user should be created on the other apps.
Here is the problem, I need to get the new created user plain password (outside of wordpress core) before being inserted on one of my apps so that I could insert this... | [
{
"answer_id": 380479,
"author": "demopix",
"author_id": 174561,
"author_profile": "https://wordpress.stackexchange.com/users/174561",
"pm_score": -1,
"selected": false,
"text": "<p>I think you need thinking about send open and close tag using HTML Entities\n(<code>&lt;</code>) inste... | 2020/12/29 | [
"https://wordpress.stackexchange.com/questions/380568",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199583/"
] | I'm trying to match users' data in multiple wordpress applications, so when user created on one app the same user should be created on the other apps.
Here is the problem, I need to get the new created user plain password (outside of wordpress core) before being inserted on one of my apps so that I could insert this us... | I was playing around with a couple of more hours it and it seems that type "text" is not equal to inner text, it still grabs innerHTML kind of encoded to entities. I've found that out, but forgot to filter it in the save function, which hasn't had an impact on saving (as expected, since the value was from the input fie... |
380,584 | <p>I've got a custom theme I build using an underscores starter theme. Inside one of my template files (page-talent.php) I've got this jQuery ajax function:</p>
<pre><code> $.ajax({
type: 'POST',
url: '<?php echo admin_url('admin-ajax.php');?>',
dataType: "html", // add d... | [
{
"answer_id": 380586,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 1,
"selected": false,
"text": "<p>Add this all to your theme functions.php file and try again..</p>\n"
},
{
"answer_id": 380587,
"au... | 2020/12/29 | [
"https://wordpress.stackexchange.com/questions/380584",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94432/"
] | I've got a custom theme I build using an underscores starter theme. Inside one of my template files (page-talent.php) I've got this jQuery ajax function:
```
$.ajax({
type: 'POST',
url: '<?php echo admin_url('admin-ajax.php');?>',
dataType: "html", // add data type
// data: { ... | You should never edit any files in the wp-admin directory. All ajax related to your theme, should be inside your theme directory. You can place your PHP code in any file, functions.php, or include some new file there you will retrive only ajax cals, that will be better. |
380,618 | <p>I am working on a simple plugin that shows an HTML form where the user can input a keyword which is used to query an external API. I currently have the form and the related jQuery set up, but when passed to the plugin's PHP file, I get a response of simply 0. At this point I'm only just trying to get any response bu... | [
{
"answer_id": 380619,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>check_ajax_referer()</code> function will <code>die()</code> if the check fails, which is why... | 2020/12/30 | [
"https://wordpress.stackexchange.com/questions/380618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199623/"
] | I am working on a simple plugin that shows an HTML form where the user can input a keyword which is used to query an external API. I currently have the form and the related jQuery set up, but when passed to the plugin's PHP file, I get a response of simply 0. At this point I'm only just trying to get any response but 0... | your ajax post callable function action "**get\_news\_callback**" not working in your Class \_\_construct() becuase You Can use simple Wordpress action in the class.
Use Action In The Class :
>
> add\_action('wp\_ajax\_get\_news\_callback', array($this,
> 'get\_news\_callback'));
> add\_action('wp\_ajax\_nopriv\_get... |
380,686 | <p>I want to display a count of items in my header, a count of how many items are in the current category...</p>
<p>Example:
User goes to "T Shirts" > in the header it says "20 Items" --- They go to "Hoodies" > Header says "10 Items"</p>
<p>I'm currently using a shortcode a... | [
{
"answer_id": 380619,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>check_ajax_referer()</code> function will <code>die()</code> if the check fails, which is why... | 2020/12/31 | [
"https://wordpress.stackexchange.com/questions/380686",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104841/"
] | I want to display a count of items in my header, a count of how many items are in the current category...
Example:
User goes to "T Shirts" > in the header it says "20 Items" --- They go to "Hoodies" > Header says "10 Items"
I'm currently using a shortcode and code in functions.php:
```php
add_shortcode( 'products-co... | your ajax post callable function action "**get\_news\_callback**" not working in your Class \_\_construct() becuase You Can use simple Wordpress action in the class.
Use Action In The Class :
>
> add\_action('wp\_ajax\_get\_news\_callback', array($this,
> 'get\_news\_callback'));
> add\_action('wp\_ajax\_nopriv\_get... |
380,708 | <p>I try to update data through ajax, but it not worked. What I did wrong?
Here is jquery ajax code</p>
<p>php code in functions.php</p>
<pre><code>function update_records(){
global $wpdb;
echo $id = $_POST['update_record'];
$db_updated = $wpdb->update( $wpdb->prefix.'contact_form',
array('names... | [
{
"answer_id": 380714,
"author": "Had1z",
"author_id": 180121,
"author_profile": "https://wordpress.stackexchange.com/users/180121",
"pm_score": 3,
"selected": true,
"text": "<p>First of all, in your jquery event handler the <code>action</code> parameter's value should be the string afte... | 2020/12/31 | [
"https://wordpress.stackexchange.com/questions/380708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/196459/"
] | I try to update data through ajax, but it not worked. What I did wrong?
Here is jquery ajax code
php code in functions.php
```
function update_records(){
global $wpdb;
echo $id = $_POST['update_record'];
$db_updated = $wpdb->update( $wpdb->prefix.'contact_form',
array('names' => $_POST['update_nam... | First of all, in your jquery event handler the `action` parameter's value should be the string after `wp_ajax_` and `wp_ajax_nopriv_`. So in your example the `action` should be `update_records`. So `display_func` is wrong.
Then in line 3 of your php code here the `echo` keyword should be removed.
So your php code... |
380,725 | <p>I am trying to add the current custom post type term to the body class of my WordPress admin page. So when I am viewing an existing custom post type that has been assigned a term it will add that term to the body class.</p>
<p>I have found the following code but cannot get it to work for me:</p>
<pre><code>add_filt... | [
{
"answer_id": 380730,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 3,
"selected": true,
"text": "<p>I think you're missing <a href=\"https://developer.wordpress.org/reference/classes/wp_screen/\" rel=\"nofollow n... | 2020/12/31 | [
"https://wordpress.stackexchange.com/questions/380725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68283/"
] | I am trying to add the current custom post type term to the body class of my WordPress admin page. So when I am viewing an existing custom post type that has been assigned a term it will add that term to the body class.
I have found the following code but cannot get it to work for me:
```
add_filter( 'admin_body_clas... | I think you're missing [`get_current_screen()`](https://developer.wordpress.org/reference/classes/wp_screen/).
```
add_filter( 'admin_body_class', 'rw_admin_body_class' );
function rw_admin_body_class( $classes ) {
$screen = get_current_screen();
if ( 'post' != $screen->base ) {
return $classes;
}
... |
380,749 | <p><a href="https://i.stack.imgur.com/uJJJQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uJJJQ.png" alt="enter image description here" /></a>I have added an image through advanced custom field. I want to retrieve image URL. I have tried with following code. It is returning null.</p>
<pre><code> $u... | [
{
"answer_id": 380750,
"author": "HK89",
"author_id": 179278,
"author_profile": "https://wordpress.stackexchange.com/users/179278",
"pm_score": 2,
"selected": true,
"text": "<p>Refer ACF link : <a href=\"https://www.advancedcustomfields.com/resources/image/\" rel=\"nofollow noreferrer\">... | 2021/01/01 | [
"https://wordpress.stackexchange.com/questions/380749",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199720/"
] | [](https://i.stack.imgur.com/uJJJQ.png)I have added an image through advanced custom field. I want to retrieve image URL. I have tried with following code. It is returning null.
```
$url = get_field('aboutus_img','aboutus');
```
aboutus\_img = fiel... | Refer ACF link : [Link](https://www.advancedcustomfields.com/resources/image/)
And use
```
<?php echo get_field('aboutus_img'); ?>
```
Choose option image url
[](https://i.stack.imgur.com/hXPyB.jpg)
This example demonstrates how to display the se... |
380,757 | <p>I'm trying to send an email using <code>wp_mail()</code> through a <code>REST</code> custom route, but it's failing somewhere.</p>
<p>EDIT: I found out where, in "sendContactMail()", <code>$request->get_json_params();</code> returns nothing, although <code>$request</code> contains all my form informatio... | [
{
"answer_id": 380783,
"author": "Zoltan Febert",
"author_id": 110887,
"author_profile": "https://wordpress.stackexchange.com/users/110887",
"pm_score": 0,
"selected": false,
"text": "<p>I tried to simulate what you did in my test environment.</p>\n<p>When I made the AJAX call like this,... | 2021/01/01 | [
"https://wordpress.stackexchange.com/questions/380757",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I'm trying to send an email using `wp_mail()` through a `REST` custom route, but it's failing somewhere.
EDIT: I found out where, in "sendContactMail()", `$request->get_json_params();` returns nothing, although `$request` contains all my form information. What's the right way to extract this information then?
```
// ... | *You didn't include the code for your `send_email()` function, but I looked at the original [source](https://wordpress.stackexchange.com/revisions/380757/1) (revision 1) of your question, and it seems to me that your `send_email()` function is good, but if this answer doesn't help solve the issue, then add the function... |
380,760 | <p>How can I make my page url to be like this in wordpress?</p>
<p>Normal link: <a href="http://www.google.com/about" rel="nofollow noreferrer">www.google.com/about</a></p>
<p>What I want: <a href="http://www.google.com/any-slug/about" rel="nofollow noreferrer">www.google.com/any-slug/about</a></p>
<p>How can I do that... | [
{
"answer_id": 380783,
"author": "Zoltan Febert",
"author_id": 110887,
"author_profile": "https://wordpress.stackexchange.com/users/110887",
"pm_score": 0,
"selected": false,
"text": "<p>I tried to simulate what you did in my test environment.</p>\n<p>When I made the AJAX call like this,... | 2021/01/01 | [
"https://wordpress.stackexchange.com/questions/380760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199728/"
] | How can I make my page url to be like this in wordpress?
Normal link: [www.google.com/about](http://www.google.com/about)
What I want: [www.google.com/any-slug/about](http://www.google.com/any-slug/about)
How can I do that? | *You didn't include the code for your `send_email()` function, but I looked at the original [source](https://wordpress.stackexchange.com/revisions/380757/1) (revision 1) of your question, and it seems to me that your `send_email()` function is good, but if this answer doesn't help solve the issue, then add the function... |
380,871 | <p>I am currently developing a theme which provides more customization in Customizer. I am trying to add color control option and it is not working. This is my code.</p>
<pre><code>/* Color Section */
$wp_customize -> add_setting( 'navbar_color', array(
'default' => '#45ace0',
) );
$wp_c... | [
{
"answer_id": 380879,
"author": "HK89",
"author_id": 179278,
"author_profile": "https://wordpress.stackexchange.com/users/179278",
"pm_score": 0,
"selected": false,
"text": "<p>According to your needs :</p>\n<p>Register Your Customizer setting , Add Below Code in your functions.php</p>\... | 2021/01/04 | [
"https://wordpress.stackexchange.com/questions/380871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/192486/"
] | I am currently developing a theme which provides more customization in Customizer. I am trying to add color control option and it is not working. This is my code.
```
/* Color Section */
$wp_customize -> add_setting( 'navbar_color', array(
'default' => '#45ace0',
) );
$wp_customize -> add_control... | Finally found the reason. The reason was i enqueued JQuery to my options pages. When i remove JQuery enqueue everything is working fine. Thanks for all the replies. |
380,881 | <p>I am working on SEO for a website.
So, I wanted to append "-coupon-codes" to all category URLs.</p>
<p>My Category Base Slug is : stores</p>
<p>Example what I wanted to achieve redirection :</p>
<pre><code>/stores/walmart to /stores/walmart-coupon-codes
</code></pre>
<p>as stores/walmart is indexed in goog... | [
{
"answer_id": 380885,
"author": "HK89",
"author_id": 179278,
"author_profile": "https://wordpress.stackexchange.com/users/179278",
"pm_score": 0,
"selected": false,
"text": "<p>Put Below Code On .htaccess File ,</p>\n<pre><code><IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBa... | 2021/01/04 | [
"https://wordpress.stackexchange.com/questions/380881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199821/"
] | I am working on SEO for a website.
So, I wanted to append "-coupon-codes" to all category URLs.
My Category Base Slug is : stores
Example what I wanted to achieve redirection :
```
/stores/walmart to /stores/walmart-coupon-codes
```
as stores/walmart is indexed in google, I want to 301 redirect to new url
I tried... | >
>
> ```
> RewriteRule ^stores/(.*)/$ /stores/$1-coupon-codes [R=301,NC,L]
>
> ```
>
>
You can perhaps use a *negative lookahead assertion* to exclude URLs that already contain `-coupon-codes` from being redirected *again*, thus preventing a redirect-loop (which I assume is what's happening here).
For example:
... |
380,938 | <p>In wordpress I am getting error SMTP Error: Could not authenticate.</p>
<p>Here is the log file:</p>
<pre><code>Versions:
WordPress: 5.6
WordPress MS: No
PHP: 7.4.3
WP Mail SMTP: 2.5.1
Params:
Mailer: smtp
Constants: Yes
ErrorInfo: SMTP Error: Could not authenticate.
Host: mail.vitalticks.com
Port: 587
SMTPSecure: ... | [
{
"answer_id": 380943,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<pre><code>Password command failed: 535 Incorrect authentication data\n</code></pre>\n<p>The password is wrong.</... | 2021/01/05 | [
"https://wordpress.stackexchange.com/questions/380938",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190787/"
] | In wordpress I am getting error SMTP Error: Could not authenticate.
Here is the log file:
```
Versions:
WordPress: 5.6
WordPress MS: No
PHP: 7.4.3
WP Mail SMTP: 2.5.1
Params:
Mailer: smtp
Constants: Yes
ErrorInfo: SMTP Error: Could not authenticate.
Host: mail.vitalticks.com
Port: 587
SMTPSecure: tls
SMTPAutoTLS: bo... | our team had enabled two factor authentication for mail so for this reason i am getting error.
after disabling the two factor authentication SMTP is working. |
380,940 | <p><strong>The problem:</strong> whenever I type something in <strong>Advanced->Additional Classes</strong> in Gutenberg editor and save the page/post and refresh, those classes disappear. I logged <strong>props.className</strong> in <code>edit</code> function. It logs the value as expected when I type the class nam... | [
{
"answer_id": 380943,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<pre><code>Password command failed: 535 Incorrect authentication data\n</code></pre>\n<p>The password is wrong.</... | 2021/01/05 | [
"https://wordpress.stackexchange.com/questions/380940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124360/"
] | **The problem:** whenever I type something in **Advanced->Additional Classes** in Gutenberg editor and save the page/post and refresh, those classes disappear. I logged **props.className** in `edit` function. It logs the value as expected when I type the class name in the **Advanced->Additional Classes** field. The pro... | our team had enabled two factor authentication for mail so for this reason i am getting error.
after disabling the two factor authentication SMTP is working. |
381,168 | <p>I am trying to get Pages, Posts and Custom Post Types In WordPress website but it is showing some other things in the list.</p>
<p><strong>My Code:</strong></p>
<pre><code><?php $types = get_post_types( ['public' => true ], 'objects' );
foreach ( $types as $type ) {
if ( isset( $typ... | [
{
"answer_id": 381175,
"author": "Tony Djukic",
"author_id": 60844,
"author_profile": "https://wordpress.stackexchange.com/users/60844",
"pm_score": 4,
"selected": true,
"text": "<p>You can make an array of the post types you don't want and then check <code>in_array()</code> to see if th... | 2021/01/08 | [
"https://wordpress.stackexchange.com/questions/381168",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/172395/"
] | I am trying to get Pages, Posts and Custom Post Types In WordPress website but it is showing some other things in the list.
**My Code:**
```
<?php $types = get_post_types( ['public' => true ], 'objects' );
foreach ( $types as $type ) {
if ( isset( $type->labels->name) ) { ?>
<?php ... | You can make an array of the post types you don't want and then check `in_array()` to see if they match before you output anything with them.
```
<?php
//You'll want to get at the actual name for My Templates.
//My attempt is just a guess.
$types_array = array( 'attachment' , 'elementor_library' );
$ty... |
381,226 | <p>Using Astra theme, I cannot use jQuery on the frontend. It keeps logging <code>Uncaught ReferenceError: jQuery is not defined at VM105:23</code>. It is actually supposed that Wordpress is equipped with jQuery, but I cannot figure out why I get that 'undefined' error message in console.</p>
<p>So as to add jQuery, I ... | [
{
"answer_id": 381229,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p><code>'jquery'</code> is already a registered script in WordPress. Your attempt to enqueue it is failing becaus... | 2021/01/09 | [
"https://wordpress.stackexchange.com/questions/381226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/197920/"
] | Using Astra theme, I cannot use jQuery on the frontend. It keeps logging `Uncaught ReferenceError: jQuery is not defined at VM105:23`. It is actually supposed that Wordpress is equipped with jQuery, but I cannot figure out why I get that 'undefined' error message in console.
So as to add jQuery, I just write the follo... | Special thanks are offered to @Pat J. The problem was actually with the jQuery code I had written.
```
jQuery(document).ready(function() {
// Some Code Goes Here...
})
```
Just take a look at the complete segment:
```
public function doSomethingSpecific() {
?>
<script type="tex... |
381,258 | <p>I have added a custom post type and I want to expose the custom field value in the rest api. As per the docs register_meta can be used.</p>
<p>I have created a custom post meta box using the wordpress way. It works fine but not getting shown in the rest api. I belive that I have to pass array</p>
<p><a href="https:/... | [
{
"answer_id": 381229,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p><code>'jquery'</code> is already a registered script in WordPress. Your attempt to enqueue it is failing becaus... | 2021/01/10 | [
"https://wordpress.stackexchange.com/questions/381258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have added a custom post type and I want to expose the custom field value in the rest api. As per the docs register\_meta can be used.
I have created a custom post meta box using the wordpress way. It works fine but not getting shown in the rest api. I belive that I have to pass array
[![enter image description her... | Special thanks are offered to @Pat J. The problem was actually with the jQuery code I had written.
```
jQuery(document).ready(function() {
// Some Code Goes Here...
})
```
Just take a look at the complete segment:
```
public function doSomethingSpecific() {
?>
<script type="tex... |
381,292 | <p>I'm trying to output the current post categories for my 'portfolio' custom post type as a shortcode.</p>
<p>At the moment I have this snippet in the functions.php</p>
<pre><code> function shows_cats(){
$page_id = get_queried_object_id();
echo '<h6>Categories</h6>';
echo get_the_category_li... | [
{
"answer_id": 381229,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p><code>'jquery'</code> is already a registered script in WordPress. Your attempt to enqueue it is failing becaus... | 2021/01/11 | [
"https://wordpress.stackexchange.com/questions/381292",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200177/"
] | I'm trying to output the current post categories for my 'portfolio' custom post type as a shortcode.
At the moment I have this snippet in the functions.php
```
function shows_cats(){
$page_id = get_queried_object_id();
echo '<h6>Categories</h6>';
echo get_the_category_list('','',$page_id);
}
add... | Special thanks are offered to @Pat J. The problem was actually with the jQuery code I had written.
```
jQuery(document).ready(function() {
// Some Code Goes Here...
})
```
Just take a look at the complete segment:
```
public function doSomethingSpecific() {
?>
<script type="tex... |
381,345 | <p>I've installed Wordpress on a bare Ubuntu20-04 box following <a href="https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-20-04-with-a-lamp-stack" rel="nofollow noreferrer">Digital Ocean's guide</a>.
Now I want to password protect the entire site but as I can't find any plugins that p... | [
{
"answer_id": 381229,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p><code>'jquery'</code> is already a registered script in WordPress. Your attempt to enqueue it is failing becaus... | 2021/01/12 | [
"https://wordpress.stackexchange.com/questions/381345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189230/"
] | I've installed Wordpress on a bare Ubuntu20-04 box following [Digital Ocean's guide](https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-20-04-with-a-lamp-stack).
Now I want to password protect the entire site but as I can't find any plugins that protect uploaded files and images, I'm at... | Special thanks are offered to @Pat J. The problem was actually with the jQuery code I had written.
```
jQuery(document).ready(function() {
// Some Code Goes Here...
})
```
Just take a look at the complete segment:
```
public function doSomethingSpecific() {
?>
<script type="tex... |
381,433 | <p>We have developed a Wordpress plugin to create a reservation engine. We use a shortcode to build the checkout process. This shortcode creates html. We would like to define a sidebar in this generated html so the plugin users can append some content regarding the reservation information.</p>
<p>Is it not a bad practi... | [
{
"answer_id": 381434,
"author": "hrsetyono",
"author_id": 33361,
"author_profile": "https://wordpress.stackexchange.com/users/33361",
"pm_score": 2,
"selected": false,
"text": "<p>There's nothing wrong with registering a sidebar via plugin. You do it the same way as registering via them... | 2021/01/13 | [
"https://wordpress.stackexchange.com/questions/381433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200295/"
] | We have developed a Wordpress plugin to create a reservation engine. We use a shortcode to build the checkout process. This shortcode creates html. We would like to define a sidebar in this generated html so the plugin users can append some content regarding the reservation information.
Is it not a bad practice to add... | There's nothing wrong with registering a sidebar via plugin. You do it the same way as registering via theme:
```php
add_action( 'widgets_init', function() {
register_sidebar([
'name' => 'Your Sidebar',
'id' => 'your-sidebar',
] );
} );
``` |
381,452 | <p>I have two Custom Post Types and would like to display one of them sorted (by title) and the other one at random places in the same query.</p>
<p>So CPT A (sorted) en CPT B (random):</p>
<p>A1 A2 A3 <strong>B2</strong> A4 A5 <strong>B5</strong> A6 A7 A8 A9 <strong>B1</strong> ...<br>
or<br>
A1 <strong>B1</strong> A2... | [
{
"answer_id": 381458,
"author": "burlakvo",
"author_id": 198451,
"author_profile": "https://wordpress.stackexchange.com/users/198451",
"pm_score": 1,
"selected": false,
"text": "<p>Try to get two different arrays of posts and loop through array A. Before get post data of A element get r... | 2021/01/13 | [
"https://wordpress.stackexchange.com/questions/381452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127299/"
] | I have two Custom Post Types and would like to display one of them sorted (by title) and the other one at random places in the same query.
So CPT A (sorted) en CPT B (random):
A1 A2 A3 **B2** A4 A5 **B5** A6 A7 A8 A9 **B1** ...
or
A1 **B1** A2 A3 **B5** A4 A5 A6 A7 A8 A9 **B7** ...
or
**B4** A1 A2 A3 A4 *... | Try to get two different arrays of posts and loop through array A. Before get post data of A element get random element from array B.
For example:
```
$array_a = ['post_id_a1', 'post_id_a2', 'post_id_a3'];
$array_b = ['post_id_b1', 'post_id_b2', 'post_id_b3'];
foreach ( $array_a as $a_post_id ) {
$is_b_should_di... |
381,520 | <p>When writting a description for a Woocoomerce Product and inserting a line break with <strong>br</strong> or <strong>p</strong> Tag, WordPress automatically removes it. This is really annoying because on some points, i want to have a little line break.</p>
<p>I often found the solution to install TinyMCE. After th... | [
{
"answer_id": 381491,
"author": "Tony Djukic",
"author_id": 60844,
"author_profile": "https://wordpress.stackexchange.com/users/60844",
"pm_score": 2,
"selected": false,
"text": "<p>Your site appears to be pretty well structured in most ways and you're getting a good score. If you're s... | 2021/01/14 | [
"https://wordpress.stackexchange.com/questions/381520",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200368/"
] | When writting a description for a Woocoomerce Product and inserting a line break with **br** or **p** Tag, WordPress automatically removes it. This is really annoying because on some points, i want to have a little line break.
I often found the solution to install TinyMCE. After that now WordPress doesnt removes the *... | Your site appears to be pretty well structured in most ways and you're getting a good score. If you're seeing a huge swing day to day, test to test, etc, then it's probably a hosting related issue. What type of hosting are you on? Is it cloud, is it shared, is it WordPress specific?
<https://developers.google.com/spee... |
381,544 | <p>I made custom plugin and done crud operation, display all data in admin page, used ajax and jquery. Data successfully deleted but not inserted or updated. Data successfully pass through ajax but not inserted.
Also What I saw if input block is empty and I put some data and updated it. It got first row data.<br>
Error... | [
{
"answer_id": 381554,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": true,
"text": "<p>I see that there's an <em>internal server error</em> (see <a href=\"https://prnt.sc/wnymkx\" rel=\"nofollow... | 2021/01/15 | [
"https://wordpress.stackexchange.com/questions/381544",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/196459/"
] | I made custom plugin and done crud operation, display all data in admin page, used ajax and jquery. Data successfully deleted but not inserted or updated. Data successfully pass through ajax but not inserted.
Also What I saw if input block is empty and I put some data and updated it. It got first row data.
Error- <h... | I see that there's an *internal server error* (see [screenshot](https://prnt.sc/wnymkx)) when you tried to *update* a record in the database, and the error is likely because you **incorrectly called [`$wpdb->update()`](https://developer.wordpress.org/reference/classes/wpdb/update/)** which has the syntax of — and note ... |
381,553 | <p>how i can enable an specific css code for visitors and an specific user role</p>
<p>for example this code:</p>
<pre class="lang-css prettyprint-override"><code>input[type=radio] {
border: 1px solid !important;
}
</code></pre>
| [
{
"answer_id": 381566,
"author": "d3mi",
"author_id": 200408,
"author_profile": "https://wordpress.stackexchange.com/users/200408",
"pm_score": 0,
"selected": false,
"text": "<p>i tried this code in the functions.php for showing to the guests this css</p>\n<p>how is that possible</p>\n<p... | 2021/01/15 | [
"https://wordpress.stackexchange.com/questions/381553",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200408/"
] | how i can enable an specific css code for visitors and an specific user role
for example this code:
```css
input[type=radio] {
border: 1px solid !important;
}
``` | You can add custom css on your html header using wp\_head hook action & checking your current User Role
```
add_action('wp_head', 'add_css_of_current_specific_user_role');
function add_css_of_current_specific_user_role()
{
/*Check Current User is Login*/
if ( is_user_logged_in() )
{
$user = wp_g... |
381,855 | <p>I have migrated more than 50 websites from Live server to Localhost in my career but have not faced this issue till now.
I used ALL IN ONE WP MIGRATION to export the data from live server.
I replaced the url during export process.</p>
<pre><code>http://www.example.com/ to http://localhost/example/
</code></pre>
<p>I... | [
{
"answer_id": 381671,
"author": "HenrijsS",
"author_id": 177555,
"author_profile": "https://wordpress.stackexchange.com/users/177555",
"pm_score": 1,
"selected": false,
"text": "<p>I just had a problem like this.</p>\n<p>Did you change the salts in wp-config by any chance?</p>\n<p>I cha... | 2021/01/20 | [
"https://wordpress.stackexchange.com/questions/381855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102414/"
] | I have migrated more than 50 websites from Live server to Localhost in my career but have not faced this issue till now.
I used ALL IN ONE WP MIGRATION to export the data from live server.
I replaced the url during export process.
```
http://www.example.com/ to http://localhost/example/
```
I imported the data in my... | I just had a problem like this.
Did you change the salts in wp-config by any chance?
I changed them mid-production and the whole back-end just went haywire.
If you have a snapshot of an older wp-config, try that! |
381,872 | <p>I am trying to redirect users(subscribers) to a particular page based on the following conditions
<code>1. (subscriber) user is logged on 2. specific page id is matched 3. wp user role = subscriber</code> which is the default role set when a user is registered on the platform</p>
<p>The Challenge i am having is cond... | [
{
"answer_id": 381873,
"author": "admcfajn",
"author_id": 123674,
"author_profile": "https://wordpress.stackexchange.com/users/123674",
"pm_score": 1,
"selected": false,
"text": "<p>We can check the <code>$request</code> which is passed to our <code>login_redirect</code> filter-function ... | 2021/01/21 | [
"https://wordpress.stackexchange.com/questions/381872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/180226/"
] | I am trying to redirect users(subscribers) to a particular page based on the following conditions
`1. (subscriber) user is logged on 2. specific page id is matched 3. wp user role = subscriber` which is the default role set when a user is registered on the platform
The Challenge i am having is conditions 1 and 2 works... | We can check the `$request` which is passed to our `login_redirect` filter-function using [url\_to\_postid](https://developer.wordpress.org/reference/functions/url_to_postid/).
```
// redirect subscribers if logging in from specific page
function wpse381872_login_redirect( $redirect_to, $request, $user ) {
// tur... |
381,875 | <p>WordPress end points default rules,</p>
<pre><code>GET ----> PUBLIC
POST, PUT, DELETE ----> AUTH
</code></pre>
<p>How can I force authentication the WordPress REST API <code>GET</code> method requests?</p>
| [
{
"answer_id": 381899,
"author": "Paul G.",
"author_id": 41288,
"author_profile": "https://wordpress.stackexchange.com/users/41288",
"pm_score": 2,
"selected": true,
"text": "<p>You can't really apply authentication based directly on whether the request is GET or otherwise, but can force... | 2021/01/21 | [
"https://wordpress.stackexchange.com/questions/381875",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/198965/"
] | WordPress end points default rules,
```
GET ----> PUBLIC
POST, PUT, DELETE ----> AUTH
```
How can I force authentication the WordPress REST API `GET` method requests? | You can't really apply authentication based directly on whether the request is GET or otherwise, but can forcefully apply authentication requirements globally in that manner, if you like.
I've been quite verbose with the code to illustrate what's happening:
```php
add_filter( 'rest_authentication_errors', function ( ... |
382,094 | <p>How can I print the taxonomy terms with links?? This code work but print the terms without link.. some advice??</p>
<pre class="lang-php prettyprint-override"><code>function show_all_terms($taxonomy){
$taxonomy_terms = get_terms($taxonomy);
foreach($taxonomy_terms as $term){
$terms[] = $term->name... | [
{
"answer_id": 381899,
"author": "Paul G.",
"author_id": 41288,
"author_profile": "https://wordpress.stackexchange.com/users/41288",
"pm_score": 2,
"selected": true,
"text": "<p>You can't really apply authentication based directly on whether the request is GET or otherwise, but can force... | 2021/01/24 | [
"https://wordpress.stackexchange.com/questions/382094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200861/"
] | How can I print the taxonomy terms with links?? This code work but print the terms without link.. some advice??
```php
function show_all_terms($taxonomy){
$taxonomy_terms = get_terms($taxonomy);
foreach($taxonomy_terms as $term){
$terms[] = $term->name;
}
if(!empty($terms)) {
echo join(... | You can't really apply authentication based directly on whether the request is GET or otherwise, but can forcefully apply authentication requirements globally in that manner, if you like.
I've been quite verbose with the code to illustrate what's happening:
```php
add_filter( 'rest_authentication_errors', function ( ... |
382,129 | <p>I'm trying to implement filter system in my website. I decided to make it via js. I created fetch function</p>
<pre><code>let filters = document.querySelectorAll('.filters-item');
let pageUrl = wp.page_url;
const postsContainer = document.querySelectorAll('.column.is-half.is-offset-1');
filters.forEach( (item) =>... | [
{
"answer_id": 382140,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 5,
"selected": true,
"text": "<blockquote>\n<p>Is it proper way to pass the data in the form like I did?</p>\n</blockquote>\n<p>If you mean ... | 2021/01/25 | [
"https://wordpress.stackexchange.com/questions/382129",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147198/"
] | I'm trying to implement filter system in my website. I decided to make it via js. I created fetch function
```
let filters = document.querySelectorAll('.filters-item');
let pageUrl = wp.page_url;
const postsContainer = document.querySelectorAll('.column.is-half.is-offset-1');
filters.forEach( (item) => {
item.... | >
> Is it proper way to pass the data in the form like I did?
>
>
>
If you mean the `body` part (of your `fetch()` call), then yes, it is okay.
However,
1. **You must send a query named `action`** as part of the request (e.g. via the URL like `example.com/wp-admin/admin-ajax.php?action=test`), so that WordPress ... |
382,130 | <p>I have this working statement for searching a single column in my database:</p>
<pre><code>$foods = $wpdb->get_results( $wpdb->prepare( "SELECT id, foodname, namevariations, calories, carbs, fat, protein, sodium FROM foodsTable WHERE namevariations like %s", "%$search_text%"), ARRAY_A );
... | [
{
"answer_id": 383572,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 2,
"selected": true,
"text": "<p>The part after <code>WHERE</code> decides which columns are searched.</p>\n<p>So you need to change it... | 2021/01/25 | [
"https://wordpress.stackexchange.com/questions/382130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200346/"
] | I have this working statement for searching a single column in my database:
```
$foods = $wpdb->get_results( $wpdb->prepare( "SELECT id, foodname, namevariations, calories, carbs, fat, protein, sodium FROM foodsTable WHERE namevariations like %s", "%$search_text%"), ARRAY_A );
```
I would like to include another co... | The part after `WHERE` decides which columns are searched.
So you need to change it this way:
```
$foods = $wpdb->get_results(
$wpdb->prepare(
"SELECT id, foodname, namevariations, calories, carbs, fat, protein, sodium FROM foodsTable WHERE namevariations like %1$s OR foodname like %1$s",
'%' . $w... |
382,138 | <br>
I'm trying to reduce the overloading by not to load all style sheets on my website's homepage. <br>
Some of those sheets is coming and loading from external plugins like woo-commerce, <br>
I have tried to do that using `wp_dequeue_style` function, but it haven't worked, those style sheets still being loaded! <br><... | [
{
"answer_id": 382157,
"author": "Celso Bessa",
"author_id": 22694,
"author_profile": "https://wordpress.stackexchange.com/users/22694",
"pm_score": 2,
"selected": false,
"text": "<p>Your basic strategy is correct. The problem is that, although there are some best practices, you can't ne... | 2021/01/25 | [
"https://wordpress.stackexchange.com/questions/382138",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/199583/"
] | I'm trying to reduce the overloading by not to load all style sheets on my website's homepage.
Some of those sheets is coming and loading from external plugins like woo-commerce,
I have tried to do that using `wp\_dequeue\_style` function, but it haven't worked, those style sheets still being loaded!
For ex... | Your basic strategy is correct. The problem is that, although there are some best practices, you can't never know for sure in a easy way, 100% of time:
1. when a plugin or theme will enqueue scripts and styles;
2. what priority is used to enqueue
3. if a plugin or theme really used enqueue/register hooks or hard-coded... |
382,173 | <p>For the purpose of transferring a very large number of user responses from non-WordPress to WordPress comments, I've been given a Google Sheet. Regardless of the method by which I turn the Sheet into a CSV file (direct download as CSV, download as xlsx then save as csv, copy-paste into Excel and save), I get some ve... | [
{
"answer_id": 382157,
"author": "Celso Bessa",
"author_id": 22694,
"author_profile": "https://wordpress.stackexchange.com/users/22694",
"pm_score": 2,
"selected": false,
"text": "<p>Your basic strategy is correct. The problem is that, although there are some best practices, you can't ne... | 2021/01/25 | [
"https://wordpress.stackexchange.com/questions/382173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35923/"
] | For the purpose of transferring a very large number of user responses from non-WordPress to WordPress comments, I've been given a Google Sheet. Regardless of the method by which I turn the Sheet into a CSV file (direct download as CSV, download as xlsx then save as csv, copy-paste into Excel and save), I get some versi... | Your basic strategy is correct. The problem is that, although there are some best practices, you can't never know for sure in a easy way, 100% of time:
1. when a plugin or theme will enqueue scripts and styles;
2. what priority is used to enqueue
3. if a plugin or theme really used enqueue/register hooks or hard-coded... |
382,200 | <p>I am trying to write a shortcode to display the page title. I only got the archive title to work, but not custom post type category and single post. Can anyone shed light how to do this?</p>
<p>The reason for going this path is Elemenentor theme builder generating too much code for simple page title and subheading i... | [
{
"answer_id": 382202,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not completely sure what you want to do but <a href=\"https://developer.wordpress.org/reference/functions/is... | 2021/01/26 | [
"https://wordpress.stackexchange.com/questions/382200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146914/"
] | I am trying to write a shortcode to display the page title. I only got the archive title to work, but not custom post type category and single post. Can anyone shed light how to do this?
The reason for going this path is Elemenentor theme builder generating too much code for simple page title and subheading inside sec... | Add Below Code For post title, page title, category title , tag title , taxonmy title , Author title .
According to your Needed.
```
function page_title_sc( ) {
$title = ('Page Title');
if ( is_page() || is_singular() ) {
$title = single_post_title();
} else if ( is_category() ) {
$title... |
382,205 | <p>I had built a functionality plugin and hooked with actions to another plugin. I had also made a style.css in myplugin/stylesheets/ directory. I placed the code there. I would like to make the styling dependent on my plugin and not my theme.</p>
<p>So far I have been trying this:</p>
<pre><code>function epf_override_... | [
{
"answer_id": 382202,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not completely sure what you want to do but <a href=\"https://developer.wordpress.org/reference/functions/is... | 2021/01/26 | [
"https://wordpress.stackexchange.com/questions/382205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200692/"
] | I had built a functionality plugin and hooked with actions to another plugin. I had also made a style.css in myplugin/stylesheets/ directory. I placed the code there. I would like to make the styling dependent on my plugin and not my theme.
So far I have been trying this:
```
function epf_override_style() {
wp_re... | Add Below Code For post title, page title, category title , tag title , taxonmy title , Author title .
According to your Needed.
```
function page_title_sc( ) {
$title = ('Page Title');
if ( is_page() || is_singular() ) {
$title = single_post_title();
} else if ( is_category() ) {
$title... |
382,212 | <p>im trying to submit the following form but it just wont work:</p>
<p>HTML:</p>
<pre><code><div class= "container">
<div class="row">
<div class= "col-md-10 mx-auto text-center">
<div style="display:none;" id="success">
<p ... | [
{
"answer_id": 382202,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not completely sure what you want to do but <a href=\"https://developer.wordpress.org/reference/functions/is... | 2021/01/26 | [
"https://wordpress.stackexchange.com/questions/382212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200961/"
] | im trying to submit the following form but it just wont work:
HTML:
```
<div class= "container">
<div class="row">
<div class= "col-md-10 mx-auto text-center">
<div style="display:none;" id="success">
<p class="pb-1 pt-1" style="color:white;background-color:#008000;font-size:20px;font-family:poppins;bor... | Add Below Code For post title, page title, category title , tag title , taxonmy title , Author title .
According to your Needed.
```
function page_title_sc( ) {
$title = ('Page Title');
if ( is_page() || is_singular() ) {
$title = single_post_title();
} else if ( is_category() ) {
$title... |
382,306 | <p>If you click on the Text tab, you can see the content, but when you switch back to the Visual tab, it displays nothing. It's not white text on white background either... it just has no content. The functionality works otherwise. I can enter or change content via the Text tab, and that works. But it never shows the c... | [
{
"answer_id": 382310,
"author": "Jeremy Caris",
"author_id": 115709,
"author_profile": "https://wordpress.stackexchange.com/users/115709",
"pm_score": 1,
"selected": true,
"text": "<p>The issue appears to be a bug with Wordpress 5.6. See <a href=\"https://github.com/CMB2/CMB2/issues/139... | 2021/01/27 | [
"https://wordpress.stackexchange.com/questions/382306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115709/"
] | If you click on the Text tab, you can see the content, but when you switch back to the Visual tab, it displays nothing. It's not white text on white background either... it just has no content. The functionality works otherwise. I can enter or change content via the Text tab, and that works. But it never shows the cont... | The issue appears to be a bug with Wordpress 5.6. See [this thread of comments for the same issue](https://github.com/CMB2/CMB2/issues/1397) with the CMB2 "developer's toolkit for building metaboxes, custom fields, and forms," which I implemented as an alternative to try (it produced the same results I get with the ori... |
382,331 | <p>I want to display a Custom post Type "Companies" filtered by zipcode.</p>
<p>In my CPT I have an ACF field called 'companies_zip_code', their values looks like this :</p>
<pre><code>29200
29860
35000
22350
...
</code></pre>
<p><strong>I want to display only companies where their companies_zip_code begins w... | [
{
"answer_id": 382310,
"author": "Jeremy Caris",
"author_id": 115709,
"author_profile": "https://wordpress.stackexchange.com/users/115709",
"pm_score": 1,
"selected": true,
"text": "<p>The issue appears to be a bug with Wordpress 5.6. See <a href=\"https://github.com/CMB2/CMB2/issues/139... | 2021/01/28 | [
"https://wordpress.stackexchange.com/questions/382331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201077/"
] | I want to display a Custom post Type "Companies" filtered by zipcode.
In my CPT I have an ACF field called 'companies\_zip\_code', their values looks like this :
```
29200
29860
35000
22350
...
```
**I want to display only companies where their companies\_zip\_code begins with `29`**
So I write this WP\_QUery :
`... | The issue appears to be a bug with Wordpress 5.6. See [this thread of comments for the same issue](https://github.com/CMB2/CMB2/issues/1397) with the CMB2 "developer's toolkit for building metaboxes, custom fields, and forms," which I implemented as an alternative to try (it produced the same results I get with the ori... |
382,528 | <p>I have a thank you page on my website and I don't want anyone can access it directly so I use the below code and it working.</p>
<pre><code>add_action('template_redirect', function() {
// ID of the thank you page
if (!is_page(947)) { //id of page
return;
}
// coming from the form, so all is ... | [
{
"answer_id": 382534,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<p>It might be better to match the thanks page, then try to match the referer and if those conditions don't match... | 2021/01/31 | [
"https://wordpress.stackexchange.com/questions/382528",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/177715/"
] | I have a thank you page on my website and I don't want anyone can access it directly so I use the below code and it working.
```
add_action('template_redirect', function() {
// ID of the thank you page
if (!is_page(947)) { //id of page
return;
}
// coming from the form, so all is fine
if (... | **Note:** WordPress deliberately misspelled the word 'referer', and thus, so did I..
If you just want to check if the referer is your `contact-us` Page or *any* single Post page, then you can first retrieve the current URL path (i.e. `example.com/<this part>/`) and then check if the path is exactly `contact-us` (or wh... |
382,701 | <pre><code>@media (max-width: 768px) {
.page-id-9334 .site-content {
display: flex;
flex-direction: column-reverse;
}
}
</code></pre>
<p>I am trying to load this CSS into Custom Taxonomy Pages...</p>
<p>My original question refers to a specific Page ID (and I edited my original question).</p>
<p>Anyways - b... | [
{
"answer_id": 382534,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<p>It might be better to match the thanks page, then try to match the referer and if those conditions don't match... | 2021/02/03 | [
"https://wordpress.stackexchange.com/questions/382701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | ```
@media (max-width: 768px) {
.page-id-9334 .site-content {
display: flex;
flex-direction: column-reverse;
}
}
```
I am trying to load this CSS into Custom Taxonomy Pages...
My original question refers to a specific Page ID (and I edited my original question).
Anyways - based upon the replies below I ... | **Note:** WordPress deliberately misspelled the word 'referer', and thus, so did I..
If you just want to check if the referer is your `contact-us` Page or *any* single Post page, then you can first retrieve the current URL path (i.e. `example.com/<this part>/`) and then check if the path is exactly `contact-us` (or wh... |
382,768 | <p>I would like to create a function that instead of hiding the products without thumbnails, would be ordered in such a way that the products with the highlighted image appear first on the shop page while those without the highlighted image appear at the end. I tried to modify an already <a href="https://stackoverflow.... | [
{
"answer_id": 382534,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<p>It might be better to match the thanks page, then try to match the referer and if those conditions don't match... | 2021/02/04 | [
"https://wordpress.stackexchange.com/questions/382768",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201411/"
] | I would like to create a function that instead of hiding the products without thumbnails, would be ordered in such a way that the products with the highlighted image appear first on the shop page while those without the highlighted image appear at the end. I tried to modify an already [existing function](https://stacko... | **Note:** WordPress deliberately misspelled the word 'referer', and thus, so did I..
If you just want to check if the referer is your `contact-us` Page or *any* single Post page, then you can first retrieve the current URL path (i.e. `example.com/<this part>/`) and then check if the path is exactly `contact-us` (or wh... |
382,793 | <p>My home page uses ACF ("settings home") fields. These fields position the items in the footer. The problem is that they don't display on other sites. How to display fields from the home page on all subpages? So that you do not have to enter the same data on each subpage</p>
<p>To display in footer.php I'm ... | [
{
"answer_id": 382534,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 0,
"selected": false,
"text": "<p>It might be better to match the thanks page, then try to match the referer and if those conditions don't match... | 2021/02/04 | [
"https://wordpress.stackexchange.com/questions/382793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147411/"
] | My home page uses ACF ("settings home") fields. These fields position the items in the footer. The problem is that they don't display on other sites. How to display fields from the home page on all subpages? So that you do not have to enter the same data on each subpage
To display in footer.php I'm using:
```
<?php t... | **Note:** WordPress deliberately misspelled the word 'referer', and thus, so did I..
If you just want to check if the referer is your `contact-us` Page or *any* single Post page, then you can first retrieve the current URL path (i.e. `example.com/<this part>/`) and then check if the path is exactly `contact-us` (or wh... |
382,892 | <p>I am using this function which works great in case anyone wants to bulk update custom fields for custom post types (just change parameters as necessary).</p>
<pre><code> $args=array(
'posts_per_page' => -1,
'post_type' => 'mycptype'
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) ... | [
{
"answer_id": 406209,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>Why not save yourself a whole lot of hassle and add a handy admin menu item "Bulk Update" that y... | 2021/02/05 | [
"https://wordpress.stackexchange.com/questions/382892",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am using this function which works great in case anyone wants to bulk update custom fields for custom post types (just change parameters as necessary).
```
$args=array(
'posts_per_page' => -1,
'post_type' => 'mycptype'
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query... | When you access `get_field()` from functions.php it will load before ACF has initialized. You can solve it by wrapping the code inside `acf/init` hook.
Update the code as follows.
Hope it helps @JoaMika
```
add_action('acf/init', 'custom_code');
function custom_code() {
$args = array(
'posts_per_page' =>... |
382,898 | <p>I'm using the following loop to pull my posts, the a is wrapped around the div to make sure it links to the post when clicked.</p>
<pre><code> <?php $query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 6
));
while ($query->have_posts()) : $query->the_post(); ?>
&l... | [
{
"answer_id": 382906,
"author": "Akash Singh",
"author_id": 191397,
"author_profile": "https://wordpress.stackexchange.com/users/191397",
"pm_score": -1,
"selected": false,
"text": "<p>if you use <strong>get_permalink()</strong> then you need to user echo and <strong>the_permalink()</st... | 2021/02/05 | [
"https://wordpress.stackexchange.com/questions/382898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201499/"
] | I'm using the following loop to pull my posts, the a is wrapped around the div to make sure it links to the post when clicked.
```
<?php $query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 6
));
while ($query->have_posts()) : $query->the_post(); ?>
<div class="carousel-cell" data-fl... | This is happening because `the_category()` outputs a list of categories, *with links*. So it's outputting its own `<a>` tags, and you cannot put `<a>` tags inside other `<a>` tags. It's not valid HTML.
What you're seeing is the browser's attempt to produce valid HTML based on invalid markup. HTML is very resilient, an... |
382,942 | <p>I client of mine recently upgraded a very basic WordPress install to version 5.6.1. While the update seemed to go well, right at the very end the site died with an error that read something like this; identifying details altered for privacy:</p>
<pre><code>[Sat Feb 06 12:12:11.123456 2021] [fcgid:warn] [pid 128] [cl... | [
{
"answer_id": 382944,
"author": "Giacomo1968",
"author_id": 52852,
"author_profile": "https://wordpress.stackexchange.com/users/52852",
"pm_score": -1,
"selected": true,
"text": "<h2>The solution is to add a PHP <code>class_exists</code> check around line 321 in <code>wp-includes/rest-a... | 2021/02/07 | [
"https://wordpress.stackexchange.com/questions/382942",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52852/"
] | I client of mine recently upgraded a very basic WordPress install to version 5.6.1. While the update seemed to go well, right at the very end the site died with an error that read something like this; identifying details altered for privacy:
```
[Sat Feb 06 12:12:11.123456 2021] [fcgid:warn] [pid 128] [client 12.34.56... | The solution is to add a PHP `class_exists` check around line 321 in `wp-includes/rest-api.php`.
------------------------------------------------------------------------------------------------
While patching WordPress core like this makes me wince, the check I added just confirms if `WP_Site_Health` exists in the cod... |
382,957 | <p>In WordPress, is it possible to hide a HTML element by class or ID with php?</p>
<p>I've used css rule <code>display: none;</code> but this is easily worked around...</p>
<p>I have tried the following via <code>functions.php</code> but to no avail:</p>
<pre><code>function MyTestFunction() {
obj = document.ge... | [
{
"answer_id": 382977,
"author": "Tony Djukic",
"author_id": 60844,
"author_profile": "https://wordpress.stackexchange.com/users/60844",
"pm_score": 2,
"selected": false,
"text": "<p>As per our discussion in the comments, all you really need to do is <code>.remove()</code> the element. ... | 2021/02/07 | [
"https://wordpress.stackexchange.com/questions/382957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/167038/"
] | In WordPress, is it possible to hide a HTML element by class or ID with php?
I've used css rule `display: none;` but this is easily worked around...
I have tried the following via `functions.php` but to no avail:
```
function MyTestFunction() {
obj = document.getElementById("div-or-class-id");
obj.st... | As per our discussion in the comments, all you really need to do is `.remove()` the element. The following is the approach I'd take. First I'd check to make sure the element exists before attempting to remove it. If it's there, then run jQuery's `.remove()`.
```
if( $( '#elementID' ).length > 0 ) {
$( '#elementID'... |
383,090 | <p><strong>HI</strong>
I use plugin: Advanced Custom Fields</p>
<p>How can I show only 5 posts from the relationship?</p>
<p>This is the code:</p>
<pre><code><?php $c_lists = get_field( 'c_lists' ); ?>
<?php if ( $c_lists ) : ?>
<?php foreach ( $c_lists as $post_ids ) : ?>
<a href="... | [
{
"answer_id": 383091,
"author": "km onur",
"author_id": 198965,
"author_profile": "https://wordpress.stackexchange.com/users/198965",
"pm_score": 0,
"selected": false,
"text": "<p>You can follow such a path</p>\n \n<pre><code><?php if ( $c_lists ) : ?>\n <?php $max = 5; $sta... | 2021/02/09 | [
"https://wordpress.stackexchange.com/questions/383090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201627/"
] | **HI**
I use plugin: Advanced Custom Fields
How can I show only 5 posts from the relationship?
This is the code:
```
<?php $c_lists = get_field( 'c_lists' ); ?>
<?php if ( $c_lists ) : ?>
<?php foreach ( $c_lists as $post_ids ) : ?>
<a href="<?php echo get_permalink( $post_ids ); ?>"><?php echo get_the_t... | You could use the key from the foreach
```
<?php
$c_lists = get_field('c_lists');
if ($c_lists) :
foreach ($c_lists as $key => $post_ids) :
if ($key > 4) break;
?>
<a href="<?= get_permalink($post_ids); ?>"><?= get_the_title($post_ids); ?></a>
<?php
endforeach;
endif;
?>
``` |
383,093 | <p>I have a block in which I'd like to display a link based on the site url. So for example, when the user enters "Futuristic", the link will display as <a href="https://my-site.com/futuristic/" rel="nofollow noreferrer">https://my-site.com/futuristic/</a></p>
<p>I've looked at <a href="https://developer.word... | [
{
"answer_id": 383114,
"author": "Hardeep Asrani",
"author_id": 33233,
"author_profile": "https://wordpress.stackexchange.com/users/33233",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>wp_localize_script</code> to pass anything you want, including site URL, to the edit... | 2021/02/09 | [
"https://wordpress.stackexchange.com/questions/383093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2044/"
] | I have a block in which I'd like to display a link based on the site url. So for example, when the user enters "Futuristic", the link will display as <https://my-site.com/futuristic/>
I've looked at [REST API `/settings/` endpoint](https://developer.wordpress.org/rest-api/reference/settings/), which is supposed to inc... | >
> Perhaps this is because I've got WP set up as multisite.
>
>
>
Yes, that's right, WordPress disables the `siteurl` (and also `admin_email`) settings on a Multisite — see [`register_initial_settings()`](https://developer.wordpress.org/reference/functions/register_initial_settings/) for the source.
And I don't ... |
383,118 | <p>I am trying to run a function only on one page or other pages in the future if I so desire. But I dont want to run it site wide. I need help on how to put the if is_page or if is_single.</p>
<pre class="lang-php prettyprint-override"><code>// disable auto-formatting
function my_formatter($content) {
$new_content... | [
{
"answer_id": 383114,
"author": "Hardeep Asrani",
"author_id": 33233,
"author_profile": "https://wordpress.stackexchange.com/users/33233",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>wp_localize_script</code> to pass anything you want, including site URL, to the edit... | 2021/02/09 | [
"https://wordpress.stackexchange.com/questions/383118",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201696/"
] | I am trying to run a function only on one page or other pages in the future if I so desire. But I dont want to run it site wide. I need help on how to put the if is\_page or if is\_single.
```php
// disable auto-formatting
function my_formatter($content) {
$new_content = '';
$pattern_full = '{(\[raw\].*?\[/raw... | >
> Perhaps this is because I've got WP set up as multisite.
>
>
>
Yes, that's right, WordPress disables the `siteurl` (and also `admin_email`) settings on a Multisite — see [`register_initial_settings()`](https://developer.wordpress.org/reference/functions/register_initial_settings/) for the source.
And I don't ... |
383,125 | <p>I am creating a dedicated WordPress ecommerce website without using WooCommerce for myself. I created the custom post type called 'products' but now I am stuck on how to add specific terms like SKU, price, variations, short description, and related products section in it.</p>
<p>Can you please help me know. I don't ... | [
{
"answer_id": 383114,
"author": "Hardeep Asrani",
"author_id": 33233,
"author_profile": "https://wordpress.stackexchange.com/users/33233",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>wp_localize_script</code> to pass anything you want, including site URL, to the edit... | 2021/02/10 | [
"https://wordpress.stackexchange.com/questions/383125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201713/"
] | I am creating a dedicated WordPress ecommerce website without using WooCommerce for myself. I created the custom post type called 'products' but now I am stuck on how to add specific terms like SKU, price, variations, short description, and related products section in it.
Can you please help me know. I don't know if I... | >
> Perhaps this is because I've got WP set up as multisite.
>
>
>
Yes, that's right, WordPress disables the `siteurl` (and also `admin_email`) settings on a Multisite — see [`register_initial_settings()`](https://developer.wordpress.org/reference/functions/register_initial_settings/) for the source.
And I don't ... |
383,176 | <p>I'm using React select so that I can create a block option that will give me the option of selecting post types and posts based on the selected post types. Basically, a query block that is in the works in Gutenberg plugin if I'm not mistaken.</p>
<p><a href="https://i.stack.imgur.com/INWlY.png" rel="noreferrer"><img... | [
{
"answer_id": 383209,
"author": "dingo_d",
"author_id": 58895,
"author_profile": "https://wordpress.stackexchange.com/users/58895",
"pm_score": 4,
"selected": true,
"text": "<p>Ok, after some research I got the result I needed:</p>\n<pre class=\"lang-js prettyprint-override\"><code>// F... | 2021/02/10 | [
"https://wordpress.stackexchange.com/questions/383176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58895/"
] | I'm using React select so that I can create a block option that will give me the option of selecting post types and posts based on the selected post types. Basically, a query block that is in the works in Gutenberg plugin if I'm not mistaken.
[](https... | Ok, after some research I got the result I needed:
```js
// Fetch all posts based on the selected postType.
const postsOptions = useSelect((select) => {
const { getEntityRecords } = select('core');
const { isResolving } = select('core/data');
const postTypeSlugs = [...postType].map((element) => element.va... |
383,179 | <p>I'm trying to show/hide two lines of text depending on whether a <code>WooCommerce</code> category is empty or has any products in it. Those lines are inserted in text blocks using <code>Elementor</code> and I've assigned a <code>CSS #ID</code> to each one, so I can control it.</p>
<p>Now, in a custom functions plug... | [
{
"answer_id": 383209,
"author": "dingo_d",
"author_id": 58895,
"author_profile": "https://wordpress.stackexchange.com/users/58895",
"pm_score": 4,
"selected": true,
"text": "<p>Ok, after some research I got the result I needed:</p>\n<pre class=\"lang-js prettyprint-override\"><code>// F... | 2021/02/10 | [
"https://wordpress.stackexchange.com/questions/383179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/170286/"
] | I'm trying to show/hide two lines of text depending on whether a `WooCommerce` category is empty or has any products in it. Those lines are inserted in text blocks using `Elementor` and I've assigned a `CSS #ID` to each one, so I can control it.
Now, in a custom functions plugin I have, I want to add a function to con... | Ok, after some research I got the result I needed:
```js
// Fetch all posts based on the selected postType.
const postsOptions = useSelect((select) => {
const { getEntityRecords } = select('core');
const { isResolving } = select('core/data');
const postTypeSlugs = [...postType].map((element) => element.va... |
383,286 | <p>I am trying to develop a bootstrap 5 theme for the latest WordPress. I am using Navwalker from here: <a href="https://github.com/wp-bootstrap/wp-bootstrap-navwalker" rel="nofollow noreferrer">https://github.com/wp-bootstrap/wp-bootstrap-navwalker</a>. My bootstrap Navbar does not dropdown on smaller screens.</p>
<p... | [
{
"answer_id": 383209,
"author": "dingo_d",
"author_id": 58895,
"author_profile": "https://wordpress.stackexchange.com/users/58895",
"pm_score": 4,
"selected": true,
"text": "<p>Ok, after some research I got the result I needed:</p>\n<pre class=\"lang-js prettyprint-override\"><code>// F... | 2021/02/12 | [
"https://wordpress.stackexchange.com/questions/383286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182317/"
] | I am trying to develop a bootstrap 5 theme for the latest WordPress. I am using Navwalker from here: <https://github.com/wp-bootstrap/wp-bootstrap-navwalker>. My bootstrap Navbar does not dropdown on smaller screens.
Is it not working because I am using Bootstrap 5 and not bootstrap 4?
Here is my code from my header.... | Ok, after some research I got the result I needed:
```js
// Fetch all posts based on the selected postType.
const postsOptions = useSelect((select) => {
const { getEntityRecords } = select('core');
const { isResolving } = select('core/data');
const postTypeSlugs = [...postType].map((element) => element.va... |
383,303 | <p>Inside my <code>content-single</code> template, I have a conditional check that displays text based on how old the post is. The idea is to inform visitors that they might be reading "old" news.</p>
<p>Problem is; the <code>6+ months old</code> text is displayed on posts that are only days old, and I do not... | [
{
"answer_id": 383311,
"author": "Chetan Vaghela",
"author_id": 169856,
"author_profile": "https://wordpress.stackexchange.com/users/169856",
"pm_score": -1,
"selected": false,
"text": "<p>By using below code, you can check if Post Was published more than 6 Months ago using get_the_date.... | 2021/02/13 | [
"https://wordpress.stackexchange.com/questions/383303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201877/"
] | Inside my `content-single` template, I have a conditional check that displays text based on how old the post is. The idea is to inform visitors that they might be reading "old" news.
Problem is; the `6+ months old` text is displayed on posts that are only days old, and I do not understand why.
**This is the code I am... | The problem is that your date format is not a standard format that `strtotime()` understands. Instead just use `get_the_date()` with the format set to `'U'`, which returns the timestamp, and compare that to `strtotime( '-1 year' )`:
```
if ( get_the_date( 'U' ) < strtotime( '-1 year' ) ) {
}
``` |