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
338,598
<p>I'm developing a theme for WordPress. I have a doubt about templates redirect. For example, I have a theme that have the <code>front-page.php</code> template and I don't use the <code>index.php</code> template. What I should do it with index.php file? Delete it or redirect like:</p> <p>index.php</p> <pre class="la...
[ { "answer_id": 338599, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 1, "selected": true, "text": "<p>I don't see any reason to redirect <code>index.php</code>. Let's say you only have a Front Page, no blog or ...
2019/05/23
[ "https://wordpress.stackexchange.com/questions/338598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168637/" ]
I'm developing a theme for WordPress. I have a doubt about templates redirect. For example, I have a theme that have the `front-page.php` template and I don't use the `index.php` template. What I should do it with index.php file? Delete it or redirect like: index.php ```php <?php wp_safe_redirect('front-page.php'); ...
I don't see any reason to redirect `index.php`. Let's say you only have a Front Page, no blog or post types with archives. You would assign the Front Page in Settings -> Reading and WordPress will do the template redirect for you. At that point, nothing uses `index.php` and there's no need to redirect it. Maybe you in...
338,649
<p><a href="https://i.stack.imgur.com/wglzJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wglzJ.png" alt="enter image description here"></a></p> <p>Right now I'm getting the id statically in my output "1778a1778" because of array_push(), but I have to send ID dynamically and get the same output.<...
[ { "answer_id": 338599, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 1, "selected": true, "text": "<p>I don't see any reason to redirect <code>index.php</code>. Let's say you only have a Front Page, no blog or ...
2019/05/24
[ "https://wordpress.stackexchange.com/questions/338649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168440/" ]
[![enter image description here](https://i.stack.imgur.com/wglzJ.png)](https://i.stack.imgur.com/wglzJ.png) Right now I'm getting the id statically in my output "1778a1778" because of array\_push(), but I have to send ID dynamically and get the same output.
I don't see any reason to redirect `index.php`. Let's say you only have a Front Page, no blog or post types with archives. You would assign the Front Page in Settings -> Reading and WordPress will do the template redirect for you. At that point, nothing uses `index.php` and there's no need to redirect it. Maybe you in...
338,653
<p>I am trying to hide WordPress admin bar from all pages except the home page.</p> <p>I added the following CODE in the theme's <code>functions.php</code> file, but it hides the admin bar on all pages:</p> <pre><code>if ( ! is_single() ) { add_filter( 'show_admin_bar', '__return_false' ); } </code></pre> <p>I wa...
[ { "answer_id": 338655, "author": "Vishwa", "author_id": 120712, "author_profile": "https://wordpress.stackexchange.com/users/120712", "pm_score": -1, "selected": false, "text": "<p>You should check if page is home page and/or front page. \n<code>is_front_page()</code> returns true when v...
2019/05/24
[ "https://wordpress.stackexchange.com/questions/338653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118356/" ]
I am trying to hide WordPress admin bar from all pages except the home page. I added the following CODE in the theme's `functions.php` file, but it hides the admin bar on all pages: ``` if ( ! is_single() ) { add_filter( 'show_admin_bar', '__return_false' ); } ``` I want it to appear only on the homepage and to ...
You should use conditional tag inside function hooked to `show_admin_bar` filter. ``` add_filter( 'show_admin_bar', 'show_adminbar_on_homepage_only', 20 ); function show_adminbar_on_homepage_only() { return is_user_logged_in() && is_front_page(); } ```
338,661
<p>i used <a href="https://wordpress.org/plugins/advanced-custom-fields/" rel="nofollow noreferrer">ACF</a> to store post data in custom fields. i'd like to copy the data from a <a href="https://www.advancedcustomfields.com/resources/wysiwyg-editor/" rel="nofollow noreferrer">wysiwyg field</a> to post_content into wp_p...
[ { "answer_id": 338673, "author": "Parthavi Patel", "author_id": 110795, "author_profile": "https://wordpress.stackexchange.com/users/110795", "pm_score": 1, "selected": false, "text": "<p>First get data from <code>wp_postmeta</code> table</p>\n\n<pre><code>$description = get_post_meta( $...
2019/05/24
[ "https://wordpress.stackexchange.com/questions/338661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77283/" ]
i used [ACF](https://wordpress.org/plugins/advanced-custom-fields/) to store post data in custom fields. i'd like to copy the data from a [wysiwyg field](https://www.advancedcustomfields.com/resources/wysiwyg-editor/) to post\_content into wp\_posts table. How can i do this? Roughly: ``` data is on wp_postmeta table,...
Putting together a working example of [@Parthavi Patel](https://wordpress.stackexchange.com/users/110795/parthavi-patel) answer. This is a page template. When the page loads the code is executed. If there's too many posts it would be good to use a conservative value on `posts_per_page` and adjust the `offset` parameter...
338,662
<p>I'm trying to add these custom CSS and JS (written inside a custom plugin) only add to a specific page.</p> <p>this is my code</p> <pre><code>&lt;?php function randomAlphaNumeric($length) { $pool = array_merge(range(0,9), range('a', 'z'),range('A', 'Z')); $key=''; for($i=0; $i &lt; $length; $i++) {...
[ { "answer_id": 338666, "author": "middlelady", "author_id": 93927, "author_profile": "https://wordpress.stackexchange.com/users/93927", "pm_score": 1, "selected": false, "text": "<ol>\n<li>Try to change the parameter from <code>page_title</code>to <code>page-slug</code> or <code>id</code...
2019/05/24
[ "https://wordpress.stackexchange.com/questions/338662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163748/" ]
I'm trying to add these custom CSS and JS (written inside a custom plugin) only add to a specific page. this is my code ``` <?php function randomAlphaNumeric($length) { $pool = array_merge(range(0,9), range('a', 'z'),range('A', 'Z')); $key=''; for($i=0; $i < $length; $i++) { $key .= $pool[mt_r...
The `init` hook is too early — WordPress hasn't yet identified the queried object (post, category, etc.); hence the `is_page()` doesn't work there: ```php add_action('init', 'register_script'); ``` So for conditional tags/functions like `is_page()`, `is_single()`, etc. to work (i.e. return the proper result), you sh...
338,692
<p>So I have a Custom Post Type named network and Custom Taxonomy name company_category. Everything is all good until I can't render <a href="http://localhost/digitalhxstaging/company" rel="nofollow noreferrer">http://localhost/digitalhxstaging/company</a>. Both Company Category and Company are all good except for arch...
[ { "answer_id": 338703, "author": "Faye", "author_id": 76600, "author_profile": "https://wordpress.stackexchange.com/users/76600", "pm_score": 0, "selected": false, "text": "<p>Reset your Permalinks (Dashboard > Settings > Permalinks). Just make a change, save and it should pick up your r...
2019/05/24
[ "https://wordpress.stackexchange.com/questions/338692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/149172/" ]
So I have a Custom Post Type named network and Custom Taxonomy name company\_category. Everything is all good until I can't render <http://localhost/digitalhxstaging/company>. Both Company Category and Company are all good except for archive-network.php. I tried removing the dynamic slug and its working but now my comp...
Reset your Permalinks (Dashboard > Settings > Permalinks). Just make a change, save and it should pick up your rewrite change. I've made this mistake a million times, you adjust a thing and forget this is needed.
338,745
<p>I want to pass the 'post title' of current post as parameter into a link</p> <p>For example in this way:</p> <pre><code>&lt;a href='http://example.com/send-cv/?job_position=seller'&gt;apply to job&lt;/a&gt; </code></pre> <p>Where the post title would be 'seller'</p> <p>How can I achieve this?</p>
[ { "answer_id": 338703, "author": "Faye", "author_id": 76600, "author_profile": "https://wordpress.stackexchange.com/users/76600", "pm_score": 0, "selected": false, "text": "<p>Reset your Permalinks (Dashboard > Settings > Permalinks). Just make a change, save and it should pick up your r...
2019/05/25
[ "https://wordpress.stackexchange.com/questions/338745", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168802/" ]
I want to pass the 'post title' of current post as parameter into a link For example in this way: ``` <a href='http://example.com/send-cv/?job_position=seller'>apply to job</a> ``` Where the post title would be 'seller' How can I achieve this?
Reset your Permalinks (Dashboard > Settings > Permalinks). Just make a change, save and it should pick up your rewrite change. I've made this mistake a million times, you adjust a thing and forget this is needed.
338,753
<p>we are receiving this error:</p> <p>Warning: preg_match(): No ending delimiter '^' found in /home/goose/public_html/wp-content/themes/goose/partials/contact.php on line 32 Please enter a valid email address</p> <p><a href="http://thegoosedarien.com" rel="nofollow noreferrer">http://thegoosedarien.com</a> - using t...
[ { "answer_id": 338756, "author": "Antti Koskinen", "author_id": 144392, "author_profile": "https://wordpress.stackexchange.com/users/144392", "pm_score": 1, "selected": false, "text": "<p>I usually try to avoid using <code>preg_match()</code>, because I get the pattern right very rarely....
2019/05/25
[ "https://wordpress.stackexchange.com/questions/338753", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168807/" ]
we are receiving this error: Warning: preg\_match(): No ending delimiter '^' found in /home/goose/public\_html/wp-content/themes/goose/partials/contact.php on line 32 Please enter a valid email address <http://thegoosedarien.com> - using the contact form, we receive this error message when submitting. No idea how t...
I usually try to avoid using `preg_match()`, because I get the pattern right very rarely. Perhaps you could try using some other functions to do the validating. For example PHP's [ctype\_alnum()](https://www.php.net/manual/en/function.ctype-alnum.php) for the name field and WP's [is\_email()](https://codex.wordpress.or...
338,757
<p>I'm beginning to like Gutenberg, but I find it too narrow, particularly when working with the 'Columns' block. Why is it so narrow, and can it safely be made wider? I could try doing so with CSS, but I thought it best to ask first, to avoid potential trouble.</p>
[ { "answer_id": 338873, "author": "WSU", "author_id": 168474, "author_profile": "https://wordpress.stackexchange.com/users/168474", "pm_score": 1, "selected": false, "text": "<p>The only way that comes to mind is to disable the options sidebar on the right. Just click on the cog icon and ...
2019/05/25
[ "https://wordpress.stackexchange.com/questions/338757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131339/" ]
I'm beginning to like Gutenberg, but I find it too narrow, particularly when working with the 'Columns' block. Why is it so narrow, and can it safely be made wider? I could try doing so with CSS, but I thought it best to ask first, to avoid potential trouble.
This worked for me, add this to the end of your themes `functions.php` file: ``` add_action('admin_head', 'wp_blocks_fullwidth'); function wp_blocks_fullwidth() { echo '<style> .wp-block { max-width: unset; } </style>'; } ```
338,834
<p>I wanted to change the default taxonomy terms order by its 'term_order' value instead of 'name' in admin side. So I tried something like below. But it doesn't work and php memory exhaust. </p> <pre><code>function uc_order_term( $wp_query ) { $wp_query-&gt;query( array( 'taxonomy' =&gt; 'cate...
[ { "answer_id": 338779, "author": "Kaloyan", "author_id": 128309, "author_profile": "https://wordpress.stackexchange.com/users/128309", "pm_score": 0, "selected": false, "text": "<p>Yes you have to create new database for new wordpress site. It's imposible to create several wordpress webs...
2019/05/26
[ "https://wordpress.stackexchange.com/questions/338834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162381/" ]
I wanted to change the default taxonomy terms order by its 'term\_order' value instead of 'name' in admin side. So I tried something like below. But it doesn't work and php memory exhaust. ``` function uc_order_term( $wp_query ) { $wp_query->query( array( 'taxonomy' => 'category', ...
Yes, usually you create a new database, user and password as well as use another copy of WordPress to create a new site. You can create a new directory in the same place where the "wordpress" directory is located and use that one for the new site. Note that it is possible to use the same database for two different sit...
338,877
<p>i have a taxonomy list in the home page made with <a href="https://wordpress.org/plugins/wp-categories-widget/" rel="nofollow noreferrer">https://wordpress.org/plugins/wp-categories-widget/</a> plugin .. i crated image field for taxonomies with ACF. i can show tax image on archive page but i cant show images of taxo...
[ { "answer_id": 338779, "author": "Kaloyan", "author_id": 128309, "author_profile": "https://wordpress.stackexchange.com/users/128309", "pm_score": 0, "selected": false, "text": "<p>Yes you have to create new database for new wordpress site. It's imposible to create several wordpress webs...
2019/05/27
[ "https://wordpress.stackexchange.com/questions/338877", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168662/" ]
i have a taxonomy list in the home page made with <https://wordpress.org/plugins/wp-categories-widget/> plugin .. i crated image field for taxonomies with ACF. i can show tax image on archive page but i cant show images of taxonomies on the list of taxonomies in home page. please help Here is my code:- ``` <?php /* P...
Yes, usually you create a new database, user and password as well as use another copy of WordPress to create a new site. You can create a new directory in the same place where the "wordpress" directory is located and use that one for the new site. Note that it is possible to use the same database for two different sit...
338,988
<p>I want to show the category name of the post when I write [category] shortcode in the post body. I'm using this code but only showing array error.</p> <p>Sorry, I'm not an expert in coding. Perhaps you can redefine my code? Please.</p> <pre><code>function cat_post() { return get_the_category(); } add_shortcode...
[ { "answer_id": 339021, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>The main problem with your code is that you register <code>[categorypost]</code> shortcode, but you w...
2019/05/28
[ "https://wordpress.stackexchange.com/questions/338988", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168974/" ]
I want to show the category name of the post when I write [category] shortcode in the post body. I'm using this code but only showing array error. Sorry, I'm not an expert in coding. Perhaps you can redefine my code? Please. ``` function cat_post() { return get_the_category(); } add_shortcode('categorypost', 'cat...
Put the code below in your **functions.php** file: ``` function register_theme_shortcodes() { add_shortcode( 'category', /** * category shortcode function. * * @param array $atts * * @return string */ function ( $atts ) { $atts = sho...
339,005
<p>Today I migrated a WordPress site from another server to a new server, there is a new domain and new host, so I follow the manual way to upload my site. That was, I downloaded files and upload it on to new fresh host and, database export and import to the new host. After that, I have changed site URL, home page URL ...
[ { "answer_id": 339021, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>The main problem with your code is that you register <code>[categorypost]</code> shortcode, but you w...
2019/05/28
[ "https://wordpress.stackexchange.com/questions/339005", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/165090/" ]
Today I migrated a WordPress site from another server to a new server, there is a new domain and new host, so I follow the manual way to upload my site. That was, I downloaded files and upload it on to new fresh host and, database export and import to the new host. After that, I have changed site URL, home page URL in ...
Put the code below in your **functions.php** file: ``` function register_theme_shortcodes() { add_shortcode( 'category', /** * category shortcode function. * * @param array $atts * * @return string */ function ( $atts ) { $atts = sho...
339,017
<p>On a business listing in a directory I have a button which will lead to a custom plugin.</p> <p>The custom plugin needs to know the userid of the user (registered user) who clicked the button to get here, plus the business id of the page it came from.</p> <p>How do I track that info in the plugin?</p> <p>Thanks.<...
[ { "answer_id": 339021, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>The main problem with your code is that you register <code>[categorypost]</code> shortcode, but you w...
2019/05/28
[ "https://wordpress.stackexchange.com/questions/339017", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/167925/" ]
On a business listing in a directory I have a button which will lead to a custom plugin. The custom plugin needs to know the userid of the user (registered user) who clicked the button to get here, plus the business id of the page it came from. How do I track that info in the plugin? Thanks.
Put the code below in your **functions.php** file: ``` function register_theme_shortcodes() { add_shortcode( 'category', /** * category shortcode function. * * @param array $atts * * @return string */ function ( $atts ) { $atts = sho...
339,043
<p>I am developing a theme and I noticed that</p> <pre><code>get_post_meta($post-&gt;ID, '_wp_page_template', true); </code></pre> <p>returns 'static-page.php' (as expected) when queried on static pages but returns nothing (expected 'single-post.php') when queried on a single blog post pages.</p> <p>I have single-po...
[ { "answer_id": 339044, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>I am using the template file name in the section to load\n corresponding css files. F...
2019/05/29
[ "https://wordpress.stackexchange.com/questions/339043", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169014/" ]
I am developing a theme and I noticed that ``` get_post_meta($post->ID, '_wp_page_template', true); ``` returns 'static-page.php' (as expected) when queried on static pages but returns nothing (expected 'single-post.php') when queried on a single blog post pages. I have single-post.php file set up and working, cont...
> > I am using the template file name in the section to load > corresponding css files. For static-page.php I am loading > static-page.css, similarly for single-post.php I would like to load > single-post.css. As said, it is working fine on my static pages, but > returns zero on single blog post page. > > > Th...
339,052
<p><strong>UPDATED:</strong></p> <p>I have a Custom Post Type <strong>Commercials</strong>. This post type has a title and a video id. I want to search from this specific post type. Right now it returns result which matches the titles only, I also want it to return result from tags too. For example, let's say I have a...
[ { "answer_id": 339064, "author": "Milan Hirpara", "author_id": 168898, "author_profile": "https://wordpress.stackexchange.com/users/168898", "pm_score": 0, "selected": false, "text": "<p>I think you need to remove </p>\n\n<pre><code>$_GET['post_type']\n</code></pre>\n\n<p>Please use belo...
2019/05/29
[ "https://wordpress.stackexchange.com/questions/339052", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109544/" ]
**UPDATED:** I have a Custom Post Type **Commercials**. This post type has a title and a video id. I want to search from this specific post type. Right now it returns result which matches the titles only, I also want it to return result from tags too. For example, let's say I have a commercial named *"**Lorem Ipsum Co...
The way you are customizing the query you are telling it to search for posts that ALSO match a custom `tax_query` criteria. This would never work, logically speaking. You said, "I want it to return a result if this **tag** is searched or if it matches the **title**" for which I understand ONE or ANOTHER. I'll show yo...
339,054
<p>I know here is an information about the issue, but I didn't find full working solution.</p> <p>I need to use product category slugs in my product permalinks so the links are to be like <code>example.com/laptops/some-laptop</code></p> <p>I selected the <em>Custom base</em> option in my <em>Permalink Settings</em>, ...
[ { "answer_id": 339115, "author": "stckvrw", "author_id": 144565, "author_profile": "https://wordpress.stackexchange.com/users/144565", "pm_score": 3, "selected": true, "text": "<p>Ok, so the second code is:</p>\n\n<pre><code>function custom_rewrite_basic() {\n\n $prodCatArgs = ['taxon...
2019/05/29
[ "https://wordpress.stackexchange.com/questions/339054", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/144565/" ]
I know here is an information about the issue, but I didn't find full working solution. I need to use product category slugs in my product permalinks so the links are to be like `example.com/laptops/some-laptop` I selected the *Custom base* option in my *Permalink Settings*, typed `/%product-cat%/` in the field and s...
Ok, so the second code is: ``` function custom_rewrite_basic() { $prodCatArgs = ['taxonomy' => 'product_cat']; $wooCats = get_categories($prodCatArgs); $catSlugs = []; foreach($wooCats as $wooCat) { $catSlugs[] = $wooCat->slug; } add_rewrite_rule( '^('.implode('|', $catSlugs).'...
339,059
<p>I'm using a plugin where I have manipulated a function within a class of the plugin. However I would like to put this function in my theme instead since if someone updates the plugin, my edits to the function will be replaced. But if I lift out my edited function and put in the theme I get the error that "Fatal erro...
[ { "answer_id": 339115, "author": "stckvrw", "author_id": 144565, "author_profile": "https://wordpress.stackexchange.com/users/144565", "pm_score": 3, "selected": true, "text": "<p>Ok, so the second code is:</p>\n\n<pre><code>function custom_rewrite_basic() {\n\n $prodCatArgs = ['taxon...
2019/05/29
[ "https://wordpress.stackexchange.com/questions/339059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11348/" ]
I'm using a plugin where I have manipulated a function within a class of the plugin. However I would like to put this function in my theme instead since if someone updates the plugin, my edits to the function will be replaced. But if I lift out my edited function and put in the theme I get the error that "Fatal error: ...
Ok, so the second code is: ``` function custom_rewrite_basic() { $prodCatArgs = ['taxonomy' => 'product_cat']; $wooCats = get_categories($prodCatArgs); $catSlugs = []; foreach($wooCats as $wooCat) { $catSlugs[] = $wooCat->slug; } add_rewrite_rule( '^('.implode('|', $catSlugs).'...
339,067
<p>Trying to add certain allowed MIME types to the upload filter - currently my custom function looks like this:</p> <pre><code>// allow SVG and video mime types for upload function cc_mime_types( $mimes ){ $mimes['svg'] = 'image/svg+xml'; $mimes['webm'] = 'video/webm'; $mimes['mp4'] = ['video/mp4','vide...
[ { "answer_id": 339090, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 2, "selected": false, "text": "<p>This filter only accepts strings for mime types. It also <a href=\"https://core.trac.wordpress.org/browser...
2019/05/29
[ "https://wordpress.stackexchange.com/questions/339067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12035/" ]
Trying to add certain allowed MIME types to the upload filter - currently my custom function looks like this: ``` // allow SVG and video mime types for upload function cc_mime_types( $mimes ){ $mimes['svg'] = 'image/svg+xml'; $mimes['webm'] = 'video/webm'; $mimes['mp4'] = ['video/mp4','video/mpeg']; ...
@MikeNGarret's answer pointed me to the interesting function `wp_get_mime_types()`. Within this function you can look up how to correctly add MIME types to the `upload_mimes` filter (<https://core.trac.wordpress.org/browser/tags/5.1.1/src/wp-includes/functions.php#L2707>). The correct answer therefore is: ``` // all...
339,082
<p>I'm adding a button to Gutenbergs RichTextToolbar with a plugin I created, but I cannot figure out how to add mulitple classes to the tag/span I create.</p> <pre><code>( function( wp ) { var MyCustomButton = function( props ) { return wp.element.createElement( wp.editor.RichTextToolbarButton...
[ { "answer_id": 359704, "author": "Evgeniy Z.", "author_id": 173367, "author_profile": "https://wordpress.stackexchange.com/users/173367", "pm_score": 1, "selected": false, "text": "<p>As we can see from the registerFormatType function <a href=\"https://github.com/WordPress/gutenberg/blob...
2019/05/29
[ "https://wordpress.stackexchange.com/questions/339082", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/155008/" ]
I'm adding a button to Gutenbergs RichTextToolbar with a plugin I created, but I cannot figure out how to add mulitple classes to the tag/span I create. ``` ( function( wp ) { var MyCustomButton = function( props ) { return wp.element.createElement( wp.editor.RichTextToolbarButton, { ...
As we can see from the registerFormatType function [source code](https://github.com/WordPress/gutenberg/blob/master/packages/rich-text/src/register-format-type.js), only letters, numbers, "\_" and "-" are allowed in the class name. ``` if ( ! /^[_a-zA-Z]+[a-zA-Z0-9-]*$/.test( settings.className ) ) { window.consol...
339,134
<p>How to detect the value of selected page template in the edit page? I have used jQuery to select the page attribute select box but it is not working when we hide the editor sidebar; Because it removes the markup of that settings. I think it keeps data somewhere as we are able to bring back the sidebar without any ch...
[ { "answer_id": 343332, "author": "SkyShab", "author_id": 63263, "author_profile": "https://wordpress.stackexchange.com/users/63263", "pm_score": 2, "selected": false, "text": "<p>To get this value, use the wp.data module. </p>\n\n<pre><code>const template = wp.data.select( 'core/editor' ...
2019/05/30
[ "https://wordpress.stackexchange.com/questions/339134", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48376/" ]
How to detect the value of selected page template in the edit page? I have used jQuery to select the page attribute select box but it is not working when we hide the editor sidebar; Because it removes the markup of that settings. I think it keeps data somewhere as we are able to bring back the sidebar without any chang...
I slightly modified SkyShab's code, because it fired template change event on page load and it didn't fire when template was changed to default (since getEditedPostAttribute( 'template' ) is then '', which equals to null when testing for template change) ``` const { select, subscribe } = wp.data; class PageTemplateSw...
339,138
<p>The introduction of the <strong>Block Editor</strong> killed all plugins which offered publishing conditions, such as minimum word counts, featured image requirements etc.</p> <p>But the Block Editor <em>did</em> introduce the <strong>pre-publish checks</strong>:</p> <p><a href="https://i.stack.imgur.com/zwGUd.png...
[ { "answer_id": 339662, "author": "Welcher", "author_id": 27210, "author_profile": "https://wordpress.stackexchange.com/users/27210", "pm_score": 5, "selected": true, "text": "<p><strong>EDIT Sept 2021:</strong></p>\n<p>An updated version of the answer that uses hooks.</p>\n<p>This versio...
2019/05/30
[ "https://wordpress.stackexchange.com/questions/339138", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
The introduction of the **Block Editor** killed all plugins which offered publishing conditions, such as minimum word counts, featured image requirements etc. But the Block Editor *did* introduce the **pre-publish checks**: [![Pre-publish checks](https://i.stack.imgur.com/zwGUd.png)](https://i.stack.imgur.com/zwGUd.p...
**EDIT Sept 2021:** An updated version of the answer that uses hooks. This version tracks changes in the editor much better. It also uses `import` statement instead of importing directly from the `wp` global. This approach when used with the `@wordpress/scripts` package will correctly add dependencies for this file w...
339,156
<p>I need to show one item from menu only for users that are logged in and have certain custom capability set.</p> <p>Is it doable from theme functions.php or does it need a custom plugin?</p> <p>Note: I already use a plugin to show/hide menu items based on user roles, but couldn't find anything for Custom Capabilities...
[ { "answer_id": 339662, "author": "Welcher", "author_id": 27210, "author_profile": "https://wordpress.stackexchange.com/users/27210", "pm_score": 5, "selected": true, "text": "<p><strong>EDIT Sept 2021:</strong></p>\n<p>An updated version of the answer that uses hooks.</p>\n<p>This versio...
2019/05/30
[ "https://wordpress.stackexchange.com/questions/339156", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65215/" ]
I need to show one item from menu only for users that are logged in and have certain custom capability set. Is it doable from theme functions.php or does it need a custom plugin? Note: I already use a plugin to show/hide menu items based on user roles, but couldn't find anything for Custom Capabilities (user meta val...
**EDIT Sept 2021:** An updated version of the answer that uses hooks. This version tracks changes in the editor much better. It also uses `import` statement instead of importing directly from the `wp` global. This approach when used with the `@wordpress/scripts` package will correctly add dependencies for this file w...
339,163
<p>I am working on a script to bring in an xml file from another server via Post request, This would then return another xml of data which I can then store into a wordpress database depending on certain values.</p> <p>I have made various attempts at this</p> <p>This first attempt some what works outside of wordpress<...
[ { "answer_id": 339175, "author": "user1348927", "author_id": 169118, "author_profile": "https://wordpress.stackexchange.com/users/169118", "pm_score": 2, "selected": true, "text": "<p>I managed to solve this by adding the following into my functions.php</p>\n\n<pre><code>add_shortcode('m...
2019/05/30
[ "https://wordpress.stackexchange.com/questions/339163", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169118/" ]
I am working on a script to bring in an xml file from another server via Post request, This would then return another xml of data which I can then store into a wordpress database depending on certain values. I have made various attempts at this This first attempt some what works outside of wordpress ``` $curl = ...
I managed to solve this by adding the following into my functions.php ``` add_shortcode('my_shortode', 'my_function'); function my_function () { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_PORT => "2222", CURLOPT_URL => "http://11.111.11.111:2222/folder/query", CURLOPT_RETURNTRANSFER => true, ...
339,209
<p>I'm tyrying to let the admin search through the users by a single meta value called 'indice de busqueda' insithe the wordpress /wp-admin/users.php page</p> <p>How can I hook into the search box in such a way so that I can change the query to look something like this?</p> <pre><code> $query = get_users([ ...
[ { "answer_id": 339213, "author": "Radley Sustaire", "author_id": 19105, "author_profile": "https://wordpress.stackexchange.com/users/19105", "pm_score": 2, "selected": true, "text": "<p>Take a look at the <a href=\"https://developer.wordpress.org/reference/hooks/pre_get_users/\" rel=\"no...
2019/05/30
[ "https://wordpress.stackexchange.com/questions/339209", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169151/" ]
I'm tyrying to let the admin search through the users by a single meta value called 'indice de busqueda' insithe the wordpress /wp-admin/users.php page How can I hook into the search box in such a way so that I can change the query to look something like this? ``` $query = get_users([ 'meta_key' => 'indice ...
Take a look at the [pre\_get\_users](https://developer.wordpress.org/reference/hooks/pre_get_users/) hook. It is very similar to pre\_get\_posts if you are familiar with that, except it is for wp\_user\_query instead of wp\_query. You will need to ensure that you only check the users screen in the dashboard, because t...
339,234
<p>How we can verify "Cancel the header auth" the "endpoint" functions of WordPress with an API key that we produce. (Note: not a different endpoint, original endpoints)</p> <p>I have my own "Crypto" class/function. In the request, I need to send an encrypted key, "decrypt" the "encrypted key" from "wp-function" and s...
[ { "answer_id": 339236, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 0, "selected": false, "text": "<p>Sounds like you can use the <a href=\"https://developer.wordpress.org/reference/hooks/rest_authentication_erro...
2019/05/31
[ "https://wordpress.stackexchange.com/questions/339234", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169188/" ]
How we can verify "Cancel the header auth" the "endpoint" functions of WordPress with an API key that we produce. (Note: not a different endpoint, original endpoints) I have my own "Crypto" class/function. In the request, I need to send an encrypted key, "decrypt" the "encrypted key" from "wp-function" and so on, and ...
``` function checkApiAuth( $result ){ $yourEncryptAPIKey = $_GET['request']; if( yourDecryptFn( $yourEncryptAPIKey ) === $realKey ): $result = true; else: $result = false; endif; return $result; } add_filter('rest_authentication_errors', 'checkApiAuth'); ```
339,253
<p>I have wordpress site and need advise regarding redirect htaccess based on useragent:</p> <p>Sample:</p> <p>my old url: myolddomain/old-post/ redirect to: mynewdomain/new-post/</p> <p>based on useragent</p> <p>thanks</p>
[ { "answer_id": 339236, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 0, "selected": false, "text": "<p>Sounds like you can use the <a href=\"https://developer.wordpress.org/reference/hooks/rest_authentication_erro...
2019/05/31
[ "https://wordpress.stackexchange.com/questions/339253", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169210/" ]
I have wordpress site and need advise regarding redirect htaccess based on useragent: Sample: my old url: myolddomain/old-post/ redirect to: mynewdomain/new-post/ based on useragent thanks
``` function checkApiAuth( $result ){ $yourEncryptAPIKey = $_GET['request']; if( yourDecryptFn( $yourEncryptAPIKey ) === $realKey ): $result = true; else: $result = false; endif; return $result; } add_filter('rest_authentication_errors', 'checkApiAuth'); ```
339,255
<p>I have a website where I need to 301 redirect all old pages that are incoming from old URLs like <code>/?page_id=261</code>, <code>/?page_id=204</code>, <code>/?page_id=2677</code> and so on to the main home page.</p> <p>What would be a proper way of doing it? Will something like this in <code>.htaccess</code> work...
[ { "answer_id": 339236, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 0, "selected": false, "text": "<p>Sounds like you can use the <a href=\"https://developer.wordpress.org/reference/hooks/rest_authentication_erro...
2019/05/31
[ "https://wordpress.stackexchange.com/questions/339255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138568/" ]
I have a website where I need to 301 redirect all old pages that are incoming from old URLs like `/?page_id=261`, `/?page_id=204`, `/?page_id=2677` and so on to the main home page. What would be a proper way of doing it? Will something like this in `.htaccess` work? I do not want to redirect all 404's - just these typ...
``` function checkApiAuth( $result ){ $yourEncryptAPIKey = $_GET['request']; if( yourDecryptFn( $yourEncryptAPIKey ) === $realKey ): $result = true; else: $result = false; endif; return $result; } add_filter('rest_authentication_errors', 'checkApiAuth'); ```
339,267
<p>I've been making a find-a-dealer type plugin in WordPress and I finally got it all done, everything works on my local <strong>and</strong> dev server.</p> <p>I push it up to production and upon activation, I get these errors/warnings:</p> <blockquote> <p>Notice: wp_register_style was called incorrectly. Scripts ...
[ { "answer_id": 339236, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 0, "selected": false, "text": "<p>Sounds like you can use the <a href=\"https://developer.wordpress.org/reference/hooks/rest_authentication_erro...
2019/05/31
[ "https://wordpress.stackexchange.com/questions/339267", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/155748/" ]
I've been making a find-a-dealer type plugin in WordPress and I finally got it all done, everything works on my local **and** dev server. I push it up to production and upon activation, I get these errors/warnings: > > Notice: wp\_register\_style was called incorrectly. Scripts and styles should not be registered or...
``` function checkApiAuth( $result ){ $yourEncryptAPIKey = $_GET['request']; if( yourDecryptFn( $yourEncryptAPIKey ) === $realKey ): $result = true; else: $result = false; endif; return $result; } add_filter('rest_authentication_errors', 'checkApiAuth'); ```
339,279
<p>I've got a bizarre problem with a website I'm working on.</p> <p>Recently, when anyone uploads images to the site, some time later (maybe an hour, sometimes several hours) one or more images disappear from the server. They still show up in the Media Library, and all the other sizes created by Wordpress are still on...
[ { "answer_id": 339300, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 1, "selected": false, "text": "<p>If it occurs periodically, the first place I would check is scheduled tasks. I would also check your error...
2019/05/31
[ "https://wordpress.stackexchange.com/questions/339279", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/143237/" ]
I've got a bizarre problem with a website I'm working on. Recently, when anyone uploads images to the site, some time later (maybe an hour, sometimes several hours) one or more images disappear from the server. They still show up in the Media Library, and all the other sizes created by Wordpress are still on the serve...
Obviously, I imagine you already checked cron jobs. No one can tell you, but whenever you have an issue and you're wondering "what the hell is interacting with my system?" and that part that's problematic (in your case, the deletion of the image) has actions inside of it, we can see what called that specific deletion....
339,297
<p>I am using WordPress FormCraft plugin on my site. I created a form and got the form short embedded code</p> <pre><code>[fc id='4'][/fc] </code></pre> <p>I want to show this form when the user opens the page.</p> <p>Can anyone tell how can approach this?</p> <p>I also try in Page Editor I got an option to add for...
[ { "answer_id": 339302, "author": "Castiblanco", "author_id": 44370, "author_profile": "https://wordpress.stackexchange.com/users/44370", "pm_score": 2, "selected": true, "text": "<p>From the <a href=\"https://formcraft-wp.com/help/how-to-use-a-custom-popup-form-trigger/\" rel=\"nofollow ...
2019/05/31
[ "https://wordpress.stackexchange.com/questions/339297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117095/" ]
I am using WordPress FormCraft plugin on my site. I created a form and got the form short embedded code ``` [fc id='4'][/fc] ``` I want to show this form when the user opens the page. Can anyone tell how can approach this? I also try in Page Editor I got an option to add form it generated below code for me. ``` [...
From the [documentation](https://formcraft-wp.com/help/how-to-use-a-custom-popup-form-trigger/), you have to use the shortcode: ``` [fc id='12' type='popup'][/fc] ``` Next, something has to trigger the form, you can create a button for that and then click it from jQury, edit the link which would trigger this form, a...
339,330
<p>I'm using the plugin <a href="https://wordpress.org/plugins/modern-events-calendar-lite/" rel="nofollow noreferrer">Modern Events Calendar Lite</a>.</p> <p>This is a recent plugin, so actually no doc exist.</p> <p>So i'm looking a way to display my upcoming events on homepage. But i can not make it to work, becaus...
[ { "answer_id": 339438, "author": "Gregory", "author_id": 139936, "author_profile": "https://wordpress.stackexchange.com/users/139936", "pm_score": 2, "selected": true, "text": "<p>i have found a solution, making a custom SQL query </p>\n\n<p>here is the code ( using WPML ) </p>\n\n<pre><...
2019/06/01
[ "https://wordpress.stackexchange.com/questions/339330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/139936/" ]
I'm using the plugin [Modern Events Calendar Lite](https://wordpress.org/plugins/modern-events-calendar-lite/). This is a recent plugin, so actually no doc exist. So i'm looking a way to display my upcoming events on homepage. But i can not make it to work, because start is stored in a second table. So i have a wpqu...
i have found a solution, making a custom SQL query here is the code ( using WPML ) ``` $startday = date("Y-m-d"); if ( defined( 'ICL_LANGUAGE_CODE' ) ) { $lang = ICL_LANGUAGE_CODE; } //echo $startday; global $wpdb,$post; $results = $wpdb->get_resu...
339,342
<p>been hacking at this for some time and haven't been able to make much progress. The goal is to add a custom body class to a specific page. -I know there are a few answered posts on this topic, and while the solution provided works if I add the custom body class globally, it fails when I add the if statement. Any ide...
[ { "answer_id": 339438, "author": "Gregory", "author_id": 139936, "author_profile": "https://wordpress.stackexchange.com/users/139936", "pm_score": 2, "selected": true, "text": "<p>i have found a solution, making a custom SQL query </p>\n\n<p>here is the code ( using WPML ) </p>\n\n<pre><...
2019/06/01
[ "https://wordpress.stackexchange.com/questions/339342", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168423/" ]
been hacking at this for some time and haven't been able to make much progress. The goal is to add a custom body class to a specific page. -I know there are a few answered posts on this topic, and while the solution provided works if I add the custom body class globally, it fails when I add the if statement. Any ideas ...
i have found a solution, making a custom SQL query here is the code ( using WPML ) ``` $startday = date("Y-m-d"); if ( defined( 'ICL_LANGUAGE_CODE' ) ) { $lang = ICL_LANGUAGE_CODE; } //echo $startday; global $wpdb,$post; $results = $wpdb->get_resu...
339,356
<p>I am working on a plugin that handles logic for when a user tries to checkout on the frontend and the order fails (e.g., person is using a credit card but it does not have enough balance to meet the cart totals, etc). I can see the order is in fact set as "FAILED" in WooCommerce, because I get the automated email fr...
[ { "answer_id": 339357, "author": "gdarko", "author_id": 73926, "author_profile": "https://wordpress.stackexchange.com/users/73926", "pm_score": 2, "selected": true, "text": "<p>You can catch specific status change by using this action hook 'woocommerce_order_status_{status}'. It is defin...
2019/06/01
[ "https://wordpress.stackexchange.com/questions/339356", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1354/" ]
I am working on a plugin that handles logic for when a user tries to checkout on the frontend and the order fails (e.g., person is using a credit card but it does not have enough balance to meet the cart totals, etc). I can see the order is in fact set as "FAILED" in WooCommerce, because I get the automated email from ...
You can catch specific status change by using this action hook 'woocommerce\_order\_status\_{status}'. It is defined in the [WC\_Order class](https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-order.php). This is how you define it: ``` /** * Executed when the status is changed to failed. * @pa...
339,364
<p>I have a problem with my WordPress site, it is working well until today.</p> <p>The problem is when I type my domain name it is redirecting to wp-admin/setup-config.php file. I have no idea why this is happening. The site works fine before.</p> <p>On domain/wp-admin/setup-config.php page shows a message</p> <bloc...
[ { "answer_id": 358857, "author": "user182877", "author_id": 182877, "author_profile": "https://wordpress.stackexchange.com/users/182877", "pm_score": 0, "selected": false, "text": "<p>I have crossed the same issue.</p>\n\n<p>First, you need to clear your browser cache and deactivate all ...
2019/06/02
[ "https://wordpress.stackexchange.com/questions/339364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/165090/" ]
I have a problem with my WordPress site, it is working well until today. The problem is when I type my domain name it is redirecting to wp-admin/setup-config.php file. I have no idea why this is happening. The site works fine before. On domain/wp-admin/setup-config.php page shows a message > > "This page isn’t work...
In my case there was a permission problem. I solved with this commands. ``` chown www-data:www-data -R * # Let Apache be owner find . -type d -exec chmod 755 {} \; # Change directory permissions rwxr-xr-x find . -type f -exec chmod 644 {} \; # Change file permissions rw-r--r-- ```
339,375
<p>I create a file name <code>custom.php</code> which is like below:</p> <pre><code>class customClass{ function dothisfunction( $mobiles , $message ){ //use parameters } } </code></pre> <p>In my <code>function.php</code> file I add the following code:</p> <pre><code>$number = '09112223344'; $mymsg = 'nad...
[ { "answer_id": 339377, "author": "gdarko", "author_id": 73926, "author_profile": "https://wordpress.stackexchange.com/users/73926", "pm_score": 3, "selected": true, "text": "<p>The <code>publish_post</code> post takes two arguments first is <code>$ID</code> of the post that is being publ...
2019/06/02
[ "https://wordpress.stackexchange.com/questions/339375", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169303/" ]
I create a file name `custom.php` which is like below: ``` class customClass{ function dothisfunction( $mobiles , $message ){ //use parameters } } ``` In my `function.php` file I add the following code: ``` $number = '09112223344'; $mymsg = 'nadia is testing'; $myClass = new customClass(); add_action(...
The `publish_post` post takes two arguments first is `$ID` of the post that is being published and the second is the `$post` instance ([See codex](https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post)). I modified your code a bit below. Your class is almost identical just renamed the parameters of the ...
339,395
<p>I'm working on a plugin that fetches remote RSS feeds using <code>wp_remote_get</code>. The problem is that Tumblr requires a cookie for GDPR compliance. This includes RSS feeds. Which means all Tumblr feeds are currently broken.</p> <p>I found <a href="https://github.com/Arvedui/tt-rss-tumblr-gdpr" rel="nofollow n...
[ { "answer_id": 339481, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 2, "selected": false, "text": "<p>The arguments array for <code>wp_remote_get</code> accepts a <code>cookies</code> parameter:</p>\n\n<pre cla...
2019/06/02
[ "https://wordpress.stackexchange.com/questions/339395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109240/" ]
I'm working on a plugin that fetches remote RSS feeds using `wp_remote_get`. The problem is that Tumblr requires a cookie for GDPR compliance. This includes RSS feeds. Which means all Tumblr feeds are currently broken. I found [an example of using CURL to acquire the cookies](https://github.com/Arvedui/tt-rss-tumblr-g...
The arguments array for `wp_remote_get` accepts a `cookies` parameter: ```php $cookies = []; $cookie = new WP_Http_Cookie( 'cookie_name' ); $cookie->name = 'cookie_name'; $cookie->value = 'your cookie value'; $cookie->expires = 7 * DAY_IN_SECONDS; // expires in 7 days $cookie->path = '/'; $cookie->domain = '.reddit.co...
339,413
<p>Good day! </p> <p>How do you properly migrate your localhost wordpress file to a live server? What I do is usually copy all my wordpress file then transferred to my website thru FTP and the database is usually imported to the target sql.</p> <p>The problem is when I do this, the website layout gets all messed up. ...
[ { "answer_id": 339417, "author": "magefms", "author_id": 157832, "author_profile": "https://wordpress.stackexchange.com/users/157832", "pm_score": 0, "selected": false, "text": "<p>Make sure to also change the <strong>site URL</strong> in your database under the <strong>wp_options</stron...
2019/06/03
[ "https://wordpress.stackexchange.com/questions/339413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162882/" ]
Good day! How do you properly migrate your localhost wordpress file to a live server? What I do is usually copy all my wordpress file then transferred to my website thru FTP and the database is usually imported to the target sql. The problem is when I do this, the website layout gets all messed up. I wanted to migra...
You can use the [WP CLI](https://wp-cli.org/) too to rename your site's hostname safely and effectively. There's a chance that your layout is being messed up because naively replacing the domain name with a simple string replace, e.g. `perl -pi -e 's/oldhost/newhost/g' backup.sql`, will not take into account things lik...
339,436
<p>When the <strong>Block Editor</strong> was added to WordPress, custom and core meta boxes became legacy, meaning, using the <a href="https://developer.wordpress.org/reference/functions/remove_meta_box/" rel="noreferrer">remove_meta_box()</a> function won't work when removing meta boxes/panels displayed on the post e...
[ { "answer_id": 339437, "author": "Christine Cooper", "author_id": 24875, "author_profile": "https://wordpress.stackexchange.com/users/24875", "pm_score": 6, "selected": true, "text": "<p>The <code>remove_meta_box()</code> function will not work with the Block Editor, because these are no...
2019/06/03
[ "https://wordpress.stackexchange.com/questions/339436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
When the **Block Editor** was added to WordPress, custom and core meta boxes became legacy, meaning, using the [remove\_meta\_box()](https://developer.wordpress.org/reference/functions/remove_meta_box/) function won't work when removing meta boxes/panels displayed on the post editing screen. So, how do we remove the `...
The `remove_meta_box()` function will not work with the Block Editor, because these are now *Panels* and work differently. There is currently no documentation on how to disable Panels, but, *let's dance*. We want to avoid *hiding* panels via CSS, and rely on the JS API. We need to use the JS function `removeEditorPan...
339,449
<p>Actually im stuck on this!</p> <ul> <li>XML-File ~ 140.000 Rows</li> <li>Filesize ~ 9.0 MB</li> <li><code>LOAD XML INFILE 'file_name'</code> isnt't allowed ( shared hosting! )</li> </ul> <p>The supplier provides a single XML file with quantity and sku. The XML is formatted like:</p> <pre class="lang-xml prettypri...
[ { "answer_id": 339459, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 1, "selected": false, "text": "<p>First of all: don't flush after every insert. I did not test this, but it should be faster if you imp...
2019/06/03
[ "https://wordpress.stackexchange.com/questions/339449", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169354/" ]
Actually im stuck on this! * XML-File ~ 140.000 Rows * Filesize ~ 9.0 MB * `LOAD XML INFILE 'file_name'` isnt't allowed ( shared hosting! ) The supplier provides a single XML file with quantity and sku. The XML is formatted like: ```xml <item> <LITM>0000001</LITM> <STQU>1<STQU> </item> <item> <LITM>0000002</LITM> <...
You can try to mitigate memory issues by using a [Generator](https://www.php.net/manual/en/language.generators.overview.php): ```php function load_xml2mysql($filename,$type) { global $wpdb; $charset = $wpdb->get_charset_collate(); $table = $wpdb->prefix.'supplier_stock'; ignore_user_abort(); $qu...
339,452
<p>I have a HTML form embedded within a PHP file with an onclick button which summons a javascript function.</p> <pre><code>&lt;form name="addStamp"&gt; Validation Code:&lt;br&gt; &lt;input type="number" name="inputcode"&gt;&lt;br&gt; &lt;input type="text" name="message" id="message"&gt;&lt;br&gt; &lt;...
[ { "answer_id": 339459, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 1, "selected": false, "text": "<p>First of all: don't flush after every insert. I did not test this, but it should be faster if you imp...
2019/06/03
[ "https://wordpress.stackexchange.com/questions/339452", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/167925/" ]
I have a HTML form embedded within a PHP file with an onclick button which summons a javascript function. ``` <form name="addStamp"> Validation Code:<br> <input type="number" name="inputcode"><br> <input type="text" name="message" id="message"><br> <input type="button" name="submitbutton" value="Submit...
You can try to mitigate memory issues by using a [Generator](https://www.php.net/manual/en/language.generators.overview.php): ```php function load_xml2mysql($filename,$type) { global $wpdb; $charset = $wpdb->get_charset_collate(); $table = $wpdb->prefix.'supplier_stock'; ignore_user_abort(); $qu...
339,485
<p>Does anyone know if there is a function to remove/bypass file types uploads filter (specifically for admins). I know there are plugins available but they often break or don't contain ALL the mime types I need to allow and to be completely honest I'm just tired of dealing with this constantly. I also know about the c...
[ { "answer_id": 339459, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 1, "selected": false, "text": "<p>First of all: don't flush after every insert. I did not test this, but it should be faster if you imp...
2019/06/03
[ "https://wordpress.stackexchange.com/questions/339485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/164435/" ]
Does anyone know if there is a function to remove/bypass file types uploads filter (specifically for admins). I know there are plugins available but they often break or don't contain ALL the mime types I need to allow and to be completely honest I'm just tired of dealing with this constantly. I also know about the cons...
You can try to mitigate memory issues by using a [Generator](https://www.php.net/manual/en/language.generators.overview.php): ```php function load_xml2mysql($filename,$type) { global $wpdb; $charset = $wpdb->get_charset_collate(); $table = $wpdb->prefix.'supplier_stock'; ignore_user_abort(); $qu...
339,495
<p>Is there any plugin or script where i can use to define maximum number of users with a specific role on subsite in a multisite network?</p> <p>I'm offering cloud helpdesk wordpress and pricing is based on number of agents, so I want to make sure that site admin is not able to add more agents than the predefined.</p...
[ { "answer_id": 339500, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 0, "selected": false, "text": "<p><strong>Update:</strong> There was a problem with my previous code based on some erroneous digging into Word...
2019/06/03
[ "https://wordpress.stackexchange.com/questions/339495", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/157457/" ]
Is there any plugin or script where i can use to define maximum number of users with a specific role on subsite in a multisite network? I'm offering cloud helpdesk wordpress and pricing is based on number of agents, so I want to make sure that site admin is not able to add more agents than the predefined. Thanks a lo...
Ok here is how I did it: ``` add_action( 'editable_roles' , 'hide_editable_roles' ); function hide_editable_roles( $roles ){ $blog_id = get_current_blog_id(); // Get current subsite id switch($blog_id) { // Define different max agents numbers depending on subsite id case 6: $max_agents = 10; //for subsite id#...
339,506
<p>I'm currently building a site on my local computer. I will transfer the finished product onto my client's new host/domain. Before he chooses this, what's the best way for him to view my current progress?</p>
[ { "answer_id": 339500, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 0, "selected": false, "text": "<p><strong>Update:</strong> There was a problem with my previous code based on some erroneous digging into Word...
2019/06/03
[ "https://wordpress.stackexchange.com/questions/339506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169383/" ]
I'm currently building a site on my local computer. I will transfer the finished product onto my client's new host/domain. Before he chooses this, what's the best way for him to view my current progress?
Ok here is how I did it: ``` add_action( 'editable_roles' , 'hide_editable_roles' ); function hide_editable_roles( $roles ){ $blog_id = get_current_blog_id(); // Get current subsite id switch($blog_id) { // Define different max agents numbers depending on subsite id case 6: $max_agents = 10; //for subsite id#...
339,507
<p>Edited for clarity and to display steps we take to reproduce the issue.</p> <h2>Question</h2> <p>What would cause absolute URLs on our staging site to prepend the staging site's subdomain to them when saved in the editor? </p> <h2>Summary</h2> <p>We write pages manually in HTML and CSS on a staging site hosted o...
[ { "answer_id": 339500, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 0, "selected": false, "text": "<p><strong>Update:</strong> There was a problem with my previous code based on some erroneous digging into Word...
2019/06/03
[ "https://wordpress.stackexchange.com/questions/339507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169384/" ]
Edited for clarity and to display steps we take to reproduce the issue. Question -------- What would cause absolute URLs on our staging site to prepend the staging site's subdomain to them when saved in the editor? Summary ------- We write pages manually in HTML and CSS on a staging site hosted on SiteGround, save...
Ok here is how I did it: ``` add_action( 'editable_roles' , 'hide_editable_roles' ); function hide_editable_roles( $roles ){ $blog_id = get_current_blog_id(); // Get current subsite id switch($blog_id) { // Define different max agents numbers depending on subsite id case 6: $max_agents = 10; //for subsite id#...
339,517
<p>Does WordPress have a built-in function that allows duplicating posts?</p> <p>I am looking for something like <code>$new_post_id = duplicate_post(post_id);</code></p>
[ { "answer_id": 339520, "author": "Mahmod Issa", "author_id": 169394, "author_profile": "https://wordpress.stackexchange.com/users/169394", "pm_score": -1, "selected": false, "text": "<p>No, there isnt built in function but there are a plenty of plugins that easily can do what you need as...
2019/06/04
[ "https://wordpress.stackexchange.com/questions/339517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123092/" ]
Does WordPress have a built-in function that allows duplicating posts? I am looking for something like `$new_post_id = duplicate_post(post_id);`
You can add your one... ``` /* * Function creates post duplicate as a draft and redirects then to the edit post screen */ function rd_duplicate_post_as_draft(){ global $wpdb; if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST[...
339,533
<p>my site have multiple authors. I need to show all type of author posts in author page that if visitors can see all posts of author when visitied his profile page.</p> <p>this code</p> <pre><code> &lt;?php get_header(); ?&gt; &lt;!-- Show custom post type posts from the author --&gt; &lt;?php global $wp_query;...
[ { "answer_id": 339539, "author": "maryyyyyyy", "author_id": 159827, "author_profile": "https://wordpress.stackexchange.com/users/159827", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if this is what you mean but this Wordpress function can display list of authors:</p>\n\n<p...
2019/06/04
[ "https://wordpress.stackexchange.com/questions/339533", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168662/" ]
my site have multiple authors. I need to show all type of author posts in author page that if visitors can see all posts of author when visitied his profile page. this code ``` <?php get_header(); ?> <!-- Show custom post type posts from the author --> <?php global $wp_query; query_posts( array( 'post_type' ...
If you use WordPress [author template](https://codex.wordpress.org/Author_Templates) to show user posts ( `example.com/author/{user_name}` ) the best solution will be to change the main query via the [pre\_get\_posts](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) filter hook. ``` function se33...
339,565
<p>I'm trying to make a post display some PHP code example. Using WordPress 5.2.1 with PHP 7.3</p> <p>The website works fine otherwise. However, when I'm editing a post, select "Formating - Code" and enter some PHP code within the block, it won't save the updated post version.</p> <p>"updating failed".</p> <p>Has a...
[ { "answer_id": 339539, "author": "maryyyyyyy", "author_id": 159827, "author_profile": "https://wordpress.stackexchange.com/users/159827", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if this is what you mean but this Wordpress function can display list of authors:</p>\n\n<p...
2019/06/04
[ "https://wordpress.stackexchange.com/questions/339565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153697/" ]
I'm trying to make a post display some PHP code example. Using WordPress 5.2.1 with PHP 7.3 The website works fine otherwise. However, when I'm editing a post, select "Formating - Code" and enter some PHP code within the block, it won't save the updated post version. "updating failed". Has anyone else had this prob...
If you use WordPress [author template](https://codex.wordpress.org/Author_Templates) to show user posts ( `example.com/author/{user_name}` ) the best solution will be to change the main query via the [pre\_get\_posts](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) filter hook. ``` function se33...
339,603
<p>I would like to get the list of all URLs from a wordpress installation. Nevertheless, I Don't want the full post titles in the permalink but I would like the shortlinks instead. I would like to get the following in the same fashion:</p> <pre><code>https://example.com/?p=123 https://example.com/?p=124 https://exampl...
[ { "answer_id": 339605, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 2, "selected": true, "text": "<p>You can get this from the <code>guid</code> column in the <code>posts</code> table of your database. </p>\n...
2019/06/04
[ "https://wordpress.stackexchange.com/questions/339603", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71531/" ]
I would like to get the list of all URLs from a wordpress installation. Nevertheless, I Don't want the full post titles in the permalink but I would like the shortlinks instead. I would like to get the following in the same fashion: ``` https://example.com/?p=123 https://example.com/?p=124 https://example.com/?p=125 h...
You can get this from the `guid` column in the `posts` table of your database. [![List of guids from database, eg http://wordpress.test/?p=1](https://i.stack.imgur.com/vFdJZ.png)](https://i.stack.imgur.com/vFdJZ.png)
339,606
<p>Here is how the loop looks? I need to exclude a few posts with the custom term, how can I manage it</p> <pre><code>&lt;?php global $post, $PIXAD_Autos; $Settings = new PIXAD_Settings(); $settings = $Settings-&gt;getSettings( 'WP_OPTIONS', '_pixad_autos_settings', true ); $validate = $Settings-&gt;g...
[ { "answer_id": 339605, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 2, "selected": true, "text": "<p>You can get this from the <code>guid</code> column in the <code>posts</code> table of your database. </p>\n...
2019/06/04
[ "https://wordpress.stackexchange.com/questions/339606", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169433/" ]
Here is how the loop looks? I need to exclude a few posts with the custom term, how can I manage it ``` <?php global $post, $PIXAD_Autos; $Settings = new PIXAD_Settings(); $settings = $Settings->getSettings( 'WP_OPTIONS', '_pixad_autos_settings', true ); $validate = $Settings->getSettings( 'WP_OPTIONS...
You can get this from the `guid` column in the `posts` table of your database. [![List of guids from database, eg http://wordpress.test/?p=1](https://i.stack.imgur.com/vFdJZ.png)](https://i.stack.imgur.com/vFdJZ.png)
339,612
<p>I’ve been searching for solution to my problem but posts already made are not fulfilling the answer to me, or I'm just not qualified enough to work this out. Here is what I need:</p> <p>I’ve got a simple landing page with a form. What I need is a way to create unique url’s for people I choose so only they can acces...
[ { "answer_id": 339613, "author": "brothman01", "author_id": 104630, "author_profile": "https://wordpress.stackexchange.com/users/104630", "pm_score": 0, "selected": false, "text": "<p>Is the page something they pay to gain access to? Why is the accessing it one time so important? Can th...
2019/06/04
[ "https://wordpress.stackexchange.com/questions/339612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169436/" ]
I’ve been searching for solution to my problem but posts already made are not fulfilling the answer to me, or I'm just not qualified enough to work this out. Here is what I need: I’ve got a simple landing page with a form. What I need is a way to create unique url’s for people I choose so only they can access this sit...
You could add a setting using `add_option( 'access_keys', [ 'key_1', 'key_2 ] )` to check against when loading the page. ``` add_action( 'init', 'wpse339612_check_access_codes' ); function wpse339612_check_access_codes(){ if( isset( $_GET['key'] ) ){ $available_keys = get_option( 'access_keys' ); ...
339,619
<p>I'm having a great deal of trouble phrasing this.</p> <p>If I were to use the filter </p> <pre><code>views_edit-page </code></pre> <p>How can I see what exactly is being passed through the filter so that I may edit them? Normally I would var_dump something similar to this, to get a breakdown of it's contents, but...
[ { "answer_id": 339613, "author": "brothman01", "author_id": 104630, "author_profile": "https://wordpress.stackexchange.com/users/104630", "pm_score": 0, "selected": false, "text": "<p>Is the page something they pay to gain access to? Why is the accessing it one time so important? Can th...
2019/06/05
[ "https://wordpress.stackexchange.com/questions/339619", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/146727/" ]
I'm having a great deal of trouble phrasing this. If I were to use the filter ``` views_edit-page ``` How can I see what exactly is being passed through the filter so that I may edit them? Normally I would var\_dump something similar to this, to get a breakdown of it's contents, but due to it being a filter, this ...
You could add a setting using `add_option( 'access_keys', [ 'key_1', 'key_2 ] )` to check against when loading the page. ``` add_action( 'init', 'wpse339612_check_access_codes' ); function wpse339612_check_access_codes(){ if( isset( $_GET['key'] ) ){ $available_keys = get_option( 'access_keys' ); ...
339,652
<p>I recently had to upload my wordpress website from live host (cpanel) to my localhost. (Took database from cpanel and updated it and changed the url settings in my database) Now when im entering the url <a href="http://localhost:8080/xxx/" rel="nofollow noreferrer">http://localhost:8080/xxx/</a> the page url redirec...
[ { "answer_id": 339613, "author": "brothman01", "author_id": 104630, "author_profile": "https://wordpress.stackexchange.com/users/104630", "pm_score": 0, "selected": false, "text": "<p>Is the page something they pay to gain access to? Why is the accessing it one time so important? Can th...
2019/06/05
[ "https://wordpress.stackexchange.com/questions/339652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/167492/" ]
I recently had to upload my wordpress website from live host (cpanel) to my localhost. (Took database from cpanel and updated it and changed the url settings in my database) Now when im entering the url <http://localhost:8080/xxx/> the page url redirects to <http://localhost/xxx/> and is showing an error. I can visit <...
You could add a setting using `add_option( 'access_keys', [ 'key_1', 'key_2 ] )` to check against when loading the page. ``` add_action( 'init', 'wpse339612_check_access_codes' ); function wpse339612_check_access_codes(){ if( isset( $_GET['key'] ) ){ $available_keys = get_option( 'access_keys' ); ...
339,699
<p>Thank you for reading my question.</p> <p>I can't seem to figure out a way to make this page full width (or almost full width). When i am on tablet and mobile phone it does fill the screen almost entirely. Does anyone have a suggestion about where to start with customising these settings?</p> <p>Thank you.</p> <p...
[ { "answer_id": 339613, "author": "brothman01", "author_id": 104630, "author_profile": "https://wordpress.stackexchange.com/users/104630", "pm_score": 0, "selected": false, "text": "<p>Is the page something they pay to gain access to? Why is the accessing it one time so important? Can th...
2019/06/06
[ "https://wordpress.stackexchange.com/questions/339699", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162007/" ]
Thank you for reading my question. I can't seem to figure out a way to make this page full width (or almost full width). When i am on tablet and mobile phone it does fill the screen almost entirely. Does anyone have a suggestion about where to start with customising these settings? Thank you. ``` <?php /** * Templa...
You could add a setting using `add_option( 'access_keys', [ 'key_1', 'key_2 ] )` to check against when loading the page. ``` add_action( 'init', 'wpse339612_check_access_codes' ); function wpse339612_check_access_codes(){ if( isset( $_GET['key'] ) ){ $available_keys = get_option( 'access_keys' ); ...
339,712
<p>This might be a beginner question, for disclaimer I'm just getting used to the WordPress templating system:</p> <p><strong>I have a purchased theme installed on my working WordPress site</strong>, looking great sofar, was relatively easy to setup.</p> <p><strong>I installed a plugin for members functionality (Ulti...
[ { "answer_id": 339613, "author": "brothman01", "author_id": 104630, "author_profile": "https://wordpress.stackexchange.com/users/104630", "pm_score": 0, "selected": false, "text": "<p>Is the page something they pay to gain access to? Why is the accessing it one time so important? Can th...
2019/06/06
[ "https://wordpress.stackexchange.com/questions/339712", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169496/" ]
This might be a beginner question, for disclaimer I'm just getting used to the WordPress templating system: **I have a purchased theme installed on my working WordPress site**, looking great sofar, was relatively easy to setup. **I installed a plugin for members functionality (Ultimate Member)**, then I wanted to **l...
You could add a setting using `add_option( 'access_keys', [ 'key_1', 'key_2 ] )` to check against when loading the page. ``` add_action( 'init', 'wpse339612_check_access_codes' ); function wpse339612_check_access_codes(){ if( isset( $_GET['key'] ) ){ $available_keys = get_option( 'access_keys' ); ...
339,718
<p>Can anyone explain why I cannot see the role from the code below:</p> <pre><code>$userID = get_current_user_id(); $user = get_userdata(userID); &lt;?php echo $user-&gt;roles; ?&gt; </code></pre> <p>but I can see all the other user data such as </p> <pre><code>&lt;?php echo $user-&gt;ID; ?&gt; &lt;?php echo $user-...
[ { "answer_id": 339721, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>You can't see any roles printed, because the <code>-&gt;roles</code> field is an <code>Array</code>, ...
2019/06/06
[ "https://wordpress.stackexchange.com/questions/339718", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169499/" ]
Can anyone explain why I cannot see the role from the code below: ``` $userID = get_current_user_id(); $user = get_userdata(userID); <?php echo $user->roles; ?> ``` but I can see all the other user data such as ``` <?php echo $user->ID; ?> <?php echo $user->user_login; ?> ``` I'm following [this](https://codex.w...
You can't see any roles printed, because the `->roles` field is an `Array`, so you can't print it using `echo`. User `print_r` instead. You also have an error in this line: ``` $user = get_userdata(userID); ``` There is no such thing like `userID` - it should be `$userID`.
339,850
<p>As my understanding, The <code>wp_ajax_{action}</code> hook only fires for logged in users. For logged-out users, <code>wp_ajax_nopriv_{action}</code>action is triggered on an ajax request.</p> <p>So, how can I write for both logged and non-logged users? Do I have to write two functions?</p> <p>Eg Situation: There...
[ { "answer_id": 339851, "author": "Bhupen", "author_id": 128529, "author_profile": "https://wordpress.stackexchange.com/users/128529", "pm_score": 2, "selected": false, "text": "<p>No. You have to write only one function. For example,</p>\n\n<pre><code>function ajaxTest(){\n//your code\n}...
2019/06/07
[ "https://wordpress.stackexchange.com/questions/339850", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123092/" ]
As my understanding, The `wp_ajax_{action}` hook only fires for logged in users. For logged-out users, `wp_ajax_nopriv_{action}`action is triggered on an ajax request. So, how can I write for both logged and non-logged users? Do I have to write two functions? Eg Situation: There is a form which can be filled by both ...
You can add the function to both hooks: ``` add_action('wp_ajax_ajaxTest', 'ajaxTest'); add_action('wp_ajax_nopriv_ajaxTest', 'ajaxTest'); ``` But, there's a better way to do it, use a REST API endpoint: ``` add_action( 'rest_api_init', function () { register_rest_route( 'yourstuff/v1', '/test/', array( ...
339,904
<p>As my title explains I am trying to migrate a customers Wordpress site to new environment and domain. Why? because Godaddy instance exploded and everything went down. I only have the complete website dumps taken from CPANEL. This includes all the website folders and a SQL dump. Of course everything in the DB and fil...
[ { "answer_id": 339911, "author": "Debbie Kurth", "author_id": 119560, "author_profile": "https://wordpress.stackexchange.com/users/119560", "pm_score": 2, "selected": true, "text": "<p>Migration with domain change can be tricky and not for the faint of heart. It is much easier to keep th...
2019/06/08
[ "https://wordpress.stackexchange.com/questions/339904", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169630/" ]
As my title explains I am trying to migrate a customers Wordpress site to new environment and domain. Why? because Godaddy instance exploded and everything went down. I only have the complete website dumps taken from CPANEL. This includes all the website folders and a SQL dump. Of course everything in the DB and files ...
Migration with domain change can be tricky and not for the faint of heart. It is much easier to keep the domain the same and port it over to a new environment and then changes the domain. Then, at the very most, it is just a matter of passwords for the database resident in the root via file: wp\_config.php file. Class...
339,909
<p>I am creating a dynamic page, in a WordPress environment. The page is created by a default standard WordPress page and then using shortcode. Combined with URL parameters in order to retrieve the necessary data. </p> <p>The problem is, this page, including the URL parameters, is "shareable" to facebook and other ...
[ { "answer_id": 339911, "author": "Debbie Kurth", "author_id": 119560, "author_profile": "https://wordpress.stackexchange.com/users/119560", "pm_score": 2, "selected": true, "text": "<p>Migration with domain change can be tricky and not for the faint of heart. It is much easier to keep th...
2019/06/08
[ "https://wordpress.stackexchange.com/questions/339909", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119560/" ]
I am creating a dynamic page, in a WordPress environment. The page is created by a default standard WordPress page and then using shortcode. Combined with URL parameters in order to retrieve the necessary data. The problem is, this page, including the URL parameters, is "shareable" to facebook and other social media....
Migration with domain change can be tricky and not for the faint of heart. It is much easier to keep the domain the same and port it over to a new environment and then changes the domain. Then, at the very most, it is just a matter of passwords for the database resident in the root via file: wp\_config.php file. Class...
339,923
<p><a href="https://www.hongkiat.com/blog/wordpress-admin-color-scheme/" rel="noreferrer">I followed this guide</a>, but idk if it doesnt work for WP 5.0+ or if im doing something wrong. </p> <p>I added this to my functions.php and the css file is a copy of the Light Scheme.</p> <pre><code> function additional_admin_...
[ { "answer_id": 339925, "author": "Paul G.", "author_id": 41288, "author_profile": "https://wordpress.stackexchange.com/users/41288", "pm_score": 2, "selected": false, "text": "<p>This code works with WordPress 5.2 and is correct.</p>\n\n<p>You now need to go to your Profile and select it...
2019/06/08
[ "https://wordpress.stackexchange.com/questions/339923", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169632/" ]
[I followed this guide](https://www.hongkiat.com/blog/wordpress-admin-color-scheme/), but idk if it doesnt work for WP 5.0+ or if im doing something wrong. I added this to my functions.php and the css file is a copy of the Light Scheme. ``` function additional_admin_color_schemes() { $theme_dir = get_template_dire...
This code works with WordPress 5.2 and is correct. You now need to go to your Profile and select it by going to `Users` > `Your Profile` > `Admin Color Scheme` select the scheme and save. [![enter image description here](https://i.stack.imgur.com/0xlHm.png)](https://i.stack.imgur.com/0xlHm.png) Edit: Adding updated ...
339,946
<p>I have a custom tracking system in place which works with an include of a .js file in the footer of each page. Unfortunately some high traffic sites are including images from my site which are already removed. therefor the 404 error page of my theme is frequenty hit and those users are registered aswell as website ...
[ { "answer_id": 339949, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>You could use the <code>is_page()</code> function on your footer to check if it is a 404 page, then do...
2019/06/08
[ "https://wordpress.stackexchange.com/questions/339946", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116018/" ]
I have a custom tracking system in place which works with an include of a .js file in the footer of each page. Unfortunately some high traffic sites are including images from my site which are already removed. therefor the 404 error page of my theme is frequenty hit and those users are registered aswell as website vis...
There is [`is_404()`](https://codex.wordpress.org/Function_Reference/is_404). I normally use it to do just the opposite, to add CSS and JS animations which are specific to the 404 error page. In your case that would be: ``` function wpse_339946() { if ( ! is_404() ) { wp_enqueue_script( 'tracking-js', get...
339,950
<p>On the WP homepage I have a Form like this:</p> <pre><code>&lt;form action="'.esc_url( admin_url('admin-post.php')).'" method="post"&gt; //etc. //etc. </code></pre> <p>and in the file <strong>functions.php</strong> I have this snipped of code.</p> <pre><code> function redirect_form() { if (isset(...
[ { "answer_id": 339951, "author": "JBarnden", "author_id": 169666, "author_profile": "https://wordpress.stackexchange.com/users/169666", "pm_score": -1, "selected": false, "text": "<p>If you're looking to customize what's displayed on product pages, there are a couple of ways you can do t...
2019/06/08
[ "https://wordpress.stackexchange.com/questions/339950", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169665/" ]
On the WP homepage I have a Form like this: ``` <form action="'.esc_url( admin_url('admin-post.php')).'" method="post"> //etc. //etc. ``` and in the file **functions.php** I have this snipped of code. ``` function redirect_form() { if (isset($_POST["var1"]) && !empty($_POST["var1"]) && isset($_POS...
I think you can maybe use $\_SESSIONS or a $\_GET var. **Option 1:** (I think this will work best for you situation) ``` function redirect_form() { if (isset($_POST["var1"]) && !empty($_POST["var1"]) && isset($_POST["var2"]) && isset($_POST["var3"]) && !empty($_POST["var3"])) { $_SESSION['var2'] = htmlentities...
339,984
<p>I have a list of articles on my website.</p> <p>Some of the articles are post types with the "Article" category and others are PDF files uploaded to the media library, also with the "Article" category. I added categories to the media library using these functions in <em>functions.php</em>:</p> <pre><code>// add ca...
[ { "answer_id": 339992, "author": "bjornredemption", "author_id": 64380, "author_profile": "https://wordpress.stackexchange.com/users/64380", "pm_score": 1, "selected": false, "text": "<p>Something like this should work :</p>\n\n<pre><code>$args = array ( 'post_type' =&gt; array( 'post', ...
2019/06/09
[ "https://wordpress.stackexchange.com/questions/339984", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168795/" ]
I have a list of articles on my website. Some of the articles are post types with the "Article" category and others are PDF files uploaded to the media library, also with the "Article" category. I added categories to the media library using these functions in *functions.php*: ``` // add categories for attachments fun...
Something like this should work : ``` $args = array ( 'post_type' => array( 'post', 'attachment'), 'category' => ARTICLE_CATID ); $query = new WP_Query( $args ); ```
339,986
<p>I have a query that get relationship fields for multiple ID.</p> <p>I get the ID of selected item, and merge it in an array with other ID's</p> <p>ex : </p> <p>my page relationship ID = 5 my other pages ID in array = 6,3,8 so i make an array = 6,3,8,5</p> <p>how can I display my value, to display first the value...
[ { "answer_id": 339992, "author": "bjornredemption", "author_id": 64380, "author_profile": "https://wordpress.stackexchange.com/users/64380", "pm_score": 1, "selected": false, "text": "<p>Something like this should work :</p>\n\n<pre><code>$args = array ( 'post_type' =&gt; array( 'post', ...
2019/06/09
[ "https://wordpress.stackexchange.com/questions/339986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/139936/" ]
I have a query that get relationship fields for multiple ID. I get the ID of selected item, and merge it in an array with other ID's ex : my page relationship ID = 5 my other pages ID in array = 6,3,8 so i make an array = 6,3,8,5 how can I display my value, to display first the value of "5", and then the other val...
Something like this should work : ``` $args = array ( 'post_type' => array( 'post', 'attachment'), 'category' => ARTICLE_CATID ); $query = new WP_Query( $args ); ```
339,990
<p>On my frontend I am using Boostrap 4, however Gutenberg block table has class <code>&lt;table class="wp-block-table"&gt;</code> so instead of creating new table style it would make more sense to append the Boostrap table class to <code>wp-block-table</code> class. Would like to know if this possible. Thanks.</p>
[ { "answer_id": 339998, "author": "Benjamin Franklin", "author_id": 162254, "author_profile": "https://wordpress.stackexchange.com/users/162254", "pm_score": 1, "selected": true, "text": "<p>Since my theme did not recognize wp block table class I have added table Sass class from Gutenberg...
2019/06/09
[ "https://wordpress.stackexchange.com/questions/339990", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162254/" ]
On my frontend I am using Boostrap 4, however Gutenberg block table has class `<table class="wp-block-table">` so instead of creating new table style it would make more sense to append the Boostrap table class to `wp-block-table` class. Would like to know if this possible. Thanks.
Since my theme did not recognize wp block table class I have added table Sass class from Gutenberg to my theme. ``` .wp-block-table { width: 100%; min-width: 240px; border-collapse: collapse; margin-bottom: 24px; td, th { padding: .3em; border: 1px solid rgba(0, 0, 0, 0.1); word-break: break-al...
340,034
<pre><code>wp_mail($emails, 'New Contact Enquiry | ' . $subject, $message, $headers, $attachments) </code></pre> <p>but getting this error.</p> <p>WP_Error Object ( [errors] => Array ( [2] => Array ( [0] => SMTP Error: data not accepted. ) ) [error_data] => Array ( [2] => Array ( [to] => Array ( [0] => noreply@capita...
[ { "answer_id": 340003, "author": "Rimarx", "author_id": 169228, "author_profile": "https://wordpress.stackexchange.com/users/169228", "pm_score": 1, "selected": false, "text": "<p>First you need to find where does the code slow down, try:</p>\n\n<ul>\n<li>Deactivating all plugins and th...
2019/06/10
[ "https://wordpress.stackexchange.com/questions/340034", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168208/" ]
``` wp_mail($emails, 'New Contact Enquiry | ' . $subject, $message, $headers, $attachments) ``` but getting this error. WP\_Error Object ( [errors] => Array ( [2] => Array ( [0] => SMTP Error: data not accepted. ) ) [error\_data] => Array ( [2] => Array ( [to] => Array ( [0] => noreply@capitalsmart.com.au ) [subject...
First you need to find where does the code slow down, try: * Deactivating all plugins and then check speed. If this works, re-activate them individually( one-by-one ) to find the problematic plugin(s). * Switching theme then check speed. * Transfer the theme and plugins to a new WordPress that installed from scratch, ...
340,060
<p>I'm trying to query wordpress with multiple values but it looks like it can't take no more than 4 keywords</p> <p>I'm currently using a loop and I already tried to switch to a <strong>IN</strong> operator but I need the query to work with wildcards and while <strong>REGEXP</strong> does the job, IN does not</p> <p...
[ { "answer_id": 340003, "author": "Rimarx", "author_id": 169228, "author_profile": "https://wordpress.stackexchange.com/users/169228", "pm_score": 1, "selected": false, "text": "<p>First you need to find where does the code slow down, try:</p>\n\n<ul>\n<li>Deactivating all plugins and th...
2019/06/10
[ "https://wordpress.stackexchange.com/questions/340060", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169734/" ]
I'm trying to query wordpress with multiple values but it looks like it can't take no more than 4 keywords I'm currently using a loop and I already tried to switch to a **IN** operator but I need the query to work with wildcards and while **REGEXP** does the job, IN does not ``` foreach ($keywords as $value) { $a...
First you need to find where does the code slow down, try: * Deactivating all plugins and then check speed. If this works, re-activate them individually( one-by-one ) to find the problematic plugin(s). * Switching theme then check speed. * Transfer the theme and plugins to a new WordPress that installed from scratch, ...
340,062
<p>After introduction of <code>WP_DISABLE_FATAL_ERROR_HANDLER</code> I'm confused with existing <code>WP_DEBUG</code> feature. Now what's the difference here? </p> <p>I mean what constant I should use to see the error if I use <code>WP_DISABLE_FATAL_ERROR_HANDLER</code> then what's the meaning of <code>WP_DEBUG</cod...
[ { "answer_id": 340067, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 4, "selected": true, "text": "<p>Those constants do different things.</p>\n\n<ul>\n<li>The <code>WP_DISABLE_FATAL_ERROR_HANDLER</code> co...
2019/06/10
[ "https://wordpress.stackexchange.com/questions/340062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169739/" ]
After introduction of `WP_DISABLE_FATAL_ERROR_HANDLER` I'm confused with existing `WP_DEBUG` feature. Now what's the difference here? I mean what constant I should use to see the error if I use `WP_DISABLE_FATAL_ERROR_HANDLER` then what's the meaning of `WP_DEBUG` now? Even though I went through some of tickets on W...
Those constants do different things. * The `WP_DISABLE_FATAL_ERROR_HANDLER` constant is for disabling the [new fatal error recovery feature](https://make.wordpress.org/core/2019/04/16/fatal-error-recovery-mode-in-5-2/) introduced in WordPress 5.2. This new feature ensures that fatal errors from plugins don't lock you ...
340,117
<p>I am developing a theme and I need to get the actual page ID, when I do:</p> <pre><code>global $post; $thePostID = $post-&gt;ID; </code></pre> <p>I get the wrong ID. I tried get_the_ID() and I get the same ID that in the code above, but both are wrong. I also tried to do wp_reset_query() before getting the ID but ...
[ { "answer_id": 340127, "author": "Manyang", "author_id": 94471, "author_profile": "https://wordpress.stackexchange.com/users/94471", "pm_score": -1, "selected": false, "text": "<p>You get the ID after another post appear or after another loop.</p>\n\n<p>if you want to get the original ma...
2019/06/11
[ "https://wordpress.stackexchange.com/questions/340117", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117809/" ]
I am developing a theme and I need to get the actual page ID, when I do: ``` global $post; $thePostID = $post->ID; ``` I get the wrong ID. I tried get\_the\_ID() and I get the same ID that in the code above, but both are wrong. I also tried to do wp\_reset\_query() before getting the ID but I still get the same wron...
As mentioned in the comments, you are trying to get the ID in the taxonomy archive (`template-taxonomy.php`) which is not a post object and has no record in the database. It just tries to show some posts and you may get the first post ID when you use `get_te_ID()` function in that archive page. Using some themes or pl...
340,139
<p>I've noticed that each call to <a href="https://developer.wordpress.org/reference/functions/update_post_meta/" rel="nofollow noreferrer">update_post_meta</a> results in a small increase in my memory usage.</p> <p>Normally, the increase is small enough to not matter. But I'm writing a CSV import function that calls ...
[ { "answer_id": 340142, "author": "Pikamander2", "author_id": 119995, "author_profile": "https://wordpress.stackexchange.com/users/119995", "pm_score": 3, "selected": true, "text": "<p>It turns out that it was due to Query Monitor, a plugin that records info about each query. Every time u...
2019/06/11
[ "https://wordpress.stackexchange.com/questions/340139", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119995/" ]
I've noticed that each call to [update\_post\_meta](https://developer.wordpress.org/reference/functions/update_post_meta/) results in a small increase in my memory usage. Normally, the increase is small enough to not matter. But I'm writing a CSV import function that calls it 10,000+ times, which eventually results in...
It turns out that it was due to Query Monitor, a plugin that records info about each query. Every time update\_post\_meta ran, Query Monitor would store some data about the query, which eventually added up to be more than the server could handle. Running my example code on a default theme like Twenty Nineteen with no ...
340,140
<p>Would it be fine if i had 1 main product category in woocommerce with lots of child categories? I'm talking about thousands products in this 1 main category with many subcategories.</p> <p>Is this alright, or not recommended? What about speed of the page, will it affect it in any way by doing this?</p>
[ { "answer_id": 340142, "author": "Pikamander2", "author_id": 119995, "author_profile": "https://wordpress.stackexchange.com/users/119995", "pm_score": 3, "selected": true, "text": "<p>It turns out that it was due to Query Monitor, a plugin that records info about each query. Every time u...
2019/06/11
[ "https://wordpress.stackexchange.com/questions/340140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169775/" ]
Would it be fine if i had 1 main product category in woocommerce with lots of child categories? I'm talking about thousands products in this 1 main category with many subcategories. Is this alright, or not recommended? What about speed of the page, will it affect it in any way by doing this?
It turns out that it was due to Query Monitor, a plugin that records info about each query. Every time update\_post\_meta ran, Query Monitor would store some data about the query, which eventually added up to be more than the server could handle. Running my example code on a default theme like Twenty Nineteen with no ...
340,143
<p>I need to get a list of the years with posts of given category. Like this: 2008, 2009, 2010, 2012, 2013 (if there were no posts in 2011, it's not included).</p> <p>I try this query, and it works — I get my list of the years:</p> <pre><code>$wpdb-&gt;get_results("SELECT YEAR(post_date) FROM {$wpdb-&gt;posts} WHERE...
[ { "answer_id": 340147, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 0, "selected": false, "text": "<p>This is because the category-relations are not stored within the wp_posts table, but in another table...
2019/06/11
[ "https://wordpress.stackexchange.com/questions/340143", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/167012/" ]
I need to get a list of the years with posts of given category. Like this: 2008, 2009, 2010, 2012, 2013 (if there were no posts in 2011, it's not included). I try this query, and it works — I get my list of the years: ``` $wpdb->get_results("SELECT YEAR(post_date) FROM {$wpdb->posts} WHERE post_status = 'publish' GR...
Relationship between post and category is not stored in the `posts` table. You must extend your query for additional tables. By category `id`: ``` SELECT YEAR(p.post_date) FROM {$wpdb->posts} p JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.id JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term...
340,161
<p><a href="https://i.stack.imgur.com/jhijR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jhijR.jpg" alt="Mike"></a> Hi! It is possible without plugin to add ability edit custom thumbnail image size and apply changes to it?</p>
[ { "answer_id": 340147, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 0, "selected": false, "text": "<p>This is because the category-relations are not stored within the wp_posts table, but in another table...
2019/06/11
[ "https://wordpress.stackexchange.com/questions/340161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169787/" ]
[![Mike](https://i.stack.imgur.com/jhijR.jpg)](https://i.stack.imgur.com/jhijR.jpg) Hi! It is possible without plugin to add ability edit custom thumbnail image size and apply changes to it?
Relationship between post and category is not stored in the `posts` table. You must extend your query for additional tables. By category `id`: ``` SELECT YEAR(p.post_date) FROM {$wpdb->posts} p JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.id JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term...
340,169
<p>I want to moving my site followourtrack.fr from http to https but i have the message ERR_TOO_MANY_REDIRECTS</p> <p><strong>wp-config.php :</strong></p> <pre><code>define('WP_HOME','https://www.followourtrack.fr/'); define('WP_SITEURL','https://www.followourtrack.fr/'); </code></pre> <p><strong>.htaccess file :</s...
[ { "answer_id": 340147, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 0, "selected": false, "text": "<p>This is because the category-relations are not stored within the wp_posts table, but in another table...
2019/06/11
[ "https://wordpress.stackexchange.com/questions/340169", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169788/" ]
I want to moving my site followourtrack.fr from http to https but i have the message ERR\_TOO\_MANY\_REDIRECTS **wp-config.php :** ``` define('WP_HOME','https://www.followourtrack.fr/'); define('WP_SITEURL','https://www.followourtrack.fr/'); ``` **.htaccess file :** ``` <IfModule mod_rewrite.c> RewriteEngine On Re...
Relationship between post and category is not stored in the `posts` table. You must extend your query for additional tables. By category `id`: ``` SELECT YEAR(p.post_date) FROM {$wpdb->posts} p JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.id JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term...
340,211
<p>I simply have a quick question. I've found information related to this, but I'm not completely sure if this is possible. I know that I can create a second database connection using the wpdb object as follows:</p> <pre><code>$new_db = new wpdb(usr, pw, name, host); </code></pre> <p>However, is this compatible with ...
[ { "answer_id": 340147, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 0, "selected": false, "text": "<p>This is because the category-relations are not stored within the wp_posts table, but in another table...
2019/06/11
[ "https://wordpress.stackexchange.com/questions/340211", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153230/" ]
I simply have a quick question. I've found information related to this, but I'm not completely sure if this is possible. I know that I can create a second database connection using the wpdb object as follows: ``` $new_db = new wpdb(usr, pw, name, host); ``` However, is this compatible with an Oracle database that wo...
Relationship between post and category is not stored in the `posts` table. You must extend your query for additional tables. By category `id`: ``` SELECT YEAR(p.post_date) FROM {$wpdb->posts} p JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.id JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term...
340,265
<p>I'm trying to repair a function that was working properly before going to php 7.2. The error comes from the count () function but I do not know how to rewrite it. Can you help me ?</p> <p>Here is the error message: Warning: count(): Parameter must be an array or an object that implements Countable in...</p> <p>Thi...
[ { "answer_id": 340227, "author": "Marc", "author_id": 71657, "author_profile": "https://wordpress.stackexchange.com/users/71657", "pm_score": 1, "selected": true, "text": "<p>As long as <code>has_category</code> is used within the loop then it should work when used within <code>index.php...
2019/06/12
[ "https://wordpress.stackexchange.com/questions/340265", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169846/" ]
I'm trying to repair a function that was working properly before going to php 7.2. The error comes from the count () function but I do not know how to rewrite it. Can you help me ? Here is the error message: Warning: count(): Parameter must be an array or an object that implements Countable in... This function is a p...
As long as `has_category` is used within the loop then it should work when used within `index.php`, `archive.php`, etc. You will likely run into issues if it is used outside of the loop on those templates.
340,272
<p>I am working on a plugin for which I need to create an array of all users (name and ID) that have one or more publish blog posts. </p> <p>Looking at the documentation for <code>get_users()</code> it does not seem to have an arg value for this particular requirement.</p> <p>How do I obtain this data?</p>
[ { "answer_id": 340274, "author": "Bhupen", "author_id": 128529, "author_profile": "https://wordpress.stackexchange.com/users/128529", "pm_score": 0, "selected": false, "text": "<p>You can set \"orderby\" and \"who\" in get_users:\n<a href=\"https://codex.wordpress.org/Function_Reference/...
2019/06/12
[ "https://wordpress.stackexchange.com/questions/340272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109240/" ]
I am working on a plugin for which I need to create an array of all users (name and ID) that have one or more publish blog posts. Looking at the documentation for `get_users()` it does not seem to have an arg value for this particular requirement. How do I obtain this data?
There is an argument for this, and it is documented. If you look at [the documentation for `get_users()`](https://developer.wordpress.org/reference/functions/get_users/) is says this: > > See [WP\_User\_Query::prepare\_query()](https://developer.wordpress.org/reference/classes/WP_User_Query/prepare_query/). for more ...
340,295
<p>How to move 1 WP site from a mult-site environment to a different multi-site area?</p> <p>Doing on same server if that assists at all.</p> <p>We know how to move a site from a multi-site area into a single site area, and vice versa. Loads of coverage and instructions on this. But not to move a site from 1 multi-si...
[ { "answer_id": 340300, "author": "Blackbam", "author_id": 12035, "author_profile": "https://wordpress.stackexchange.com/users/12035", "pm_score": 2, "selected": false, "text": "<p>If you know how WordPress is structured internally it should not be too hard. Here are the steps:</p>\n\n<ol...
2019/06/12
[ "https://wordpress.stackexchange.com/questions/340295", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80415/" ]
How to move 1 WP site from a mult-site environment to a different multi-site area? Doing on same server if that assists at all. We know how to move a site from a multi-site area into a single site area, and vice versa. Loads of coverage and instructions on this. But not to move a site from 1 multi-site WP area to ano...
If you know how WordPress is structured internally it should not be too hard. Here are the steps: 1. For your site to migrate create a new site in the WordPress multisite environment (the information in the following tables must fit the new environment) > > > ``` > wp_blogs (especially this) > wp_blogs_versions (pr...
340,328
<p>How do I create a page(in wordpress theme folder) so that it can be accessed on my site as <code>examplepage.com/somepost.php</code>?</p> <p>I can see it as <code>examplepage.com/wp-content/themes/mytheme/somepost.php</code> but is there any way to cut off the path? Placing the file in the root folder is not an opt...
[ { "answer_id": 340332, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 2, "selected": true, "text": "<p>You could accomplish this by setting up a redirect. If you're using an Apache server, for your example, yo...
2019/06/12
[ "https://wordpress.stackexchange.com/questions/340328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162638/" ]
How do I create a page(in wordpress theme folder) so that it can be accessed on my site as `examplepage.com/somepost.php`? I can see it as `examplepage.com/wp-content/themes/mytheme/somepost.php` but is there any way to cut off the path? Placing the file in the root folder is not an option. Thanks in advance.
You could accomplish this by setting up a redirect. If you're using an Apache server, for your example, you would add this to .htaccess above the WordPress block: ``` RewriteEngine On RewriteRule somepost.php ^/somepost/ ``` It's much more common, and recommended, to create a PHP file *and* a Page (or other post typ...
340,343
<p>I'm displaying list of term from each taxonomy assigned to custom post:</p> <pre><code>&lt;?php $taxonomies = get_object_taxonomies( $post ); foreach ( $taxonomies as $taxonomy ) { the_terms( $post-&gt;ID, $taxonomy, '&lt;span class="e-article__category__item"&gt;&lt;strong&gt;' . SINGULAR_NAME . ': &lt;/strong&gt...
[ { "answer_id": 340332, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 2, "selected": true, "text": "<p>You could accomplish this by setting up a redirect. If you're using an Apache server, for your example, yo...
2019/06/12
[ "https://wordpress.stackexchange.com/questions/340343", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163478/" ]
I'm displaying list of term from each taxonomy assigned to custom post: ``` <?php $taxonomies = get_object_taxonomies( $post ); foreach ( $taxonomies as $taxonomy ) { the_terms( $post->ID, $taxonomy, '<span class="e-article__category__item"><strong>' . SINGULAR_NAME . ': </strong> ', ", ", '</span>' ); } ?> ``` bu...
You could accomplish this by setting up a redirect. If you're using an Apache server, for your example, you would add this to .htaccess above the WordPress block: ``` RewriteEngine On RewriteRule somepost.php ^/somepost/ ``` It's much more common, and recommended, to create a PHP file *and* a Page (or other post typ...
340,351
<p>I used an ACF repeater field for data sheets/instruction manual download links of products in woocommerce. There's 50 products and each has 1 to 4 download links on their product page. I've been searching for a way to list all the links form all 50 products on one page the way you would query all posts on a page in ...
[ { "answer_id": 340332, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 2, "selected": true, "text": "<p>You could accomplish this by setting up a redirect. If you're using an Apache server, for your example, yo...
2019/06/12
[ "https://wordpress.stackexchange.com/questions/340351", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103767/" ]
I used an ACF repeater field for data sheets/instruction manual download links of products in woocommerce. There's 50 products and each has 1 to 4 download links on their product page. I've been searching for a way to list all the links form all 50 products on one page the way you would query all posts on a page in a l...
You could accomplish this by setting up a redirect. If you're using an Apache server, for your example, you would add this to .htaccess above the WordPress block: ``` RewriteEngine On RewriteRule somepost.php ^/somepost/ ``` It's much more common, and recommended, to create a PHP file *and* a Page (or other post typ...
340,358
<p>Given this code:</p> <pre><code>class test_class { function greeting() { echo 'Howdy! Test is successful!'; } function greeting_head() { //Close PHP tags ?&gt; &lt;?php greeting() ?&gt; &lt;?php //Open PHP tags } } add_action( 'wp_head', array( 'test_class', 'greetin...
[ { "answer_id": 340363, "author": "Adnane Zarrouk", "author_id": 64067, "author_profile": "https://wordpress.stackexchange.com/users/64067", "pm_score": -1, "selected": false, "text": "<p>1 - Inside your <strong>class</strong> you are trying to call the function <strong>greeting()</strong...
2019/06/12
[ "https://wordpress.stackexchange.com/questions/340358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119814/" ]
Given this code: ``` class test_class { function greeting() { echo 'Howdy! Test is successful!'; } function greeting_head() { //Close PHP tags ?> <?php greeting() ?> <?php //Open PHP tags } } add_action( 'wp_head', array( 'test_class', 'greeting_head' ) ); ``` `greeti...
You're using the *static* class method call when supplying a [callable/callback](https://www.php.net/manual/en/language.types.callable.php) to `add_action()`: ```php add_action( 'wp_head', array( 'test_class', 'greeting_head' ) ); ``` So you should make the `greeting_head()` a static method in your `test_class` clas...
340,362
<p>I'm getting several create_function is depreciated errors from a plugin as the result of a recent WP upgrade to 5.2. The plugin is no longer supported which means I need to refactor the code myself. Would anyone be able to get me pointed in the right direction?</p> <pre><code> function _options_page(){ if...
[ { "answer_id": 340364, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 3, "selected": false, "text": "<p>There is an inbuilt function for returning <code>null</code>: <code>__return_null</code>. </p>\n\n<p>So you ca...
2019/06/13
[ "https://wordpress.stackexchange.com/questions/340362", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116635/" ]
I'm getting several create\_function is depreciated errors from a plugin as the result of a recent WP upgrade to 5.2. The plugin is no longer supported which means I need to refactor the code myself. Would anyone be able to get me pointed in the right direction? ``` function _options_page(){ if($this->args['pa...
There is an inbuilt function for returning `null`: `__return_null`. So you can replace `create_function('$a', 'return null;');` with just `'__return_null'` (note the quotes) as it seems `$a` is not used anyway. Or you can use an anonymous function as the argument directly: `function($a) {return null;}` (no quotes). ...
340,372
<p>I need to retrieve the name of all the categories that a given user has published posts for. If I can also get a URL for the archive of that cat for that user only, this would make me very happy.</p> <p>How do I get a list of all categories that a given user has written blog posts for (and possibly the URL for that ...
[ { "answer_id": 340364, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 3, "selected": false, "text": "<p>There is an inbuilt function for returning <code>null</code>: <code>__return_null</code>. </p>\n\n<p>So you ca...
2019/06/13
[ "https://wordpress.stackexchange.com/questions/340372", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109240/" ]
I need to retrieve the name of all the categories that a given user has published posts for. If I can also get a URL for the archive of that cat for that user only, this would make me very happy. How do I get a list of all categories that a given user has written blog posts for (and possibly the URL for that user's ca...
There is an inbuilt function for returning `null`: `__return_null`. So you can replace `create_function('$a', 'return null;');` with just `'__return_null'` (note the quotes) as it seems `$a` is not used anyway. Or you can use an anonymous function as the argument directly: `function($a) {return null;}` (no quotes). ...
340,379
<p>I wanted to show you this issue. This is happening first time with me in my 10 years career, I have cloned many sites to another domain in past but this is for the first time when I do not see the "site URL and home options" under Wp_Options (phpmyadmin)</p> <p>This is the domain name which I cloned </p> <p><stron...
[ { "answer_id": 340382, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>Check wp-config.php. It's possible to define these values there, in which case they won't be available ...
2019/06/13
[ "https://wordpress.stackexchange.com/questions/340379", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169913/" ]
I wanted to show you this issue. This is happening first time with me in my 10 years career, I have cloned many sites to another domain in past but this is for the first time when I do not see the "site URL and home options" under Wp\_Options (phpmyadmin) This is the domain name which I cloned **<https://13cabsonlin...
Check wp-config.php. It's possible to define these values there, in which case they won't be available as settings, which means they won't be saved in the database. > > It is possible to set the site URL manually in the wp-config.php file. > > > Add these two lines to your wp-config.php, where “example.com” is the ...
340,432
<p>I'm stuck trying to do the remote SSH with WP-CLI.</p> <p>I have installed WP-CLI on my <strong>Webfaction server</strong> and tested it's working</p> <pre><code># This is in server $ wp --info OS: Linux web561.webfaction.com 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 Shell: /bin/...
[ { "answer_id": 340459, "author": "hrsetyono", "author_id": 33361, "author_profile": "https://wordpress.stackexchange.com/users/33361", "pm_score": 2, "selected": false, "text": "<p>Found a solution here <a href=\"https://github.com/hrsetyono/wordpress/wiki/WP-CLI-on-Webfaction\" rel=\"no...
2019/06/13
[ "https://wordpress.stackexchange.com/questions/340432", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33361/" ]
I'm stuck trying to do the remote SSH with WP-CLI. I have installed WP-CLI on my **Webfaction server** and tested it's working ``` # This is in server $ wp --info OS: Linux web561.webfaction.com 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 Shell: /bin/bash PHP binary: /usr/local/bi...
Found a solution here <https://github.com/hrsetyono/wordpress/wiki/WP-CLI-on-Webfaction> . This seems to be Webfaction specific issue You simply need to open FTP and append this line in `/home/yourname/.bashrc` ``` export PATH=$PATH:$HOME/bin ```
340,523
<p>I have enabled SVG uploads using this code:</p> <pre><code>add_filter('upload_mimes', function($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; }); </code></pre> <p>However, uploads of SVG files that start with the <code>&lt;svg&gt;</code> tag fail with the usual "Sorry, this file type is not permitte...
[ { "answer_id": 340535, "author": "twelvell", "author_id": 138568, "author_profile": "https://wordpress.stackexchange.com/users/138568", "pm_score": 3, "selected": true, "text": "<p>It seems that in the recent releases of WordPress, changes were made to the mime type handling to make sure...
2019/06/14
[ "https://wordpress.stackexchange.com/questions/340523", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131339/" ]
I have enabled SVG uploads using this code: ``` add_filter('upload_mimes', function($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; }); ``` However, uploads of SVG files that start with the `<svg>` tag fail with the usual "Sorry, this file type is not permitted for security reasons." error that WordPre...
It seems that in the recent releases of WordPress, changes were made to the mime type handling to make sure that files have the extension they say they do: <https://make.wordpress.org/core/2018/12/13/backwards-compatibility-breaks-in-5-0-1/> This poses an issue for SVG files without the tag in them. SVG is actually a...
340,531
<p>I want to add a button (that will open an INFO popup screen with info about a certain option in a woocommerce variable product), all that can be easily created with a plugin that converts the whole thing to a shortcode, the problem is to insert it into the products page, this will run on hundreds of products so i ca...
[ { "answer_id": 340535, "author": "twelvell", "author_id": 138568, "author_profile": "https://wordpress.stackexchange.com/users/138568", "pm_score": 3, "selected": true, "text": "<p>It seems that in the recent releases of WordPress, changes were made to the mime type handling to make sure...
2019/06/14
[ "https://wordpress.stackexchange.com/questions/340531", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170002/" ]
I want to add a button (that will open an INFO popup screen with info about a certain option in a woocommerce variable product), all that can be easily created with a plugin that converts the whole thing to a shortcode, the problem is to insert it into the products page, this will run on hundreds of products so i canno...
It seems that in the recent releases of WordPress, changes were made to the mime type handling to make sure that files have the extension they say they do: <https://make.wordpress.org/core/2018/12/13/backwards-compatibility-breaks-in-5-0-1/> This poses an issue for SVG files without the tag in them. SVG is actually a...
340,539
<p>I am working on an options panel for a plugin. And have an array being posted and updated to the options table. I am using the array_map() function to iterate over the array with sanitize_text_fields() </p> <p>Is this an optimal way to do this? </p> <pre><code> if( ! empty( $_POST['my_array'] ) ) { for...
[ { "answer_id": 340544, "author": "Lucas Vendramini", "author_id": 168637, "author_profile": "https://wordpress.stackexchange.com/users/168637", "pm_score": 2, "selected": false, "text": "<p>I think you are in the right path. What you can do to improve is:</p>\n\n<p>Separate the logic in ...
2019/06/15
[ "https://wordpress.stackexchange.com/questions/340539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138567/" ]
I am working on an options panel for a plugin. And have an array being posted and updated to the options table. I am using the array\_map() function to iterate over the array with sanitize\_text\_fields() Is this an optimal way to do this? ``` if( ! empty( $_POST['my_array'] ) ) { foreach( $_POST['my_a...
It's probably not a great idea. Firstly, if you've got other field types then you should probably use more appropriate functions. For example, `textarea` fields should be sanitised with `sanitize_textarea_field()`, and color pickers should be sanitized with `sanitize_hex_color()`. You should also consider that `$_POST...
340,648
<p>I'm developing Wordpress locally with XAMPP, and currently trying to install the WP-CLI tools <a href="https://wp-cli.org/#installing" rel="nofollow noreferrer">as described here</a> using Cygwin. </p> <p>I renamed <code>wp-cli.phar</code> to <code>wp</code>, made it executable and moved it to the <code>XAMPP/php</...
[ { "answer_id": 340662, "author": "leymannx", "author_id": 30597, "author_profile": "https://wordpress.stackexchange.com/users/30597", "pm_score": 2, "selected": false, "text": "<p>There are at least two interesting questions on SO:</p>\n\n<ul>\n<li><a href=\"https://stackoverflow.com/q/2...
2019/06/16
[ "https://wordpress.stackexchange.com/questions/340648", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/167562/" ]
I'm developing Wordpress locally with XAMPP, and currently trying to install the WP-CLI tools [as described here](https://wp-cli.org/#installing) using Cygwin. I renamed `wp-cli.phar` to `wp`, made it executable and moved it to the `XAMPP/php` folder. However, running `wp` gives me the error: > > Could not open i...
I finally managed to scrape together enough information from disparate sources to figure out how to fix this, because - as I'm increasingly finding with anything related to Wordpress development - the documentation is so woefully inadequate. The fact that it took so much research and hacking together on my part just t...
340,698
<p>Hi there could somedoby explain please why <a href="https://www" rel="nofollow noreferrer">https://www</a>. SUBdomain does not redirect to <a href="https://non-www.sudomain" rel="nofollow noreferrer">https://non-www.sudomain</a></p> <p>I am running nginx and seems like set up all the redirects but the one above see...
[ { "answer_id": 340662, "author": "leymannx", "author_id": 30597, "author_profile": "https://wordpress.stackexchange.com/users/30597", "pm_score": 2, "selected": false, "text": "<p>There are at least two interesting questions on SO:</p>\n\n<ul>\n<li><a href=\"https://stackoverflow.com/q/2...
2019/06/17
[ "https://wordpress.stackexchange.com/questions/340698", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130477/" ]
Hi there could somedoby explain please why <https://www>. SUBdomain does not redirect to <https://non-www.sudomain> I am running nginx and seems like set up all the redirects but the one above seem to be redirected wrongly by Wordpress, I have all A records set up 2 for http version of main domain with and without www...
I finally managed to scrape together enough information from disparate sources to figure out how to fix this, because - as I'm increasingly finding with anything related to Wordpress development - the documentation is so woefully inadequate. The fact that it took so much research and hacking together on my part just t...
340,718
<p>I try to get gutenberg media gallery block output, and want to use default figcaption text feature for images titles (for js lightbox). How can i get this property figcaption text value?</p> <pre><code>add_filter( 'render_block', function( $block_content, $block ) { if ( 'core/gallery' !== $block['blockName'] |...
[ { "answer_id": 340740, "author": "Vortac", "author_id": 167651, "author_profile": "https://wordpress.stackexchange.com/users/167651", "pm_score": 0, "selected": false, "text": "<p>Try <code>wp_get_attachment_caption( $id )</code> for caption and <code>get_post_meta( $id, '_wp_attachment_...
2019/06/17
[ "https://wordpress.stackexchange.com/questions/340718", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169787/" ]
I try to get gutenberg media gallery block output, and want to use default figcaption text feature for images titles (for js lightbox). How can i get this property figcaption text value? ``` add_filter( 'render_block', function( $block_content, $block ) { if ( 'core/gallery' !== $block['blockName'] || ! isset( $bl...
You’re right...the figcaptions are encoded as html in `$block['innerHTML']`. You could do sth. like `$tmpArray = explode('</li>',$block['innerHTML']);` before your `foreach` loop to split the HTML string into an array that matches your gallery items and inside the loop `strip_tags($tmpArray[i]);` to strip away all html...
340,731
<p>The link <a href="https://vreqenz-stream.de/shop/" rel="nofollow noreferrer">https://vreqenz-stream.de/shop/</a> throws warning when opened on some devices and not on others. <br> I thought it may be a cahce issue but I have cleared cache from WP-rocket and also browser. Just for the info I am using Plesk web admin ...
[ { "answer_id": 340734, "author": "Ilona", "author_id": 136877, "author_profile": "https://wordpress.stackexchange.com/users/136877", "pm_score": 0, "selected": false, "text": "<p>Try checking your php.ini file. display_errors may be turned on there and it might be overriding your wp_conf...
2019/06/17
[ "https://wordpress.stackexchange.com/questions/340731", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170150/" ]
The link <https://vreqenz-stream.de/shop/> throws warning when opened on some devices and not on others. I thought it may be a cahce issue but I have cleared cache from WP-rocket and also browser. Just for the info I am using Plesk web admin tool. Below is my WP\_Config settings ``` ini_set('log_errors','On'); ...
Thanks all of you for your response the issue got resolved. The problem was with cached copy of this link <https://vreqenz-stream.de/shop/> . I had WP Rocket for caching and apparently it is not doing very good job of purging the cache. I got sure that it is cache issue when I defined the WP\_CACHE as false which was ...
340,759
<p>I have created a table in which i have delete link something like <a href="http://localhost/wptheme/wp-admin/admin.php?page=batch-op-settings&amp;action=batch-delete&amp;post_id=5" rel="nofollow noreferrer">http://localhost/wptheme/wp-admin/admin.php?page=batch-op-settings&amp;action=batch-delete&amp;post_id=5</a> ...
[ { "answer_id": 340834, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 2, "selected": true, "text": "<p>Parcel is intended to be used to build apps from the ground up. That's why they recommend starting with a i...
2019/06/18
[ "https://wordpress.stackexchange.com/questions/340759", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/151182/" ]
I have created a table in which i have delete link something like <http://localhost/wptheme/wp-admin/admin.php?page=batch-op-settings&action=batch-delete&post_id=5> and i have added a code to delete the post ``` if ($action == 'batch-delete') { require_once (plugin_dir_path( __FILE__ ).'views/single_batch_delete...
Parcel is intended to be used to build apps from the ground up. That's why they recommend starting with a index.js or index.html file. You might be able to use Parcel's packaging for a theme or plugin, but you would lose the built-in server and live reloading ("hot module replacement") among other things. There may b...
340,767
<p>Is it possible to some how make my plugin dequeue / deregister any styles and any scripts from what ever theme activated. so it doesn't matter what theme will be installed the styles and scripts of that theme will be dequeue / deregister?</p> <p>Just to be super clear:</p> <ol> <li>I don't know what theme will be ...
[ { "answer_id": 340768, "author": "Chetan Vaghela", "author_id": 169856, "author_profile": "https://wordpress.stackexchange.com/users/169856", "pm_score": 1, "selected": false, "text": "<p>May be this will helps you. try </p>\n\n<pre><code>#For dequeue JavaScripts\nfunction remove_unneces...
2019/06/18
[ "https://wordpress.stackexchange.com/questions/340767", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/159259/" ]
Is it possible to some how make my plugin dequeue / deregister any styles and any scripts from what ever theme activated. so it doesn't matter what theme will be installed the styles and scripts of that theme will be dequeue / deregister? Just to be super clear: 1. I don't know what theme will be used. 2. I need to d...
The tricky thing is knowing whether or not a particular script or style was enqueued by the theme. Themes and plugins both use the same hooks and functions, so they're not explicitly labelled in any way as belonging to a specific theme or plugin. This means that the only way to know whether a script or style is from ...
340,814
<p>I need a list of every shortcode inside the content. Is there any way to list them?</p> <p>This is what I need:</p> <pre><code>$str = '[term value="Value" id="600"][term value="Term" id="609"]'; </code></pre> <p>So every shortcode should be inside the <code>$str</code>.</p> <p>I found a code snippet to check if ...
[ { "answer_id": 340817, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 2, "selected": false, "text": "<p>If you only need the Shortcodes without the attributes, you can use this function:</p>\n\n<pre><code>...
2019/06/18
[ "https://wordpress.stackexchange.com/questions/340814", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96806/" ]
I need a list of every shortcode inside the content. Is there any way to list them? This is what I need: ``` $str = '[term value="Value" id="600"][term value="Term" id="609"]'; ``` So every shortcode should be inside the `$str`. I found a code snippet to check if there is a shortcode. But how can I display them al...
Here's one way: You can look at [has\_shortcode()](https://developer.wordpress.org/reference/functions/has_shortcode/) and find the parsing there: ``` preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); ``` using the [get\_shortcode\_regex()](https://develope...
340,829
<p>I need to add a link to the drop-down user menu in the admin bar. Is there a hook or function for this?</p> <p><a href="https://i.stack.imgur.com/JZA97.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JZA97.png" alt="WP admin bar user drop-down menu"></a></p>
[ { "answer_id": 340830, "author": "RiddleMeThis", "author_id": 86845, "author_profile": "https://wordpress.stackexchange.com/users/86845", "pm_score": 3, "selected": true, "text": "<p>You want to use <a href=\"https://codex.wordpress.org/Class_Reference/WP_Admin_Bar/add_node\" rel=\"nofol...
2019/06/18
[ "https://wordpress.stackexchange.com/questions/340829", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60726/" ]
I need to add a link to the drop-down user menu in the admin bar. Is there a hook or function for this? [![WP admin bar user drop-down menu](https://i.stack.imgur.com/JZA97.png)](https://i.stack.imgur.com/JZA97.png)
You want to use [$wp\_admin\_bar->add\_node( $args )](https://codex.wordpress.org/Class_Reference/WP_Admin_Bar/add_node). Below is a tested working example. ``` function wpse_add_toolbar_edit($wp_admin_bar) { $wp_admin_bar->add_node( array( 'id' => 'mylink', 'title' => 'My New Link', ...
340,871
<p>I'm creating a custom form for a wordpress page, and I'm using admin-post.php as my action. However, whenever I try to submit the form, I get a 404.</p> <p>Below is the code which outputs the form:</p> <pre><code>function output_email_verification() { $error = ''; if(isset($_COOKIE['rguroo_form_error']...
[ { "answer_id": 340873, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>First of all...</p>\n\n<p>Your <code>action</code> is called <code>rguroo_email_verification_form</co...
2019/06/19
[ "https://wordpress.stackexchange.com/questions/340871", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153230/" ]
I'm creating a custom form for a wordpress page, and I'm using admin-post.php as my action. However, whenever I try to submit the form, I get a 404. Below is the code which outputs the form: ``` function output_email_verification() { $error = ''; if(isset($_COOKIE['rguroo_form_error'])) { $error...
First of all... Your `action` is called `rguroo_email_verification_form`, so you should use it when registering your hooks. But you use this instead: ``` add_action( 'admin_post_nopriv_email_verification_form', 'verify_and_sanitize_email_form', $priority = 10, $accepted_args = 1 ); add_action( 'admin_post_email_verif...
340,906
<p>I made a custom post type filters for others post types. The slug is a concatenation like <code>"filters-" . $custom-post-type</code>.</p> <p>And the custom post type appears correctly in the menu :</p> <p><a href="https://i.stack.imgur.com/xxsiZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x...
[ { "answer_id": 340873, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>First of all...</p>\n\n<p>Your <code>action</code> is called <code>rguroo_email_verification_form</co...
2019/06/19
[ "https://wordpress.stackexchange.com/questions/340906", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128094/" ]
I made a custom post type filters for others post types. The slug is a concatenation like `"filters-" . $custom-post-type`. And the custom post type appears correctly in the menu : [![enter image description here](https://i.stack.imgur.com/xxsiZ.jpg)](https://i.stack.imgur.com/xxsiZ.jpg) My problem is when I try to ...
First of all... Your `action` is called `rguroo_email_verification_form`, so you should use it when registering your hooks. But you use this instead: ``` add_action( 'admin_post_nopriv_email_verification_form', 'verify_and_sanitize_email_form', $priority = 10, $accepted_args = 1 ); add_action( 'admin_post_email_verif...
340,911
<p>both main and second domain (addon domain ) are in same host i want to find a way to change upload directory to another directory that located in another domain root.</p> <p><strong>default location (first location) :</strong> My main domain upload directory is : /domains/domain1.com/public_html/wp-content/uploads<...
[ { "answer_id": 340913, "author": "Lucas Vendramini", "author_id": 168637, "author_profile": "https://wordpress.stackexchange.com/users/168637", "pm_score": 1, "selected": false, "text": "<p>Well, what you want to achieve saving uploads in another domain? You want to share the uploads fol...
2019/06/19
[ "https://wordpress.stackexchange.com/questions/340911", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170293/" ]
both main and second domain (addon domain ) are in same host i want to find a way to change upload directory to another directory that located in another domain root. **default location (first location) :** My main domain upload directory is : /domains/domain1.com/public\_html/wp-content/uploads **destination locatio...
Well, what you want to achieve saving uploads in another domain? You want to share the uploads folder with another domain? Did you know you can use more than one domain (site) in a single WordPress Installation? It's called Multisite: <https://premium.wpmudev.org/blog/ultimate-guide-multisite/> To change the upload ...