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 |
|---|---|---|---|---|---|---|
400,841 | <p>I have bought a wordpress template but the developers say they cannot help me with what I need.</p>
<p>The theme has a hotel reservation system integrated, and the form brings a field to “place” the user email, however this option is disabled, only a Text appears that says “Need to be logged in” but when I click ove... | [
{
"answer_id": 400821,
"author": "Maytha8",
"author_id": 200755,
"author_profile": "https://wordpress.stackexchange.com/users/200755",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>user_can( wp_get_current_user(), 'administrator' )</code> to determine if the user is logged in a... | 2022/01/02 | [
"https://wordpress.stackexchange.com/questions/400841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/217483/"
] | I have bought a wordpress template but the developers say they cannot help me with what I need.
The theme has a hotel reservation system integrated, and the form brings a field to “place” the user email, however this option is disabled, only a Text appears that says “Need to be logged in” but when I click over there n... | I would advise againt using anonymous functions for callback (when ever you can) as you can't use a targeted `remove_action` on it.
What Maythan8 answered will work but it can be done with fewer functions.
```php
add_action('template_redirect', 'bt_maintenance_redirect');
function bt_maintenance_redirect () {
i... |
400,872 | <p>I have extracted the reply emails. The original emails are saved as CPT and work as Tickets in my plugin. I want the reply email to go as a comment to the original email.</p>
<pre><code> for($j = 1; $j <= $total; $j++){
$mail = $emails->get($j);
//This checks if the email is reply or not and if the... | [
{
"answer_id": 400821,
"author": "Maytha8",
"author_id": 200755,
"author_profile": "https://wordpress.stackexchange.com/users/200755",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>user_can( wp_get_current_user(), 'administrator' )</code> to determine if the user is logged in a... | 2022/01/03 | [
"https://wordpress.stackexchange.com/questions/400872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190661/"
] | I have extracted the reply emails. The original emails are saved as CPT and work as Tickets in my plugin. I want the reply email to go as a comment to the original email.
```
for($j = 1; $j <= $total; $j++){
$mail = $emails->get($j);
//This checks if the email is reply or not and if the email is reply mak... | I would advise againt using anonymous functions for callback (when ever you can) as you can't use a targeted `remove_action` on it.
What Maythan8 answered will work but it can be done with fewer functions.
```php
add_action('template_redirect', 'bt_maintenance_redirect');
function bt_maintenance_redirect () {
i... |
400,876 | <p>In admin, I need to fire the <code>save_post</code> action before firing the <code>transition_post_status</code> hook. But according to <a href="http://rachievee.com/the-wordpress-hooks-firing-sequence/" rel="nofollow noreferrer">this</a>, the <code>transition_post_status</code> fires first before the post is saved.... | [
{
"answer_id": 400821,
"author": "Maytha8",
"author_id": 200755,
"author_profile": "https://wordpress.stackexchange.com/users/200755",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>user_can( wp_get_current_user(), 'administrator' )</code> to determine if the user is logged in a... | 2022/01/03 | [
"https://wordpress.stackexchange.com/questions/400876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/217284/"
] | In admin, I need to fire the `save_post` action before firing the `transition_post_status` hook. But according to [this](http://rachievee.com/the-wordpress-hooks-firing-sequence/), the `transition_post_status` fires first before the post is saved.
How can I reverse it? I tried changing the priority order below, but I ... | I would advise againt using anonymous functions for callback (when ever you can) as you can't use a targeted `remove_action` on it.
What Maythan8 answered will work but it can be done with fewer functions.
```php
add_action('template_redirect', 'bt_maintenance_redirect');
function bt_maintenance_redirect () {
i... |
400,885 | <p>I have WordPress code like below.</p>
<pre><code>function get_preselect_values()
{
$volunteers = get_post_meta($_POST['element_id'], "volunteers", false);
$users = array();
foreach ($volunteers as $volunteer) {
foreach ($volunteer as $volun) {
$users = $volun['ID'];
... | [
{
"answer_id": 400821,
"author": "Maytha8",
"author_id": 200755,
"author_profile": "https://wordpress.stackexchange.com/users/200755",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>user_can( wp_get_current_user(), 'administrator' )</code> to determine if the user is logged in a... | 2022/01/03 | [
"https://wordpress.stackexchange.com/questions/400885",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65189/"
] | I have WordPress code like below.
```
function get_preselect_values()
{
$volunteers = get_post_meta($_POST['element_id'], "volunteers", false);
$users = array();
foreach ($volunteers as $volunteer) {
foreach ($volunteer as $volun) {
$users = $volun['ID'];
}
}
echo json_... | I would advise againt using anonymous functions for callback (when ever you can) as you can't use a targeted `remove_action` on it.
What Maythan8 answered will work but it can be done with fewer functions.
```php
add_action('template_redirect', 'bt_maintenance_redirect');
function bt_maintenance_redirect () {
i... |
400,886 | <p>Based on my test, get_bloginfo('url') will not return backslash, so it will return URL like this:</p>
<pre><code>https://www.example.com/blogs
</code></pre>
<p>In this post <a href="https://wordpress.stackexchange.com/questions/16161/what-is-difference-between-get-bloginfourl-and-get-site-url">What is difference bet... | [
{
"answer_id": 400888,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n<p>it is said get_bloginfo('url') calls home_url().</p>\n</blockquote>\n<p><strong>Correct</strong>... | 2022/01/03 | [
"https://wordpress.stackexchange.com/questions/400886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182824/"
] | Based on my test, get\_bloginfo('url') will not return backslash, so it will return URL like this:
```
https://www.example.com/blogs
```
In this post [What is difference between get\_bloginfo('url') and get\_site\_url()?](https://wordpress.stackexchange.com/questions/16161/what-is-difference-between-get-bloginfourl-... | [The Codex example for home\_url()](https://developer.wordpress.org/reference/functions/home_url/#comment-428) says you want `home_url( '/' )` to get the blog's URL with a trailing slash.
Alternatively you could use `trailingslashit( home_url() )`. That may be safer if your site's home option somehow ends up stored wi... |
400,914 | <p>This is a strange task but I really faced with it. On the home page there is loop for showing all custom post type. And I need to have oportunity when user click to the cpt link from the home page display one type of the single page. And if user go to the custom post type from inner page show other single custom pos... | [
{
"answer_id": 400915,
"author": "Sébastien Serre",
"author_id": 62892,
"author_profile": "https://wordpress.stackexchange.com/users/62892",
"pm_score": 2,
"selected": true,
"text": "<p>I think you need to work on the<code>template_include</code> hook. <a href=\"https://developer.wordpre... | 2022/01/04 | [
"https://wordpress.stackexchange.com/questions/400914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201628/"
] | This is a strange task but I really faced with it. On the home page there is loop for showing all custom post type. And I need to have oportunity when user click to the cpt link from the home page display one type of the single page. And if user go to the custom post type from inner page show other single custom post t... | I think you need to work on the`template_include` hook. <https://developer.wordpress.org/reference/hooks/template_include>
At this point you can add a condition and returning the correct template path
```
add_filter( 'template_include', 'redirect_single' );
function redirect_single( $template ){
if($_POST['template']... |
400,997 | <p>I am trying to run a function that executes only on the first page of any post. So, if a post is paginated because you have used the <code><!--nextpage--></code> tag and you are on page 2 or greater of that article, then the function should not run.</p>
<p><a href="https://codex.wordpress.org/Conditional_Tags#... | [
{
"answer_id": 400998,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": -1,
"selected": false,
"text": "<p>If you are trying to determine if a singular <code>single.php</code> post page is on a <code>paged()</cod... | 2022/01/06 | [
"https://wordpress.stackexchange.com/questions/400997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/103103/"
] | I am trying to run a function that executes only on the first page of any post. So, if a post is paginated because you have used the `<!--nextpage-->` tag and you are on page 2 or greater of that article, then the function should not run.
[Even the Wordpress documentation](https://codex.wordpress.org/Conditional_Tags#... | >
> The problem is that it also shows the featured image, in the same
> spot, on pages 2, 3, 4, etc of the same article (when I have used
> `<!--nextpage-->`). The featured image should only show on the first
> page of any article.
>
>
>
In that case, then this might work for you:
```php
function insert_feat_imag... |
401,070 | <p>I'm querying posts using the following wp query:</p>
<pre><code>function custom_retrieve_posts_function() {
$paged = get_query_var( "paged" ) ? get_query_var( "paged" ) : 1;
$args = array(
'post_type' => 'my_post_type',
'posts_per_page' => 7,
'paged' => $paged
);... | [
{
"answer_id": 401075,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>Because of this line:</p>\n<pre class=\"lang-php prettyprint-override\"><code>$paged = get_query_var( "p... | 2022/01/07 | [
"https://wordpress.stackexchange.com/questions/401070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188571/"
] | I'm querying posts using the following wp query:
```
function custom_retrieve_posts_function() {
$paged = get_query_var( "paged" ) ? get_query_var( "paged" ) : 1;
$args = array(
'post_type' => 'my_post_type',
'posts_per_page' => 7,
'paged' => $paged
);
$query = new \WP_Query( $args );
$output ... | Because of this line:
```php
$paged = get_query_var( "paged" ) ? get_query_var( "paged" ) : 1;
```
This is inside a function that is used on both an AJAX handler, and on a page request. `get_query_var` pulls the parameters from the main query ( aka the primary `WP_Query` that powers functions such as `the_post`, `ha... |
401,091 | <p>I just want to add a class if li is parent class should be level-0 and if li is the child then level-1 etc. I am using the following loop.</p>
<pre><code> <?php
$categories = get_categories();
foreach($categories as $category) {
echo '<li class="here-i-want-to-add"><a href="... | [
{
"answer_id": 401095,
"author": "Sabry Suleiman",
"author_id": 174580,
"author_profile": "https://wordpress.stackexchange.com/users/174580",
"pm_score": 1,
"selected": false,
"text": "<p>The category object stores the parent ID like this: <code>$category->parent</code></p>\n<p>In the... | 2022/01/08 | [
"https://wordpress.stackexchange.com/questions/401091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200785/"
] | I just want to add a class if li is parent class should be level-0 and if li is the child then level-1 etc. I am using the following loop.
```
<?php
$categories = get_categories();
foreach($categories as $category) {
echo '<li class="here-i-want-to-add"><a href="' . get_category_link($category->term_id... | The category object stores the parent ID like this: `$category->parent`
In the event that there is no parent it's equal to `0`.
In this way, it is possible to create a variable equal to the parent class or the child parent according to the value of `$category->parent`:
```php
$categories = get_categories();
if ( ! i... |
401,108 | <p>I am building my own WordPress theme. I have the front page working. However, when I try to view a test post full of Lorem Ipsum, I get the "No matching template found" error.</p>
<p>I have the following code in single.php</p>
<pre><code><?php
get_header();
if( have_posts()){
while( hav... | [
{
"answer_id": 401095,
"author": "Sabry Suleiman",
"author_id": 174580,
"author_profile": "https://wordpress.stackexchange.com/users/174580",
"pm_score": 1,
"selected": false,
"text": "<p>The category object stores the parent ID like this: <code>$category->parent</code></p>\n<p>In the... | 2022/01/09 | [
"https://wordpress.stackexchange.com/questions/401108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/213315/"
] | I am building my own WordPress theme. I have the front page working. However, when I try to view a test post full of Lorem Ipsum, I get the "No matching template found" error.
I have the following code in single.php
```
<?php
get_header();
if( have_posts()){
while( have_posts() ){
the_pos... | The category object stores the parent ID like this: `$category->parent`
In the event that there is no parent it's equal to `0`.
In this way, it is possible to create a variable equal to the parent class or the child parent according to the value of `$category->parent`:
```php
$categories = get_categories();
if ( ! i... |
401,129 | <p>I've been working on WP since a week so far i've seen bunch of tutorials and videos about wp but i feel stuck and since i'm a wp noob i cant find or think any solution for a simple problem.
i have created custom field using plug-in for a custom post type, my problem is i want to hide the -div- when there is nothing... | [
{
"answer_id": 401132,
"author": "wp_noob",
"author_id": 217723,
"author_profile": "https://wordpress.stackexchange.com/users/217723",
"pm_score": 1,
"selected": false,
"text": "<p>So i resolved that noob question... here is a recipe step by step;</p>\n<ol>\n<li>get some sleep</li>\n<li>... | 2022/01/09 | [
"https://wordpress.stackexchange.com/questions/401129",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/217723/"
] | I've been working on WP since a week so far i've seen bunch of tutorials and videos about wp but i feel stuck and since i'm a wp noob i cant find or think any solution for a simple problem.
i have created custom field using plug-in for a custom post type, my problem is i want to hide the -div- when there is nothing wri... | So i resolved that noob question... here is a recipe step by step;
1. get some sleep
2. repeat what you leaned with a fresh mind
3. apply the structure:
```
<?php if( get_field('field_name') ): ?>
<p>My field value: <?php the_field('field_name'); ?></p>
<?php endif; ?>
``` |
401,161 | <p>Hello every one i am new to wordpress development. i am working on a plugin in which i have created a custom post type with the name of application when the user submits a form from the frontend a new application is created with the user data. i have a custom taxonomy in it with the name of application_status. I wa... | [
{
"answer_id": 401132,
"author": "wp_noob",
"author_id": 217723,
"author_profile": "https://wordpress.stackexchange.com/users/217723",
"pm_score": 1,
"selected": false,
"text": "<p>So i resolved that noob question... here is a recipe step by step;</p>\n<ol>\n<li>get some sleep</li>\n<li>... | 2022/01/10 | [
"https://wordpress.stackexchange.com/questions/401161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/217763/"
] | Hello every one i am new to wordpress development. i am working on a plugin in which i have created a custom post type with the name of application when the user submits a form from the frontend a new application is created with the user data. i have a custom taxonomy in it with the name of application\_status. I want ... | So i resolved that noob question... here is a recipe step by step;
1. get some sleep
2. repeat what you leaned with a fresh mind
3. apply the structure:
```
<?php if( get_field('field_name') ): ?>
<p>My field value: <?php the_field('field_name'); ?></p>
<?php endif; ?>
``` |
401,221 | <p>I add this code (modify from <a href="https://developer.wordpress.org/reference/hooks/the_content/#comment-5125" rel="nofollow noreferrer">this comment</a>) into my plugin:</p>
<pre class="lang-php prettyprint-override"><code>function wpdocs_replace_content( $text_content ) {
if ( is_page() ) {
$text = a... | [
{
"answer_id": 401222,
"author": "Ooker",
"author_id": 64282,
"author_profile": "https://wordpress.stackexchange.com/users/64282",
"pm_score": 2,
"selected": false,
"text": "<p>Notice the <code>if ( is_page() </code> line. It's to indicate that the snippet only works with pages, not post... | 2022/01/11 | [
"https://wordpress.stackexchange.com/questions/401221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64282/"
] | I add this code (modify from [this comment](https://developer.wordpress.org/reference/hooks/the_content/#comment-5125)) into my plugin:
```php
function wpdocs_replace_content( $text_content ) {
if ( is_page() ) {
$text = array(
'chamber' => '<strong>chamber</strong>',
);
$text_c... | Notice the `if ( is_page()` line. It's to indicate that the snippet only works with pages, not posts. Pull it out of the if condition if you want to apply it site-wide.
```php
function wpdocs_replace_content( $text_content ) {
$text = array(
'chamber' => '<strong>chamber</strong>',
);
$text_conten... |
401,261 | <p>I have a piece of code for creating video passes after someone buys a product with the ID 1136. For some reason, the order_status_completed is not doing anything. I tried hooking the function to woocommerce_thankyou and woocommerce_payment_complete. I am at a loss. I ran the code without hooking it to an action and ... | [
{
"answer_id": 401263,
"author": "Kevsterino",
"author_id": 138461,
"author_profile": "https://wordpress.stackexchange.com/users/138461",
"pm_score": 0,
"selected": false,
"text": "<p>$item['id'] should be $item['product_id']</p>\n"
},
{
"answer_id": 401269,
"author": "RamMoh... | 2022/01/12 | [
"https://wordpress.stackexchange.com/questions/401261",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/138461/"
] | I have a piece of code for creating video passes after someone buys a product with the ID 1136. For some reason, the order\_status\_completed is not doing anything. I tried hooking the function to woocommerce\_thankyou and woocommerce\_payment\_complete. I am at a loss. I ran the code without hooking it to an action an... | I think you must try changing $item['id'] to this
```
foreach ( $order->get_items() as $item )
{
$product = $item->get_data();
$item_id = $item->get_product_id();
if( $item_id == 1136 )
{
// Keep Your code here.
}
}
```
Keep Posted. |
401,279 | <p>What is the best way of using WordPress's core classes in the context of an <em>object-oriented design</em>?</p>
<p>I am trying to use <strong>$wp_admin_bar</strong> to remove a couple of the default WordPress designs but I am not able to find where to add $wp_admin_bar that does not trigger an error.</p>
<p>Below i... | [
{
"answer_id": 401280,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n<p>I am trying to use <strong>$wp_admin_bar</strong> to remove a couple of the default\nWordPres... | 2022/01/13 | [
"https://wordpress.stackexchange.com/questions/401279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/217212/"
] | What is the best way of using WordPress's core classes in the context of an *object-oriented design*?
I am trying to use **$wp\_admin\_bar** to remove a couple of the default WordPress designs but I am not able to find where to add $wp\_admin\_bar that does not trigger an error.
Below is my code. ***The comments shou... | >
> I am trying to use **$wp\_admin\_bar** to remove a couple of the default
> WordPress designs but I am not able to find where to add $wp\_admin\_bar
> that does not trigger an error.
>
>
>
The [`wp_before_admin_bar_render` hook](https://developer.wordpress.org/reference/hooks/wp_before_admin_bar_render/) doesn'... |
401,318 | <p>Some posts have a more "readable value" even though they are free to read. To highlight their increased reader value, I've managed to get together this piece of code.</p>
<p>"Problem" is, for some reason when navigation through the blog pages, the menu items gets the "Worth Reading" lab... | [
{
"answer_id": 401290,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 1,
"selected": false,
"text": "<p>What you're seeing are probably calls from <a href=\"https://wordpress.org/support/article/trackbacks-and-pi... | 2022/01/14 | [
"https://wordpress.stackexchange.com/questions/401318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/217540/"
] | Some posts have a more "readable value" even though they are free to read. To highlight their increased reader value, I've managed to get together this piece of code.
"Problem" is, for some reason when navigation through the blog pages, the menu items gets the "Worth Reading" label as well - which is not the idea.
**... | What you're seeing are probably calls from [Pingbacks](https://wordpress.org/support/article/trackbacks-and-pingbacks/).
If you don't want them you can either disable them [globally in the settings](https://wordpress.org/support/article/settings-discussion-screen/#default-article-setting) or just for a specific post i... |
401,335 | <p>I added my block to an article and the new full site editing. The block renders an tag. When I select the block in the editor I click on the tag and I get a "Cannot destructure property 'frameElement' of 'r' as it is null." and reloads itself.</p>
<pre><code>export default function Edit( { attributes, se... | [
{
"answer_id": 401290,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 1,
"selected": false,
"text": "<p>What you're seeing are probably calls from <a href=\"https://wordpress.org/support/article/trackbacks-and-pi... | 2022/01/14 | [
"https://wordpress.stackexchange.com/questions/401335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33797/"
] | I added my block to an article and the new full site editing. The block renders an tag. When I select the block in the editor I click on the tag and I get a "Cannot destructure property 'frameElement' of 'r' as it is null." and reloads itself.
```
export default function Edit( { attributes, setAttributes } ) {
re... | What you're seeing are probably calls from [Pingbacks](https://wordpress.org/support/article/trackbacks-and-pingbacks/).
If you don't want them you can either disable them [globally in the settings](https://wordpress.org/support/article/settings-discussion-screen/#default-article-setting) or just for a specific post i... |
401,437 | <p>I made a custom plugin for inserting staging / production versions of a Google Tag Manager container based on the server's IP address.</p>
<p>How do I make it compatible with WP-CLI so it will update when I run the <code>wp plugin update --all</code> command?</p>
| [
{
"answer_id": 401439,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 0,
"selected": false,
"text": "<p>Support for plugins that do not reside on wordpress.org appears to be supported by <code>wp plugin install</c... | 2022/01/17 | [
"https://wordpress.stackexchange.com/questions/401437",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78660/"
] | I made a custom plugin for inserting staging / production versions of a Google Tag Manager container based on the server's IP address.
How do I make it compatible with WP-CLI so it will update when I run the `wp plugin update --all` command? | You would implement this:
<https://make.wordpress.org/core/2021/06/29/introducing-update-uri-plugin-header-in-wordpress-5-8/>
First you would add a `Update URI:` header to your plugin with a custom domain.
Second, you would add a filter to your plugin, using the filter name `update_plugins_{$hostname}` where `{$hos... |
401,440 | <p>I have a category page, how do i display this category sibling categories on this page as well? I know how to display children categories:</p>
<pre><code><ul class="slider-container-list sub-categories-block front-categories-block front-categories-scroll">
<?php
$term = get_qu... | [
{
"answer_id": 401450,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n<p>I have a category page, how do i display this category sibling\ncategories on this page as we... | 2022/01/18 | [
"https://wordpress.stackexchange.com/questions/401440",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76850/"
] | I have a category page, how do i display this category sibling categories on this page as well? I know how to display children categories:
```
<ul class="slider-container-list sub-categories-block front-categories-block front-categories-scroll">
<?php
$term = get_queried_object();
$chil... | >
> I have a category page, how do i display this category sibling
> categories on this page as well? I know how to display children
> categories
>
>
>
>
> I think i need to get term\_id somehow
>
>
>
On a term archive page, e.g. at `example.com/category/foo/` (for the default `category` taxonomy),
1. You ca... |
401,463 | <pre><code>foreach( $posts as $post ) {
// Search for images and fill the missing dimensions in the current post content
$post_content = $this->add_image_dimensions( $post->post_content );
// Update the post content in the database only if the new $post_co... | [
{
"answer_id": 401450,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n<p>I have a category page, how do i display this category sibling\ncategories on this page as we... | 2022/01/18 | [
"https://wordpress.stackexchange.com/questions/401463",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/151498/"
] | ```
foreach( $posts as $post ) {
// Search for images and fill the missing dimensions in the current post content
$post_content = $this->add_image_dimensions( $post->post_content );
// Update the post content in the database only if the new $post_content it is not the s... | >
> I have a category page, how do i display this category sibling
> categories on this page as well? I know how to display children
> categories
>
>
>
>
> I think i need to get term\_id somehow
>
>
>
On a term archive page, e.g. at `example.com/category/foo/` (for the default `category` taxonomy),
1. You ca... |
401,470 | <p>I see a lot of these in premium themes/plugins.</p>
<p><strong>#1 - Why would you escape this? It's your own data. For consistency?</strong></p>
<pre><code>function prefix_a() {
$class_attr = 'a b c';
// Some more code.
return '<div class="' . esc_attr( $class_attr ) . '">Content</di... | [
{
"answer_id": 401483,
"author": "Sébastien Serre",
"author_id": 62892,
"author_profile": "https://wordpress.stackexchange.com/users/62892",
"pm_score": 0,
"selected": false,
"text": "<p>I think the best answer is in the official doc: <a href=\"https://developer.wordpress.org/plugins/sec... | 2022/01/18 | [
"https://wordpress.stackexchange.com/questions/401470",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49286/"
] | I see a lot of these in premium themes/plugins.
**#1 - Why would you escape this? It's your own data. For consistency?**
```
function prefix_a() {
$class_attr = 'a b c';
// Some more code.
return '<div class="' . esc_attr( $class_attr ) . '">Content</div>';
}
// Called somewhere.
prefix_a();
```
**#2... | 1. You probably wouldn't. If you did it would be to make sure it was in place already if in future you decided to make the variable dynamic or filterable.
2. In this case I would suggest it for similar reasons to #1. You may know where `$class` is coming from now, but this may change in future, and it prepares the func... |
401,476 | <p>I have the following custom search active in our WP admin for only administrators</p>
<pre><code>add_action('pre_get_posts', 'query_custom_admin_search', 21 );
function query_custom_admin_search( $wp_query ) {
global $current_user;
if( is_admin() ) {
if (get_current_user_role()=="administrator... | [
{
"answer_id": 401639,
"author": "tiago calado",
"author_id": 198152,
"author_profile": "https://wordpress.stackexchange.com/users/198152",
"pm_score": 0,
"selected": false,
"text": "<p>try to return the $wp_query when is not admin</p>\n<pre class=\"lang-php prettyprint-override\"><code>... | 2022/01/18 | [
"https://wordpress.stackexchange.com/questions/401476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28543/"
] | I have the following custom search active in our WP admin for only administrators
```
add_action('pre_get_posts', 'query_custom_admin_search', 21 );
function query_custom_admin_search( $wp_query ) {
global $current_user;
if( is_admin() ) {
if (get_current_user_role()=="administrator"){
if... | >
> The only problem is that the default search columns in the wp\_posts
> table such as post\_title seem to no longer be searched.
>
>
>
They're actually being searched, but the operator used is `AND` instead of `OR` as in `WHERE ( <search query> AND <meta query> )`, hence if for example one searched for `foo`, t... |
401,525 | <p>Looking for the filter hook for the admin/comments/reply to process (where you use 'reply to' in the comments administration screen). This will be used in a custom plugin.</p>
<p>(The plugin adds a hidden field to a front-end entered comment to reduce bot-entered comments. The extra field is inserted properly on the... | [
{
"answer_id": 401586,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n<p>Is there a filter for the adding of fields to the comment box form\nthat is on the admin/com... | 2022/01/19 | [
"https://wordpress.stackexchange.com/questions/401525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29416/"
] | Looking for the filter hook for the admin/comments/reply to process (where you use 'reply to' in the comments administration screen). This will be used in a custom plugin.
(The plugin adds a hidden field to a front-end entered comment to reduce bot-entered comments. The extra field is inserted properly on the front en... | Although @SallyCJ's answer might work, and is probably good information, I went in a different direction that worked for my application.
My application needs a hidden field in the comment form. Although you can easily add the hidden field to the front-end comment form, the back-end doesn't use that process. But my app... |
401,568 | <p>.Net developer here trying to learn some of the basics of wordpress. I have a basic question but I guess there's so much that I don't know that I can't even get a relevant result when searching here or via Google.</p>
<p>If I create a plugin and activate it, and run <code>flush_rewrite_rules();</code> in my activati... | [
{
"answer_id": 401569,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 0,
"selected": false,
"text": "<p>Welcome to WordPress and WPSE!</p>\n<p>Plugins are meant to alter or add functionality to what is already... | 2022/01/20 | [
"https://wordpress.stackexchange.com/questions/401568",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/218133/"
] | .Net developer here trying to learn some of the basics of wordpress. I have a basic question but I guess there's so much that I don't know that I can't even get a relevant result when searching here or via Google.
If I create a plugin and activate it, and run `flush_rewrite_rules();` in my activation code, should I be... | Generally you do not want to access your PHP files directly within WordPress because you lose a lot of "juice", meaning all WP functionality would have to be re-imported (and might break). WP is setup in a way that all requests to the CMS get routed to *index.php* and some mechanisms then decide what to do with the req... |
401,607 | <p>In my WordPress installation every User has an Organization. I am fetching user data using <code>get_user_meta ($user->ID)</code>. With these data I can fetch Organization ID.</p>
<p>Organizations are saved as Custom Post.</p>
<p>How can I fetch Organization name ?</p>
| [
{
"answer_id": 401569,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 0,
"selected": false,
"text": "<p>Welcome to WordPress and WPSE!</p>\n<p>Plugins are meant to alter or add functionality to what is already... | 2022/01/21 | [
"https://wordpress.stackexchange.com/questions/401607",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65189/"
] | In my WordPress installation every User has an Organization. I am fetching user data using `get_user_meta ($user->ID)`. With these data I can fetch Organization ID.
Organizations are saved as Custom Post.
How can I fetch Organization name ? | Generally you do not want to access your PHP files directly within WordPress because you lose a lot of "juice", meaning all WP functionality would have to be re-imported (and might break). WP is setup in a way that all requests to the CMS get routed to *index.php* and some mechanisms then decide what to do with the req... |
401,617 | <p>I'm not exactly sure how to explain this, but I have a slider I built using ACF that I placed on my home page. After this code, I want to use a WP block I built, and after that I want to put another slider. So it would look like this:</p>
<pre><code> <div class="col-lg-9 col-sm-12">
... | [
{
"answer_id": 401569,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 0,
"selected": false,
"text": "<p>Welcome to WordPress and WPSE!</p>\n<p>Plugins are meant to alter or add functionality to what is already... | 2022/01/21 | [
"https://wordpress.stackexchange.com/questions/401617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/208199/"
] | I'm not exactly sure how to explain this, but I have a slider I built using ACF that I placed on my home page. After this code, I want to use a WP block I built, and after that I want to put another slider. So it would look like this:
```
<div class="col-lg-9 col-sm-12">
<div class="row slide-area... | Generally you do not want to access your PHP files directly within WordPress because you lose a lot of "juice", meaning all WP functionality would have to be re-imported (and might break). WP is setup in a way that all requests to the CMS get routed to *index.php* and some mechanisms then decide what to do with the req... |
401,620 | <p>I have a function that expires posts after a certain amount of time. It also sets a custom post status of <code>'expired'</code>. I would like it to function like a <code>'draft'</code> post in that the URL is no longer accessible to the public. At the moment, once the post is set to <code>'expired'</code>, the full... | [
{
"answer_id": 401633,
"author": "tiago calado",
"author_id": 198152,
"author_profile": "https://wordpress.stackexchange.com/users/198152",
"pm_score": -1,
"selected": false,
"text": "<p>this function changes the post to draft, you only have to call it and pass the post id where you want... | 2022/01/21 | [
"https://wordpress.stackexchange.com/questions/401620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57571/"
] | I have a function that expires posts after a certain amount of time. It also sets a custom post status of `'expired'`. I would like it to function like a `'draft'` post in that the URL is no longer accessible to the public. At the moment, once the post is set to `'expired'`, the full permalink is still visible. Here is... | This line of code:
`'public' => true,`
change to
`'public' => false,` |
401,740 | <p>TLDR: My custom post type items are sorting differently on a local environment and a live server. Can't figure out why!</p>
<p>I have a local install (MAMP) and an online dev install (GoDaddy shared, for the client to view) of a site with pages of Custom Post Type posts. The CPT posts are real estate properties. The... | [
{
"answer_id": 401745,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": 1,
"selected": false,
"text": "<p>A php issue retuning different results on 2 or more synced environments (if each env db data is the same a... | 2022/01/25 | [
"https://wordpress.stackexchange.com/questions/401740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80029/"
] | TLDR: My custom post type items are sorting differently on a local environment and a live server. Can't figure out why!
I have a local install (MAMP) and an online dev install (GoDaddy shared, for the client to view) of a site with pages of Custom Post Type posts. The CPT posts are real estate properties. The CPT post... | A php issue retuning different results on 2 or more synced environments (if each env db data is the same and any passed data is the same)... that could be tricky.
The only other thing I noticed is your `meta_query` arg does not contain a child array containing `state_clause` and `prop_type`.
Your code is...
```php
'... |
401,781 | <p>I've created a custom shortcode to add pop-up definitions to selected vocabulary terms. The shortcode looks like this:</p>
<pre><code>[glossary term="data breach"]data breaches[/glossary]
</code></pre>
<p>The function searches posts in a custom post type called 'glossary-term' for the term's definition, pr... | [
{
"answer_id": 401745,
"author": "joshmoto",
"author_id": 111152,
"author_profile": "https://wordpress.stackexchange.com/users/111152",
"pm_score": 1,
"selected": false,
"text": "<p>A php issue retuning different results on 2 or more synced environments (if each env db data is the same a... | 2022/01/25 | [
"https://wordpress.stackexchange.com/questions/401781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/218387/"
] | I've created a custom shortcode to add pop-up definitions to selected vocabulary terms. The shortcode looks like this:
```
[glossary term="data breach"]data breaches[/glossary]
```
The function searches posts in a custom post type called 'glossary-term' for the term's definition, prints it in a div, and turns the en... | A php issue retuning different results on 2 or more synced environments (if each env db data is the same and any passed data is the same)... that could be tricky.
The only other thing I noticed is your `meta_query` arg does not contain a child array containing `state_clause` and `prop_type`.
Your code is...
```php
'... |
401,785 | <p>I'm looking for a way on how to display only a few posts on a first page of my archive. This is my archive template — <code>page-archive.php</code>, which I am using as a template to display all my posts/recipes:</p>
<pre><code><?php
get_header('archive'); ?>
<div id="primary" class="conten... | [
{
"answer_id": 401789,
"author": "tiago calado",
"author_id": 198152,
"author_profile": "https://wordpress.stackexchange.com/users/198152",
"pm_score": 0,
"selected": false,
"text": "<p>let's say you want to keep your html, its possible to put this in the function and save this function ... | 2022/01/25 | [
"https://wordpress.stackexchange.com/questions/401785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76850/"
] | I'm looking for a way on how to display only a few posts on a first page of my archive. This is my archive template — `page-archive.php`, which I am using as a template to display all my posts/recipes:
```
<?php
get_header('archive'); ?>
<div id="primary" class="content-area blog-archive col-md-9">
<main id="main"... | >
> This is my archive template — `page-archive.php`, which I am using as
> a template to display all my posts/recipes
>
>
>
So if you're using a [Page (post of the `page` type)](https://wordpress.org/support/article/pages-screen/) with a custom/specific [Page Template](https://developer.wordpress.org/themes/templ... |
401,909 | <p>I was trying to translate some plugin when I see in their .po file there are two "Sign in"s. I believe Wordpress uses <code>__</code> to parse text that needs to be translated.</p>
<p>So when codes like</p>
<pre><code>__('Sign in', 'buddyboss-theme')
</code></pre>
<p>is executed, how does it know which &qu... | [
{
"answer_id": 401789,
"author": "tiago calado",
"author_id": 198152,
"author_profile": "https://wordpress.stackexchange.com/users/198152",
"pm_score": 0,
"selected": false,
"text": "<p>let's say you want to keep your html, its possible to put this in the function and save this function ... | 2022/01/28 | [
"https://wordpress.stackexchange.com/questions/401909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125207/"
] | I was trying to translate some plugin when I see in their .po file there are two "Sign in"s. I believe Wordpress uses `__` to parse text that needs to be translated.
So when codes like
```
__('Sign in', 'buddyboss-theme')
```
is executed, how does it know which "Sign in" entry in the .po file is the one to look for... | >
> This is my archive template — `page-archive.php`, which I am using as
> a template to display all my posts/recipes
>
>
>
So if you're using a [Page (post of the `page` type)](https://wordpress.org/support/article/pages-screen/) with a custom/specific [Page Template](https://developer.wordpress.org/themes/templ... |
401,984 | <p>I'm working on a plugin with a custom post type called "important_dates"</p>
<p>I want to delete the Wordpress admin notification when a new custom post is created.</p>
<p>Here is my code - it deletes the notifications for all post types. How do I make it work for only my "important_dates" custom... | [
{
"answer_id": 401789,
"author": "tiago calado",
"author_id": 198152,
"author_profile": "https://wordpress.stackexchange.com/users/198152",
"pm_score": 0,
"selected": false,
"text": "<p>let's say you want to keep your html, its possible to put this in the function and save this function ... | 2022/01/29 | [
"https://wordpress.stackexchange.com/questions/401984",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/189596/"
] | I'm working on a plugin with a custom post type called "important\_dates"
I want to delete the Wordpress admin notification when a new custom post is created.
Here is my code - it deletes the notifications for all post types. How do I make it work for only my "important\_dates" custom post type?
```
add_filter( 'pos... | >
> This is my archive template — `page-archive.php`, which I am using as
> a template to display all my posts/recipes
>
>
>
So if you're using a [Page (post of the `page` type)](https://wordpress.org/support/article/pages-screen/) with a custom/specific [Page Template](https://developer.wordpress.org/themes/templ... |
401,995 | <p>By constant options I mean properties of the theme that don't change during every day use in production, but are changeable by the developer primarily for reusability purposes. Things like custom posts, sidebars, forms, custom features, etc.</p>
<p>There's really two ways that I see as viable and both of them are us... | [
{
"answer_id": 401999,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<p>You should look at wordpress options page:</p>\n<p><a href=\"https://codex.wordpress.org/Creating_Options_Page... | 2022/01/30 | [
"https://wordpress.stackexchange.com/questions/401995",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/161042/"
] | By constant options I mean properties of the theme that don't change during every day use in production, but are changeable by the developer primarily for reusability purposes. Things like custom posts, sidebars, forms, custom features, etc.
There's really two ways that I see as viable and both of them are used in Wor... | Generally you should try to keep the amount of global variables/constants to a minimum. The third (constant) option might be a good idea if you don't have too many options, but it can get messy with time as you add more and more options.
What I usually do, is scope the constant to the corresponding classes as `const` ... |
402,011 | <p>I am building a word-press website, and I have changed my domain name from <code>websiteold.com</code> to <code>websitenew.com</code>.</p>
<p>The domain transfer was done by the web server host.</p>
<p>However, I am not able to use the rest API since I changed to the new domain name. This is the error I am getting f... | [
{
"answer_id": 402202,
"author": "Lovor",
"author_id": 135704,
"author_profile": "https://wordpress.stackexchange.com/users/135704",
"pm_score": 0,
"selected": false,
"text": "<p>Did you change all strings in the WordPress database from old domain to new domain? You can use some plugins ... | 2022/01/30 | [
"https://wordpress.stackexchange.com/questions/402011",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/217604/"
] | I am building a word-press website, and I have changed my domain name from `websiteold.com` to `websitenew.com`.
The domain transfer was done by the web server host.
However, I am not able to use the rest API since I changed to the new domain name. This is the error I am getting from postman.
```json
{
"status":... | WordPress stores the domain of the installation in several places of the database. So you have to change them in numerous tables. In the case of working, look at the `options` table, entries `siteurl` and `homeurl`.
It is also possible to set this via `wp-config.php`:
```
// Home URL of your WordPress.
define( 'WP_SIT... |
402,029 | <p>I know I'm bad with coding, but I tried whatever I could find on the internet, and I ended up with this, which is not giving an error, but also when using the shortcode [my_playlist] in a post, only a part is showing "Listen to the full score songs playlist frompostname"</p>
<p>Can you please tell me what ... | [
{
"answer_id": 402202,
"author": "Lovor",
"author_id": 135704,
"author_profile": "https://wordpress.stackexchange.com/users/135704",
"pm_score": 0,
"selected": false,
"text": "<p>Did you change all strings in the WordPress database from old domain to new domain? You can use some plugins ... | 2022/01/30 | [
"https://wordpress.stackexchange.com/questions/402029",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6927/"
] | I know I'm bad with coding, but I tried whatever I could find on the internet, and I ended up with this, which is not giving an error, but also when using the shortcode [my\_playlist] in a post, only a part is showing "Listen to the full score songs playlist frompostname"
Can you please tell me what am I doing wrong, ... | WordPress stores the domain of the installation in several places of the database. So you have to change them in numerous tables. In the case of working, look at the `options` table, entries `siteurl` and `homeurl`.
It is also possible to set this via `wp-config.php`:
```
// Home URL of your WordPress.
define( 'WP_SIT... |
402,072 | <p>In a plugin I am currently coding, I want to use the Simple HTML DOM Parser library. However, when I include it</p>
<pre><code>require(CPS_PLUGIN_PATH . '/vendor/simple_html_dom.php');
</code></pre>
<p>I get this error:</p>
<pre><code>Fatal error: Cannot redeclare file_get_html() (previously declared in /www/htdocs/... | [
{
"answer_id": 402202,
"author": "Lovor",
"author_id": 135704,
"author_profile": "https://wordpress.stackexchange.com/users/135704",
"pm_score": 0,
"selected": false,
"text": "<p>Did you change all strings in the WordPress database from old domain to new domain? You can use some plugins ... | 2022/02/01 | [
"https://wordpress.stackexchange.com/questions/402072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118091/"
] | In a plugin I am currently coding, I want to use the Simple HTML DOM Parser library. However, when I include it
```
require(CPS_PLUGIN_PATH . '/vendor/simple_html_dom.php');
```
I get this error:
```
Fatal error: Cannot redeclare file_get_html() (previously declared in /www/htdocs/12345/mydomain.com/wp-content/plug... | WordPress stores the domain of the installation in several places of the database. So you have to change them in numerous tables. In the case of working, look at the `options` table, entries `siteurl` and `homeurl`.
It is also possible to set this via `wp-config.php`:
```
// Home URL of your WordPress.
define( 'WP_SIT... |
402,122 | <p>i am building a template for the search page (in full site editing, therefore html and no php), and i want to have a search results heading. i have this:</p>
<pre><code> <!-- wp:group {"layout":{"inherit":true}} -->
<div class="wp-block-group">
<!-- wp:heading {&qu... | [
{
"answer_id": 402202,
"author": "Lovor",
"author_id": 135704,
"author_profile": "https://wordpress.stackexchange.com/users/135704",
"pm_score": 0,
"selected": false,
"text": "<p>Did you change all strings in the WordPress database from old domain to new domain? You can use some plugins ... | 2022/02/02 | [
"https://wordpress.stackexchange.com/questions/402122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/210642/"
] | i am building a template for the search page (in full site editing, therefore html and no php), and i want to have a search results heading. i have this:
```
<!-- wp:group {"layout":{"inherit":true}} -->
<div class="wp-block-group">
<!-- wp:heading {"level":1} -->
<h1>Search Results</h1>
<!-- /wp:headi... | WordPress stores the domain of the installation in several places of the database. So you have to change them in numerous tables. In the case of working, look at the `options` table, entries `siteurl` and `homeurl`.
It is also possible to set this via `wp-config.php`:
```
// Home URL of your WordPress.
define( 'WP_SIT... |
402,164 | <p>Is there any <strong>plugin or alternative method</strong> to hide featured images of all the posts falling under the same category? Please guide.</p>
<p>For example:</p>
<p>There's a website category:</p>
<p>abc.net/category/fruits
Under this category the following posts are published
Apple, Mango, Cherry, Orange</... | [
{
"answer_id": 402202,
"author": "Lovor",
"author_id": 135704,
"author_profile": "https://wordpress.stackexchange.com/users/135704",
"pm_score": 0,
"selected": false,
"text": "<p>Did you change all strings in the WordPress database from old domain to new domain? You can use some plugins ... | 2022/02/03 | [
"https://wordpress.stackexchange.com/questions/402164",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/218718/"
] | Is there any **plugin or alternative method** to hide featured images of all the posts falling under the same category? Please guide.
For example:
There's a website category:
abc.net/category/fruits
Under this category the following posts are published
Apple, Mango, Cherry, Orange
All the posts under fruits categor... | WordPress stores the domain of the installation in several places of the database. So you have to change them in numerous tables. In the case of working, look at the `options` table, entries `siteurl` and `homeurl`.
It is also possible to set this via `wp-config.php`:
```
// Home URL of your WordPress.
define( 'WP_SIT... |
402,275 | <p>Got a mac development machine with PHP installed via brew. I'm trying to get testing tools set up. I successfully set up test scaffolding with <code>wp</code> cli and managed to get <code>bin/install-wp-tests.sh</code> to do its thing.</p>
<p>But I get an error with <code>phpunit tests/test-sample.php</code>:</p>
<p... | [
{
"answer_id": 402277,
"author": "StevieD",
"author_id": 86700,
"author_profile": "https://wordpress.stackexchange.com/users/86700",
"pm_score": 1,
"selected": false,
"text": "<p>OK, I was reading from an outdated tutorial. Command for running tests is now:</p>\n<p><code>vendor/bin/phpun... | 2022/02/06 | [
"https://wordpress.stackexchange.com/questions/402275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86700/"
] | Got a mac development machine with PHP installed via brew. I'm trying to get testing tools set up. I successfully set up test scaffolding with `wp` cli and managed to get `bin/install-wp-tests.sh` to do its thing.
But I get an error with `phpunit tests/test-sample.php`:
```
Error: The PHPUnit Polyfills library is a r... | OK, I was reading from an outdated tutorial. Command for running tests is now:
`vendor/bin/phpunit <path_to_file>`
This command should be Run from root directory of wordpress. |
402,292 | <p>Our custom post type posts have an extra feed in their source code:</p>
<p><code>www.example/post-type/post/feed/</code></p>
<p>I want to remove the extra <code>/feed/</code> from our CPTs, as they generate 404s.</p>
<p>From the <a href="https://developer.wordpress.org/reference/functions/register_post_type/" rel="n... | [
{
"answer_id": 402340,
"author": "KNT111_WP",
"author_id": 218905,
"author_profile": "https://wordpress.stackexchange.com/users/218905",
"pm_score": -1,
"selected": false,
"text": "<p>Paste this in your functions.php and replace your-cpt slug.</p>\n<pre><code>function wpse_191804_pre_get... | 2022/02/07 | [
"https://wordpress.stackexchange.com/questions/402292",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | Our custom post type posts have an extra feed in their source code:
`www.example/post-type/post/feed/`
I want to remove the extra `/feed/` from our CPTs, as they generate 404s.
From the [register\_post\_type](https://developer.wordpress.org/reference/functions/register_post_type/) function reference, I've tried addi... | From [this post](https://kinsta.com/knowledgebase/wordpress-disable-rss-feed/), I added
```
remove_action( 'wp_head', 'feed_links_extra', 3 );
```
to our child theme's `functions.php`.
Our SEO manager was okay with the fact this would remove feeds for categories as well. |
402,327 | <p>This is my first time posting a question here.
I have this problem that I feel that I am soooo close to solve, but can't manage to do it.</p>
<p>I have a custom taxonomy called "aplication" and another called "segment". Each "aplication" term has an "segment" term associated w... | [
{
"answer_id": 402363,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p><strong>You would not use SQL to do this</strong>, and that filter has nothing to do with SQL queries. This ... | 2022/02/07 | [
"https://wordpress.stackexchange.com/questions/402327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/218755/"
] | This is my first time posting a question here.
I have this problem that I feel that I am soooo close to solve, but can't manage to do it.
I have a custom taxonomy called "aplication" and another called "segment". Each "aplication" term has an "segment" term associated with it trought a custom field (ACF).
What I'm tr... | Following @TomJNowell advices I descarted the usage of SQL query and aimed at the meta\_value sorting. I'll describe the scenario from the beggining with the solution.
I have a custom taxonomy called "aplication" and another called "segment", and every application term has a custom field (ACF) for a segment term.
What... |
402,636 | <p>I've been trying to redirect users to the profile page when accessing profiles of users and self. Currently it's redirecting to activity page by default.</p>
<blockquote>
<p>Eg: example.com/members/username</p>
</blockquote>
<p>is showing the activity page as default.</p>
<p>I've tried setting the below line in wp-c... | [
{
"answer_id": 402363,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p><strong>You would not use SQL to do this</strong>, and that filter has nothing to do with SQL queries. This ... | 2022/02/14 | [
"https://wordpress.stackexchange.com/questions/402636",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89569/"
] | I've been trying to redirect users to the profile page when accessing profiles of users and self. Currently it's redirecting to activity page by default.
>
> Eg: example.com/members/username
>
>
>
is showing the activity page as default.
I've tried setting the below line in wp-config.php as suggested in [Buddypr... | Following @TomJNowell advices I descarted the usage of SQL query and aimed at the meta\_value sorting. I'll describe the scenario from the beggining with the solution.
I have a custom taxonomy called "aplication" and another called "segment", and every application term has a custom field (ACF) for a segment term.
What... |
402,749 | <p>I have a program that can run standalone (outside WP) or inside WP. If the program is running 'inside' WP (via a custom template using appropriate enqueue scripts and add_actions), then there is a constant that the program needs to be defined - an email address that the standalone program will use.</p>
<p>If the pro... | [
{
"answer_id": 402757,
"author": "Sébastien Serre",
"author_id": 62892,
"author_profile": "https://wordpress.stackexchange.com/users/62892",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know if others CMS or system may use ABSPATH or not but it's seems to be a generic words.\nI ... | 2022/02/16 | [
"https://wordpress.stackexchange.com/questions/402749",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29416/"
] | I have a program that can run standalone (outside WP) or inside WP. If the program is running 'inside' WP (via a custom template using appropriate enqueue scripts and add\_actions), then there is a constant that the program needs to be defined - an email address that the standalone program will use.
If the program is ... | Based on the other answer, I decided that looking for a specific WP function is the best approach to determine if my code is running in WP or not.
I used this code block:
```
if (function_exists('get_bloginfo')) { // most likely a WordPress function
if (get_bloginfo('admin_email')) { // set it only if there ... |
402,750 | <p>I have a wordpress install where I want to serve a static page/template for anyone arriving at a child of a certain page, e.g.</p>
<pre><code>https://example.com/products/*
</code></pre>
<p>Would all serve a php template from within Wordpress (or even just a static file) without changing the slug, so the following:<... | [
{
"answer_id": 402753,
"author": "jmcgrory",
"author_id": 219284,
"author_profile": "https://wordpress.stackexchange.com/users/219284",
"pm_score": 1,
"selected": true,
"text": "<p>Okay so I have resolved this by combining several different wordpress functionalities:</p>\n<ol>\n<li>Catch... | 2022/02/16 | [
"https://wordpress.stackexchange.com/questions/402750",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/219284/"
] | I have a wordpress install where I want to serve a static page/template for anyone arriving at a child of a certain page, e.g.
```
https://example.com/products/*
```
Would all serve a php template from within Wordpress (or even just a static file) without changing the slug, so the following:
```
https://example.com... | Okay so I have resolved this by combining several different wordpress functionalities:
1. Catches the template include conditionally `add_filter( 'template_include', '...' );`, in my case based on a regex match of the expected URI pattern
2. `locate_template('example-template.php')` to then resolve my (essentially) st... |
402,786 | <p>I am trying to fetch <code>users</code> All information by using below code.</p>
<pre><code>if($_POST['orga_id']) {
$users_query = new WP_User_Query(array(
'meta_query' => array(
'relation' => 'AND',
array(
'relation' => 'OR',
... | [
{
"answer_id": 402787,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>There's been a fundamental misunderstanding of how <code>meta_query</code> works. <code>meta_query</code> is... | 2022/02/17 | [
"https://wordpress.stackexchange.com/questions/402786",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65189/"
] | I am trying to fetch `users` All information by using below code.
```
if($_POST['orga_id']) {
$users_query = new WP_User_Query(array(
'meta_query' => array(
'relation' => 'AND',
array(
'relation' => 'OR',
array(
... | Actually since you already have the ID you could just loop through and get the meta.
<https://developer.wordpress.org/reference/functions/get_user_meta/>
```
get_user_meta(ID)
``` |
402,836 | <p>This is a follow-up to my previous post regarding multiple categories/posts on one page.</p>
<p>Currently, I have a page filled with multiple loops of each category of a custom post type. The problem is that the code is becoming a bit much to edit and organize. Here's a small example of the multiple categories I hav... | [
{
"answer_id": 402854,
"author": "Artemy Kaydash",
"author_id": 191232,
"author_profile": "https://wordpress.stackexchange.com/users/191232",
"pm_score": 2,
"selected": false,
"text": "<p>Split your code into smaller parts. For example, you can use a separate template part for each loop.... | 2022/02/18 | [
"https://wordpress.stackexchange.com/questions/402836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/200652/"
] | This is a follow-up to my previous post regarding multiple categories/posts on one page.
Currently, I have a page filled with multiple loops of each category of a custom post type. The problem is that the code is becoming a bit much to edit and organize. Here's a small example of the multiple categories I have:
```
$... | You could move the query configs into one config array and loop that for querying the posts and rendering the content sections. Inside the content section partial you'd have another loop for the posts.
The magic ingredient here is the third `$args` parameter you can use with `get_template_part()`. Use it to pass data ... |
402,862 | <p>I use the following code to add a custom option in the Gutenberg-sidebar. Its visible and saving the Checkbox-value works.</p>
<p>But: if I click on the CheckboxControl nothing visible changes on it. If it is not checked and I want to check it, it does not go checked. The "Update"-button goes active and I ... | [
{
"answer_id": 402872,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>Because React is unaware that anything changed, all the props are the same, and so is the state, so no updat... | 2022/02/18 | [
"https://wordpress.stackexchange.com/questions/402862",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/219391/"
] | I use the following code to add a custom option in the Gutenberg-sidebar. Its visible and saving the Checkbox-value works.
But: if I click on the CheckboxControl nothing visible changes on it. If it is not checked and I want to check it, it does not go checked. The "Update"-button goes active and I see the checked Che... | **Solution found:**
```
const { __ } = wp.i18n;
const { useSelect, useDispatch } = wp.data;
const { PluginDocumentSettingPanel } = wp.editPost;
const { CheckboxControl, PanelRow } = wp.components;
const Sidebar = () => {
const { postMeta } = useSelect( ( select ) => {
return {
postMeta: select... |
402,874 | <p>I have developed a custom taxonomy post type. I have displayed categories & inside categories posts/(products).</p>
<p>I am getting the Post title & Image as they should be (which I add), but the descriptions of all the posts are same.</p>
<p>I have no idea why same desc keeps displaying,even though everythi... | [
{
"answer_id": 402872,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>Because React is unaware that anything changed, all the props are the same, and so is the state, so no updat... | 2022/02/19 | [
"https://wordpress.stackexchange.com/questions/402874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/179815/"
] | I have developed a custom taxonomy post type. I have displayed categories & inside categories posts/(products).
I am getting the Post title & Image as they should be (which I add), but the descriptions of all the posts are same.
I have no idea why same desc keeps displaying,even though everything else is dynamic.
He... | **Solution found:**
```
const { __ } = wp.i18n;
const { useSelect, useDispatch } = wp.data;
const { PluginDocumentSettingPanel } = wp.editPost;
const { CheckboxControl, PanelRow } = wp.components;
const Sidebar = () => {
const { postMeta } = useSelect( ( select ) => {
return {
postMeta: select... |
402,946 | <p>If I have declared, <code>viewScript</code> in my block.json file. Do I need to enqueue the script manually within my <code>register_block_type();</code> function also? (I didn't think it was necessary for 5.9?)</p>
<p><strong>My Block.json</strong></p>
<pre><code>"textdomain": "postcode-pricing-wizar... | [
{
"answer_id": 402981,
"author": "Lewis",
"author_id": 105112,
"author_profile": "https://wordpress.stackexchange.com/users/105112",
"pm_score": 4,
"selected": true,
"text": "<p><strong>Note to self, rest-up and re-read the docs.</strong></p>\n<p>So it turns out that the answer <strong>i... | 2022/02/21 | [
"https://wordpress.stackexchange.com/questions/402946",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105112/"
] | If I have declared, `viewScript` in my block.json file. Do I need to enqueue the script manually within my `register_block_type();` function also? (I didn't think it was necessary for 5.9?)
**My Block.json**
```
"textdomain": "postcode-pricing-wizard",
"editorScript": "file:./index.js",
"viewScript": "file:./view.js"... | **Note to self, rest-up and re-read the docs.**
So it turns out that the answer **is written in the docs**, but rather obscurely. If you check out the [Frontend Enqueueing](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#frontend-enqueueing) section of the Block Editor Handbook,... |
402,999 | <p>I'm trying to move my wordpress site in to different server and url.
How ever i seem to have a persistent redirect loop problem. I think this is not a cache, cookie or plugin problem and I am suspecting incorrect/missing settings in .htaccess file might be the culprit.
The server where i am doing the moving from, us... | [
{
"answer_id": 403003,
"author": "Anass",
"author_id": 77227,
"author_profile": "https://wordpress.stackexchange.com/users/77227",
"pm_score": 1,
"selected": false,
"text": "<p>As WordPress documentation says about <code>.htaccess</code> file:</p>\n<blockquote>\n<p>WordPress uses this fi... | 2022/02/22 | [
"https://wordpress.stackexchange.com/questions/402999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/219553/"
] | I'm trying to move my wordpress site in to different server and url.
How ever i seem to have a persistent redirect loop problem. I think this is not a cache, cookie or plugin problem and I am suspecting incorrect/missing settings in .htaccess file might be the culprit.
The server where i am doing the moving from, uses ... | As WordPress documentation says about `.htaccess` file:
>
> WordPress uses this file to manipulate how Apache serves files from
> its root directory, and subdirectories thereof. Most notably, WP
> modifies this file to be able to handle pretty permalinks.
>
>
>
And a basic .htaccess file content will looks like t... |
403,052 | <pre><code>$loop3 = new WP_Query( array(
'posts_per_page' => 10000,
'post_type' => 'volunteers',
'meta_key' => 'state',
'meta_value' => $stateselect,
'meta_compare' => '=',
'meta_key' => 'volunteer_type',
'meta_value' => 'painter',
'meta_compare' => '=',
)... | [
{
"answer_id": 403003,
"author": "Anass",
"author_id": 77227,
"author_profile": "https://wordpress.stackexchange.com/users/77227",
"pm_score": 1,
"selected": false,
"text": "<p>As WordPress documentation says about <code>.htaccess</code> file:</p>\n<blockquote>\n<p>WordPress uses this fi... | 2022/02/23 | [
"https://wordpress.stackexchange.com/questions/403052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/219604/"
] | ```
$loop3 = new WP_Query( array(
'posts_per_page' => 10000,
'post_type' => 'volunteers',
'meta_key' => 'state',
'meta_value' => $stateselect,
'meta_compare' => '=',
'meta_key' => 'volunteer_type',
'meta_value' => 'painter',
'meta_compare' => '=',
) );
```
Hello. I'm new to PH... | As WordPress documentation says about `.htaccess` file:
>
> WordPress uses this file to manipulate how Apache serves files from
> its root directory, and subdirectories thereof. Most notably, WP
> modifies this file to be able to handle pretty permalinks.
>
>
>
And a basic .htaccess file content will looks like t... |
403,103 | <p>I'm aware that this is a well discussed question, nevertheless I did not find any answer for my issue. I have the following code on a Wordpress page (inline, necessary for this project):</p>
<pre><code><script>
(function ($) {
$(document).ready(function () {
$('.choosekurs').on('click', function() {
... | [
{
"answer_id": 403117,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p>If the inline <code><script></code> is in the <code><head></code> or <code><body></code> of y... | 2022/02/24 | [
"https://wordpress.stackexchange.com/questions/403103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/135201/"
] | I'm aware that this is a well discussed question, nevertheless I did not find any answer for my issue. I have the following code on a Wordpress page (inline, necessary for this project):
```
<script>
(function ($) {
$(document).ready(function () {
$('.choosekurs').on('click', function() {
$('textarea[n... | The error is self-explanatory. When you insert your code, jQuery has not been defined. You have to put that `script` after jQuery is loaded.
If you can't change where jQuery is defined, as you say in your comment to [Pat J's answer](https://wordpress.stackexchange.com/a/403117/208483), then insert your script in the `... |
403,191 | <p>I'm trying to append a query string to the end of every URL for logged in users for cache busting purposes. Here is the code I have but it doesn't seem to work. Any ideas?</p>
<pre class="lang-php prettyprint-override"><code>function add_admin_qs($url){
if ( is_user_logged_in() ) {
return add_query_arg('... | [
{
"answer_id": 403201,
"author": "Sébastien Serre",
"author_id": 62892,
"author_profile": "https://wordpress.stackexchange.com/users/62892",
"pm_score": 0,
"selected": false,
"text": "<p>Does</p>\n<pre><code>function add_admin_qs($url){\n if ( is_user_logged_in() ) {\n return a... | 2022/02/27 | [
"https://wordpress.stackexchange.com/questions/403191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/219741/"
] | I'm trying to append a query string to the end of every URL for logged in users for cache busting purposes. Here is the code I have but it doesn't seem to work. Any ideas?
```php
function add_admin_qs($url){
if ( is_user_logged_in() ) {
return add_query_arg('nocfcache', 'true', $url);
}
}
if ( is_user... | The problem is that I used the wrong type of quote marks. You cannot see it in my first post because apparently they were changed when I pasted in the code.
[](https://i.stack.imgur.com/U0RNv.png) |
403,278 | <p>in a child theme of WP theme "twenty-twenty-one" I like to remove the original style.css of the parent theme - based in the link-tag id='twenty-twenty-one-style-css' - from the header.</p>
<p>Here is the code</p>
<pre><code> <link rel='stylesheet' id='twenty-twenty-one-style-css' href='http://localh... | [
{
"answer_id": 403307,
"author": "FDue",
"author_id": 219857,
"author_profile": "https://wordpress.stackexchange.com/users/219857",
"pm_score": 0,
"selected": false,
"text": "<p>For the moment I solved it the brutal way: I removed the link-tag with the parent-css ( <link rel='styleshe... | 2022/03/01 | [
"https://wordpress.stackexchange.com/questions/403278",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/219827/"
] | in a child theme of WP theme "twenty-twenty-one" I like to remove the original style.css of the parent theme - based in the link-tag id='twenty-twenty-one-style-css' - from the header.
Here is the code
```
<link rel='stylesheet' id='twenty-twenty-one-style-css' href='http://localhost/ml_wp_220228/wp-content/them... | The file 'style.css' is integrated via function 'twenty\_twenty\_one\_scripts' in the parent themes functions.php.
```
function twenty_twenty_one_scripts() {
// Note, the is_IE global variable is defined by WordPress and is used
// to detect if the current browser is internet explorer.
global $is_IE, $wp_... |
403,327 | <p>In gutenberg/block-editor, how can I check whether I've already registered a block type? Is there a function I can use? Searching through the Block Editor Handbook I couldn't see a function to check this.</p>
<p>An example of what I am trying to do is below:</p>
<pre><code>class My_Block {
public function __con... | [
{
"answer_id": 403399,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 2,
"selected": false,
"text": "<p><strong><strong>EDIT</strong></strong></p>\n<p>I just realized you're doing this on the PHP side. There is a ... | 2022/03/03 | [
"https://wordpress.stackexchange.com/questions/403327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75260/"
] | In gutenberg/block-editor, how can I check whether I've already registered a block type? Is there a function I can use? Searching through the Block Editor Handbook I couldn't see a function to check this.
An example of what I am trying to do is below:
```
class My_Block {
public function __construct() {
... | ****EDIT****
I just realized you're doing this on the PHP side. There is a class called `WP_Block_Type_Registry` that you can use to see what is already registered:
```
$registry = WP_Block_Type_Registry::get_instance();
if ( ! $registry->get_registered( 'foo/column' ) ) {
// YOUR CODE
}
```
Gutenberg should fi... |
403,342 | <p>I would like to ask if there is a way to automatically delay emails after completion?</p>
<p>I want these emails to arrive 1-2 hours later.</p>
<p>Is there a snippet of code for this?</p>
<p>Thank you!</p>
| [
{
"answer_id": 403343,
"author": "tieum",
"author_id": 171342,
"author_profile": "https://wordpress.stackexchange.com/users/171342",
"pm_score": 0,
"selected": false,
"text": "<p>not tested but maybe you could simply use sleep using wpcf7_before_send_email</p>\n<p>something like this:</p... | 2022/03/03 | [
"https://wordpress.stackexchange.com/questions/403342",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/218233/"
] | I would like to ask if there is a way to automatically delay emails after completion?
I want these emails to arrive 1-2 hours later.
Is there a snippet of code for this?
Thank you! | not tested but maybe you could simply use sleep using wpcf7\_before\_send\_email
something like this:
```
add_action("wpcf7_before_send_mail", "wpcf7_pause_send");
function wpcf7_pause_send($cf7) {
sleep(3600);
}
``` |
403,379 | <p>I am trying to workout the best way to do a slightly abnormal orderby.</p>
<p>I have a query that returns 2 types (Post and Event). As expected by default it orders both, together, by publish date.</p>
<p>What I want is, posts to be ordered by publish date, events by <code>event->start_date</code></p>
<p>I could ... | [
{
"answer_id": 403343,
"author": "tieum",
"author_id": 171342,
"author_profile": "https://wordpress.stackexchange.com/users/171342",
"pm_score": 0,
"selected": false,
"text": "<p>not tested but maybe you could simply use sleep using wpcf7_before_send_email</p>\n<p>something like this:</p... | 2022/03/04 | [
"https://wordpress.stackexchange.com/questions/403379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/194372/"
] | I am trying to workout the best way to do a slightly abnormal orderby.
I have a query that returns 2 types (Post and Event). As expected by default it orders both, together, by publish date.
What I want is, posts to be ordered by publish date, events by `event->start_date`
I could just get them, loop over them and m... | not tested but maybe you could simply use sleep using wpcf7\_before\_send\_email
something like this:
```
add_action("wpcf7_before_send_mail", "wpcf7_pause_send");
function wpcf7_pause_send($cf7) {
sleep(3600);
}
``` |
403,447 | <p>I have made checkboxes to every post in post list.</p>
<p><strong>Question:</strong><br>
How can I change the the position for the new column.<br>
Now it`s at the right side of the post list. After "Date".<br>
How can I move it example before the title column ?<br><br></p>
<p>The files for the plugin is he... | [
{
"answer_id": 403343,
"author": "tieum",
"author_id": 171342,
"author_profile": "https://wordpress.stackexchange.com/users/171342",
"pm_score": 0,
"selected": false,
"text": "<p>not tested but maybe you could simply use sleep using wpcf7_before_send_email</p>\n<p>something like this:</p... | 2022/03/06 | [
"https://wordpress.stackexchange.com/questions/403447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/219954/"
] | I have made checkboxes to every post in post list.
**Question:**
How can I change the the position for the new column.
Now it`s at the right side of the post list. After "Date".
How can I move it example before the title column ?
The files for the plugin is here, if you would take a look.
<https://githu... | not tested but maybe you could simply use sleep using wpcf7\_before\_send\_email
something like this:
```
add_action("wpcf7_before_send_mail", "wpcf7_pause_send");
function wpcf7_pause_send($cf7) {
sleep(3600);
}
``` |
403,572 | <p>I want to apply following 2 case :</p>
<p>If User not logged in and cart has product: Then redirect user to login and after login redirect to checkout page. I have used a code but it redirecting to the current page i.e if we check out from home page it will redirect to home page itself after login, if it is from sho... | [
{
"answer_id": 403343,
"author": "tieum",
"author_id": 171342,
"author_profile": "https://wordpress.stackexchange.com/users/171342",
"pm_score": 0,
"selected": false,
"text": "<p>not tested but maybe you could simply use sleep using wpcf7_before_send_email</p>\n<p>something like this:</p... | 2022/03/10 | [
"https://wordpress.stackexchange.com/questions/403572",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/220122/"
] | I want to apply following 2 case :
If User not logged in and cart has product: Then redirect user to login and after login redirect to checkout page. I have used a code but it redirecting to the current page i.e if we check out from home page it will redirect to home page itself after login, if it is from shop page it... | not tested but maybe you could simply use sleep using wpcf7\_before\_send\_email
something like this:
```
add_action("wpcf7_before_send_mail", "wpcf7_pause_send");
function wpcf7_pause_send($cf7) {
sleep(3600);
}
``` |
403,573 | <p>I have created a new page on my WordPress site to test the paypal payment flow. I have subscription based products. Attached code is for the paypal subscription button code.</p>
<pre><code> <div id="paypal-button-container-P-91F08612M1573283BMIUWMOA"></div>
<script src="https://www.payp... | [
{
"answer_id": 403343,
"author": "tieum",
"author_id": 171342,
"author_profile": "https://wordpress.stackexchange.com/users/171342",
"pm_score": 0,
"selected": false,
"text": "<p>not tested but maybe you could simply use sleep using wpcf7_before_send_email</p>\n<p>something like this:</p... | 2022/03/10 | [
"https://wordpress.stackexchange.com/questions/403573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/218901/"
] | I have created a new page on my WordPress site to test the paypal payment flow. I have subscription based products. Attached code is for the paypal subscription button code.
```
<div id="paypal-button-container-P-91F08612M1573283BMIUWMOA"></div>
<script src="https://www.paypal.com/sdk/js?client-id=AfGWAPJxdGbCj7b51a2... | not tested but maybe you could simply use sleep using wpcf7\_before\_send\_email
something like this:
```
add_action("wpcf7_before_send_mail", "wpcf7_pause_send");
function wpcf7_pause_send($cf7) {
sleep(3600);
}
``` |
403,666 | <p>I add on my wordpress a function to save a json file , when a post is saved on admin. Basically i get the title ( that will be a json string ) and convert it to JSON.
From that JSON i need to extract the id , to use like a name of the file created. But when i try to get the id , i have an empty value.</p>
<pre><code... | [
{
"answer_id": 403667,
"author": "Raja Aman Ullah",
"author_id": 172088,
"author_profile": "https://wordpress.stackexchange.com/users/172088",
"pm_score": -1,
"selected": false,
"text": "<pre class=\"lang-php prettyprint-override\"><code>add_action('save_post', function($ID, $post) {\n ... | 2022/03/12 | [
"https://wordpress.stackexchange.com/questions/403666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128870/"
] | I add on my wordpress a function to save a json file , when a post is saved on admin. Basically i get the title ( that will be a json string ) and convert it to JSON.
From that JSON i need to extract the id , to use like a name of the file created. But when i try to get the id , i have an empty value.
```
add_acti... | `json_encode` takes an array/object and turns it into a JSON string.
`json_decode` takes a JSON string and turns it into a PHP array/object/etc
With this in mind, we can see some critical mistakes are made in the code, caused by muddling up the two.
1. You're taking a string of JSON and JSON encoding it, aka double ... |
403,740 | <p>I wrote a little custom shortcode and when I try to use it in a custom post it won't take into account the parameter I set up.</p>
<p><strong>What it's supposed to do</strong></p>
<p>The shortcode is supposed to take a custom post ID into parameter and display a div that use the thumbnail of this post as a backgroun... | [
{
"answer_id": 403667,
"author": "Raja Aman Ullah",
"author_id": 172088,
"author_profile": "https://wordpress.stackexchange.com/users/172088",
"pm_score": -1,
"selected": false,
"text": "<pre class=\"lang-php prettyprint-override\"><code>add_action('save_post', function($ID, $post) {\n ... | 2022/03/15 | [
"https://wordpress.stackexchange.com/questions/403740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/220306/"
] | I wrote a little custom shortcode and when I try to use it in a custom post it won't take into account the parameter I set up.
**What it's supposed to do**
The shortcode is supposed to take a custom post ID into parameter and display a div that use the thumbnail of this post as a background if there's one, and then d... | `json_encode` takes an array/object and turns it into a JSON string.
`json_decode` takes a JSON string and turns it into a PHP array/object/etc
With this in mind, we can see some critical mistakes are made in the code, caused by muddling up the two.
1. You're taking a string of JSON and JSON encoding it, aka double ... |
403,753 | <p>This is happening with a fresh, new WordPress install. But all you need to do is look at the crazy <a href="https://core.trac.wordpress.org/browser/tags/5.9/src/wp-includes/functions.php#L1671" rel="nofollow noreferrer">do_robots()</a> function, which outputs the following...</p>
<pre><code>User-agent: *
Disallow: /... | [
{
"answer_id": 403758,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>First: have a read-up on <a href=\"https://blog.hubspot.com/website/robots-txt-wordpress\" rel=\"nofollow noref... | 2022/03/15 | [
"https://wordpress.stackexchange.com/questions/403753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3453/"
] | This is happening with a fresh, new WordPress install. But all you need to do is look at the crazy [do\_robots()](https://core.trac.wordpress.org/browser/tags/5.9/src/wp-includes/functions.php#L1671) function, which outputs the following...
```
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitema... | First: have a read-up on [robots.txt](https://blog.hubspot.com/website/robots-txt-wordpress), if you haven't. Another good reference is [this one from Yoast](https://yoast.com/ultimate-guide-robots-txt/).
The sample you posted:
```
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://k... |
403,759 | <p>I'm on wordpress 5.9+ and creating CPT's has become relatively easy. But having a landing page for a CPT is new grounds for me.</p>
<ul>
<li>I have successfully created a custom post type called Career Finders</li>
<li>I have created an archive template for this CPT, named <code>archive-career-finders.php</code></li... | [
{
"answer_id": 403758,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>First: have a read-up on <a href=\"https://blog.hubspot.com/website/robots-txt-wordpress\" rel=\"nofollow noref... | 2022/03/15 | [
"https://wordpress.stackexchange.com/questions/403759",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98671/"
] | I'm on wordpress 5.9+ and creating CPT's has become relatively easy. But having a landing page for a CPT is new grounds for me.
* I have successfully created a custom post type called Career Finders
* I have created an archive template for this CPT, named `archive-career-finders.php`
* I can see that template being us... | First: have a read-up on [robots.txt](https://blog.hubspot.com/website/robots-txt-wordpress), if you haven't. Another good reference is [this one from Yoast](https://yoast.com/ultimate-guide-robots-txt/).
The sample you posted:
```
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://k... |
403,781 | <p>In WordPress I make SQL-requests to the database but LIKE request doesn't work correctly.</p>
<p>Actial value of <code>meta_value</code> field in the database is such string:</p>
<pre><code>a:1:{i:0;s:9:"full-time";}
</code></pre>
<p>if I make this request all works fine:</p>
<pre><code>$query = $wpdb->... | [
{
"answer_id": 403758,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>First: have a read-up on <a href=\"https://blog.hubspot.com/website/robots-txt-wordpress\" rel=\"nofollow noref... | 2022/03/16 | [
"https://wordpress.stackexchange.com/questions/403781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128503/"
] | In WordPress I make SQL-requests to the database but LIKE request doesn't work correctly.
Actial value of `meta_value` field in the database is such string:
```
a:1:{i:0;s:9:"full-time";}
```
if I make this request all works fine:
```
$query = $wpdb->prepare("SELECT meta_value FROM wp_postmeta WHERE meta_key = 'jo... | First: have a read-up on [robots.txt](https://blog.hubspot.com/website/robots-txt-wordpress), if you haven't. Another good reference is [this one from Yoast](https://yoast.com/ultimate-guide-robots-txt/).
The sample you posted:
```
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://k... |
403,800 | <p>There are loads of articles out there on how to completely disable Wordpress RSS feeds, my configuration (<code>functions.php</code>) is:</p>
<pre><code>function disable_feed() {
wp_die( 'You Died' , 200 );
}
add_action('do_feed', 'disable_feed', 1);
add_action('do_feed_rdf', 'disable_feed', 1);
add_action('do_fee... | [
{
"answer_id": 403758,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>First: have a read-up on <a href=\"https://blog.hubspot.com/website/robots-txt-wordpress\" rel=\"nofollow noref... | 2022/03/16 | [
"https://wordpress.stackexchange.com/questions/403800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/167472/"
] | There are loads of articles out there on how to completely disable Wordpress RSS feeds, my configuration (`functions.php`) is:
```
function disable_feed() {
wp_die( 'You Died' , 200 );
}
add_action('do_feed', 'disable_feed', 1);
add_action('do_feed_rdf', 'disable_feed', 1);
add_action('do_feed_rss', 'disable_feed', ... | First: have a read-up on [robots.txt](https://blog.hubspot.com/website/robots-txt-wordpress), if you haven't. Another good reference is [this one from Yoast](https://yoast.com/ultimate-guide-robots-txt/).
The sample you posted:
```
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://k... |
403,838 | <p>I created a custom post:</p>
<pre><code>/*= Add Custom Post Type: Board Members
/****************************************************/
add_action( 'init', 'create_board_posttype' );
function create_board_posttype() {
register_post_type( 'board',
array(
'labels' => array(
'name' => __( 'Boa... | [
{
"answer_id": 403758,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>First: have a read-up on <a href=\"https://blog.hubspot.com/website/robots-txt-wordpress\" rel=\"nofollow noref... | 2022/03/17 | [
"https://wordpress.stackexchange.com/questions/403838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10368/"
] | I created a custom post:
```
/*= Add Custom Post Type: Board Members
/****************************************************/
add_action( 'init', 'create_board_posttype' );
function create_board_posttype() {
register_post_type( 'board',
array(
'labels' => array(
'name' => __( 'Board Members' ),
... | First: have a read-up on [robots.txt](https://blog.hubspot.com/website/robots-txt-wordpress), if you haven't. Another good reference is [this one from Yoast](https://yoast.com/ultimate-guide-robots-txt/).
The sample you posted:
```
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://k... |
403,911 | <p>In a local wordpress installation, when I install a plugin it only offers me installation via FTP, even if I load the plugin .zip file from my pc. Why does this happen?
I use Ubuntu linux and apache 2 as web server. Thank you.</p>
| [
{
"answer_id": 403758,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>First: have a read-up on <a href=\"https://blog.hubspot.com/website/robots-txt-wordpress\" rel=\"nofollow noref... | 2022/03/20 | [
"https://wordpress.stackexchange.com/questions/403911",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/220467/"
] | In a local wordpress installation, when I install a plugin it only offers me installation via FTP, even if I load the plugin .zip file from my pc. Why does this happen?
I use Ubuntu linux and apache 2 as web server. Thank you. | First: have a read-up on [robots.txt](https://blog.hubspot.com/website/robots-txt-wordpress), if you haven't. Another good reference is [this one from Yoast](https://yoast.com/ultimate-guide-robots-txt/).
The sample you posted:
```
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://k... |
403,956 | <p>I am trying to allow visitors to seek specific times on the embed rumble video inside the wordpress post by clicking to timestamp links. I can do it for youtube videos using Skip to Timestamp plugin or methods like <a href="https://wickydesign.com/how-to-add-timestamps-to-embedded-youtube-videos/" rel="nofollow nore... | [
{
"answer_id": 403758,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>First: have a read-up on <a href=\"https://blog.hubspot.com/website/robots-txt-wordpress\" rel=\"nofollow noref... | 2022/03/21 | [
"https://wordpress.stackexchange.com/questions/403956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/220514/"
] | I am trying to allow visitors to seek specific times on the embed rumble video inside the wordpress post by clicking to timestamp links. I can do it for youtube videos using Skip to Timestamp plugin or methods like [this one](https://wickydesign.com/how-to-add-timestamps-to-embedded-youtube-videos/) however, I cannot m... | First: have a read-up on [robots.txt](https://blog.hubspot.com/website/robots-txt-wordpress), if you haven't. Another good reference is [this one from Yoast](https://yoast.com/ultimate-guide-robots-txt/).
The sample you posted:
```
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://k... |
404,009 | <p>I have a custom register form page, and I want to create a 301 redirect to force people to use this form (and not the original URL of WordPress)</p>
<p>I try to do a redirect 301 like this in my <code>.htaccess</code>, but it doesn't work.</p>
<pre><code>Redirect 301 /wp-login.php?action=register https://monsite.com... | [
{
"answer_id": 404013,
"author": "DeltaG",
"author_id": 168537,
"author_profile": "https://wordpress.stackexchange.com/users/168537",
"pm_score": 2,
"selected": false,
"text": "<p>I would advice you to not use the htaccess for this, but to use a WordPress hook instead.</p>\n<p>Check out ... | 2022/03/23 | [
"https://wordpress.stackexchange.com/questions/404009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130804/"
] | I have a custom register form page, and I want to create a 301 redirect to force people to use this form (and not the original URL of WordPress)
I try to do a redirect 301 like this in my `.htaccess`, but it doesn't work.
```
Redirect 301 /wp-login.php?action=register https://monsite.com/register/
```
What's wrong ... | I would advice you to not use the htaccess for this, but to use a WordPress hook instead.
Check out <https://developer.wordpress.org/reference/hooks/login_url/> |
404,065 | <p>I Need to filter content for posts. If the user is not logged in, then the post content should display "please log in....". If he is logged in, then he can see the post content.
I wrote the filter:</p>
<pre><code>add_filter('the_content', 'check_user_logedin',10);
function check_user_logedin($content){
gl... | [
{
"answer_id": 404070,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p>Per the user-contributed comment by Hay on the <a href=\"https://developer.wordpress.org/reference/functions/ge... | 2022/03/24 | [
"https://wordpress.stackexchange.com/questions/404065",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/214120/"
] | I Need to filter content for posts. If the user is not logged in, then the post content should display "please log in....". If he is logged in, then he can see the post content.
I wrote the filter:
```
add_filter('the_content', 'check_user_logedin',10);
function check_user_logedin($content){
global $post;
if ( $pos... | *tl;dr. There's probably a good way for you to do this in the specific case you describe, although WordPress does **not** allow for good, general filtering of the return value from `get_the_content()`.*
### You cannot do this directly, but ...
There currently (as of WordPress 5.9.2, checked on 24 March 2022) isn't a ... |
404,089 | <p>How can we change the redirect_url for a redirect action based on the response from an API?</p>
<p>I have created a custom action (extending <code>NF_Abstracts_Action </code>) that runs during submission with <code>late</code> timing and calls an external API.</p>
<p>Based on that response I want to change the page... | [
{
"answer_id": 404436,
"author": "ScottM",
"author_id": 185972,
"author_profile": "https://wordpress.stackexchange.com/users/185972",
"pm_score": 0,
"selected": false,
"text": "<p>I recommend deleting the redirect action for the form, then in your code for the custom action that is run a... | 2022/03/25 | [
"https://wordpress.stackexchange.com/questions/404089",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/490/"
] | How can we change the redirect\_url for a redirect action based on the response from an API?
I have created a custom action (extending `NF_Abstracts_Action` ) that runs during submission with `late` timing and calls an external API.
Based on that response I want to change the page being redirected to. I cam get the a... | So, the way I've ended up doing this is as follows. It's probably not the optimal way but I can't find a way to change the submission data during the submission workflow (the redirect action always seems to read the original entered data). Basically, the key hook is `ninja_forms_run_action_settings` where you can filte... |
404,120 | <p>I have a hierarchical CPT <code>event</code> with taxonomy <code>event_category</code>. One of those categories is "Recap". When a user saves a post (could be draft, publish, or edit existing), if the <code>event_category</code> is Recap and the post has a parent, I want to set the slug to "recap"... | [
{
"answer_id": 404436,
"author": "ScottM",
"author_id": 185972,
"author_profile": "https://wordpress.stackexchange.com/users/185972",
"pm_score": 0,
"selected": false,
"text": "<p>I recommend deleting the redirect action for the form, then in your code for the custom action that is run a... | 2022/03/26 | [
"https://wordpress.stackexchange.com/questions/404120",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63369/"
] | I have a hierarchical CPT `event` with taxonomy `event_category`. One of those categories is "Recap". When a user saves a post (could be draft, publish, or edit existing), if the `event_category` is Recap and the post has a parent, I want to set the slug to "recap" automatically.
The problem is, when `wp_insert_post()... | So, the way I've ended up doing this is as follows. It's probably not the optimal way but I can't find a way to change the submission data during the submission workflow (the redirect action always seems to read the original entered data). Basically, the key hook is `ninja_forms_run_action_settings` where you can filte... |
404,399 | <p>I'm trying to include more than one term_id(multiple checkboxes filter) on a single category page.
I managed to recollect enough to build a tax_query with pre_get_posts, but now it seems, I have two tax_queries, one is in WP_Query->query_vars and the other is just in WP_Query(that one is of WP_Tax_Query type):</p... | [
{
"answer_id": 404406,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n<p>but now it seems, I have two tax_queries, one is in\nWP_Query->query_vars and the other i... | 2022/04/04 | [
"https://wordpress.stackexchange.com/questions/404399",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32588/"
] | I'm trying to include more than one term\_id(multiple checkboxes filter) on a single category page.
I managed to recollect enough to build a tax\_query with pre\_get\_posts, but now it seems, I have two tax\_queries, one is in WP\_Query->query\_vars and the other is just in WP\_Query(that one is of WP\_Tax\_Query type)... | >
> but now it seems, I have two tax\_queries, one is in
> WP\_Query->query\_vars and the other is just in WP\_Query
>
>
>
That is normal.
* `WP_Query::$query_vars` is an array of query vars merged with the default ones for [`WP_Query`](https://developer.wordpress.org/reference/classes/wp_query/).
So if you do `... |
404,665 | <p>Here is summary of the problem and required solution:</p>
<ul>
<li><p>Access to mywebsite.com/wp-admin is blocked for subscribers [which is good]</p>
</li>
<li><p>However, if i enter the link manually on the browser as follows:
<a href="https://mywebsite.com/wp-admin/user-edit.php?user_id=113" rel="nofollow noreferr... | [
{
"answer_id": 404687,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n<p>Hence, I want to block access of subscribers to all wp-admin\nmenus/plugin pages including th... | 2022/04/11 | [
"https://wordpress.stackexchange.com/questions/404665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/217604/"
] | Here is summary of the problem and required solution:
* Access to mywebsite.com/wp-admin is blocked for subscribers [which is good]
* However, if i enter the link manually on the browser as follows:
<https://mywebsite.com/wp-admin/user-edit.php?user_id=113>
then the user has access to his user settings
* Problem with ... | >
> Hence, I want to block access of subscribers to all wp-admin
> menus/plugin pages including this link
> `https://mywebsite.com/wp-admin/user-edit.php?user_id=113`
>
>
>
This isn't a bulletproof solution, but it should work in that non-admin users would no longer be able to access any admin pages when they're *... |
404,725 | <p>I moved a wordpress site into a subdirectory on the same folder and changed the WP address and site address to reflect this.</p>
<p>I then used search-replace on the database files to replace the previous url with the subdirectory url.</p>
<p>I then re-saved the permalink structure from the wp-admin control page and... | [
{
"answer_id": 404728,
"author": "DeltaG",
"author_id": 168537,
"author_profile": "https://wordpress.stackexchange.com/users/168537",
"pm_score": 0,
"selected": false,
"text": "<p>If your WordPress files are inside a subdirectory, your htaccess should reflect that. I don't see a subdirec... | 2022/04/12 | [
"https://wordpress.stackexchange.com/questions/404725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/220425/"
] | I moved a wordpress site into a subdirectory on the same folder and changed the WP address and site address to reflect this.
I then used search-replace on the database files to replace the previous url with the subdirectory url.
I then re-saved the permalink structure from the wp-admin control page and checked that t... | OK fixed it!
I had some errant lines in the .htaccess file:
```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# WP REWRITE LOOP END
```
This was taking precedence over the `<IfModule mod_rewrite.c>` block - and explains why it was redirecting to the parent dire... |
404,776 | <p>I want to output the Yoast SEO category meta-description within a custom loop. Current code (below) works if there is a meta-description present. However, if no category meta-description is set it breaks.</p>
<p>Is there a better way to write this so that it fails silently if no meta-description is set</p>
<pre><cod... | [
{
"answer_id": 404778,
"author": "DeltaG",
"author_id": 168537,
"author_profile": "https://wordpress.stackexchange.com/users/168537",
"pm_score": 1,
"selected": false,
"text": "<p>You can just check if <code>$meta</code> and <code>$meta_desc</code> exist. If not, don't echo anything.</p>... | 2022/04/13 | [
"https://wordpress.stackexchange.com/questions/404776",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/201500/"
] | I want to output the Yoast SEO category meta-description within a custom loop. Current code (below) works if there is a meta-description present. However, if no category meta-description is set it breaks.
Is there a better way to write this so that it fails silently if no meta-description is set
```
<?php
$popular_t... | Wrap in a `!empty` statement
```
if(!empty( $meta['category'][$id]['wpseo_desc'] )) {
echo $meta['category'][$id]['wpseo_desc'];
}
else {
echo "Meta not present";
}
``` |
404,876 | <p>There is an icon to open the search form on my site, and when it is clicked, the search form opens in full screen. I want the search form to be selected automatically, how can I do that?</p>
<p>Here: <a href="https://wisekitten.com/" rel="nofollow noreferrer">https://wisekitten.com/</a></p>
<p>I'm not using jQuery i... | [
{
"answer_id": 404778,
"author": "DeltaG",
"author_id": 168537,
"author_profile": "https://wordpress.stackexchange.com/users/168537",
"pm_score": 1,
"selected": false,
"text": "<p>You can just check if <code>$meta</code> and <code>$meta_desc</code> exist. If not, don't echo anything.</p>... | 2022/04/17 | [
"https://wordpress.stackexchange.com/questions/404876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/161959/"
] | There is an icon to open the search form on my site, and when it is clicked, the search form opens in full screen. I want the search form to be selected automatically, how can I do that?
Here: <https://wisekitten.com/>
I'm not using jQuery in my project. | Wrap in a `!empty` statement
```
if(!empty( $meta['category'][$id]['wpseo_desc'] )) {
echo $meta['category'][$id]['wpseo_desc'];
}
else {
echo "Meta not present";
}
``` |
404,948 | <p>I have an option <code>admins_settings</code> that has an array of sub-options that is stored in the <code>wp_options</code> table. Before I get its value from the table, I check if this field exists by running this code:</p>
<pre class="lang-php prettyprint-override"><code>if ( !isset( get_option( 'admins_settings'... | [
{
"answer_id": 404949,
"author": "ScottM",
"author_id": 185972,
"author_profile": "https://wordpress.stackexchange.com/users/185972",
"pm_score": 1,
"selected": false,
"text": "<p>Upon entering the <code>if()</code> statement of your code, it will return to the calling function either wa... | 2022/04/19 | [
"https://wordpress.stackexchange.com/questions/404948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/161580/"
] | I have an option `admins_settings` that has an array of sub-options that is stored in the `wp_options` table. Before I get its value from the table, I check if this field exists by running this code:
```php
if ( !isset( get_option( 'admins_settings' )['option_name'] ) ) {
return false;
} else {
return get_opti... | >
> I'm hitting the table 2 times (if the field exists) to get its value.
>
>
>
No, you aren't, and there is no evidence for this. You may not be hitting the database at all if it has autoload enabled. WordPress caches things in memory during the same request, and it bulk fetches options set to autoload for perfor... |
404,977 | <p>I have the following script added to <em>functions.php</em> in my <strong>child</strong> theme:</p>
<pre><code>function getlatestfile() {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('wp-content/uploads/cams/'));
foreach ($iterator as $file) {
if ($file->isDir()) conti... | [
{
"answer_id": 404979,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>When you're editing the page, you're in the directory <code>wp-admin</code>, and <code>wp-admin</code> doesn't ... | 2022/04/20 | [
"https://wordpress.stackexchange.com/questions/404977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/150852/"
] | I have the following script added to *functions.php* in my **child** theme:
```
function getlatestfile() {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('wp-content/uploads/cams/'));
foreach ($iterator as $file) {
if ($file->isDir()) continue;
$path = $file->getPathn... | ABSPATH helps to display the page in the backend in editmode. But for the frontend, the path for the `<img../>` tag needs to be modified. `cutprefix()` function (taken from [here](https://stackoverflow.com/questions/4517067/remove-a-string-from-the-beginning-of-a-string)) does the job.
This is the working solution for... |
405,113 | <p>UPDATE: I have realised that I need to use a plugin like PHP Snipping or Insert PHP to make this work, I have updated my screen shots to reflect where Im upto from my research.</p>
<p>The code is working and outputting the right User ID but the SQL is not echoing the Table data, if you have some advice on where I mi... | [
{
"answer_id": 405120,
"author": "Digitalchild",
"author_id": 3170,
"author_profile": "https://wordpress.stackexchange.com/users/3170",
"pm_score": 0,
"selected": false,
"text": "<p>Without seeing the values of your custom table, <code>wp_get_current_user()</code> is probably returning t... | 2022/04/24 | [
"https://wordpress.stackexchange.com/questions/405113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/221583/"
] | UPDATE: I have realised that I need to use a plugin like PHP Snipping or Insert PHP to make this work, I have updated my screen shots to reflect where Im upto from my research.
The code is working and outputting the right User ID but the SQL is not echoing the Table data, if you have some advice on where I might of go... | The evolution of this question makes it difficult to succinctly answer, but in brief summary:
* Using [`$wpdb->prepare()`](https://developer.wordpress.org/reference/classes/wpdb/prepare/) to construct arbitrary SQL queries to execute against the database helps to mitigate [injection vulnerabilities](https://xkcd.com/3... |
405,207 | <p>so if i have a function that gets terms from the database ( not the user ) do I need to use prepare first ( before get_results() ), or some sort of data sanitizing?</p>
| [
{
"answer_id": 405209,
"author": "The Oracle",
"author_id": 217604,
"author_profile": "https://wordpress.stackexchange.com/users/217604",
"pm_score": -1,
"selected": false,
"text": "<p>You shouldn't need to pre-sanitize, wordpress takes care of that with the wpdb class.</p>\n<pre><code> ... | 2022/04/27 | [
"https://wordpress.stackexchange.com/questions/405207",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/192901/"
] | so if i have a function that gets terms from the database ( not the user ) do I need to use prepare first ( before get\_results() ), or some sort of data sanitizing? | >
> so if i have a function that gets terms from the database ( not the user ) do I need to use prepare first ( before get\_results() ), or some sort of data sanitizing?
>
>
>
Yes, but you should be using `get_terms`/`WP_Term_Query`/`wp_get_object_terms`/etc and the other term APIs instead as they're safer and can... |
405,260 | <p>I would like to show both "author" (one or more) and "reviewed by" (just one person) for Wordpress posts and pages on my website.</p>
<p>This would be for example a situation where an article is written by a content producer but the information has to be reviewed by an MD or other credentialed me... | [
{
"answer_id": 405209,
"author": "The Oracle",
"author_id": 217604,
"author_profile": "https://wordpress.stackexchange.com/users/217604",
"pm_score": -1,
"selected": false,
"text": "<p>You shouldn't need to pre-sanitize, wordpress takes care of that with the wpdb class.</p>\n<pre><code> ... | 2022/04/28 | [
"https://wordpress.stackexchange.com/questions/405260",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97162/"
] | I would like to show both "author" (one or more) and "reviewed by" (just one person) for Wordpress posts and pages on my website.
This would be for example a situation where an article is written by a content producer but the information has to be reviewed by an MD or other credentialed medical expert.
This type of f... | >
> so if i have a function that gets terms from the database ( not the user ) do I need to use prepare first ( before get\_results() ), or some sort of data sanitizing?
>
>
>
Yes, but you should be using `get_terms`/`WP_Term_Query`/`wp_get_object_terms`/etc and the other term APIs instead as they're safer and can... |
405,330 | <p>I like to basically use a modified version of the below function.</p>
<p>There is <code>pre_render_block</code> and other filters. I have not found out how to get attributes and context the exact way that function does.</p>
<p><a href="https://github.com/WordPress/wordpress-develop/blob/5.9/src/wp-includes/blocks.ph... | [
{
"answer_id": 408204,
"author": "Ronak J Vanpariya",
"author_id": 170878,
"author_profile": "https://wordpress.stackexchange.com/users/170878",
"pm_score": 3,
"selected": true,
"text": "<p>Try This one on your <code>functions.php</code> or main Plugin file</p>\n<pre><code>add_filter('re... | 2022/04/30 | [
"https://wordpress.stackexchange.com/questions/405330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38602/"
] | I like to basically use a modified version of the below function.
There is `pre_render_block` and other filters. I have not found out how to get attributes and context the exact way that function does.
<https://github.com/WordPress/wordpress-develop/blob/5.9/src/wp-includes/blocks.php>
I see how I can filter the con... | Try This one on your `functions.php` or main Plugin file
```
add_filter('register_block_type_args', function ($settings, $name) {
if ($name == 'demo/content-with-sidebar') {
$settings['render_callback'] = 'demo_blocks_content_with_sidebar';
}
return $settings;
}, null, 2);
```
replace your block ... |
405,465 | <p>I just installed this plugin and I must say it does everything I need.</p>
<p>I am using a custom made popup div with a CF7 inside it.</p>
<p>I need to hide response messages (error, success message) after 5 seconds. Is that possible?</p>
| [
{
"answer_id": 405467,
"author": "Patidar Praful",
"author_id": 215316,
"author_profile": "https://wordpress.stackexchange.com/users/215316",
"pm_score": 3,
"selected": true,
"text": "<p>you can use below code to hide message</p>\n<pre><code>// Contact Form 7 submit event fire\ndocument.... | 2022/05/06 | [
"https://wordpress.stackexchange.com/questions/405465",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/196307/"
] | I just installed this plugin and I must say it does everything I need.
I am using a custom made popup div with a CF7 inside it.
I need to hide response messages (error, success message) after 5 seconds. Is that possible? | you can use below code to hide message
```
// Contact Form 7 submit event fire
document.addEventListener('wpcf7submit', function(event) {
setTimeout(function() {
jQuery('form.wpcf7-form').removeClass('sent');
jQuery('form.wpcf7-form').removeClass('failed');
jQuery('form.wpcf7-form').addClass(... |
405,562 | <p>I use this function to set and get post view of post in my WordPress</p>
<pre><code>function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add... | [
{
"answer_id": 405585,
"author": "Bysander",
"author_id": 47618,
"author_profile": "https://wordpress.stackexchange.com/users/47618",
"pm_score": 1,
"selected": false,
"text": "<p>Short answer:</p>\n<p>You can't from that code</p>\n<hr>\nLonger answer:\n<p>So the code above will simply i... | 2022/05/09 | [
"https://wordpress.stackexchange.com/questions/405562",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/222021/"
] | I use this function to set and get post view of post in my WordPress
```
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($p... | Short answer:
You can't from that code
---
Longer answer:
So the code above will simply increment a counter based on the last value the counter was on. There's no way to tell when that page-view or count starts from it's simply a number. You have no data on when that page view was counted or even last updated and ce... |
405,588 | <p>I’m trying to apply the <code>pre_get_posts</code> to a specific <em>core/query</em> block, in order to programatically modify the number of posts displayed when a custom attribute is set. If I use the <code>render_block</code> hook, the block is already pre-rendered and so modifying the query using <code>pre_get_po... | [
{
"answer_id": 405596,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Update:</strong></p>\n<p>It's possible to use the <a href=\"https://developer.wordpress.org/reference... | 2022/05/10 | [
"https://wordpress.stackexchange.com/questions/405588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83412/"
] | I’m trying to apply the `pre_get_posts` to a specific *core/query* block, in order to programatically modify the number of posts displayed when a custom attribute is set. If I use the `render_block` hook, the block is already pre-rendered and so modifying the query using `pre_get_posts` has no effect. Is there any way ... | **Update:**
It's possible to use the [`render_block_data`](https://developer.wordpress.org/reference/hooks/render_block_data/) filter to modify the query block's data before it's rendered.
Since 6.1. the [`query_loop_block_query_vars`](https://developer.wordpress.org/reference/hooks/query_loop_block_query_vars/) filt... |
405,649 | <p>We’re using WP Engine for web hosting.</p>
<p>I originally manually turned on Multisite through <code>wp-config.php</code> & <code>Tools > Network Setup</code>.</p>
<p>Since then, I've learned we need to use their <code>Enable Multisite</code> function to enable subdirectory multisite.</p>
<p>When <code>WP_DE... | [
{
"answer_id": 405926,
"author": "Bysander",
"author_id": 47618,
"author_profile": "https://wordpress.stackexchange.com/users/47618",
"pm_score": 0,
"selected": false,
"text": "<p>The URL to access the network database update is</p>\n<p><a href=\"https://www.website.test/wp-admin/network... | 2022/05/12 | [
"https://wordpress.stackexchange.com/questions/405649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | We’re using WP Engine for web hosting.
I originally manually turned on Multisite through `wp-config.php` & `Tools > Network Setup`.
Since then, I've learned we need to use their `Enable Multisite` function to enable subdirectory multisite.
When `WP_DEBUG` is on, we see a message:
>
> Notice: wp\_check\_site\_meta\... | This was an error on an older version of WordPress, version 5.1 ([Core Issue #46167](https://core.trac.wordpress.org/ticket/46167)). Do you use the last stable version of WordPress?
But try the following options to solve the problem.
Install again, Core or WP CLI
=============================
Copy all files from the... |
405,683 | <p>I need to list all categories and their respective posts.
Each taxonomy has an image created by ACF in jetengine plugin. I created the loop that returns the list of categories and posts for each category. But I can't capture the custom field from the taxonomy image. Can anyone give me some tips on how to do it?</p>
... | [
{
"answer_id": 405688,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>The thumbnail is probably stored in the <code>termmeta</code> table using a meta key specified the jetengin... | 2022/05/13 | [
"https://wordpress.stackexchange.com/questions/405683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/191774/"
] | I need to list all categories and their respective posts.
Each taxonomy has an image created by ACF in jetengine plugin. I created the loop that returns the list of categories and posts for each category. But I can't capture the custom field from the taxonomy image. Can anyone give me some tips on how to do it?
```
fo... | Since you are using ACF, you can take advantage of the `get_field()` function ACF provides.
You will need to pass the term object as the second parameter.
```
$image = get_field( 'field_key', $custom_term );
``` |
405,747 | <p>I'm trying to use <a href="https://developer.wordpress.org/reference/functions/unzip_file/" rel="nofollow noreferrer">unzip_file</a> to extract the remote archive with no success. It works only with the local path using <strong>get_template_directory()</strong> but with a remote zip archive URL I'm getting <em>Incom... | [
{
"answer_id": 405688,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>The thumbnail is probably stored in the <code>termmeta</code> table using a meta key specified the jetengin... | 2022/05/15 | [
"https://wordpress.stackexchange.com/questions/405747",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112255/"
] | I'm trying to use [unzip\_file](https://developer.wordpress.org/reference/functions/unzip_file/) to extract the remote archive with no success. It works only with the local path using **get\_template\_directory()** but with a remote zip archive URL I'm getting *Incompatible Archive.* message.
Here is the stripped vers... | Since you are using ACF, you can take advantage of the `get_field()` function ACF provides.
You will need to pass the term object as the second parameter.
```
$image = get_field( 'field_key', $custom_term );
``` |
405,795 | <p>Is there a way to add additional first and last page links to the pagination object if it is rendere with the <code>the_posts_pagination()</code> method?</p>
<p>At this point I have the following</p>
<pre><code>the_posts_pagination(
[
'screen_reader_text' => ' ',
'mid... | [
{
"answer_id": 405688,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>The thumbnail is probably stored in the <code>termmeta</code> table using a meta key specified the jetengin... | 2022/05/17 | [
"https://wordpress.stackexchange.com/questions/405795",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23759/"
] | Is there a way to add additional first and last page links to the pagination object if it is rendere with the `the_posts_pagination()` method?
At this point I have the following
```
the_posts_pagination(
[
'screen_reader_text' => ' ',
'mid_size' => 2,
'pr... | Since you are using ACF, you can take advantage of the `get_field()` function ACF provides.
You will need to pass the term object as the second parameter.
```
$image = get_field( 'field_key', $custom_term );
``` |
405,823 | <p>I would like to sort the output of my WP Query. I want the events that are coming up soon to be at the beginning. The events that have already taken place should be at the end. So the first array in my meta_query should be output first, then the second array.</p>
<pre><code> $the_query = new WP_Query(
ar... | [
{
"answer_id": 405688,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>The thumbnail is probably stored in the <code>termmeta</code> table using a meta key specified the jetengin... | 2022/05/18 | [
"https://wordpress.stackexchange.com/questions/405823",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/222289/"
] | I would like to sort the output of my WP Query. I want the events that are coming up soon to be at the beginning. The events that have already taken place should be at the end. So the first array in my meta\_query should be output first, then the second array.
```
$the_query = new WP_Query(
array(
... | Since you are using ACF, you can take advantage of the `get_field()` function ACF provides.
You will need to pass the term object as the second parameter.
```
$image = get_field( 'field_key', $custom_term );
``` |
405,832 | <p>I'm using Cryto Plugin and want to get coin price data from plugin db.<br>
<a href="https://i.stack.imgur.com/4tOn4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4tOn4.png" alt="enter image description here" /></a></p>
<p>For easy practice, I'm trying to get BTC data.</p>
<pre><code><?php fun... | [
{
"answer_id": 405688,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>The thumbnail is probably stored in the <code>termmeta</code> table using a meta key specified the jetengin... | 2022/05/18 | [
"https://wordpress.stackexchange.com/questions/405832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/221273/"
] | I'm using Cryto Plugin and want to get coin price data from plugin db.
[](https://i.stack.imgur.com/4tOn4.png)
For easy practice, I'm trying to get BTC data.
```
<?php function get_coin_price($coin_symbol) {
global $wpdb;
$coin_price = $wpdb-... | Since you are using ACF, you can take advantage of the `get_field()` function ACF provides.
You will need to pass the term object as the second parameter.
```
$image = get_field( 'field_key', $custom_term );
``` |
405,852 | <p>I have a site with many custom queries. Some take many seconds to load a page. To solve that issue, I have been using a caching plugin. The issue is, my caching plugin does not cache a page until I click it once. I'd prefer to do this entire process without a plugin if possible. If the plugin route is the best way t... | [
{
"answer_id": 405688,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>The thumbnail is probably stored in the <code>termmeta</code> table using a meta key specified the jetengin... | 2022/05/18 | [
"https://wordpress.stackexchange.com/questions/405852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/222023/"
] | I have a site with many custom queries. Some take many seconds to load a page. To solve that issue, I have been using a caching plugin. The issue is, my caching plugin does not cache a page until I click it once. I'd prefer to do this entire process without a plugin if possible. If the plugin route is the best way to g... | Since you are using ACF, you can take advantage of the `get_field()` function ACF provides.
You will need to pass the term object as the second parameter.
```
$image = get_field( 'field_key', $custom_term );
``` |
405,886 | <p>I'm wondering if it's possible to logout all users 2 times a day using the function wp_logout() ?</p>
<p>I see loads of plugins who can logout idled users but we want to log out every single users twice a day at</p>
<p>2PM and 10PM</p>
<p>Hope someone can help me with this.</p>
| [
{
"answer_id": 405901,
"author": "Tim",
"author_id": 118534,
"author_profile": "https://wordpress.stackexchange.com/users/118534",
"pm_score": 2,
"selected": false,
"text": "<p>This should be possible, WordPress provides the <a href=\"https://developer.wordpress.org/reference/classes/wp_... | 2022/05/19 | [
"https://wordpress.stackexchange.com/questions/405886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/222333/"
] | I'm wondering if it's possible to logout all users 2 times a day using the function wp\_logout() ?
I see loads of plugins who can logout idled users but we want to log out every single users twice a day at
2PM and 10PM
Hope someone can help me with this. | This should be possible, WordPress provides the [WP\_Session\_Tokens](https://developer.wordpress.org/reference/classes/wp_session_tokens/) class to manage logged in sessions. Then it's just a matter of connecting it to the cron. The following is a simple plugin file which I think should do it. Add it to the plugins di... |
405,965 | <p>I have the following functions:</p>
<pre><code>function test($post_id){
do_action('test_action',$post_id);
echo $post_id;
}
add_action('test_action',function($post_id){
if ( $post_id == 2 ) //Stop test function execution
}
</code></pre>
<p>Using the function hooked to <code>add_action</code>, how to stop the e... | [
{
"answer_id": 405901,
"author": "Tim",
"author_id": 118534,
"author_profile": "https://wordpress.stackexchange.com/users/118534",
"pm_score": 2,
"selected": false,
"text": "<p>This should be possible, WordPress provides the <a href=\"https://developer.wordpress.org/reference/classes/wp_... | 2022/05/22 | [
"https://wordpress.stackexchange.com/questions/405965",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142821/"
] | I have the following functions:
```
function test($post_id){
do_action('test_action',$post_id);
echo $post_id;
}
add_action('test_action',function($post_id){
if ( $post_id == 2 ) //Stop test function execution
}
```
Using the function hooked to `add_action`, how to stop the execution of `test()` function witho... | This should be possible, WordPress provides the [WP\_Session\_Tokens](https://developer.wordpress.org/reference/classes/wp_session_tokens/) class to manage logged in sessions. Then it's just a matter of connecting it to the cron. The following is a simple plugin file which I think should do it. Add it to the plugins di... |
405,993 | <p>I am using <code>get_pages</code> to pull the children pages from a parent and listing them in a similar way to the standard WP loop for pages. This works well using the code referenced below - however.. what I would like to be able to do is to list a page I know the ID for at the top irrespective of its publish dat... | [
{
"answer_id": 405901,
"author": "Tim",
"author_id": 118534,
"author_profile": "https://wordpress.stackexchange.com/users/118534",
"pm_score": 2,
"selected": false,
"text": "<p>This should be possible, WordPress provides the <a href=\"https://developer.wordpress.org/reference/classes/wp_... | 2022/05/23 | [
"https://wordpress.stackexchange.com/questions/405993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/176049/"
] | I am using `get_pages` to pull the children pages from a parent and listing them in a similar way to the standard WP loop for pages. This works well using the code referenced below - however.. what I would like to be able to do is to list a page I know the ID for at the top irrespective of its publish date (I am listin... | This should be possible, WordPress provides the [WP\_Session\_Tokens](https://developer.wordpress.org/reference/classes/wp_session_tokens/) class to manage logged in sessions. Then it's just a matter of connecting it to the cron. The following is a simple plugin file which I think should do it. Add it to the plugins di... |
406,014 | <p>I'm wondering if there is a way to remove the typography and custom color panels from the sidebar for <em>just</em> the paragraph block.</p>
<p>I've currently written a function that I've added add_theme_support to for the typography panel and custom color picker but it's affecting every block that can utilize those... | [
{
"answer_id": 405901,
"author": "Tim",
"author_id": 118534,
"author_profile": "https://wordpress.stackexchange.com/users/118534",
"pm_score": 2,
"selected": false,
"text": "<p>This should be possible, WordPress provides the <a href=\"https://developer.wordpress.org/reference/classes/wp_... | 2022/05/23 | [
"https://wordpress.stackexchange.com/questions/406014",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/222462/"
] | I'm wondering if there is a way to remove the typography and custom color panels from the sidebar for *just* the paragraph block.
I've currently written a function that I've added add\_theme\_support to for the typography panel and custom color picker but it's affecting every block that can utilize those things. Here ... | This should be possible, WordPress provides the [WP\_Session\_Tokens](https://developer.wordpress.org/reference/classes/wp_session_tokens/) class to manage logged in sessions. Then it's just a matter of connecting it to the cron. The following is a simple plugin file which I think should do it. Add it to the plugins di... |
406,113 | <p>If I need to edit a specific post then I need to click the "All Posts" link and then find it. It would be nice to click directly on a link from within the popup hover sub menu.</p>
<p>Something like this:</p>
<p><a href="https://i.stack.imgur.com/48y7s.png" rel="nofollow noreferrer"><img src="https://i.sta... | [
{
"answer_id": 406114,
"author": "IT goldman",
"author_id": 222554,
"author_profile": "https://wordpress.stackexchange.com/users/222554",
"pm_score": 1,
"selected": false,
"text": "<p>Yes you can. By hooking into the <code>admin_menu</code> hook you can add sub menu pages, and they will ... | 2022/05/26 | [
"https://wordpress.stackexchange.com/questions/406113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/222554/"
] | If I need to edit a specific post then I need to click the "All Posts" link and then find it. It would be nice to click directly on a link from within the popup hover sub menu.
Something like this:
[](https://i.stack.imgur.com/... | Yes you can. By hooking into the `admin_menu` hook you can add sub menu pages, and they will appear
on hover by default. All you have to do is iterate the recent posts and add them one by one.
```
add_action('admin_menu', function () {
$args = array(
'post_type' => 'post',
'post_status' => 'publish... |
406,123 | <p>How can I disable wordpress login temporarily even for administrator users? is there any solution?</p>
| [
{
"answer_id": 406124,
"author": "Bysander",
"author_id": 47618,
"author_profile": "https://wordpress.stackexchange.com/users/47618",
"pm_score": 2,
"selected": false,
"text": "<p>You could hook into the <a href=\"https://developer.wordpress.org/reference/hooks/wp_authenticate_user/\" re... | 2022/05/26 | [
"https://wordpress.stackexchange.com/questions/406123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/154510/"
] | How can I disable wordpress login temporarily even for administrator users? is there any solution? | You could hook into the [`wp_authenticate_user` filter](https://developer.wordpress.org/reference/hooks/wp_authenticate_user/) and return an error.
Something like:
```php
add_filter( 'wp_authenticate_user', 'wpse_406123_stop_login', -1 );
function wpse_406123_stop_login() {
$message = new WP_Error( 'login_disabl... |