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 |
|---|---|---|---|---|---|---|
357,540 | <p>I have this loop:</p>
<pre><code><?php
$categories = get_terms('my_category');
foreach ( $categories as $category ) :
?>
</code></pre>
<p>I want to split the posts into 4 separate div columns so that post titles will be alphabetical vertically like:</p>
<pre>
a | d | g | j
b | e | h | k
c | f | i | l
</pre>... | [
{
"answer_id": 357544,
"author": "Waldo Rabie",
"author_id": 172667,
"author_profile": "https://wordpress.stackexchange.com/users/172667",
"pm_score": 0,
"selected": false,
"text": "<p>The answer is CSS and you've got a couple options! </p>\n\n<pre><code><?php $categories = get_terms(... | 2020/01/30 | [
"https://wordpress.stackexchange.com/questions/357540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28232/"
] | I have this loop:
```
<?php
$categories = get_terms('my_category');
foreach ( $categories as $category ) :
?>
```
I want to split the posts into 4 separate div columns so that post titles will be alphabetical vertically like:
```
a | d | g | j
b | e | h | k
c | f | i | l
```
How do you get the total post count a... | I had a similar problem couple years ago. Here's a gist I've published, which shows the basic idea how I solved the problem,<https://gist.github.com/koskinenaa/4d8461116885c0e64d5ca167ae53434d>
Applying the gist to your situation I think the solution could be something like this. I didn't test this so it might require... |
357,650 | <p>I'm trying to override the number of posts to show on pagination for my search.php template, to be 16 vs 4. In the Reading settings on the back end, it is set to 4, which is desired because my front page uses the same code to display the 4 most recent posts.</p>
<p>Is there a way to designate this on the search.php... | [
{
"answer_id": 357544,
"author": "Waldo Rabie",
"author_id": 172667,
"author_profile": "https://wordpress.stackexchange.com/users/172667",
"pm_score": 0,
"selected": false,
"text": "<p>The answer is CSS and you've got a couple options! </p>\n\n<pre><code><?php $categories = get_terms(... | 2020/01/31 | [
"https://wordpress.stackexchange.com/questions/357650",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/181216/"
] | I'm trying to override the number of posts to show on pagination for my search.php template, to be 16 vs 4. In the Reading settings on the back end, it is set to 4, which is desired because my front page uses the same code to display the 4 most recent posts.
Is there a way to designate this on the search.php template ... | I had a similar problem couple years ago. Here's a gist I've published, which shows the basic idea how I solved the problem,<https://gist.github.com/koskinenaa/4d8461116885c0e64d5ca167ae53434d>
Applying the gist to your situation I think the solution could be something like this. I didn't test this so it might require... |
357,710 | <p>One of my websites scan by a security firm and came up with below to block
"<a href="http://domain.com/wp-includes/sodium_compat/composer.json" rel="nofollow noreferrer">http://domain.com/wp-includes/sodium_compat/composer.json</a>" access over the internet. I've tried few plugins but none of them work, does anyone ... | [
{
"answer_id": 357544,
"author": "Waldo Rabie",
"author_id": 172667,
"author_profile": "https://wordpress.stackexchange.com/users/172667",
"pm_score": 0,
"selected": false,
"text": "<p>The answer is CSS and you've got a couple options! </p>\n\n<pre><code><?php $categories = get_terms(... | 2020/02/02 | [
"https://wordpress.stackexchange.com/questions/357710",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97402/"
] | One of my websites scan by a security firm and came up with below to block
"<http://domain.com/wp-includes/sodium_compat/composer.json>" access over the internet. I've tried few plugins but none of them work, does anyone know how to block similar files display JSON on the browser. | I had a similar problem couple years ago. Here's a gist I've published, which shows the basic idea how I solved the problem,<https://gist.github.com/koskinenaa/4d8461116885c0e64d5ca167ae53434d>
Applying the gist to your situation I think the solution could be something like this. I didn't test this so it might require... |
357,733 | <p>this seems hard to understand. I created a plugin, and it works fine on different installations of me and a few other blogs.</p>
<p>But on one blog of someone else it fails. After getting through debugs and console entries, I believe I found the source of the failure:</p>
<p>At some step of the process the plugin ... | [
{
"answer_id": 357544,
"author": "Waldo Rabie",
"author_id": 172667,
"author_profile": "https://wordpress.stackexchange.com/users/172667",
"pm_score": 0,
"selected": false,
"text": "<p>The answer is CSS and you've got a couple options! </p>\n\n<pre><code><?php $categories = get_terms(... | 2020/02/02 | [
"https://wordpress.stackexchange.com/questions/357733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/176007/"
] | this seems hard to understand. I created a plugin, and it works fine on different installations of me and a few other blogs.
But on one blog of someone else it fails. After getting through debugs and console entries, I believe I found the source of the failure:
At some step of the process the plugin calls a function ... | I had a similar problem couple years ago. Here's a gist I've published, which shows the basic idea how I solved the problem,<https://gist.github.com/koskinenaa/4d8461116885c0e64d5ca167ae53434d>
Applying the gist to your situation I think the solution could be something like this. I didn't test this so it might require... |
357,765 | <p>I want to add a "New" badge to the titles of recent post's widgets. whenever I add any new post from that time to 5 days this "New" badge should show after that it should disappear. this badge is a "new.gif" file. I also added an image for your reference.
<a href="https://i.stack.imgur.com/hbmLC.jpg" rel="nofollow ... | [
{
"answer_id": 357544,
"author": "Waldo Rabie",
"author_id": 172667,
"author_profile": "https://wordpress.stackexchange.com/users/172667",
"pm_score": 0,
"selected": false,
"text": "<p>The answer is CSS and you've got a couple options! </p>\n\n<pre><code><?php $categories = get_terms(... | 2020/02/03 | [
"https://wordpress.stackexchange.com/questions/357765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130910/"
] | I want to add a "New" badge to the titles of recent post's widgets. whenever I add any new post from that time to 5 days this "New" badge should show after that it should disappear. this badge is a "new.gif" file. I also added an image for your reference.
[ to automatically get the affiliate ID attached to it.</p>
<p>Example:</p>
<p>link I put in my blog post editor <a href="https://rads.stackoverflow.com/amzn/click/com/B07K344J3N" rel="nofollow noreferrer" rel="nofollow noreferr... | [
{
"answer_id": 357544,
"author": "Waldo Rabie",
"author_id": 172667,
"author_profile": "https://wordpress.stackexchange.com/users/172667",
"pm_score": 0,
"selected": false,
"text": "<p>The answer is CSS and you've got a couple options! </p>\n\n<pre><code><?php $categories = get_terms(... | 2020/02/03 | [
"https://wordpress.stackexchange.com/questions/357790",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182082/"
] | My goal:
I want external links to shops I'm affiliated with (for example amazon) to automatically get the affiliate ID attached to it.
Example:
link I put in my blog post editor [https://www.amazon.com/dp/B07K344J3N/](https://rads.stackoverflow.com/amzn/click/com/B07K344J3N)
changes in frontend to [https://www.amaz... | I had a similar problem couple years ago. Here's a gist I've published, which shows the basic idea how I solved the problem,<https://gist.github.com/koskinenaa/4d8461116885c0e64d5ca167ae53434d>
Applying the gist to your situation I think the solution could be something like this. I didn't test this so it might require... |
357,827 | <p>I had started my wordpress site with the host SiteGround. Later I moved to another host.</p>
<p>I now see that in my wp-config.php file the following settings are present near the end of the file:</p>
<pre><code>/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( ... | [
{
"answer_id": 357544,
"author": "Waldo Rabie",
"author_id": 172667,
"author_profile": "https://wordpress.stackexchange.com/users/172667",
"pm_score": 0,
"selected": false,
"text": "<p>The answer is CSS and you've got a couple options! </p>\n\n<pre><code><?php $categories = get_terms(... | 2020/02/04 | [
"https://wordpress.stackexchange.com/questions/357827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/167402/"
] | I had started my wordpress site with the host SiteGround. Later I moved to another host.
I now see that in my wp-config.php file the following settings are present near the end of the file:
```
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )... | I had a similar problem couple years ago. Here's a gist I've published, which shows the basic idea how I solved the problem,<https://gist.github.com/koskinenaa/4d8461116885c0e64d5ca167ae53434d>
Applying the gist to your situation I think the solution could be something like this. I didn't test this so it might require... |
357,831 | <p>I am developing a Form in Admin Panel. My Form code is like below</p>
<pre><code><form method="post" action="<?php echo home_url(add_query_arg(array(), $wp->request));?>" name="newAddress" id="createuser" class="validate" novalidate="novalidate">
</code></pre>
<p>My Current URL is like below</p>
<p... | [
{
"answer_id": 357834,
"author": "Patryk Parcheta",
"author_id": 181863,
"author_profile": "https://wordpress.stackexchange.com/users/181863",
"pm_score": 2,
"selected": true,
"text": "<p>Just use <code>$_SERVER['REQUEST_URI'];</code> instead of <code>home_url(add_query_arg(array(), $wp-... | 2020/02/04 | [
"https://wordpress.stackexchange.com/questions/357831",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65189/"
] | I am developing a Form in Admin Panel. My Form code is like below
```
<form method="post" action="<?php echo home_url(add_query_arg(array(), $wp->request));?>" name="newAddress" id="createuser" class="validate" novalidate="novalidate">
```
My Current URL is like below
```
http://localhost/wordpress123/wp-admin/admi... | Just use `$_SERVER['REQUEST_URI'];` instead of `home_url(add_query_arg(array(), $wp->request));` |
357,851 | <p>Using <code>add_theme_support( 'editor-color-palette' )</code> one can replace the color palette in the Gutenberg editor by a custom one:</p>
<pre><code>add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'Strong magenta', 'themeLangDomain' ),
'slug' => 'strong-magenta',... | [
{
"answer_id": 357855,
"author": "Vitauts Stočka",
"author_id": 181289,
"author_profile": "https://wordpress.stackexchange.com/users/181289",
"pm_score": 3,
"selected": false,
"text": "<p>You can merge palettes</p>\n\n<pre><code>$existing = get_theme_support( 'editor-color-palette' );\n\... | 2020/02/04 | [
"https://wordpress.stackexchange.com/questions/357851",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33049/"
] | Using `add_theme_support( 'editor-color-palette' )` one can replace the color palette in the Gutenberg editor by a custom one:
```
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'Strong magenta', 'themeLangDomain' ),
'slug' => 'strong-magenta',
'color' => '#a156b4',
... | You can merge palettes
```
$existing = get_theme_support( 'editor-color-palette' );
$new = array_merge( $existing[0], array(
array(
'name' => __( 'Strong magenta', 'themeLangDomain' ),
'slug' => 'strong-magenta',
'color' => '#a156b4',
),
array(
'name' => __( 'Light grayish ... |
357,852 | <p>I am learning WordPress plugin development. Now I need to place jQuery code in one file. Where can I place jQuery code ?</p>
| [
{
"answer_id": 357863,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>You should place your javascript inside a <code>.js</code> file in your plugin, then enqueue it using the <c... | 2020/02/04 | [
"https://wordpress.stackexchange.com/questions/357852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65189/"
] | I am learning WordPress plugin development. Now I need to place jQuery code in one file. Where can I place jQuery code ? | You should place the `.js` file into your plugin directory (it can be root or any other folder like `assets` or `js`).
### To enqueue JS and CSS files in the front-end:
```
function wp_357866_enqueue_frontend()
{
wp_enqueue_script('your-script', get_template_directory_uri() . '/path/to/js/your-script.js', array()... |
357,864 | <p>I'm trying to get a link from a custom post with a custom taxonomy but I'm running into issues trying to get it. I'm wanting to send the user straight to the post if the taxonomy count is 1. If it's greater than one post, it goes to a page showing all the posts of the taxonomy. I have this second part working, but I... | [
{
"answer_id": 357919,
"author": "rajat.gite",
"author_id": 180636,
"author_profile": "https://wordpress.stackexchange.com/users/180636",
"pm_score": 0,
"selected": false,
"text": "<p>Here is my working code brother you can try this.</p>\n\n<pre><code>$terms = get_terms( array(\n 'taxon... | 2020/02/04 | [
"https://wordpress.stackexchange.com/questions/357864",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164293/"
] | I'm trying to get a link from a custom post with a custom taxonomy but I'm running into issues trying to get it. I'm wanting to send the user straight to the post if the taxonomy count is 1. If it's greater than one post, it goes to a page showing all the posts of the taxonomy. I have this second part working, but I ca... | >
> I can't get the first bit to work, I can't get the taxonomy to return
> the post.
>
>
>
So the following is the first bit which queries posts in a single taxonomy term:
```php
$posts_array = get_posts(
array( 'showposts' => -1,
'post_type' => 'treatment',
'tax_query' => array(
... |
357,948 | <p>Is it possible to edit order item totals and custom fees in the woocommerce admin edit order screen? The only hook that I can find is <code>woocommerce_new_order_item</code>, but when I add/remove a product in the admin I need to adjust the custom order items totals (e.g. like deposit and delivery fees which are ord... | [
{
"answer_id": 357964,
"author": "Yashar",
"author_id": 146615,
"author_profile": "https://wordpress.stackexchange.com/users/146615",
"pm_score": -1,
"selected": false,
"text": "<p>First of all, welcome to the community :)</p>\n<p>When you add/remove an order item (e.g a product), WooCom... | 2020/02/05 | [
"https://wordpress.stackexchange.com/questions/357948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66596/"
] | Is it possible to edit order item totals and custom fees in the woocommerce admin edit order screen? The only hook that I can find is `woocommerce_new_order_item`, but when I add/remove a product in the admin I need to adjust the custom order items totals (e.g. like deposit and delivery fees which are order line item f... | The `woocommerce_order_before_calculate_totals` hook executes in the Edit Order admin screen when an item is changed or the 'recalculate' button is pressed. This allows you to loop through each item and fee in the order and edit as required. I have a fee called 'Deposit' which I update if it exists or I add if it doesn... |
357,962 | <p>I have tried this code, but it doesn't work.</p>
<pre class="lang-php prettyprint-override"><code>function university_adjust_queries($query) {
$query->set('post_per_page', '1');
}
add_action('pre_get_posts', 'university_adjust_queries');
</code></pre>
| [
{
"answer_id": 357965,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>You're missing an s.</p>\n\n<p><code>$query->set('posts_per_page', '1');</code></p>\n\n<p>However - yo... | 2020/02/05 | [
"https://wordpress.stackexchange.com/questions/357962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182221/"
] | I have tried this code, but it doesn't work.
```php
function university_adjust_queries($query) {
$query->set('post_per_page', '1');
}
add_action('pre_get_posts', 'university_adjust_queries');
``` | You're missing an s.
`$query->set('posts_per_page', '1');`
However - you probably don't want to do this for every query, since that affects everything - widgets, back end, everything. You should make it conditional. For example:
```
<?php
function university_adjust_queries($query) {
// If this is the main query,... |
357,992 | <p>I have a function to obtain specific taxonomies in each entry. The problem is, for each entry, it shows all the values that the taxonomy contains. How can I do to show the correct value to each entry?
I don't know about programming. I appreciate you being clear in the answer. Thank you</p>
<pre><code> $terms = get... | [
{
"answer_id": 357965,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>You're missing an s.</p>\n\n<p><code>$query->set('posts_per_page', '1');</code></p>\n\n<p>However - yo... | 2020/02/06 | [
"https://wordpress.stackexchange.com/questions/357992",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182248/"
] | I have a function to obtain specific taxonomies in each entry. The problem is, for each entry, it shows all the values that the taxonomy contains. How can I do to show the correct value to each entry?
I don't know about programming. I appreciate you being clear in the answer. Thank you
```
$terms = get_terms( ( arra... | You're missing an s.
`$query->set('posts_per_page', '1');`
However - you probably don't want to do this for every query, since that affects everything - widgets, back end, everything. You should make it conditional. For example:
```
<?php
function university_adjust_queries($query) {
// If this is the main query,... |
358,004 | <p>i need to get a list of all updates the wp site need (core, plugin and themes). i already know about wp_get_update_data(), but it give me back only the number. i need to get for example:</p>
<blockquote>
<p>plugin1 | actual version | new version</p>
<p>plugin2 | actual version | new version</p>
<p>theme... | [
{
"answer_id": 358006,
"author": "Antti Koskinen",
"author_id": 144392,
"author_profile": "https://wordpress.stackexchange.com/users/144392",
"pm_score": 2,
"selected": false,
"text": "<p>When on the admin view you can use the following functions to get update data.</p>\n\n<ul>\n<li><a h... | 2020/02/06 | [
"https://wordpress.stackexchange.com/questions/358004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182053/"
] | i need to get a list of all updates the wp site need (core, plugin and themes). i already know about wp\_get\_update\_data(), but it give me back only the number. i need to get for example:
>
> plugin1 | actual version | new version
>
>
> plugin2 | actual version | new version
>
>
> theme1 | actual version | new ... | When on the admin view you can use the following functions to get update data.
* [get\_plugin\_updates()](https://developer.wordpress.org/reference/functions/get_plugin_updates/)
* [get\_theme\_updates()](https://developer.wordpress.org/reference/functions/get_theme_updates/)
* [get\_core\_updates()](https://developer... |
358,031 | <p>So Yoast SEO has an issue where you can't define a global default twitter card image.</p>
<p>So I'm looking to both set a default twitter card image but allow for the override on the specific pages to actually work.</p>
<p>I'm currently using:</p>
<pre><code>$default_opengraph = 'https://website.com/image.png';
f... | [
{
"answer_id": 358061,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 0,
"selected": false,
"text": "<p>If there is already an image set then it is <a href=\"https://github.com/Yoast/wordpress-seo/blob/13.0/frontend/cla... | 2020/02/06 | [
"https://wordpress.stackexchange.com/questions/358031",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91245/"
] | So Yoast SEO has an issue where you can't define a global default twitter card image.
So I'm looking to both set a default twitter card image but allow for the override on the specific pages to actually work.
I'm currently using:
```
$default_opengraph = 'https://website.com/image.png';
function default_opengraph() ... | Here's how I fixed it. If you paste this code in your theme's functions.php, it will use the image set for Facebook also for Twitter if no image is set for Twitter.
If there is not image set for both Facebook and Twitter, it falls back to the default Facebook image in the Yoast settings (unfortunately, you can't provi... |
358,037 | <p>I’d like to generate images suitable to insert into metadata (like Open Graph or twitter:image). Basically I want to create a collage based on posts for each tag. So let’s say I had the tag “cats” which had 30 posts, 10 of which had a “featured image” of cats in them.</p>
<p>If someone shares <a href="http://exampl... | [
{
"answer_id": 358178,
"author": "Antti Koskinen",
"author_id": 144392,
"author_profile": "https://wordpress.stackexchange.com/users/144392",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Are there native WordPress functions to manipulate images</p>\n</blockquote>\n\n<p>Y... | 2020/02/06 | [
"https://wordpress.stackexchange.com/questions/358037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12/"
] | I’d like to generate images suitable to insert into metadata (like Open Graph or twitter:image). Basically I want to create a collage based on posts for each tag. So let’s say I had the tag “cats” which had 30 posts, 10 of which had a “featured image” of cats in them.
If someone shares <http://example.org/tag/cats> to... | Ignoring our off-topic request for a plugin, the good news is: yes, this is possible. On the other hand, it is quite some work, so I will give just an outline here.
WordPress does have built-in image manipulation. The default one is [Image Magick](https://developer.wordpress.org/reference/classes/wp_image_editor_imagi... |
358,046 | <p>I created a block template and attached it to my cpt and I get this message on the post page neither of the two buttons or the two links in the vertical dot button work unless I disable <code>$pages_type_object->template_lock = 'all';</code></p>
<p><a href="https://i.stack.imgur.com/eDHDB.png" rel="nofollow nore... | [
{
"answer_id": 358135,
"author": "Will",
"author_id": 48698,
"author_profile": "https://wordpress.stackexchange.com/users/48698",
"pm_score": 0,
"selected": false,
"text": "<p>There sounds like there may be a couple issues going on. </p>\n\n<p>Regarding the message \"this block contains ... | 2020/02/06 | [
"https://wordpress.stackexchange.com/questions/358046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144783/"
] | I created a block template and attached it to my cpt and I get this message on the post page neither of the two buttons or the two links in the vertical dot button work unless I disable `$pages_type_object->template_lock = 'all';`
[](https://i.stack.i... | seems my problem was in my array
```
'level' => '3',
```
should've been
```
'level' => 3,
``` |
358,053 | <p>I have taken over a site from someone.
He has a list of businesses on the site, each one has a URL, saved as a field:</p>
<p><code>$iframe_url = get_field(‘manufacturer_url’);</code></p>
<p>It seems he used to manage this URL on a custom post-type page, but the actual field to edit the URL has disappeared – maybe ... | [
{
"answer_id": 358135,
"author": "Will",
"author_id": 48698,
"author_profile": "https://wordpress.stackexchange.com/users/48698",
"pm_score": 0,
"selected": false,
"text": "<p>There sounds like there may be a couple issues going on. </p>\n\n<p>Regarding the message \"this block contains ... | 2020/02/06 | [
"https://wordpress.stackexchange.com/questions/358053",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78146/"
] | I have taken over a site from someone.
He has a list of businesses on the site, each one has a URL, saved as a field:
`$iframe_url = get_field(‘manufacturer_url’);`
It seems he used to manage this URL on a custom post-type page, but the actual field to edit the URL has disappeared – maybe in some recent WordPress upd... | seems my problem was in my array
```
'level' => '3',
```
should've been
```
'level' => 3,
``` |
358,091 | <p>I have a custom post type created using the following code:</p>
<pre><code>// Event Post type
register_post_type('event', array(
'capability_type' => 'event',
'map_meta_cap' => true,
'supports' => array('title', 'editor', 'excerpt', 'revisions'),
'rewrite' => array('slug' => 'events'),
'has... | [
{
"answer_id": 358098,
"author": "user3135691",
"author_id": 59755,
"author_profile": "https://wordpress.stackexchange.com/users/59755",
"pm_score": 0,
"selected": false,
"text": "<p>From what I can see on a first glance, you have a single-quote missing:</p>\n\n<pre><code>'name' => 'E... | 2020/02/07 | [
"https://wordpress.stackexchange.com/questions/358091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/168795/"
] | I have a custom post type created using the following code:
```
// Event Post type
register_post_type('event', array(
'capability_type' => 'event',
'map_meta_cap' => true,
'supports' => array('title', 'editor', 'excerpt', 'revisions'),
'rewrite' => array('slug' => 'events'),
'has_archive' => true,
'public'... | CPT capabilities do not cover taxonomies. Each taxonomy has its own capabilities. If you want to use default Categories, unfortunately you must give user "Edit Posts" capability. There is no easy way around it, especially with Gutenberg. Best solution would be to create custom taxonomy "Event Categories" with matching ... |
358,157 | <p>I have a custom taxonomy (<code>video-category</code>) for a custom post type (<code>video</code>), and I'm trying to rewrite their paths in line with the examples below:</p>
<p>Post (Archive):
<code>about-us/video-center/category-name</code></p>
<p>Post (Single):
<code>about-us/video-center/category-name/post-tit... | [
{
"answer_id": 358186,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 3,
"selected": true,
"text": "<p><strong><em>(Revised on March 7<sup>th</sup> 2020 UTC)</em></strong></p>\n\n<p>So sharing the same permalin... | 2020/02/07 | [
"https://wordpress.stackexchange.com/questions/358157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/163962/"
] | I have a custom taxonomy (`video-category`) for a custom post type (`video`), and I'm trying to rewrite their paths in line with the examples below:
Post (Archive):
`about-us/video-center/category-name`
Post (Single):
`about-us/video-center/category-name/post-title`
The post rewrite works as expected using:
`'rewrit... | ***(Revised on March 7th 2020 UTC)***
So sharing the same permalink path (or **rewrite slug/base** as in `example.com/<rewrite slug>/<term slug>` and `example.com/<rewrite slug>/<post slug>`) is possible, and here's the (updated) code which enables you to share **the exact same rewrite slug** between a taxonomy and a ... |
358,214 | <p>I want to hide page menu from the admin panel for a specific user type. I tried it with the below codes in </p>
<p><code>functions.php</code></p>
<pre><code>function hide_menu_items() {
global $menu;
global $current_user;
get_currentuserinfo();
if( $current_user->user_login == 'username' )... | [
{
"answer_id": 358193,
"author": "Pavel Janicek",
"author_id": 10575,
"author_profile": "https://wordpress.stackexchange.com/users/10575",
"pm_score": 1,
"selected": false,
"text": "<p>Surprisingly, for plugin development, correct answer is <strong>none</strong></p>\n\n<p>From <a href=\"... | 2020/02/09 | [
"https://wordpress.stackexchange.com/questions/358214",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/171190/"
] | I want to hide page menu from the admin panel for a specific user type. I tried it with the below codes in
`functions.php`
```
function hide_menu_items() {
global $menu;
global $current_user;
get_currentuserinfo();
if( $current_user->user_login == 'username' ):
remove_menu_page( 'admin... | The minimum requirements are that it passes the [zxcvbn](https://github.com/dropbox/zxcvbn) library's strength check. I can't see a simple summary of their rules. This is registered as script 'zxcvbn-async' that you can enqueue / make a dependency of your own scripts, and then you can run the check yourself on the clie... |
358,285 | <p>I have a Page like:</p>
<pre><code><?php
/*
Template Name: Agenda
*/
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
My Hompagetext
</main><!-- #main -->
</div&... | [
{
"answer_id": 358193,
"author": "Pavel Janicek",
"author_id": 10575,
"author_profile": "https://wordpress.stackexchange.com/users/10575",
"pm_score": 1,
"selected": false,
"text": "<p>Surprisingly, for plugin development, correct answer is <strong>none</strong></p>\n\n<p>From <a href=\"... | 2020/02/10 | [
"https://wordpress.stackexchange.com/questions/358285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182482/"
] | I have a Page like:
```
<?php
/*
Template Name: Agenda
*/
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
My Hompagetext
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar('test'); ?>
<... | The minimum requirements are that it passes the [zxcvbn](https://github.com/dropbox/zxcvbn) library's strength check. I can't see a simple summary of their rules. This is registered as script 'zxcvbn-async' that you can enqueue / make a dependency of your own scripts, and then you can run the check yourself on the clie... |
358,302 | <p>I'm not sure if I'm asking the right question, so here is the context.</p>
<p>I'm making a POST to an API (The api is to a Google Sheets Script - so there are some unusual limitations). When I use postman the data is returned in a json file. In order to get it to work in postman I have to send the parameters via th... | [
{
"answer_id": 358304,
"author": "Tim Elsass",
"author_id": 80375,
"author_profile": "https://wordpress.stackexchange.com/users/80375",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to set <code>headers</code> to use <code>content-type: application/json</code>:</p>\n<p... | 2020/02/10 | [
"https://wordpress.stackexchange.com/questions/358302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182225/"
] | I'm not sure if I'm asking the right question, so here is the context.
I'm making a POST to an API (The api is to a Google Sheets Script - so there are some unusual limitations). When I use postman the data is returned in a json file. In order to get it to work in postman I have to send the parameters via the body and... | I got this one working, you have to pass the json\_encoded array on the body parameter of the request.
```
$customer_details = [
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $email,
];
$customer_details['body'] = json_encode($customer_details)... |
358,347 | <p>I have followed the documentation of WordPress on translating Gutenberg block, I have used WP CLI to create the .pot, .po and .json file and uploaded to my langauges folder inside the folder of that plugin, but still it is not working. Can someone tell me whats wrong with my code?</p>
<p>PHP:</p>
<pre><code>functi... | [
{
"answer_id": 358304,
"author": "Tim Elsass",
"author_id": 80375,
"author_profile": "https://wordpress.stackexchange.com/users/80375",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to set <code>headers</code> to use <code>content-type: application/json</code>:</p>\n<p... | 2020/02/11 | [
"https://wordpress.stackexchange.com/questions/358347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/180921/"
] | I have followed the documentation of WordPress on translating Gutenberg block, I have used WP CLI to create the .pot, .po and .json file and uploaded to my langauges folder inside the folder of that plugin, but still it is not working. Can someone tell me whats wrong with my code?
PHP:
```
function custom_blocks_load... | I got this one working, you have to pass the json\_encoded array on the body parameter of the request.
```
$customer_details = [
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $email,
];
$customer_details['body'] = json_encode($customer_details)... |
358,373 | <p>The following code comes from one of the Gutenberg blocks official examples. The block is pretty simple and just create an editable field that outputs a <code>p</code> element.</p>
<pre><code>registerBlockType( 'gutenberg-examples/example-03-editable-esnext', {
title: __( 'Example: Editable (ESNext)', 'gutenber... | [
{
"answer_id": 358396,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": true,
"text": "<p>The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could ... | 2020/02/11 | [
"https://wordpress.stackexchange.com/questions/358373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122690/"
] | The following code comes from one of the Gutenberg blocks official examples. The block is pretty simple and just create an editable field that outputs a `p` element.
```
registerBlockType( 'gutenberg-examples/example-03-editable-esnext', {
title: __( 'Example: Editable (ESNext)', 'gutenberg-examples' ),
icon: ... | The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could use something like Create-Guten-Block to set up that build process, and then replace the contents of "block.js" with that JS from the docs. (I sure wish they would improve the docs to make things like this clearer.... |
358,414 | <p>I want to limit the access to a wordpress app only to registered users.</p>
<p>I've putted this inside the function file, but I'm able to see the home also if I'm not logged in. How I fix this?</p>
<pre><code>if( is_home() || is_page() || is_single() && !is_user_logged_in() ){
wp_safe_redirect( wp_logi... | [
{
"answer_id": 358396,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": true,
"text": "<p>The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could ... | 2020/02/11 | [
"https://wordpress.stackexchange.com/questions/358414",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/177581/"
] | I want to limit the access to a wordpress app only to registered users.
I've putted this inside the function file, but I'm able to see the home also if I'm not logged in. How I fix this?
```
if( is_home() || is_page() || is_single() && !is_user_logged_in() ){
wp_safe_redirect( wp_login_url() );
}
``` | The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could use something like Create-Guten-Block to set up that build process, and then replace the contents of "block.js" with that JS from the docs. (I sure wish they would improve the docs to make things like this clearer.... |
358,421 | <p>I'm trying to disable a form button (contact form 7) after submitting and then save the disabled state to localstorage. This disables the button after submitting:</p>
<pre><code>jQuery(document).ready(function($) {
$("#buttonID").click(function () {
setTimeout(function () { disableButton(); }, 100);
});
fu... | [
{
"answer_id": 358396,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": true,
"text": "<p>The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could ... | 2020/02/11 | [
"https://wordpress.stackexchange.com/questions/358421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/135201/"
] | I'm trying to disable a form button (contact form 7) after submitting and then save the disabled state to localstorage. This disables the button after submitting:
```
jQuery(document).ready(function($) {
$("#buttonID").click(function () {
setTimeout(function () { disableButton(); }, 100);
});
function disable... | The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could use something like Create-Guten-Block to set up that build process, and then replace the contents of "block.js" with that JS from the docs. (I sure wish they would improve the docs to make things like this clearer.... |
358,428 | <p>I'm creating a block and using rich text to save some text this is my edit function.</p>
<pre><code> edit: (props) => {
const { attributes: { content, backgroundImage }, setAttributes } = props;
const onImageSelect = (imageObject) => {
setAttributes({ backgroundImage: imageObject.sizes.fu... | [
{
"answer_id": 358396,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": true,
"text": "<p>The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could ... | 2020/02/11 | [
"https://wordpress.stackexchange.com/questions/358428",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/167299/"
] | I'm creating a block and using rich text to save some text this is my edit function.
```
edit: (props) => {
const { attributes: { content, backgroundImage }, setAttributes } = props;
const onImageSelect = (imageObject) => {
setAttributes({ backgroundImage: imageObject.sizes.full.url });
}
... | The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could use something like Create-Guten-Block to set up that build process, and then replace the contents of "block.js" with that JS from the docs. (I sure wish they would improve the docs to make things like this clearer.... |
358,441 | <p>I now you can hide the entry-header using css but what if I want just to hide it for a specific category?</p>
<pre><code><div class="entry-header">
<div class="entry-meta category-meta">
<div class="cat-links"><a href="https://web.com/category/mycategory/" rel="category tag">Ausp... | [
{
"answer_id": 358396,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": true,
"text": "<p>The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could ... | 2020/02/12 | [
"https://wordpress.stackexchange.com/questions/358441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148926/"
] | I now you can hide the entry-header using css but what if I want just to hide it for a specific category?
```
<div class="entry-header">
<div class="entry-meta category-meta">
<div class="cat-links"><a href="https://web.com/category/mycategory/" rel="category tag">Auspiciadores</a></div>
</div><!-- .en... | The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could use something like Create-Guten-Block to set up that build process, and then replace the contents of "block.js" with that JS from the docs. (I sure wish they would improve the docs to make things like this clearer.... |
358,475 | <p>How do you escape these two examples?
<code>wc_price()</code> wraps the already escaped <code>$product_price</code> in <code>p</code> and <code>span</code> tags with currency symbol.</p>
<pre><code>$product_price = $product->get_price();
<p><?php echo wc_price( esc_html( $product_price ) ); ?></p... | [
{
"answer_id": 358396,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": true,
"text": "<p>The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could ... | 2020/02/12 | [
"https://wordpress.stackexchange.com/questions/358475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121059/"
] | How do you escape these two examples?
`wc_price()` wraps the already escaped `$product_price` in `p` and `span` tags with currency symbol.
```
$product_price = $product->get_price();
<p><?php echo wc_price( esc_html( $product_price ) ); ?></p>
```
The next one outputs the complete image with all attributes: `src`, ... | The code from the docs is JavaScript. You have to set up Webpack and build this type of JS. So, you could use something like Create-Guten-Block to set up that build process, and then replace the contents of "block.js" with that JS from the docs. (I sure wish they would improve the docs to make things like this clearer.... |
358,541 | <p>Using an example given here: <a href="https://rudrastyh.com/gutenberg/remove-default-blocks.html" rel="nofollow noreferrer">enter link description here</a> I've successfully been able to restrict the block types available globally or by post type (eg: page). But what I really would like to do is restrict the the blo... | [
{
"answer_id": 358510,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 1,
"selected": false,
"text": "<p>You can use FTP to edit edit your .htaccess file, which should be found in the root WordPress install. ... | 2020/02/13 | [
"https://wordpress.stackexchange.com/questions/358541",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51930/"
] | Using an example given here: [enter link description here](https://rudrastyh.com/gutenberg/remove-default-blocks.html) I've successfully been able to restrict the block types available globally or by post type (eg: page). But what I really would like to do is restrict the the block types by page template.
I have tried ... | You can use FTP to edit edit your .htaccess file, which should be found in the root WordPress install.
For example...
`Redirect 301 /old-url /some-new-url`
Put the old page first and just a / for the homepage second.
Note: Make your edits after the `# END WordPress` line
Note 2: There are a ton of plugins that ca... |
358,558 | <p>I wrote a shortcode to display all my jobs. When there are no jobs, I want to display a message instead of the available jobs. I used an else-statement to do this, but when the message shows, it shows on top of the page instead of the place where I added the shortcode.</p>
<p><strong>My code:</strong></p>
<pre><co... | [
{
"answer_id": 358559,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>You can add another if around the code such as:</p>\n\n<pre><code>$total_posts = $query->found_posts;\n... | 2020/02/13 | [
"https://wordpress.stackexchange.com/questions/358558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/167092/"
] | I wrote a shortcode to display all my jobs. When there are no jobs, I want to display a message instead of the available jobs. I used an else-statement to do this, but when the message shows, it shows on top of the page instead of the place where I added the shortcode.
**My code:**
```
function dfib_jobs_shortcode( $... | **Answer**
I found the answer, thanks to a comment and after some digging myself:
```
function dfib_jobs_shortcode( $atts ) {
ob_start();
$query = new WP_Query( array(
'post_type' => 'jobpost',
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'rand',
) );
?>
<div class="vacatures__wrapper">
<?p... |
358,571 | <p>I use this code:</p>
<pre><code>if ( ! function_exists( 'WPScripts_enqueue' ) ) {
function WPScripts_enqueue() {
// Removing default jQuery
wp_deregister_script( 'jquery' );
// Enqueue the new jQuery
wp_enqueue_script('jquery', 'https://code.jquery.com/jquery-3.2.1.slim.min.js'... | [
{
"answer_id": 358593,
"author": "Sonali Yewle",
"author_id": 178505,
"author_profile": "https://wordpress.stackexchange.com/users/178505",
"pm_score": -1,
"selected": false,
"text": "<p>You have to first dequeue the script first & then deregister the script as given as bellow</p>\n\... | 2020/02/13 | [
"https://wordpress.stackexchange.com/questions/358571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/172430/"
] | I use this code:
```
if ( ! function_exists( 'WPScripts_enqueue' ) ) {
function WPScripts_enqueue() {
// Removing default jQuery
wp_deregister_script( 'jquery' );
// Enqueue the new jQuery
wp_enqueue_script('jquery', 'https://code.jquery.com/jquery-3.2.1.slim.min.js', false, '3.2.... | **Use the Following sequence to override jquery**
Install latest jQuery version 3.4.1.
Update the following sequence of code and try!!!!
```
wp_deregister_script('jquery');
wp_register_script('jquery',("https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"),
false);
wp_enqueue_scri... |
358,577 | <p>I am trying to show post thumbnail with the_post_thumbnail() function but the function automatically set image size inline CSS that why my CSS is not working properly.</p>
| [
{
"answer_id": 358593,
"author": "Sonali Yewle",
"author_id": 178505,
"author_profile": "https://wordpress.stackexchange.com/users/178505",
"pm_score": -1,
"selected": false,
"text": "<p>You have to first dequeue the script first & then deregister the script as given as bellow</p>\n\... | 2020/02/13 | [
"https://wordpress.stackexchange.com/questions/358577",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182666/"
] | I am trying to show post thumbnail with the\_post\_thumbnail() function but the function automatically set image size inline CSS that why my CSS is not working properly. | **Use the Following sequence to override jquery**
Install latest jQuery version 3.4.1.
Update the following sequence of code and try!!!!
```
wp_deregister_script('jquery');
wp_register_script('jquery',("https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"),
false);
wp_enqueue_scri... |
358,598 | <p>I just installed a wordpress from my c panel, when i tried login to wp-admin it shows an unknown page instead of wp-admin.
please somebody can help ??<a href="https://i.stack.imgur.com/byOIv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/byOIv.png" alt="enter image description here"></a> </p>
| [
{
"answer_id": 358593,
"author": "Sonali Yewle",
"author_id": 178505,
"author_profile": "https://wordpress.stackexchange.com/users/178505",
"pm_score": -1,
"selected": false,
"text": "<p>You have to first dequeue the script first & then deregister the script as given as bellow</p>\n\... | 2020/02/13 | [
"https://wordpress.stackexchange.com/questions/358598",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182676/"
] | I just installed a wordpress from my c panel, when i tried login to wp-admin it shows an unknown page instead of wp-admin.
please somebody can help ??[](https://i.stack.imgur.com/byOIv.png) | **Use the Following sequence to override jquery**
Install latest jQuery version 3.4.1.
Update the following sequence of code and try!!!!
```
wp_deregister_script('jquery');
wp_register_script('jquery',("https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"),
false);
wp_enqueue_scri... |
358,682 | <p>I am working, on a code, where i need to loop Through all posts of a given author, and then for each post of that author, count the number of media attachments, the post has and then echo it.</p>
<p>I am able to loop Through posts, and it works as expected, but then i want to count the number of attachments of each... | [
{
"answer_id": 358593,
"author": "Sonali Yewle",
"author_id": 178505,
"author_profile": "https://wordpress.stackexchange.com/users/178505",
"pm_score": -1,
"selected": false,
"text": "<p>You have to first dequeue the script first & then deregister the script as given as bellow</p>\n\... | 2020/02/14 | [
"https://wordpress.stackexchange.com/questions/358682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/166927/"
] | I am working, on a code, where i need to loop Through all posts of a given author, and then for each post of that author, count the number of media attachments, the post has and then echo it.
I am able to loop Through posts, and it works as expected, but then i want to count the number of attachments of each post, whe... | **Use the Following sequence to override jquery**
Install latest jQuery version 3.4.1.
Update the following sequence of code and try!!!!
```
wp_deregister_script('jquery');
wp_register_script('jquery',("https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"),
false);
wp_enqueue_scri... |
358,708 | <p>I have an issue where <code>is_user_logged_in()</code> appears to alternate between being true and false.</p>
<p>Additionally, <code>get_current_user_id()</code> gives the correct user ID if <code>is_user_logged_in()</code> is true.</p>
<p>Here's my code: </p>
<p>.htaccess:</p>
<pre><code># BEGIN WordPress
<I... | [
{
"answer_id": 358814,
"author": "Mike",
"author_id": 62621,
"author_profile": "https://wordpress.stackexchange.com/users/62621",
"pm_score": 0,
"selected": false,
"text": "<p>The file that would normally be called to kick off the Wordpress setup is wp-blog-header.php so maybe try swappi... | 2020/02/15 | [
"https://wordpress.stackexchange.com/questions/358708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109355/"
] | I have an issue where `is_user_logged_in()` appears to alternate between being true and false.
Additionally, `get_current_user_id()` gives the correct user ID if `is_user_logged_in()` is true.
Here's my code:
.htaccess:
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^inde... | I've run your code and it works fine to me except for the inclusion in file-access.php:
`require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');`
enable debug to see if there are errors depending on other issues and not regarding these specific code lines.
But.. as per WP documentation: [actions reference](https://c... |
358,722 | <p>I am working with Wordpress Multisite (with sub-directory structure). Everything works fine instead of Wordpress pages. When I publish a page and I try to visit it, it redirects to the main multisite.</p>
<p>So for example, if the page is in this path:</p>
<p><a href="https://example.com/en-us/my-new-page/" rel="n... | [
{
"answer_id": 358814,
"author": "Mike",
"author_id": 62621,
"author_profile": "https://wordpress.stackexchange.com/users/62621",
"pm_score": 0,
"selected": false,
"text": "<p>The file that would normally be called to kick off the Wordpress setup is wp-blog-header.php so maybe try swappi... | 2020/02/15 | [
"https://wordpress.stackexchange.com/questions/358722",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49659/"
] | I am working with Wordpress Multisite (with sub-directory structure). Everything works fine instead of Wordpress pages. When I publish a page and I try to visit it, it redirects to the main multisite.
So for example, if the page is in this path:
<https://example.com/en-us/my-new-page/>
it automatically redirects to:... | I've run your code and it works fine to me except for the inclusion in file-access.php:
`require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');`
enable debug to see if there are errors depending on other issues and not regarding these specific code lines.
But.. as per WP documentation: [actions reference](https://c... |
358,827 | <p>In an upcoming WordPress project I have to display a listing of offices, and these offices would have a bunch of user fillable fields. </p>
<p>I have spent some time thinking about the anatomy of an office and decided it would have the following:</p>
<p>Things that make up an office (in my scenario):</p>
<ul>
<li... | [
{
"answer_id": 358814,
"author": "Mike",
"author_id": 62621,
"author_profile": "https://wordpress.stackexchange.com/users/62621",
"pm_score": 0,
"selected": false,
"text": "<p>The file that would normally be called to kick off the Wordpress setup is wp-blog-header.php so maybe try swappi... | 2020/02/17 | [
"https://wordpress.stackexchange.com/questions/358827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146071/"
] | In an upcoming WordPress project I have to display a listing of offices, and these offices would have a bunch of user fillable fields.
I have spent some time thinking about the anatomy of an office and decided it would have the following:
Things that make up an office (in my scenario):
* Name
* Address line 1
* Add... | I've run your code and it works fine to me except for the inclusion in file-access.php:
`require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');`
enable debug to see if there are errors depending on other issues and not regarding these specific code lines.
But.. as per WP documentation: [actions reference](https://c... |
358,852 | <p>I'm making a custom recent-posts shortcode and I have a problem with the thumbnail image, it always shows it above everything else (permalink, title, etc...) even though I put it after in the code, is there something in wordpress that forces this behavior ?</p>
<p>Here is the code:</p>
<pre><code>function mmx_rece... | [
{
"answer_id": 358862,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is:</p>\n\n<p><code>the_post_thumbnail()</code> outputs its content immediately. It's basical... | 2020/02/17 | [
"https://wordpress.stackexchange.com/questions/358852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182873/"
] | I'm making a custom recent-posts shortcode and I have a problem with the thumbnail image, it always shows it above everything else (permalink, title, etc...) even though I put it after in the code, is there something in wordpress that forces this behavior ?
Here is the code:
```
function mmx_recent_posts_shortcode($a... | The problem is:
`the_post_thumbnail()` outputs its content immediately. It's basically like `echo`ing instead of `return`ing.
To fix it, you should be able to just replace
```php
the_post_thumbnail('thumbnail', ['class' => 'droplet-img', 'title' => get_the_title()])
```
with
```php
get_the_post_thumbnail('thumbna... |
358,855 | <p>I have wordpress v5.3.2 installed on my site. I want to make it a MultiSite and I have read and done all steps mentioned in Wordpress documentation.
I like to set my network as SubDomains. I have Direct Admin panel and I don't know if there is anything else I must do on my host.</p>
<p>Everything seems fine since ... | [
{
"answer_id": 358862,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is:</p>\n\n<p><code>the_post_thumbnail()</code> outputs its content immediately. It's basical... | 2020/02/17 | [
"https://wordpress.stackexchange.com/questions/358855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121268/"
] | I have wordpress v5.3.2 installed on my site. I want to make it a MultiSite and I have read and done all steps mentioned in Wordpress documentation.
I like to set my network as SubDomains. I have Direct Admin panel and I don't know if there is anything else I must do on my host.
Everything seems fine since my Network... | The problem is:
`the_post_thumbnail()` outputs its content immediately. It's basically like `echo`ing instead of `return`ing.
To fix it, you should be able to just replace
```php
the_post_thumbnail('thumbnail', ['class' => 'droplet-img', 'title' => get_the_title()])
```
with
```php
get_the_post_thumbnail('thumbna... |
358,870 | <p>I have to make calls to multiple pages of a Woocommerce product database (getting all products in one go seems to not be an option), and the looping and collection of the results isn't working as I expect. I should see an array with just under 900 objects, but all I'm seeing is an empty array. I'm very new to PHP. T... | [
{
"answer_id": 358862,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is:</p>\n\n<p><code>the_post_thumbnail()</code> outputs its content immediately. It's basical... | 2020/02/17 | [
"https://wordpress.stackexchange.com/questions/358870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/181194/"
] | I have to make calls to multiple pages of a Woocommerce product database (getting all products in one go seems to not be an option), and the looping and collection of the results isn't working as I expect. I should see an array with just under 900 objects, but all I'm seeing is an empty array. I'm very new to PHP. THe ... | The problem is:
`the_post_thumbnail()` outputs its content immediately. It's basically like `echo`ing instead of `return`ing.
To fix it, you should be able to just replace
```php
the_post_thumbnail('thumbnail', ['class' => 'droplet-img', 'title' => get_the_title()])
```
with
```php
get_the_post_thumbnail('thumbna... |
358,886 | <p>I changed my WordPress language to Arabic, Now <code>get_the_date()</code> returns <code>يناير 30, 2020</code> (half Arabic & half english) but I need to get date full Arabic like: <code>يناير ٣٠, ٢٠٢٠</code> </p>
<p>How can I do this?</p>
| [
{
"answer_id": 358862,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is:</p>\n\n<p><code>the_post_thumbnail()</code> outputs its content immediately. It's basical... | 2020/02/18 | [
"https://wordpress.stackexchange.com/questions/358886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136708/"
] | I changed my WordPress language to Arabic, Now `get_the_date()` returns `يناير 30, 2020` (half Arabic & half english) but I need to get date full Arabic like: `يناير ٣٠, ٢٠٢٠`
How can I do this? | The problem is:
`the_post_thumbnail()` outputs its content immediately. It's basically like `echo`ing instead of `return`ing.
To fix it, you should be able to just replace
```php
the_post_thumbnail('thumbnail', ['class' => 'droplet-img', 'title' => get_the_title()])
```
with
```php
get_the_post_thumbnail('thumbna... |
358,925 | <p>In WordPress, how do I get the number of posts next to <code><?php single_cat_title(''); ?></code> in the category.php file?</p>
<pre><code><h1><?php single_cat_title(''); ?> (<?php ????code to count number of posts in the category shown?>?? ?>)</h1>
</code></pre>
| [
{
"answer_id": 358926,
"author": "Dipendra Pancholi",
"author_id": 182923,
"author_profile": "https://wordpress.stackexchange.com/users/182923",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the function get_category() to get the category object and then just simply echo the ... | 2020/02/18 | [
"https://wordpress.stackexchange.com/questions/358925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/170708/"
] | In WordPress, how do I get the number of posts next to `<?php single_cat_title(''); ?>` in the category.php file?
```
<h1><?php single_cat_title(''); ?> (<?php ????code to count number of posts in the category shown?>?? ?>)</h1>
``` | I figured out how to do it.
This code shows the number of posts on a page after clicking on a category in WordPress. Even if the post has lots of categories.
```
<?php $category = get_queried_object(); echo $category->count; ?>
```
I used this code as the code was in the category.php file and not part of the regul... |
358,953 | <p>I have a simple shortcode which parses "user" id from URL and loads specific data from another mysql db for that user inside one custom page:</p>
<pre><code>$sql_u = 'user';
$sql_p = 'password';
$sql_db = 'database';
$sql_ip = '10.10.10.10';
function fetch_data_func ($atts) {
global $wpdb,$sql_u,$sql_p,$sql_db,$s... | [
{
"answer_id": 358958,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>PHP and many other languages have a special construct to combine state an behavior – because that's what you want. Tha... | 2020/02/18 | [
"https://wordpress.stackexchange.com/questions/358953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182948/"
] | I have a simple shortcode which parses "user" id from URL and loads specific data from another mysql db for that user inside one custom page:
```
$sql_u = 'user';
$sql_p = 'password';
$sql_db = 'database';
$sql_ip = '10.10.10.10';
function fetch_data_func ($atts) {
global $wpdb,$sql_u,$sql_p,$sql_db,$sql_ip;
$reg =... | PHP and many other languages have a special construct to combine state an behavior – because that's what you want. That construct is called an **object**.
Objects are defined by **classes**. So you need a class that remembers the current user data (the state) and delivers the parts that you need (the behavior). This c... |
359,025 | <p>I made a grid with bootstrap where i want to show 5 differents posts but for some reason it duplicates the grids and shows one post per grid. <a href="https://i.stack.imgur.com/2j0X5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2j0X5.png" alt="Here you can see how it starts to duplicate the gri... | [
{
"answer_id": 358958,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>PHP and many other languages have a special construct to combine state an behavior – because that's what you want. Tha... | 2020/02/19 | [
"https://wordpress.stackexchange.com/questions/359025",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182997/"
] | I made a grid with bootstrap where i want to show 5 differents posts but for some reason it duplicates the grids and shows one post per grid. [](https://i.stack.imgur.com/2j0X5.png)
[ and delivers the parts that you need (the behavior). This c... |
359,056 | <p>I need to implement vuejs to load the categories of my store. I've read that the woocoomerce rest api need authenticate requets to work, so I'm trying to get the categories using oauth on localhost with https enabled:</p>
<pre><code>// This is in my functions file to pass the parameters
// wp_localize_script( 'main... | [
{
"answer_id": 358958,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>PHP and many other languages have a special construct to combine state an behavior – because that's what you want. Tha... | 2020/02/20 | [
"https://wordpress.stackexchange.com/questions/359056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/177581/"
] | I need to implement vuejs to load the categories of my store. I've read that the woocoomerce rest api need authenticate requets to work, so I'm trying to get the categories using oauth on localhost with https enabled:
```
// This is in my functions file to pass the parameters
// wp_localize_script( 'main', 'woo',
... | PHP and many other languages have a special construct to combine state an behavior – because that's what you want. That construct is called an **object**.
Objects are defined by **classes**. So you need a class that remembers the current user data (the state) and delivers the parts that you need (the behavior). This c... |
359,092 | <p>I am new to the Gutenberg editor. Previously I used the Classic editor (plugin) when editing WordPress. The editor area "resized" according to the browser window.
With the Gutenberg approach I get a very narrow area to edit in. When I use the HTML-block all I get is a 890px wide and 250px high area with scrollbars.... | [
{
"answer_id": 359105,
"author": "Juan Díaz-Bustamante",
"author_id": 183053,
"author_profile": "https://wordpress.stackexchange.com/users/183053",
"pm_score": 2,
"selected": false,
"text": "<p>You have to enqueue first the style editor css</p>\n\n<pre><code>function legit_block_editor_s... | 2020/02/20 | [
"https://wordpress.stackexchange.com/questions/359092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3977/"
] | I am new to the Gutenberg editor. Previously I used the Classic editor (plugin) when editing WordPress. The editor area "resized" according to the browser window.
With the Gutenberg approach I get a very narrow area to edit in. When I use the HTML-block all I get is a 890px wide and 250px high area with scrollbars. I ... | Here is what I did:
functions.php
```
/* Editor styles EXTENDED */
add_action('admin_enqueue_scripts', 'load_admin_style');
function load_admin_style() {
wp_enqueue_style('admin_css', get_stylesheet_directory_uri() .'/gutenberg-styles-extra-wide.css' );
}
```
gutenberg-styles-extra-wide.css
```
/*-------------... |
359,097 | <p>Is there any way to force a Gutenberg block to be on every page of a post type?</p>
<p>I tried to add a <strong>template</strong> on my <strong>page</strong> and it does almost what I need, but I can still remove my default blocks.</p>
<p>The closest I've come is this:</p>
<pre class="lang-php prettyprint-overrid... | [
{
"answer_id": 359116,
"author": "Vitauts Stočka",
"author_id": 181289,
"author_profile": "https://wordpress.stackexchange.com/users/181289",
"pm_score": 0,
"selected": false,
"text": "<p>No fast and easy solution for you. Read discussion <a href=\"https://github.com/WordPress/gutenberg/... | 2020/02/20 | [
"https://wordpress.stackexchange.com/questions/359097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113538/"
] | Is there any way to force a Gutenberg block to be on every page of a post type?
I tried to add a **template** on my **page** and it does almost what I need, but I can still remove my default blocks.
The closest I've come is this:
```php
function ckt_mina_init_required_block()
{
// create a new page template (pag... | There is a lock feature that can be toggled in the blocks toolbar which is marked up like this. I'm not sure in what version this feature was implemented.
```
<!-- wp:paragraph {"lock":{"move":true,"remove":true}} -->
<p>C1</p>
<!-- /wp:paragraph -->
```
To lock your excerpt paragraph I would do this.
```
[
'co... |
359,104 | <p>I have a category called "Featured", but I don't want this category tag to be shown at the bottom of single post pages. I do want to display the other category tags. How do I hide the tag for this one category? </p>
| [
{
"answer_id": 359116,
"author": "Vitauts Stočka",
"author_id": 181289,
"author_profile": "https://wordpress.stackexchange.com/users/181289",
"pm_score": 0,
"selected": false,
"text": "<p>No fast and easy solution for you. Read discussion <a href=\"https://github.com/WordPress/gutenberg/... | 2020/02/20 | [
"https://wordpress.stackexchange.com/questions/359104",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69240/"
] | I have a category called "Featured", but I don't want this category tag to be shown at the bottom of single post pages. I do want to display the other category tags. How do I hide the tag for this one category? | There is a lock feature that can be toggled in the blocks toolbar which is marked up like this. I'm not sure in what version this feature was implemented.
```
<!-- wp:paragraph {"lock":{"move":true,"remove":true}} -->
<p>C1</p>
<!-- /wp:paragraph -->
```
To lock your excerpt paragraph I would do this.
```
[
'co... |
359,127 | <p>I use following function to get my custom posts ordering by title</p>
<pre><code>$posts = get_posts(
array(
"orderby"=> "title",
"order" => "ASC",
"post_type" => "my-custom-post-type",
"posts_per_page" => -1,
"fields" => "ids",
"meta_query" => ar... | [
{
"answer_id": 360034,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 5,
"selected": true,
"text": "<p>Try this...</p>\n\n<pre><code>$posts = get_posts(\n array(\n \"orderby\"=> \"slug\",\n ... | 2020/02/20 | [
"https://wordpress.stackexchange.com/questions/359127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130208/"
] | I use following function to get my custom posts ordering by title
```
$posts = get_posts(
array(
"orderby"=> "title",
"order" => "ASC",
"post_type" => "my-custom-post-type",
"posts_per_page" => -1,
"fields" => "ids",
"meta_query" => array(
array(
... | Try this...
```
$posts = get_posts(
array(
"orderby"=> "slug",
"order" => "ASC",
"post_type" => "my-custom-post-type",
"posts_per_page" => -1,
"fields" => "ids",
"meta_query" => array(
array(
"key" => "ams_park_id",
"value"... |
359,163 | <p>I'm trying to make this as simple as possible just to get the basics down, but I keep getting a 400 error and 0 response from admin-ajax.php. I just want to hit ajax with some data. Here's my js:</p>
<pre><code>jQuery(document).ready(function($) {
$('body').click(function(e){
$.ajax({
action: 'the... | [
{
"answer_id": 359165,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 1,
"selected": true,
"text": "<p>From codex: <a href=\"https://developer.wordpress.org/reference/hooks/wp_ajax_action/\" rel=\"nofollow... | 2020/02/21 | [
"https://wordpress.stackexchange.com/questions/359163",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183099/"
] | I'm trying to make this as simple as possible just to get the basics down, but I keep getting a 400 error and 0 response from admin-ajax.php. I just want to hit ajax with some data. Here's my js:
```
jQuery(document).ready(function($) {
$('body').click(function(e){
$.ajax({
action: 'the_ajax_hook',
... | From codex: [wp\_ajax\_{$action}](https://developer.wordpress.org/reference/hooks/wp_ajax_action/) and wp\_ajax\_nopriv{$action}
the dinamic part {$action} must be the same name as the function, so instead of:
```
add_action( 'wp_ajax_the_ajax_hook', 'the_action_function' );
add_action( 'wp_ajax_nopriv_the_ajax_hook',... |
359,171 | <p>Good Morning,</p>
<p>I use Events Calendar for our Website, now I want to change the "Now onwards" and
"onwards" on top of the page, also the next and previous at the bottom of the event calendar. I already tried to change it with their documentation (and support) but it didn't work. As we are a German business wi... | [
{
"answer_id": 359175,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>For only a couple of words I would use the gettext filter e.g.</p>\n\n<pre><code>function wse_text_filter(... | 2020/02/21 | [
"https://wordpress.stackexchange.com/questions/359171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183105/"
] | Good Morning,
I use Events Calendar for our Website, now I want to change the "Now onwards" and
"onwards" on top of the page, also the next and previous at the bottom of the event calendar. I already tried to change it with their documentation (and support) but it didn't work. As we are a German business without Engl... | The "Now onwards" string is translated with [\_x()](https://developer.wordpress.org/reference/functions/_x/) which is different than \_\_() because it allows context to be added to the string being translated.
Because there is context, you need to use [gettext\_with\_context](https://developer.wordpress.org/reference... |
359,174 | <p>I am trying to apply a format to the selected text, but the apply format method of gutenberg doesnt return any error and fails silently.</p>
<p>I am registering my format type like this</p>
<pre><code>import { registerFormatType } from "@wordpress/rich-text";
registerFormatType(BLOCK_NAME, {
title: "Ans... | [
{
"answer_id": 359175,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>For only a couple of words I would use the gettext filter e.g.</p>\n\n<pre><code>function wse_text_filter(... | 2020/02/21 | [
"https://wordpress.stackexchange.com/questions/359174",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/180218/"
] | I am trying to apply a format to the selected text, but the apply format method of gutenberg doesnt return any error and fails silently.
I am registering my format type like this
```
import { registerFormatType } from "@wordpress/rich-text";
registerFormatType(BLOCK_NAME, {
title: "Answer",
tagNa... | The "Now onwards" string is translated with [\_x()](https://developer.wordpress.org/reference/functions/_x/) which is different than \_\_() because it allows context to be added to the string being translated.
Because there is context, you need to use [gettext\_with\_context](https://developer.wordpress.org/reference... |
359,186 | <p>Can't figure out why this isn't working. I'm trying to query posts for a member mailing list and simply don't want to include users that are not members. Right now even the users that have an empty meta_value to the meta_key 'member' are shown. Please help! (WP version 5.3.2)</p>
<pre><code> function get_all_use... | [
{
"answer_id": 359175,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>For only a couple of words I would use the gettext filter e.g.</p>\n\n<pre><code>function wse_text_filter(... | 2020/02/21 | [
"https://wordpress.stackexchange.com/questions/359186",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164427/"
] | Can't figure out why this isn't working. I'm trying to query posts for a member mailing list and simply don't want to include users that are not members. Right now even the users that have an empty meta\_value to the meta\_key 'member' are shown. Please help! (WP version 5.3.2)
```
function get_all_users () {
... | The "Now onwards" string is translated with [\_x()](https://developer.wordpress.org/reference/functions/_x/) which is different than \_\_() because it allows context to be added to the string being translated.
Because there is context, you need to use [gettext\_with\_context](https://developer.wordpress.org/reference... |
359,213 | <p>I am trying to add Wordpress featured image in tag. I used these 3 shortcodes.</p>
<pre><code><?php echo $image_large[0]; ?>
<?php echo get_the_post_thumbnail(null,'thumbnail');?>
<?php echo get_the_post_thumbnail( $page->ID, 'full' ); ?>
</code></pre>
<p>Example</p>
<pre><code><a href="&... | [
{
"answer_id": 359175,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>For only a couple of words I would use the gettext filter e.g.</p>\n\n<pre><code>function wse_text_filter(... | 2020/02/21 | [
"https://wordpress.stackexchange.com/questions/359213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183135/"
] | I am trying to add Wordpress featured image in tag. I used these 3 shortcodes.
```
<?php echo $image_large[0]; ?>
<?php echo get_the_post_thumbnail(null,'thumbnail');?>
<?php echo get_the_post_thumbnail( $page->ID, 'full' ); ?>
```
Example
```
<a href="<?php echo get_the_post_thumbnail( $page->ID, 'full' ); ?>" >Vi... | The "Now onwards" string is translated with [\_x()](https://developer.wordpress.org/reference/functions/_x/) which is different than \_\_() because it allows context to be added to the string being translated.
Because there is context, you need to use [gettext\_with\_context](https://developer.wordpress.org/reference... |
359,215 | <p>Im currently using User Role editor to modify permission for the user role. I'd like to be able to restrict the role from publishing a post. They can save the draft but they should not be able to publish. Is there a better way to do it?</p>
| [
{
"answer_id": 359175,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>For only a couple of words I would use the gettext filter e.g.</p>\n\n<pre><code>function wse_text_filter(... | 2020/02/21 | [
"https://wordpress.stackexchange.com/questions/359215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101716/"
] | Im currently using User Role editor to modify permission for the user role. I'd like to be able to restrict the role from publishing a post. They can save the draft but they should not be able to publish. Is there a better way to do it? | The "Now onwards" string is translated with [\_x()](https://developer.wordpress.org/reference/functions/_x/) which is different than \_\_() because it allows context to be added to the string being translated.
Because there is context, you need to use [gettext\_with\_context](https://developer.wordpress.org/reference... |
359,221 | <p>I'm getting <code>Error establishing a database connection</code> when installing WP.</p>
<p>The following prints "Connected" when putting into <code>wp-config.php</code>:</p>
<pre><code>$mysqli_connection = mysqli_connect(
$_dbsettings['host'],
$_dbsettings['user'],
$_dbsettings['pass'],
trim( $_dbsetting... | [
{
"answer_id": 359175,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>For only a couple of words I would use the gettext filter e.g.</p>\n\n<pre><code>function wse_text_filter(... | 2020/02/21 | [
"https://wordpress.stackexchange.com/questions/359221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/155818/"
] | I'm getting `Error establishing a database connection` when installing WP.
The following prints "Connected" when putting into `wp-config.php`:
```
$mysqli_connection = mysqli_connect(
$_dbsettings['host'],
$_dbsettings['user'],
$_dbsettings['pass'],
trim( $_dbsettings['path'], '/' ),
$_dbsettings['port']
);... | The "Now onwards" string is translated with [\_x()](https://developer.wordpress.org/reference/functions/_x/) which is different than \_\_() because it allows context to be added to the string being translated.
Because there is context, you need to use [gettext\_with\_context](https://developer.wordpress.org/reference... |
359,286 | <p>I would like to remove the category title or tag from my individual posts on my archive pages. I have already succeeded in removing the tags from the homepage and archive page header but they still show up on the individual posts (they are in a red font). So the posts always have the category "Latest Post" next to t... | [
{
"answer_id": 359175,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>For only a couple of words I would use the gettext filter e.g.</p>\n\n<pre><code>function wse_text_filter(... | 2020/02/22 | [
"https://wordpress.stackexchange.com/questions/359286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183185/"
] | I would like to remove the category title or tag from my individual posts on my archive pages. I have already succeeded in removing the tags from the homepage and archive page header but they still show up on the individual posts (they are in a red font). So the posts always have the category "Latest Post" next to the ... | The "Now onwards" string is translated with [\_x()](https://developer.wordpress.org/reference/functions/_x/) which is different than \_\_() because it allows context to be added to the string being translated.
Because there is context, you need to use [gettext\_with\_context](https://developer.wordpress.org/reference... |
359,291 | <p>I am working on a small online shop and I am using Averta Phlox theme. As I encounter they have bug in a shopping cart. The cart do not work on mobile phones, as I can work a little fix for it using simple css and html, I am able to fix this bug. But I can't find the place for HTML part in this because it use aux de... | [
{
"answer_id": 359175,
"author": "GarethTF",
"author_id": 181549,
"author_profile": "https://wordpress.stackexchange.com/users/181549",
"pm_score": 0,
"selected": false,
"text": "<p>For only a couple of words I would use the gettext filter e.g.</p>\n\n<pre><code>function wse_text_filter(... | 2020/02/22 | [
"https://wordpress.stackexchange.com/questions/359291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183190/"
] | I am working on a small online shop and I am using Averta Phlox theme. As I encounter they have bug in a shopping cart. The cart do not work on mobile phones, as I can work a little fix for it using simple css and html, I am able to fix this bug. But I can't find the place for HTML part in this because it use aux desig... | The "Now onwards" string is translated with [\_x()](https://developer.wordpress.org/reference/functions/_x/) which is different than \_\_() because it allows context to be added to the string being translated.
Because there is context, you need to use [gettext\_with\_context](https://developer.wordpress.org/reference... |
359,313 | <p>Wordpress compresses jpeg files to a lvl 82 quality. Should I upload my files in 100 quality to avoid double compression? Or will Wordpress know the file is already compressed and will skip this process?</p>
<p>I usually save my files in photoshop in 80 quality , as progressive.</p>
<p>Thank you</p>
| [
{
"answer_id": 359315,
"author": "vbaimas",
"author_id": 183044,
"author_profile": "https://wordpress.stackexchange.com/users/183044",
"pm_score": 1,
"selected": false,
"text": "<p>If you want to showcase high-quality images on your website, then you can turn off image compression in Wor... | 2020/02/23 | [
"https://wordpress.stackexchange.com/questions/359313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71513/"
] | Wordpress compresses jpeg files to a lvl 82 quality. Should I upload my files in 100 quality to avoid double compression? Or will Wordpress know the file is already compressed and will skip this process?
I usually save my files in photoshop in 80 quality , as progressive.
Thank you | If you want to showcase high-quality images on your website, then you can turn off image compression in WordPress.
You can do that by adding this part of code in your `functions.php` :
`add_filter('jpeg_quality', function($arg){return 100;});`
Or you can create your plugin :
```
<?php
/**
* Plugin Name: R... |
359,400 | <p>I have some meta boxes setup, some are my own, some are initialized in plugins.</p>
<p>As the title indicates, these meta boxes are not updating graphically after the post has been submitted.</p>
<p>Here's an example of the problem, I have a metabox with a single toggle to enable notifications.
After the first not... | [
{
"answer_id": 359403,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 1,
"selected": false,
"text": "<p>I'd use a \"Search and Replace\" plugin (I like \"Better Search and Replace\") to search for all <a hr... | 2020/02/24 | [
"https://wordpress.stackexchange.com/questions/359400",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183281/"
] | I have some meta boxes setup, some are my own, some are initialized in plugins.
As the title indicates, these meta boxes are not updating graphically after the post has been submitted.
Here's an example of the problem, I have a metabox with a single toggle to enable notifications.
After the first notification is sent... | I'd use a "Search and Replace" plugin (I like "Better Search and Replace") to search for all <http://www.example.com> and replace with <https://www.example.com> . That will fix media URLs, for instance, and other settings.
It could also be that your theme is calling `http` resources rather than `https`. You could look... |
359,541 | <p>I am initializing a class where the constructor requires a WP_Post object. The object I would like to pass comes from <code>get_queried_object()</code> which could return almost anything. I am using <code>is_a()</code> to make sure I have the right type, which "works", but my IDE does not recognize that I have const... | [
{
"answer_id": 359403,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 1,
"selected": false,
"text": "<p>I'd use a \"Search and Replace\" plugin (I like \"Better Search and Replace\") to search for all <a hr... | 2020/02/26 | [
"https://wordpress.stackexchange.com/questions/359541",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11310/"
] | I am initializing a class where the constructor requires a WP\_Post object. The object I would like to pass comes from `get_queried_object()` which could return almost anything. I am using `is_a()` to make sure I have the right type, which "works", but my IDE does not recognize that I have constrained the type.
Is the... | I'd use a "Search and Replace" plugin (I like "Better Search and Replace") to search for all <http://www.example.com> and replace with <https://www.example.com> . That will fix media URLs, for instance, and other settings.
It could also be that your theme is calling `http` resources rather than `https`. You could look... |
359,560 | <p>am trying to crop my thumbnail in my loop, am having some problems when i crop using codes some images appear either big in width or height here is my code
Css</p>
<pre><code>.imgholder {float:left;margin-right:20px; margin-left:20px;height:240px;width:240px;}
</code></pre>
<p>loop</p>
<pre><code><?php the_pos... | [
{
"answer_id": 359403,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 1,
"selected": false,
"text": "<p>I'd use a \"Search and Replace\" plugin (I like \"Better Search and Replace\") to search for all <a hr... | 2020/02/26 | [
"https://wordpress.stackexchange.com/questions/359560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183184/"
] | am trying to crop my thumbnail in my loop, am having some problems when i crop using codes some images appear either big in width or height here is my code
Css
```
.imgholder {float:left;margin-right:20px; margin-left:20px;height:240px;width:240px;}
```
loop
```
<?php the_post_thumbnail( 'large' , array('class' => ... | I'd use a "Search and Replace" plugin (I like "Better Search and Replace") to search for all <http://www.example.com> and replace with <https://www.example.com> . That will fix media URLs, for instance, and other settings.
It could also be that your theme is calling `http` resources rather than `https`. You could look... |
359,597 | <p>I'm trying to use this simple code to insert page (1) content into another page (2): </p>
<pre><code> <?php
$id = 216;
$p = get_page($id);
echo apply_filters('the_content', $p->post_content);
?>
</code></pre>
<p>So far so good. The inserted page (1), though, is some html code that at one point contains </... | [
{
"answer_id": 359611,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>There's a fundamental problem in your code, and one that suggests you're doing something very dangerous in y... | 2020/02/27 | [
"https://wordpress.stackexchange.com/questions/359597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183438/"
] | I'm trying to use this simple code to insert page (1) content into another page (2):
```
<?php
$id = 216;
$p = get_page($id);
echo apply_filters('the_content', $p->post_content);
?>
```
So far so good. The inserted page (1), though, is some html code that at one point contains
```
value="<?php echo $url?>"
```
... | Assuming you want to replace it with some static value (well, you can always change this anyway), some kind of find and replace snippet like this can do the trick:
```
$content = apply_filters( 'the_content', $post->post_content);
// set the replacement string value
$replace = "REPLACEMENT";
// make sure the quotes us... |
359,599 | <p>I am using this code in my plugin to enqueue script:</p>
<pre><code>wp_enqueue_script( 'wpfrank-ptbw-pinit-js', PTBW_PLUGIN_URL . 'assets/js/pinit.js', array('jquery'), '', true );
</code></pre>
<p>The <code>wp_enqueue_script</code> function making a default <code><script></code> tag output like this:</p>
<... | [
{
"answer_id": 359606,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 3,
"selected": false,
"text": "<p>I revised the answer once more because I recently noticed how the <a href=\"https://wordpress.org/themes/t... | 2020/02/27 | [
"https://wordpress.stackexchange.com/questions/359599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25262/"
] | I am using this code in my plugin to enqueue script:
```
wp_enqueue_script( 'wpfrank-ptbw-pinit-js', PTBW_PLUGIN_URL . 'assets/js/pinit.js', array('jquery'), '', true );
```
The `wp_enqueue_script` function making a default `<script>` tag output like this:
```
<script type='text/javascript' src='http://localhost/de... | I revised the answer once more because I recently noticed how the [Twenty Twenty](https://wordpress.org/themes/twentytwenty/) developers use the `script_loader_tag` hook to add `async` and `defer` to the `<script>` tag for the theme scripts.
1. In `twentytwenty_theme_support()` in `functions.php`, [lines #139 & #140](... |
359,632 | <p>Within the network admin, the <strong>My Sites</strong> link, is not linking to the main parent site. Instead, it links to a child site blog. How can I change this link? Is there a way to rebuild WP menu? I haven't a clue how it became the wrong link.</p>
<p><a href="https://i.stack.imgur.com/11kFS.png" rel="nofoll... | [
{
"answer_id": 359606,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 3,
"selected": false,
"text": "<p>I revised the answer once more because I recently noticed how the <a href=\"https://wordpress.org/themes/t... | 2020/02/27 | [
"https://wordpress.stackexchange.com/questions/359632",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/181079/"
] | Within the network admin, the **My Sites** link, is not linking to the main parent site. Instead, it links to a child site blog. How can I change this link? Is there a way to rebuild WP menu? I haven't a clue how it became the wrong link.
[](https://i... | I revised the answer once more because I recently noticed how the [Twenty Twenty](https://wordpress.org/themes/twentytwenty/) developers use the `script_loader_tag` hook to add `async` and `defer` to the `<script>` tag for the theme scripts.
1. In `twentytwenty_theme_support()` in `functions.php`, [lines #139 & #140](... |
359,660 | <p>I've created a quick function and shortcode to allow me to include logged-in user only content:</p>
<pre><code>function content_for_logged_in($atts,$content){
$logged_in_content = "";
if(is_user_logged_in()){
$logged_in_content = $content;
}
return $logged_in_content;
}
add_shortcode('logg... | [
{
"answer_id": 359661,
"author": "ScottM",
"author_id": 57399,
"author_profile": "https://wordpress.stackexchange.com/users/57399",
"pm_score": 0,
"selected": false,
"text": "<p>I found a way to achieve what I need right now...</p>\n\n<pre><code> function content_for_logged_in($atts,$... | 2020/02/28 | [
"https://wordpress.stackexchange.com/questions/359660",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57399/"
] | I've created a quick function and shortcode to allow me to include logged-in user only content:
```
function content_for_logged_in($atts,$content){
$logged_in_content = "";
if(is_user_logged_in()){
$logged_in_content = $content;
}
return $logged_in_content;
}
add_shortcode('logged-in-content'... | The function you are looking for is named `do_shortcode` (there will also be a function `apply_shortcode` in Wordpress 5.4 that does the same). [Codex Page](https://developer.wordpress.org/reference/functions/do_shortcode/)
For your example, this will work:
```
function content_for_logged_in($atts,$content){
$log... |
359,665 | <p>I have used custom php form for uploading image via ajax. And has successfully uploaded the image and getting the attachment id & the image url also,</p>
<p>Is there any way to attach the attachment id or the image url to the user profile image, so the admin can also view the user profile image in user list. </... | [
{
"answer_id": 359661,
"author": "ScottM",
"author_id": 57399,
"author_profile": "https://wordpress.stackexchange.com/users/57399",
"pm_score": 0,
"selected": false,
"text": "<p>I found a way to achieve what I need right now...</p>\n\n<pre><code> function content_for_logged_in($atts,$... | 2020/02/28 | [
"https://wordpress.stackexchange.com/questions/359665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/170387/"
] | I have used custom php form for uploading image via ajax. And has successfully uploaded the image and getting the attachment id & the image url also,
Is there any way to attach the attachment id or the image url to the user profile image, so the admin can also view the user profile image in user list.
Thanks. | The function you are looking for is named `do_shortcode` (there will also be a function `apply_shortcode` in Wordpress 5.4 that does the same). [Codex Page](https://developer.wordpress.org/reference/functions/do_shortcode/)
For your example, this will work:
```
function content_for_logged_in($atts,$content){
$log... |
359,695 | <p>I'm trying and failing to register an embed code for content from padlet.com (strangely it's supported in WP.com but not WP.org). A URL like</p>
<pre><code> https://padlet.com/cogdogblog/aos9fosbbwk4
</code></pre>
<p>should embed like</p>
<pre class="lang-html prettyprint-override"><code><div class="padlet-emb... | [
{
"answer_id": 359696,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Have you considered using a simpler regex such as:</p>\n\n<pre class=\"lang-php prettyprint-override\"><code... | 2020/02/28 | [
"https://wordpress.stackexchange.com/questions/359695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14945/"
] | I'm trying and failing to register an embed code for content from padlet.com (strangely it's supported in WP.com but not WP.org). A URL like
```
https://padlet.com/cogdogblog/aos9fosbbwk4
```
should embed like
```html
<div class="padlet-embed" style="border:1px solid rgba(0,0,0,0.1);border-radius:2px;box-sizing:bo... | Have you considered using a simpler regex such as:
```php
'#^https?://padlet\.com/(\?.+)?$#'
```
Then breaking apart the latter section with `explode` to get the video ID? |
359,737 | <p>I want to be able to change the WordPress default logo url (not the logo image) based on the user role. The image/logo will remain the same, only the url will change. Any assistance or ideas will be greatly appreciated.</p>
| [
{
"answer_id": 359696,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Have you considered using a simpler regex such as:</p>\n\n<pre class=\"lang-php prettyprint-override\"><code... | 2020/02/29 | [
"https://wordpress.stackexchange.com/questions/359737",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183556/"
] | I want to be able to change the WordPress default logo url (not the logo image) based on the user role. The image/logo will remain the same, only the url will change. Any assistance or ideas will be greatly appreciated. | Have you considered using a simpler regex such as:
```php
'#^https?://padlet\.com/(\?.+)?$#'
```
Then breaking apart the latter section with `explode` to get the video ID? |
359,744 | <p>I have installed wordpress on google compute engine..</p>
<p>Running nginx, wordpress and https.. The site doesn't load the admin panel or the images..</p>
<p>throws up 404 error on chrome inspection </p>
<blockquote>
<p>HTTP404: NOT FOUND - The server has not found anything matching the
requested URI (Unifor... | [
{
"answer_id": 359696,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Have you considered using a simpler regex such as:</p>\n\n<pre class=\"lang-php prettyprint-override\"><code... | 2020/02/29 | [
"https://wordpress.stackexchange.com/questions/359744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183558/"
] | I have installed wordpress on google compute engine..
Running nginx, wordpress and https.. The site doesn't load the admin panel or the images..
throws up 404 error on chrome inspection
>
> HTTP404: NOT FOUND - The server has not found anything matching the
> requested URI (Uniform Resource Identifier). GET -
> ... | Have you considered using a simpler regex such as:
```php
'#^https?://padlet\.com/(\?.+)?$#'
```
Then breaking apart the latter section with `explode` to get the video ID? |
359,762 | <p>I ama newbie in WordPress Plugin development in which I have some HTML form on the main plugin page that will get the data from the admin who is logged in and a back page where I have some different functions in PHP like to get information from the database etc. To explain in detail, here is the code...</p>
<p><str... | [
{
"answer_id": 360242,
"author": "Muhammad Hassan",
"author_id": 52859,
"author_profile": "https://wordpress.stackexchange.com/users/52859",
"pm_score": 1,
"selected": true,
"text": "<p>Finally after trying my best, here I am sharing the working complete basic example of my question in e... | 2020/02/29 | [
"https://wordpress.stackexchange.com/questions/359762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52859/"
] | I ama newbie in WordPress Plugin development in which I have some HTML form on the main plugin page that will get the data from the admin who is logged in and a back page where I have some different functions in PHP like to get information from the database etc. To explain in detail, here is the code...
**Main Plugin ... | Finally after trying my best, here I am sharing the working complete basic example of my question in easy steps. This answer is also considered as a full Ajax Plugin Example in a professional way. I now recommend keeping every file separate for better, clean and comfortable coding...
**Main Plugin File:**
```
<?php
/... |
359,766 | <p>I’ve got a simple php script which is connecting to my wordpress to create a product. Using the woocommerce rest api library.</p>
<pre><code>$woocommerce = new Client(
'https://dev.example.co.uk',
'123456789',
'123456789',
[
'wp_api' => true,
'version' => 'wc/v3',
'sslverify' => f... | [
{
"answer_id": 368584,
"author": "Mudasser Mian",
"author_id": 189653,
"author_profile": "https://wordpress.stackexchange.com/users/189653",
"pm_score": 0,
"selected": false,
"text": "<p>@wharfdale I faced the same problem. All you need to do is to open the file vendor\\automattic\\wooco... | 2020/02/29 | [
"https://wordpress.stackexchange.com/questions/359766",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52096/"
] | I’ve got a simple php script which is connecting to my wordpress to create a product. Using the woocommerce rest api library.
```
$woocommerce = new Client(
'https://dev.example.co.uk',
'123456789',
'123456789',
[
'wp_api' => true,
'version' => 'wc/v3',
'sslverify' => false,
]
);
// foreac... | You can disable the ssl verification by using `'verify_ssl' => false`. So in your code you should change:
```
[
'wp_api' => true,
'version' => 'wc/v3',
'sslverify' => false,
]
```
to:
```
[
'wp_api' => true,
'version' => 'wc/v3',
'verify_ssl' => false,
]
```
Then y... |
359,788 | <p>I am trying to add a product with an image via the WooCommerce REST API but getting this error:</p>
<blockquote>
<p>Fatal error: Uncaught
Automattic\WooCommerce\HttpClient\HttpClientException: Error: #0 is an
invalid image ID.</p>
</blockquote>
<p>Despite many other threads similar, no one seems to have an a... | [
{
"answer_id": 368584,
"author": "Mudasser Mian",
"author_id": 189653,
"author_profile": "https://wordpress.stackexchange.com/users/189653",
"pm_score": 0,
"selected": false,
"text": "<p>@wharfdale I faced the same problem. All you need to do is to open the file vendor\\automattic\\wooco... | 2020/03/01 | [
"https://wordpress.stackexchange.com/questions/359788",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52096/"
] | I am trying to add a product with an image via the WooCommerce REST API but getting this error:
>
> Fatal error: Uncaught
> Automattic\WooCommerce\HttpClient\HttpClientException: Error: #0 is an
> invalid image ID.
>
>
>
Despite many other threads similar, no one seems to have an actual answer to why this happe... | You can disable the ssl verification by using `'verify_ssl' => false`. So in your code you should change:
```
[
'wp_api' => true,
'version' => 'wc/v3',
'sslverify' => false,
]
```
to:
```
[
'wp_api' => true,
'version' => 'wc/v3',
'verify_ssl' => false,
]
```
Then y... |
359,803 | <p>I've been going at this issue for hours now, and please save me before i go crazy.....</p>
<p>I'm trying to use Wordpress' WP_User_Query to retrieve users from db</p>
<p>I've been feeding it with arguments like this, and it works fine...:</p>
<pre><code>function getSomeUsers ($year, $month, $day)
{
$arg = [
... | [
{
"answer_id": 359813,
"author": "Siddhesh Shirodkar",
"author_id": 163787,
"author_profile": "https://wordpress.stackexchange.com/users/163787",
"pm_score": 0,
"selected": false,
"text": "<p>Here is the reference code:</p>\n\n<pre><code>$args = array (\n'role' => 'reporter',\n'order'... | 2020/03/01 | [
"https://wordpress.stackexchange.com/questions/359803",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183613/"
] | I've been going at this issue for hours now, and please save me before i go crazy.....
I'm trying to use Wordpress' WP\_User\_Query to retrieve users from db
I've been feeding it with arguments like this, and it works fine...:
```
function getSomeUsers ($year, $month, $day)
{
$arg = [
'meta_key' =... | I've tried the meta query on another simple wordpress site, and it works there, so there must be something else going on, meddling with the query..
I've been doing some digging with the Query Monitor plugin... I thought it might have been because I've also been meddling with pre\_user\_query, but I can see that I don'... |
359,887 | <p>I want to add jquery plugin to wordpress webpage to provide some animations.
I have downloaded "jquery.plate.js" from jqueryscript.net and saved it locally in my custom themes,(js/jquery.plate.js) js folder.</p>
<pre><code><script src="//code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script sr... | [
{
"answer_id": 359820,
"author": "Chipsy",
"author_id": 132006,
"author_profile": "https://wordpress.stackexchange.com/users/132006",
"pm_score": -1,
"selected": false,
"text": "<p>Kindly check the Error Log file to know the exact error. HTTP 500 error can be due to a lot of things. </p>... | 2020/03/03 | [
"https://wordpress.stackexchange.com/questions/359887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/181471/"
] | I want to add jquery plugin to wordpress webpage to provide some animations.
I have downloaded "jquery.plate.js" from jqueryscript.net and saved it locally in my custom themes,(js/jquery.plate.js) js folder.
```
<script src="//code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="jquery.plate.js"></script>... | there might be these possibilities please check both the cases
* Please allow the debugging mode in your wp-config file
`define('WP_DEBUG', false);` make it true.
* If after enabling the debug you didn't get any fatal error, then this
problem is related to your hosting server, do check with their
support. |
359,899 | <p>I have added the ability for a social security number to be added for users. This field can be edited on the individual users screen but the data is saved to the usermeta table. When editing a new user, I want to check if that number is being used somewhere else for another user as duplicates should not be allowed. ... | [
{
"answer_id": 359901,
"author": "Chetan Vaghela",
"author_id": 169856,
"author_profile": "https://wordpress.stackexchange.com/users/169856",
"pm_score": 2,
"selected": true,
"text": "<p>You can check duplicate user meta using sql query.in below code if duplicate record found of other us... | 2020/03/03 | [
"https://wordpress.stackexchange.com/questions/359899",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165412/"
] | I have added the ability for a social security number to be added for users. This field can be edited on the individual users screen but the data is saved to the usermeta table. When editing a new user, I want to check if that number is being used somewhere else for another user as duplicates should not be allowed.
M... | You can check duplicate user meta using sql query.in below code if duplicate record found of other users then it will display error message and not update value. add below code in active theme's functions.php file.
```
function save_cust_user_profile_fields( $user_id ) {
if ( isset($_POST['social_number']) ) {
... |
359,906 | <p>when someone send a link of a website in facebook, sometimes it shows the hero image of the website.Like this:<a href="https://i.stack.imgur.com/m4WXg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m4WXg.png" alt="image 1"></a></p>
<p>How can i set that for my website?</p>
| [
{
"answer_id": 359901,
"author": "Chetan Vaghela",
"author_id": 169856,
"author_profile": "https://wordpress.stackexchange.com/users/169856",
"pm_score": 2,
"selected": true,
"text": "<p>You can check duplicate user meta using sql query.in below code if duplicate record found of other us... | 2020/03/03 | [
"https://wordpress.stackexchange.com/questions/359906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/180966/"
] | when someone send a link of a website in facebook, sometimes it shows the hero image of the website.Like this:[](https://i.stack.imgur.com/m4WXg.png)
How can i set that for my website? | You can check duplicate user meta using sql query.in below code if duplicate record found of other users then it will display error message and not update value. add below code in active theme's functions.php file.
```
function save_cust_user_profile_fields( $user_id ) {
if ( isset($_POST['social_number']) ) {
... |
359,909 | <p>I've got a child theme activated and I don't see any head and body in my child theme to place the GTM snippet. </p>
<p>How do I do this? I rather not paste in the whole head and body in the child theme to overwrite the parent theme and miss out on updates. </p>
| [
{
"answer_id": 359901,
"author": "Chetan Vaghela",
"author_id": 169856,
"author_profile": "https://wordpress.stackexchange.com/users/169856",
"pm_score": 2,
"selected": true,
"text": "<p>You can check duplicate user meta using sql query.in below code if duplicate record found of other us... | 2020/03/03 | [
"https://wordpress.stackexchange.com/questions/359909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183724/"
] | I've got a child theme activated and I don't see any head and body in my child theme to place the GTM snippet.
How do I do this? I rather not paste in the whole head and body in the child theme to overwrite the parent theme and miss out on updates. | You can check duplicate user meta using sql query.in below code if duplicate record found of other users then it will display error message and not update value. add below code in active theme's functions.php file.
```
function save_cust_user_profile_fields( $user_id ) {
if ( isset($_POST['social_number']) ) {
... |
359,930 | <p>In my template i'm using a link for downloading a file (probably a PDF or a JPEG) that I will upload from Media Library.
How can I get the url path for this specific file?
What template tag I have to use?</p>
<p>Thanks</p>
| [
{
"answer_id": 359901,
"author": "Chetan Vaghela",
"author_id": 169856,
"author_profile": "https://wordpress.stackexchange.com/users/169856",
"pm_score": 2,
"selected": true,
"text": "<p>You can check duplicate user meta using sql query.in below code if duplicate record found of other us... | 2020/03/03 | [
"https://wordpress.stackexchange.com/questions/359930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70257/"
] | In my template i'm using a link for downloading a file (probably a PDF or a JPEG) that I will upload from Media Library.
How can I get the url path for this specific file?
What template tag I have to use?
Thanks | You can check duplicate user meta using sql query.in below code if duplicate record found of other users then it will display error message and not update value. add below code in active theme's functions.php file.
```
function save_cust_user_profile_fields( $user_id ) {
if ( isset($_POST['social_number']) ) {
... |
359,933 | <p>I have managed to change the width of the <strong>WordPress block editor</strong> so it uses my max width of my actual theme, making it easier to do layouts during the writing process. Now I wanted to change that to <strong>only</strong> happen when I edit <strong>pages</strong>, <em>not posts</em> or other taxonomi... | [
{
"answer_id": 359934,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 0,
"selected": false,
"text": "<p>In the admin, if you inspect the body tag you will see WP is adding specific classess, similar to on the... | 2020/03/03 | [
"https://wordpress.stackexchange.com/questions/359933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/154998/"
] | I have managed to change the width of the **WordPress block editor** so it uses my max width of my actual theme, making it easier to do layouts during the writing process. Now I wanted to change that to **only** happen when I edit **pages**, *not posts* or other taxonomies.
How do I do that?
**My current procedure ... | Because the WordPress hook `add_theme_support( 'editor-styles' );` adds the css in the style-editor.css and appends the class `.editor-styles-wrapper` before my `.wp-block`, the usage of the body classes for page vs. post styles fails. Instead I use the answer from [here, from David Walsh](https://davidwalsh.name/add-c... |
359,972 | <p>I've been making a plugin for wordpress that adds two simple text field options. The options are saved successfully in plugin options page but don't work, it doesn't output saved options.</p>
<p><a href="https://i.stack.imgur.com/iCvSz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iCvSz.png" al... | [
{
"answer_id": 359934,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 0,
"selected": false,
"text": "<p>In the admin, if you inspect the body tag you will see WP is adding specific classess, similar to on the... | 2020/03/04 | [
"https://wordpress.stackexchange.com/questions/359972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33903/"
] | I've been making a plugin for wordpress that adds two simple text field options. The options are saved successfully in plugin options page but don't work, it doesn't output saved options.
[](https://i.stack.imgur.com/iCvSz.png)
Here's the code:
```
... | Because the WordPress hook `add_theme_support( 'editor-styles' );` adds the css in the style-editor.css and appends the class `.editor-styles-wrapper` before my `.wp-block`, the usage of the body classes for page vs. post styles fails. Instead I use the answer from [here, from David Walsh](https://davidwalsh.name/add-c... |
359,988 | <p>Private posts are visible only to administrators and editors, but I have found that they are displayed publicly in RSS feeds.
How can I remove them from there?</p>
<p>I have this code but it doesn't work:</p>
<pre><code>function removeRssPrivatePost($content)
{
global $post;
if ($post->post_status == 'priva... | [
{
"answer_id": 359934,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 0,
"selected": false,
"text": "<p>In the admin, if you inspect the body tag you will see WP is adding specific classess, similar to on the... | 2020/03/04 | [
"https://wordpress.stackexchange.com/questions/359988",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/174158/"
] | Private posts are visible only to administrators and editors, but I have found that they are displayed publicly in RSS feeds.
How can I remove them from there?
I have this code but it doesn't work:
```
function removeRssPrivatePost($content)
{
global $post;
if ($post->post_status == 'private') {
return;
}
... | Because the WordPress hook `add_theme_support( 'editor-styles' );` adds the css in the style-editor.css and appends the class `.editor-styles-wrapper` before my `.wp-block`, the usage of the body classes for page vs. post styles fails. Instead I use the answer from [here, from David Walsh](https://davidwalsh.name/add-c... |
360,052 | <p>I try, when click the submit button then pass the ajax request with some values then calculate that values and return.</p>
<p><strong>My Problem</strong> : when I make custom Ajax Call then I get 400 error from admin-ajax.php.
Please help me to find my mistake or best way to do this.</p>
<p><strong>Ajax Call - fo... | [
{
"answer_id": 360019,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 0,
"selected": false,
"text": "<p>If you create and activate a child theme you will not lose any pages or posts.</p>\n\n<p>BUT, depending ... | 2020/03/05 | [
"https://wordpress.stackexchange.com/questions/360052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152021/"
] | I try, when click the submit button then pass the ajax request with some values then calculate that values and return.
**My Problem** : when I make custom Ajax Call then I get 400 error from admin-ajax.php.
Please help me to find my mistake or best way to do this.
**Ajax Call - footer.php(theme footer)**
```
<scrip... | Your content is stored in the database, not in the theme. If you switch themes or use a child theme, the content is still there.
Also, if you run a child theme, the parent theme is still in use: Any modifications from it that you don't overwrite are still executed. |
360,077 | <p>I am new to wordpress development, I am leaning how to make a theme from scratch. I don't want to use any plugin to achieve this. </p>
<p>How to create first post/ fifth post/ ninth post full width, rest in three columns and so on.</p>
<p>I tried this but first post is not repeating</p>
<pre><code> <?php ge... | [
{
"answer_id": 360069,
"author": "TomC",
"author_id": 36980,
"author_profile": "https://wordpress.stackexchange.com/users/36980",
"pm_score": 0,
"selected": false,
"text": "<p>Then do it as a plugin and then use <code>include();</code> to organise your PHP custom functions in their own P... | 2020/03/05 | [
"https://wordpress.stackexchange.com/questions/360077",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183839/"
] | I am new to wordpress development, I am leaning how to make a theme from scratch. I don't want to use any plugin to achieve this.
How to create first post/ fifth post/ ninth post full width, rest in three columns and so on.
I tried this but first post is not repeating
```
<?php get_header() ?>
<div class="cont... | Since you want to be able to use these functions within your themes AND plugins, and taking into consideration your comment regarding loading, I'd recommend the following approach.
Organize your functions into a library - depending on your methods and approaches, this could be multiple or single files. It could be jus... |
360,088 | <p>I have created the custom taxonomy for categories. I want to list the child categories lists of current parent category in child page.</p>
<pre><code>$cateID = get_queried_object_id();
$args = array(
'format' => 'name',
'separator' => ' ',
'link' => false,
'inclusive' => true
);
$checkparent... | [
{
"answer_id": 360128,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 3,
"selected": true,
"text": "<p>On a taxonomy archive page, be it for a child or parent term, you can get the current/<em>queried</em> term... | 2020/03/05 | [
"https://wordpress.stackexchange.com/questions/360088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/163406/"
] | I have created the custom taxonomy for categories. I want to list the child categories lists of current parent category in child page.
```
$cateID = get_queried_object_id();
$args = array(
'format' => 'name',
'separator' => ' ',
'link' => false,
'inclusive' => true
);
$checkparent = get_term_parents_list(... | On a taxonomy archive page, be it for a child or parent term, you can get the current/*queried* term object/data using [`get_queried_object()`](https://developer.wordpress.org/reference/functions/get_queried_object/) which contains properties like `term_id` (the term ID) and `slug` (the term slug). And the property nam... |
360,145 | <p>I used a theme, which created a custom type.
Now I want to change the theme, but when I disable the theme, the custom type is also disabled. I tried using CPT plugin, and re-create the custom type, but it tells me that the custom type is already present and it can't recreate it.</p>
<p>I tried looking into the them... | [
{
"answer_id": 360146,
"author": "KiwisTasteGood",
"author_id": 81335,
"author_profile": "https://wordpress.stackexchange.com/users/81335",
"pm_score": -1,
"selected": false,
"text": "<p>In your old theme copy all of the code that registers the post \"type register_post_type()\" etc into... | 2020/03/06 | [
"https://wordpress.stackexchange.com/questions/360145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183906/"
] | I used a theme, which created a custom type.
Now I want to change the theme, but when I disable the theme, the custom type is also disabled. I tried using CPT plugin, and re-create the custom type, but it tells me that the custom type is already present and it can't recreate it.
I tried looking into the theme's functi... | You can create a new folder in the plugins folder, called something like 'custom-taxonomy'. Create a file with the name 'custom-taxonomy.php' and paste the code below in it. The words 'Image' and 'Images' should be replaced with the name of the custom taxonomy of your current theme.
Don't forget to activate the plugin... |
360,187 | <p>If I for example filter my custom post type by date and it only shows 2 records on screen, I only want to export those 2 records, but it is exporting a bunch of records out of my control ie: the wrong records. </p>
<p>How can I modify this to only export what is showing up on screen ie: the 2 records in this case?<... | [
{
"answer_id": 360146,
"author": "KiwisTasteGood",
"author_id": 81335,
"author_profile": "https://wordpress.stackexchange.com/users/81335",
"pm_score": -1,
"selected": false,
"text": "<p>In your old theme copy all of the code that registers the post \"type register_post_type()\" etc into... | 2020/03/07 | [
"https://wordpress.stackexchange.com/questions/360187",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165412/"
] | If I for example filter my custom post type by date and it only shows 2 records on screen, I only want to export those 2 records, but it is exporting a bunch of records out of my control ie: the wrong records.
How can I modify this to only export what is showing up on screen ie: the 2 records in this case?
```
add_a... | You can create a new folder in the plugins folder, called something like 'custom-taxonomy'. Create a file with the name 'custom-taxonomy.php' and paste the code below in it. The words 'Image' and 'Images' should be replaced with the name of the custom taxonomy of your current theme.
Don't forget to activate the plugin... |
360,207 | <p>I have registered settings and need it to be showed in REST API. </p>
<pre><code>$args = [
'show_in_rest' => true
];
register_setting('default_sidebars', 'default_sidebars', $args);
</code></pre>
<p>When I save a single value and then request data on endpoint <code>/wp-json/wp/v2/settings</code>, everything... | [
{
"answer_id": 360218,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": false,
"text": "<p><em>Not sure if there's a <strong>better</strong> way when using the default Settings endpoint, but this w... | 2020/03/07 | [
"https://wordpress.stackexchange.com/questions/360207",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/157270/"
] | I have registered settings and need it to be showed in REST API.
```
$args = [
'show_in_rest' => true
];
register_setting('default_sidebars', 'default_sidebars', $args);
```
When I save a single value and then request data on endpoint `/wp-json/wp/v2/settings`, everything works perfectly.
But the problem is th... | JSON Schema
-----------
It's supported if you explicitly register the **object JSON schema** as:
```
$args = array(
'show_in_rest' => array(
'schema' => array(
'type' => 'object',
'properties' => array(
'post' => array(
'type' => 'string',
... |
360,209 | <p>I am struggling with the translations of my theme. I use the function <code>get_permalink_date</code> of my class. The relevant snippet is:</p>
<pre><code>$permalink_title = sprintf(
/* translators: 1 = Post Title, 2 = Author Name */
esc_html_x( '%1$s by %2$s', 'permalink title', 'themeberger' ),
__( 'A... | [
{
"answer_id": 360218,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": false,
"text": "<p><em>Not sure if there's a <strong>better</strong> way when using the default Settings endpoint, but this w... | 2020/03/07 | [
"https://wordpress.stackexchange.com/questions/360209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45070/"
] | I am struggling with the translations of my theme. I use the function `get_permalink_date` of my class. The relevant snippet is:
```
$permalink_title = sprintf(
/* translators: 1 = Post Title, 2 = Author Name */
esc_html_x( '%1$s by %2$s', 'permalink title', 'themeberger' ),
__( 'A post', 'themeberger' ),
... | JSON Schema
-----------
It's supported if you explicitly register the **object JSON schema** as:
```
$args = array(
'show_in_rest' => array(
'schema' => array(
'type' => 'object',
'properties' => array(
'post' => array(
'type' => 'string',
... |
360,244 | <p>I have been looking into setting up WordPress and its plugins and themes using composer. I notice alot of the tutorials around have composer installing wordpress into its own sub directory for example /wp and the themes, plugins, must use plugins to a completely different directory like /content. Is there a reason ... | [
{
"answer_id": 360218,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": false,
"text": "<p><em>Not sure if there's a <strong>better</strong> way when using the default Settings endpoint, but this w... | 2020/03/08 | [
"https://wordpress.stackexchange.com/questions/360244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183961/"
] | I have been looking into setting up WordPress and its plugins and themes using composer. I notice alot of the tutorials around have composer installing wordpress into its own sub directory for example /wp and the themes, plugins, must use plugins to a completely different directory like /content. Is there a reason why ... | JSON Schema
-----------
It's supported if you explicitly register the **object JSON schema** as:
```
$args = array(
'show_in_rest' => array(
'schema' => array(
'type' => 'object',
'properties' => array(
'post' => array(
'type' => 'string',
... |
360,254 | <p>Is there any difference in using</p>
<pre><code><?php get_the_title(); ?>
</code></pre>
<p>or</p>
<pre><code><?php single_post_title(); ?>
</code></pre>
<p>Because I can always get same value </p>
| [
{
"answer_id": 360271,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, there are some differences in the two. Lets take a look.</p>\n<p><strong><a href=\"https://develop... | 2020/03/08 | [
"https://wordpress.stackexchange.com/questions/360254",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/175502/"
] | Is there any difference in using
```
<?php get_the_title(); ?>
```
or
```
<?php single_post_title(); ?>
```
Because I can always get same value | `single_post_title()` and `get_the_title()` work completely differently.
`get_the_title()` (or `the_title()`, which works the same) will get the title for the current post in [the loop](https://developer.wordpress.org/themes/basics/the-loop/):
```
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();... |
360,263 | <p>My previous plugin was saving the comments as type="wp_review_comment". I have handled the previous custom fields as below. But I'm having difficulty saving the comments as a custom comment type.</p>
<pre><code>// Add default fields
add_filter('comment_form_default_fields','custom_fields');
function custom_fields(... | [
{
"answer_id": 360517,
"author": "Asha",
"author_id": 92824,
"author_profile": "https://wordpress.stackexchange.com/users/92824",
"pm_score": 2,
"selected": false,
"text": "<pre><code> $data = array(\n 'comment_post_ID' => $post_id,\n 'comment_author' => 'admin',\n 'com... | 2020/03/08 | [
"https://wordpress.stackexchange.com/questions/360263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145504/"
] | My previous plugin was saving the comments as type="wp\_review\_comment". I have handled the previous custom fields as below. But I'm having difficulty saving the comments as a custom comment type.
```
// Add default fields
add_filter('comment_form_default_fields','custom_fields');
function custom_fields($fields) {
... | In addition. You already have code which can kind of do what you need.
```
add_filter( 'preprocess_comment', 'verify_comment_meta_data' );
function verify_comment_meta_data( $commentdata ) {
if ( ! isset( $_POST['wp_review_comment_rating'] ) )
wp_die( __( 'A rating is required. Hit the BACK button and resubmit... |
360,279 | <p>I have a plugin that implements a REST API that needs to be notified when an admin adds one of my supported shortcodes to a page or post. I hook save_post with my function like this.</p>
<pre><code> add_action( 'save_post', 'detect_shortcodes');
</code></pre>
<p>However, when I update from the editor, it d... | [
{
"answer_id": 360288,
"author": "BenB",
"author_id": 62909,
"author_profile": "https://wordpress.stackexchange.com/users/62909",
"pm_score": 0,
"selected": false,
"text": "<p>I think this hook should work:</p>\n\n<pre><code>function run_hooks( $post, $request ) {\n // Here you can ru... | 2020/03/08 | [
"https://wordpress.stackexchange.com/questions/360279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183987/"
] | I have a plugin that implements a REST API that needs to be notified when an admin adds one of my supported shortcodes to a page or post. I hook save\_post with my function like this.
```
add_action( 'save_post', 'detect_shortcodes');
```
However, when I update from the editor, it does an ajax call that inst... | You could try with the following instead to detect if rest
```
if ( is_admin() || defined( 'REST_REQUEST' ) && REST_REQUEST ) {
}
``` |
360,372 | <p>I need a function to redirect user to the plugin settings page, right after plugin activation. </p>
<p>I use this function to create a custom menu settings page:</p>
<pre><code>// add option page menu link
function axl_ads_add_admin_menu() {
$icon = 'dashicons-align-left"';
add_menu_page( 'AXL Ads', 'AX... | [
{
"answer_id": 360391,
"author": "Zakaria Binsaifullah",
"author_id": 158754,
"author_profile": "https://wordpress.stackexchange.com/users/158754",
"pm_score": 0,
"selected": false,
"text": "<p>There is a hook named register_activation_hook that usually works at the time of the plugin ac... | 2020/03/10 | [
"https://wordpress.stackexchange.com/questions/360372",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33903/"
] | I need a function to redirect user to the plugin settings page, right after plugin activation.
I use this function to create a custom menu settings page:
```
// add option page menu link
function axl_ads_add_admin_menu() {
$icon = 'dashicons-align-left"';
add_menu_page( 'AXL Ads', 'AXL Ads', 'manage_optio... | You can use [register\_activation\_hook()](https://developer.wordpress.org/reference/functions/register_activation_hook/). Add this to your plugin, tested and works.
```
register_activation_hook(__FILE__, 'redirect_after_activation');
function redirect_after_activation() {
add_option('redirect_after_activation_op... |
360,377 | <p>I am new to Wordpress and following a training course. Its told me to enable to use of Featured Images I need to add the following line into my functions.php:</p>
<pre class="lang-php prettyprint-override"><code>add_theme_support('post-thumbnails');
</code></pre>
<p>and then the following in my post types file:</p... | [
{
"answer_id": 360378,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 2,
"selected": true,
"text": "<p>That one line is all you need, try adding this to your functions.php file.</p>\n\n<pre><code>function my_... | 2020/03/10 | [
"https://wordpress.stackexchange.com/questions/360377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/184073/"
] | I am new to Wordpress and following a training course. Its told me to enable to use of Featured Images I need to add the following line into my functions.php:
```php
add_theme_support('post-thumbnails');
```
and then the following in my post types file:
```php
'supports' => array('title', 'editor', 'thumbnail')... | That one line is all you need, try adding this to your functions.php file.
```
function my_theme_setup(){
add_theme_support('post-thumbnails');
}
add_action('after_setup_theme', 'my_theme_setup');
```
I'm not sure what your "post types file" is but the above should be enough to add support. |
360,379 | <pre><code><?php global $current_user; echo array_shift($current_user->roles);>
</code></pre>
<p>Using this i can display user role slug but i want to display Name of the role. Any suggestion ? Thanks</p>
| [
{
"answer_id": 360384,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 4,
"selected": true,
"text": "<p>WordPress does not (currently) have a <em>global</em> function (e.g. <code>get_role_name()</code>) for gett... | 2020/03/10 | [
"https://wordpress.stackexchange.com/questions/360379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164836/"
] | ```
<?php global $current_user; echo array_shift($current_user->roles);>
```
Using this i can display user role slug but i want to display Name of the role. Any suggestion ? Thanks | WordPress does not (currently) have a *global* function (e.g. `get_role_name()`) for getting the role *name* (e.g. `Shop Manager` for `shop-manager` or maybe `shop_manager` etc.), but you can easily get (and then display) it like so:
```php
$role = 'shop-manager'; // the role slug; it's up to you how to get the value.... |
360,407 | <p>there is this loop which sorts by the date. But I want to throw in a specific meta key for a even higher priority. The meta_key "high_prio" should move it to the top of the sorting.
(I hope that makes sence). </p>
<p>Let's speak some code:</p>
<pre><code>$loop = new WP_Query( array(
'post_type' => 'event'... | [
{
"answer_id": 360529,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 1,
"selected": false,
"text": "<p>As I already pointed in the comment, all you need to do is change your <code>orderby</code> parameter so t... | 2020/03/10 | [
"https://wordpress.stackexchange.com/questions/360407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/184095/"
] | there is this loop which sorts by the date. But I want to throw in a specific meta key for a even higher priority. The meta\_key "high\_prio" should move it to the top of the sorting.
(I hope that makes sence).
Let's speak some code:
```
$loop = new WP_Query( array(
'post_type' => 'event',
'posts_per_pag... | The issue has been the **relation**. Of course, it must be "AND"
```
$loop = new WP_Query( array(
'post_type' => 'event',
'posts_per_page' => 3,
'cat' => '4',
'orderby' => array('meta_prio' => 'DESC', 'meta_start' => 'ASC'),
'meta_query' => array(
'relation' => '**AND**',
... |