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 |
|---|---|---|---|---|---|---|
309,219 | <p>new here and to wordpress plugins development, go easy on me :D</p>
<p>Anyway, I am trying to create a new plugin and I am getting a 500 error.
I changed <code>WP_DEBUG</code> in config.php to true in order to see what is causing the 500 error and got this message:</p>
<p><code>Fatal error: Uncaught Error: Call to... | [
{
"answer_id": 309239,
"author": "Futuritous",
"author_id": 122392,
"author_profile": "https://wordpress.stackexchange.com/users/122392",
"pm_score": 2,
"selected": false,
"text": "<p>If you want to check one Plugin's Function / Class etc. from another Plugin, then it's best to use a hoo... | 2018/07/22 | [
"https://wordpress.stackexchange.com/questions/309219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147331/"
] | new here and to wordpress plugins development, go easy on me :D
Anyway, I am trying to create a new plugin and I am getting a 500 error.
I changed `WP_DEBUG` in config.php to true in order to see what is causing the 500 error and got this message:
`Fatal error: Uncaught Error: Call to undefined function is_woocommerc... | If you want to check one Plugin's Function / Class etc. from another Plugin, then it's best to use a hook like [`plugins_loaded`](https://codex.wordpress.org/Plugin_API/Action_Reference/plugins_loaded).
Based on this, your Plugin CODE will look like:
```
<?php
/*
Plugin Name: YOUR PLUGIN NAME
*/
defined( 'ABSPATH' )... |
309,222 | <p>My website is a product review website. I'm using woocomerce in order to store all products and let user be able to search them by category and attributes.</p>
<p>Due this, I would like to remove some unnecessary options from my wordpress admin like inventory and shipping.</p>
<p>.<a href="https://i.stack.imgur.co... | [
{
"answer_id": 309281,
"author": "Sitezilla",
"author_id": 143362,
"author_profile": "https://wordpress.stackexchange.com/users/143362",
"pm_score": 0,
"selected": false,
"text": "<p>Do you give users access to the backpanel? Shipping and inventory are not attributes that really distract... | 2018/07/22 | [
"https://wordpress.stackexchange.com/questions/309222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97543/"
] | My website is a product review website. I'm using woocomerce in order to store all products and let user be able to search them by category and attributes.
Due this, I would like to remove some unnecessary options from my wordpress admin like inventory and shipping.
.[{
unset($tabs['inventory']);
unset($tabs['shipping']);
return($tabs);
}
add_filter('woocommerce_product_data_tabs', 'remove_linked_products', 10, 1);
/*Remove Virtual and Downloadebl... |
309,223 | <p>I have created a code through which the current user can add other users to his project. These users are only shown on the project page. They will not have any right to modify the project.</p>
<p>Once these users are inserted to database it sends an email to them. I want to restrict sending mail to the current user... | [
{
"answer_id": 309306,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 1,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>//after $wpdb->insert function\n\n$current_user = wp_get_current_user... | 2018/07/22 | [
"https://wordpress.stackexchange.com/questions/309223",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124069/"
] | I have created a code through which the current user can add other users to his project. These users are only shown on the project page. They will not have any right to modify the project.
Once these users are inserted to database it sends an email to them. I want to restrict sending mail to the current user. How can ... | I have found the answer. Here it is:
```
if ( ! empty( $member_result ) ) {
$user_emails = $member_details->user_email;
for ($i=1; $i < count($user_emails); $i++) {
$user_email[] = $user_emails[$i];
}
$to = $user_email;
$subject = "Congrats! You are added to the Project - " . "'" . $project_title . "'";
$mes... |
309,240 | <p>I've cloned the production site at example.com to my own dev server, calling it example.mydomain.com. It displays OK, as long as I use port 8080 (bypassing my varnish server).</p>
<p>I can successfully log in to the <code>wp-admin</code> page at <strong>example.com</strong>, but I can't reach the page at <strong>ex... | [
{
"answer_id": 309241,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 2,
"selected": true,
"text": "<p>Check for <code>wp-config.php</code> file.</p>\n\n<p>Find these two lines to your <code>wp-config.php</cod... | 2018/07/22 | [
"https://wordpress.stackexchange.com/questions/309240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147347/"
] | I've cloned the production site at example.com to my own dev server, calling it example.mydomain.com. It displays OK, as long as I use port 8080 (bypassing my varnish server).
I can successfully log in to the `wp-admin` page at **example.com**, but I can't reach the page at **example.mydomain.com/wp-admin** - it redir... | Check for `wp-config.php` file.
Find these two lines to your `wp-config.php`, and make sure "example.com" is the correct location of your site.
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
Also on the database, check for table `wp_options`, check these two **option\_nam... |
309,310 | <p>used this code and that did not worked for me.</p>
<pre><code>echo str_replace( "<br>", "", wp_list_categories(array('title_li' => false, 'style' => false)));
</code></pre>
<p>what did I missed?</p>
| [
{
"answer_id": 309312,
"author": "Trilok",
"author_id": 145962,
"author_profile": "https://wordpress.stackexchange.com/users/145962",
"pm_score": 1,
"selected": false,
"text": "<pre><code>Please use below code it will help you\n $args = [\n 'style' => 'none',\n 'separator' =... | 2018/07/23 | [
"https://wordpress.stackexchange.com/questions/309310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147385/"
] | used this code and that did not worked for me.
```
echo str_replace( "<br>", "", wp_list_categories(array('title_li' => false, 'style' => false)));
```
what did I missed? | You can replace '<br>' with '' by setting **separator** value
```
echo wp_list_categories(array('title_li' => false, 'style' => false, 'separator' => ''));
``` |
309,331 | <p>I create a table in the footer.</p>
<p>I would like to show some statistics, like total posts, weekly posts, total posts of the specific category.</p>
<p>I just echo total posts with <code>wp_count_posts()->publish;</code></p>
<p>What can I do for the other one?</p>
| [
{
"answer_id": 309333,
"author": "idpokute",
"author_id": 87895,
"author_profile": "https://wordpress.stackexchange.com/users/87895",
"pm_score": 1,
"selected": false,
"text": "<p>Wordpress query supports <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters\" re... | 2018/07/23 | [
"https://wordpress.stackexchange.com/questions/309331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/141105/"
] | I create a table in the footer.
I would like to show some statistics, like total posts, weekly posts, total posts of the specific category.
I just echo total posts with `wp_count_posts()->publish;`
What can I do for the other one? | You already have the total post, so in order to get the total post within the last week, it's better if you do this on your `functions.php` file:
```
function get_posts_count_from_last_week($post_type ='post') {
global $wpdb;
$numposts = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(ID) ".... |
309,395 | <p>Is it possible to add custom meta boxes to the default blocks in Gutenberg? I would need to add a user-defined data-attribute to each block. This data-attribute then would be printed on the frontend to the wrapper element. I havent been able to find any documentation on how to do this.</p>
<p>An image to illustrate... | [
{
"answer_id": 309401,
"author": "Harsh",
"author_id": 131853,
"author_profile": "https://wordpress.stackexchange.com/users/131853",
"pm_score": -1,
"selected": false,
"text": "<p>For custom meta boxes usees in Gutenberg, please check the following link.\n<a href=\"https://wordpress.org/... | 2018/07/24 | [
"https://wordpress.stackexchange.com/questions/309395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97361/"
] | Is it possible to add custom meta boxes to the default blocks in Gutenberg? I would need to add a user-defined data-attribute to each block. This data-attribute then would be printed on the frontend to the wrapper element. I havent been able to find any documentation on how to do this.
An image to illustrate what I me... | Using [filters](https://wordpress.org/gutenberg/handbook/designers-developers/developers/filters/block-filters/) we can modify the props and attributes of blocks.
First we extend the attributes to include the new attribute:
```
const { addFilter } = wp.hooks;
// Register/add the new attribute.
const addExtraAttribute... |
309,403 | <p>I have created an Add / Remove Dynamic input fields. I am using <code>wp_mail();</code> to send mails. I have restricted the first user from receiving mail. I want to send mail to other users. Everything is working properly. The only problem is that every user is getting double emails. <code>wp_mail();</code> create... | [
{
"answer_id": 309406,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 0,
"selected": false,
"text": "<p>The problem here is, you first create an array of all the email addresses, and then in your second \"for\... | 2018/07/24 | [
"https://wordpress.stackexchange.com/questions/309403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124069/"
] | I have created an Add / Remove Dynamic input fields. I am using `wp_mail();` to send mails. I have restricted the first user from receiving mail. I want to send mail to other users. Everything is working properly. The only problem is that every user is getting double emails. `wp_mail();` creates it twice at same time.
... | These `POST` variables: `$_POST['user_email']`, `$_POST['user_role']`, and `$_POST['status']` (which each is an `array`) are connected to each other by their index, hence you can loop through just one of them and use the *same index* (or iterator) to access the items in the *other* arrays.
This should help you underst... |
309,430 | <p>Could someone please help me to add category id with in this query so this will return posts from a certain category? Thanks in advance.</p>
<pre><code><?php foreach(_get($wp_query->posts? : array()) as $n => $post){ setup_postdata($post); ?>
// HTML and post Tags
<?php } ?>
</code></pre>
| [
{
"answer_id": 309481,
"author": "Suraj Rathod",
"author_id": 141555,
"author_profile": "https://wordpress.stackexchange.com/users/141555",
"pm_score": 1,
"selected": true,
"text": "<p>Please follow proper wordpress method not follow someone's code or copy paste code.</p>\n\n<pre><code> ... | 2018/07/24 | [
"https://wordpress.stackexchange.com/questions/309430",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147385/"
] | Could someone please help me to add category id with in this query so this will return posts from a certain category? Thanks in advance.
```
<?php foreach(_get($wp_query->posts? : array()) as $n => $post){ setup_postdata($post); ?>
// HTML and post Tags
<?php } ?>
``` | Please follow proper wordpress method not follow someone's code or copy paste code.
```
/*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-
includes/query.php
*/
$args = array(
//////Category Parameters - Show posts associ... |
309,462 | <p>I migrated my site from localhost (LAMP) to Namecheap and it is broken in that the images it is supposed to load from <code>/wp-content</code> return a 404 error. </p>
<p>I can login to wp-admin and I can see the pages which load menus and text correctly. But I can't seem to get the images to load, I have tried:</p... | [
{
"answer_id": 309465,
"author": "juggler",
"author_id": 147502,
"author_profile": "https://wordpress.stackexchange.com/users/147502",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like your localhost site had WordPress installed in the root directory but your production site is... | 2018/07/25 | [
"https://wordpress.stackexchange.com/questions/309462",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118088/"
] | I migrated my site from localhost (LAMP) to Namecheap and it is broken in that the images it is supposed to load from `/wp-content` return a 404 error.
I can login to wp-admin and I can see the pages which load menus and text correctly. But I can't seem to get the images to load, I have tried:
* flushing permalinks
... | It looks like your localhost site had WordPress installed in the root directory but your production site is in a sub-directory.
You should review the instructions in the the WordPress Codex for [Moving WordPress](https://codex.wordpress.org/Moving_WordPress "Moving WordPress") to see if you missed any steps. It descri... |
309,535 | <pre><code><?php
$args = array(
'post_type'=>'weather_today',
'orderby'=>'ID',
'order'=>'ASC',
'posts_per_page'=>1
);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ( have_posts() ) : the_post();
the_content();
... | [
{
"answer_id": 309538,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>Try this </p>\n\n<pre><code><?php\n $args = array(\n 'post_type'=>'weather_today',\n 'order... | 2018/07/25 | [
"https://wordpress.stackexchange.com/questions/309535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77764/"
] | ```
<?php
$args = array(
'post_type'=>'weather_today',
'orderby'=>'ID',
'order'=>'ASC',
'posts_per_page'=>1
);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ( have_posts() ) : the_post();
the_content();
endwhile;
}
wp_... | Try this
```
<?php
$args = array(
'post_type'=>'weather_today',
'orderby'=>'ID',
'order'=>'ASC',
'posts_per_page'=>1
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
//loop
endwhile;
wp_reset_postdata();
?>
``` |
309,548 | <p>I am using wordpress 4.9.7 and would like to add a custom taxonomy to my post-type.</p>
<p>I have packed my code in a <code>mu-plugins</code> folder so that it is required by wordpress. Find below my code:</p>
<pre><code><?php
function computerBoxBuilder_post_types()
{
// Computer Hardware Post Type
reg... | [
{
"answer_id": 309554,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 1,
"selected": false,
"text": "<p>Try to change order of <code>add_action</code>:</p>\n\n<p><code>add_action( 'init', 'computerBoxBuilder_post_ty... | 2018/07/25 | [
"https://wordpress.stackexchange.com/questions/309548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48703/"
] | I am using wordpress 4.9.7 and would like to add a custom taxonomy to my post-type.
I have packed my code in a `mu-plugins` folder so that it is required by wordpress. Find below my code:
```
<?php
function computerBoxBuilder_post_types()
{
// Computer Hardware Post Type
register_post_type('Computer-Hardwar... | Just change this line, it will display in admin
```
register_taxonomy( 'Hardware-Creator', array( 'Computer-Hardware' ), $args );
```
to
```
register_taxonomy( 'Hardware-Creator', array( 'computer-hardware' ), $args );
``` |
309,550 | <p>I tried to make mysite.com/category page where I want to see list of categories.
How to show list of categories I know.
I can not make a link 'category'.
I have tried to call this file 'archive-category.php', but site response 404.
If I tried to call this file 'category.php' , then site route url mysite.com/category... | [
{
"answer_id": 309554,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 1,
"selected": false,
"text": "<p>Try to change order of <code>add_action</code>:</p>\n\n<p><code>add_action( 'init', 'computerBoxBuilder_post_ty... | 2018/07/25 | [
"https://wordpress.stackexchange.com/questions/309550",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147561/"
] | I tried to make mysite.com/category page where I want to see list of categories.
How to show list of categories I know.
I can not make a link 'category'.
I have tried to call this file 'archive-category.php', but site response 404.
If I tried to call this file 'category.php' , then site route url mysite.com/category/in... | Just change this line, it will display in admin
```
register_taxonomy( 'Hardware-Creator', array( 'Computer-Hardware' ), $args );
```
to
```
register_taxonomy( 'Hardware-Creator', array( 'computer-hardware' ), $args );
``` |
309,564 | <p>I appreciate all help in advance. I am building a fairly customised website using Avada theme and BNE Flyouts.</p>
<p>I need to be able to enable the Avada's Fusion Builder when editing flyouts, so it can be edited in drag and drop mode.</p>
<p>I have tried enabling both for custom post types, but still when I go ... | [
{
"answer_id": 309554,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 1,
"selected": false,
"text": "<p>Try to change order of <code>add_action</code>:</p>\n\n<p><code>add_action( 'init', 'computerBoxBuilder_post_ty... | 2018/07/26 | [
"https://wordpress.stackexchange.com/questions/309564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143166/"
] | I appreciate all help in advance. I am building a fairly customised website using Avada theme and BNE Flyouts.
I need to be able to enable the Avada's Fusion Builder when editing flyouts, so it can be edited in drag and drop mode.
I have tried enabling both for custom post types, but still when I go to edit the flyou... | Just change this line, it will display in admin
```
register_taxonomy( 'Hardware-Creator', array( 'Computer-Hardware' ), $args );
```
to
```
register_taxonomy( 'Hardware-Creator', array( 'computer-hardware' ), $args );
``` |
309,610 | <p>I created a custom template. It contains 3 columns, and the middle column should only display the post thumbnail. But no matter what size attribute I'm setting, it's not changing the size the way I want. I'd like the image to take over most of the space from that column.</p>
<pre><code> <div class="col-lg-4"&... | [
{
"answer_id": 309554,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 1,
"selected": false,
"text": "<p>Try to change order of <code>add_action</code>:</p>\n\n<p><code>add_action( 'init', 'computerBoxBuilder_post_ty... | 2018/07/26 | [
"https://wordpress.stackexchange.com/questions/309610",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/137532/"
] | I created a custom template. It contains 3 columns, and the middle column should only display the post thumbnail. But no matter what size attribute I'm setting, it's not changing the size the way I want. I'd like the image to take over most of the space from that column.
```
<div class="col-lg-4">
.. first ... | Just change this line, it will display in admin
```
register_taxonomy( 'Hardware-Creator', array( 'Computer-Hardware' ), $args );
```
to
```
register_taxonomy( 'Hardware-Creator', array( 'computer-hardware' ), $args );
``` |
309,647 | <p>I want to add a filter to a form submission
<a href="https://gravitywp.com/capitalize-fields-in-gravity-forms/" rel="nofollow noreferrer">like it is done here</a>.</p>
<pre><code>add_action('gform_pre_submission_6', 'capitalize_fields_6');
function capitalize_fields_6($form){
// Code here
}
</code></pre>
<p>My... | [
{
"answer_id": 309648,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>If you look at the list of Forms (Forms > Forms) in the back end there's a column that tells you the ID.... | 2018/07/26 | [
"https://wordpress.stackexchange.com/questions/309647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145214/"
] | I want to add a filter to a form submission
[like it is done here](https://gravitywp.com/capitalize-fields-in-gravity-forms/).
```
add_action('gform_pre_submission_6', 'capitalize_fields_6');
function capitalize_fields_6($form){
// Code here
}
```
My question is, how do you get the form ID on the WP admin side? ... | If you look at the list of Forms (Forms > Forms) in the back end there's a column that tells you the ID. You can also get it from the top of the screen when editing a form. Next to the form's Title there's an orange box that says "ID: 6". |
309,652 | <p>I'm trying to cutomise the TinyMce editor within WordPress and I took this code from an older WP site I did, but the buttons I have set don't seem to be working, for example, this is what I have:</p>
<pre><code>add_filter( 'tiny_mce_before_init', 'blm_format_tiny_mce' );
function blm_format_tiny_mce( $in ) {
$... | [
{
"answer_id": 309648,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>If you look at the list of Forms (Forms > Forms) in the back end there's a column that tells you the ID.... | 2018/07/26 | [
"https://wordpress.stackexchange.com/questions/309652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1839/"
] | I'm trying to cutomise the TinyMce editor within WordPress and I took this code from an older WP site I did, but the buttons I have set don't seem to be working, for example, this is what I have:
```
add_filter( 'tiny_mce_before_init', 'blm_format_tiny_mce' );
function blm_format_tiny_mce( $in ) {
$in['remove_lin... | If you look at the list of Forms (Forms > Forms) in the back end there's a column that tells you the ID. You can also get it from the top of the screen when editing a form. Next to the form's Title there's an orange box that says "ID: 6". |
309,670 | <p>When I add a new WP_Query, everything works, but if I add a 'tax_query' with a taxonomy, it doesn't pull the posts. post_count would always be 0.</p>
<pre><code> $products = new WP_Query([
'post_type' => 'post',
'tax_query' => [
[
'taxonomy' => 'show_product_o... | [
{
"answer_id": 309669,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Such a link does exist and is already in the admin menu:</p>\n\n<p><a href=\"https://i.stack.imgur.com/lSXwd... | 2018/07/26 | [
"https://wordpress.stackexchange.com/questions/309670",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147639/"
] | When I add a new WP\_Query, everything works, but if I add a 'tax\_query' with a taxonomy, it doesn't pull the posts. post\_count would always be 0.
```
$products = new WP_Query([
'post_type' => 'post',
'tax_query' => [
[
'taxonomy' => 'show_product_on_only_premium',
... | You can use this function `<?php get_edit_user_link( $user_id ) ?>`
Read more: <https://codex.wordpress.org/Function_Reference/get_edit_user_link>
Best regards, |
309,697 | <p>I've created a custom post type & taxonomy, however when I go to my taxonomy page it throws a 404 error and I can't understand why.</p>
<pre><code>// Register Custom Post Type
function portfolio_post_type() {
register_taxonomy_for_object_type('category','portfolio');
register_post_type( 'portfolio',
... | [
{
"answer_id": 309669,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Such a link does exist and is already in the admin menu:</p>\n\n<p><a href=\"https://i.stack.imgur.com/lSXwd... | 2018/07/27 | [
"https://wordpress.stackexchange.com/questions/309697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115473/"
] | I've created a custom post type & taxonomy, however when I go to my taxonomy page it throws a 404 error and I can't understand why.
```
// Register Custom Post Type
function portfolio_post_type() {
register_taxonomy_for_object_type('category','portfolio');
register_post_type( 'portfolio',
array(
... | You can use this function `<?php get_edit_user_link( $user_id ) ?>`
Read more: <https://codex.wordpress.org/Function_Reference/get_edit_user_link>
Best regards, |
309,700 | <p>Each field of the default Woocommerce form checkout has this markup: </p>
<pre><code><p class="form-row form-row-first validate-required" id="billing_first_name_field" data-priority="10">
<label for="billing_first_name" class="">Name&nbsp;
<abbr class="required" title="required"&g... | [
{
"answer_id": 309788,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 4,
"selected": true,
"text": "<p>There is no hook <code>woocommerce_form_field</code>, there is hook <code>woocommerce_form_field_{$args[type]}</... | 2018/07/27 | [
"https://wordpress.stackexchange.com/questions/309700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/100514/"
] | Each field of the default Woocommerce form checkout has this markup:
```
<p class="form-row form-row-first validate-required" id="billing_first_name_field" data-priority="10">
<label for="billing_first_name" class="">Name
<abbr class="required" title="required">*</abbr>
</label>
<span ... | There is no hook `woocommerce_form_field`, there is hook `woocommerce_form_field_{$args[type]}` [(doc)](https://docs.woocommerce.com/wc-apidocs/hook-docs.html).
`$args[type]` can be (look [here](https://docs.woocommerce.com/wc-apidocs/source-function-woocommerce_form_field.html#2147) for available options):
* text,
... |
309,706 | <p>I have moved my wordpress from one hosting to other but it gives database error </p>
<pre><code>Warning: mysqli_real_connect(): (28000/1045): Access denied for user 'user'@'localhost' (using password: YES) in /home/########/public_html/fvas/wp-includes/wp-db.php on line 1531
</code></pre>
<p>I have change the data... | [
{
"answer_id": 309788,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 4,
"selected": true,
"text": "<p>There is no hook <code>woocommerce_form_field</code>, there is hook <code>woocommerce_form_field_{$args[type]}</... | 2018/07/27 | [
"https://wordpress.stackexchange.com/questions/309706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140035/"
] | I have moved my wordpress from one hosting to other but it gives database error
```
Warning: mysqli_real_connect(): (28000/1045): Access denied for user 'user'@'localhost' (using password: YES) in /home/########/public_html/fvas/wp-includes/wp-db.php on line 1531
```
I have change the database name in wp-config.php... | There is no hook `woocommerce_form_field`, there is hook `woocommerce_form_field_{$args[type]}` [(doc)](https://docs.woocommerce.com/wc-apidocs/hook-docs.html).
`$args[type]` can be (look [here](https://docs.woocommerce.com/wc-apidocs/source-function-woocommerce_form_field.html#2147) for available options):
* text,
... |
309,727 | <p>Here is the code which gives me only day and month.</p>
<p>I want to show all: year, month, day, hour and minutes.</p>
<p>How can I do this?</p>
<pre><code>print '<time class="entry-date updated" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( the_date('F j, Y','G:i')) . '</time>';
... | [
{
"answer_id": 309728,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": false,
"text": "<h2>PHP Date Format in WordPress function:</h2>\n\n<p>You'll have to use the proper <a href=\"http://www.php.net... | 2018/07/27 | [
"https://wordpress.stackexchange.com/questions/309727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147675/"
] | Here is the code which gives me only day and month.
I want to show all: year, month, day, hour and minutes.
How can I do this?
```
print '<time class="entry-date updated" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( the_date('F j, Y','G:i')) . '</time>';
``` | PHP Date Format in WordPress function:
--------------------------------------
You'll have to use the proper [`date format string`](http://www.php.net/manual/en/function.date.php) (as used in PHP `date` function) in the WordPress [`get_the_date()`](https://developer.wordpress.org/reference/functions/get_the_date/) func... |
309,735 | <p>I have created a WP loop to display Services from 'Services' Custom Post Type: </p>
<p><strong>Here is the code:</strong></p>
<pre><code><?php
$services_loop = new WP_Query( array( 'post_type' => 'service', 'posts_per_page' => -1 ) );
if ( $services_loop->have_posts() ) :
while ( $servi... | [
{
"answer_id": 309728,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": false,
"text": "<h2>PHP Date Format in WordPress function:</h2>\n\n<p>You'll have to use the proper <a href=\"http://www.php.net... | 2018/07/27 | [
"https://wordpress.stackexchange.com/questions/309735",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/137372/"
] | I have created a WP loop to display Services from 'Services' Custom Post Type:
**Here is the code:**
```
<?php
$services_loop = new WP_Query( array( 'post_type' => 'service', 'posts_per_page' => -1 ) );
if ( $services_loop->have_posts() ) :
while ( $services_loop->have_posts() ) : $services_loop->the... | PHP Date Format in WordPress function:
--------------------------------------
You'll have to use the proper [`date format string`](http://www.php.net/manual/en/function.date.php) (as used in PHP `date` function) in the WordPress [`get_the_date()`](https://developer.wordpress.org/reference/functions/get_the_date/) func... |
309,736 | <p>I have a div and inside I wish display by random a post from category-a or a product from category-b. I'm looking for a query to do that.</p>
<p>I tried this: </p>
<pre><code> <?php
$args = array(
'post_type' => array('product', 'post'),
'posts_per_page' => 1,
'cat' =>... | [
{
"answer_id": 309747,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": -1,
"selected": false,
"text": "<p>you don't need global $product, and is_singular() is a template function, not usable in the loop, al... | 2018/07/27 | [
"https://wordpress.stackexchange.com/questions/309736",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/141407/"
] | I have a div and inside I wish display by random a post from category-a or a product from category-b. I'm looking for a query to do that.
I tried this:
```
<?php
$args = array(
'post_type' => array('product', 'post'),
'posts_per_page' => 1,
'cat' => 1,2,
'orderby' => 'RAN... | The following code selects IDs of all posts type `product` and `post`, which belong to terms `category-a` or `category-b`, with `taxonomy_01` and `taxonomy_02`, respectively.
```
$args = [
'post_type' => ['product','post'],
'posts_per_page' => -1,
'fields' => 'ids',
'tax_query' => [
'relation' ... |
309,748 | <p>In my contact form I need a drop down for order quantities. On selection of "other", I want to display a number field for input. Below is my code but it's not working. Can anyone help? Thanks in advance.</p>
<pre><code><script language="javascript" type="text/javascript">
document.getElementById("OrderQuantit... | [
{
"answer_id": 309769,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 0,
"selected": false,
"text": "<p>Note that <strong>[select* drop-down-menu id=\"OrderQuantity\"]</strong> CF7 shortcode will not outpu... | 2018/07/27 | [
"https://wordpress.stackexchange.com/questions/309748",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147684/"
] | In my contact form I need a drop down for order quantities. On selection of "other", I want to display a number field for input. Below is my code but it's not working. Can anyone help? Thanks in advance.
```
<script language="javascript" type="text/javascript">
document.getElementById("OrderQuantity").addEventListener... | You can try this add-on to make conditional fields.
<https://nl.wordpress.org/plugins/cf7-conditional-fields/> |
309,754 | <p>With the latest version of WordPress, how can we publish revisions of a post, in addition to showing the latest post? </p>
<p>I want my front end users to see multiple versions of the same post. The same post is going to change "some" of its content every friday. All weekly versions will then be compared by non-ad... | [
{
"answer_id": 309761,
"author": "Martin Jarvis",
"author_id": 147693,
"author_profile": "https://wordpress.stackexchange.com/users/147693",
"pm_score": 0,
"selected": false,
"text": "<p>That's an interesting idea. There are, of course, manual ways to do it - e.g. cloning the post, makin... | 2018/07/27 | [
"https://wordpress.stackexchange.com/questions/309754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98671/"
] | With the latest version of WordPress, how can we publish revisions of a post, in addition to showing the latest post?
I want my front end users to see multiple versions of the same post. The same post is going to change "some" of its content every friday. All weekly versions will then be compared by non-administrator... | **I suggest you look at** <https://codex.wordpress.org/Function_Reference/wp_get_post_revisions>
```
<?php
// Lets get the revisions of the given $post we are accessing by ID ( you are probably going to want to limit your internal revision count for this
$revisions = wp_get_post_revisions($po... |
309,780 | <p>I'm having a problem with a custom function. This function counts the post and assigns a number to that post. It then saves the number to a custom field and then updates the permalink to the post.</p>
<p>My problems are:</p>
<p>1). When a post is saved, it saves a post twice (Shows up as 2 revisions). I'm trying t... | [
{
"answer_id": 309786,
"author": "Andrius Vlasovas",
"author_id": 147625,
"author_profile": "https://wordpress.stackexchange.com/users/147625",
"pm_score": 2,
"selected": false,
"text": "<p>Always lean back on WordPress Codex.</p>\n\n<p>In this case, you are using 'save_post' action hook... | 2018/07/28 | [
"https://wordpress.stackexchange.com/questions/309780",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8049/"
] | I'm having a problem with a custom function. This function counts the post and assigns a number to that post. It then saves the number to a custom field and then updates the permalink to the post.
My problems are:
1). When a post is saved, it saves a post twice (Shows up as 2 revisions). I'm trying to find a way so t... | It duplicate because when you run the `wp_update_post()`, it will use the `wp_insert_post()` function and the action `save_post` will run again.
please use the filter `wp_insert_post_data` to filter the value before save. <https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data>
Example:
```
func... |
309,806 | <p>I'm trying to disable all functionality related to pingbacks/trackbacks in WordPress and so far I have this:</p>
<pre><code>add_action( 'pre_ping', 'disable_pingback' );
function disable_pingback( &$links ) {
foreach ( $links as $l => $link ) {
if ( 0 === strpos( $link, get_option( 'home' ) ) ) ... | [
{
"answer_id": 309809,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>Your code is correct, AFAIK. It will disable the ability to do trackback/pings. It doesn't remove that... | 2018/07/28 | [
"https://wordpress.stackexchange.com/questions/309806",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1839/"
] | I'm trying to disable all functionality related to pingbacks/trackbacks in WordPress and so far I have this:
```
add_action( 'pre_ping', 'disable_pingback' );
function disable_pingback( &$links ) {
foreach ( $links as $l => $link ) {
if ( 0 === strpos( $link, get_option( 'home' ) ) ) {
unset( ... | The WordPress Codex solutions weren't working for me regardless of what parameters I used or the priorities set, probably because my setup is pretty complex or as others have commented. The first chunk of code may work for you but I don't have a default environment at the moment to test. The second chunk of code defini... |
309,828 | <p>Question regarding template structure: </p>
<p>In a custom loop, I inserted a get_template_part('resources', 'layout') which contains the following markup:</p>
<pre><code><div class="custom-content">
<?php if ( get_post_type() === 'videos' ) { ?>
<div class="video-popup">
... | [
{
"answer_id": 309809,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>Your code is correct, AFAIK. It will disable the ability to do trackback/pings. It doesn't remove that... | 2018/07/29 | [
"https://wordpress.stackexchange.com/questions/309828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146256/"
] | Question regarding template structure:
In a custom loop, I inserted a get\_template\_part('resources', 'layout') which contains the following markup:
```
<div class="custom-content">
<?php if ( get_post_type() === 'videos' ) { ?>
<div class="video-popup">
<?php the_field('video_popup'); ?>
... | The WordPress Codex solutions weren't working for me regardless of what parameters I used or the priorities set, probably because my setup is pretty complex or as others have commented. The first chunk of code may work for you but I don't have a default environment at the moment to test. The second chunk of code defini... |
309,840 | <p>Hope someone can help, am looking for some suggestions on how to override/replace some functions that are loading in a parent theme and move them into the child theme so we can make alterations to the files themselves in the child theme.</p>
<p>We will "duplicate" the structure and files into the child theme, but c... | [
{
"answer_id": 309842,
"author": "Pim",
"author_id": 50432,
"author_profile": "https://wordpress.stackexchange.com/users/50432",
"pm_score": 0,
"selected": false,
"text": "<p>Simply use</p>\n\n<pre><code>function moto_setup() { \n // Your new moto_setup function\n}\n</code></pre>\n\n<p>... | 2018/07/29 | [
"https://wordpress.stackexchange.com/questions/309840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147731/"
] | Hope someone can help, am looking for some suggestions on how to override/replace some functions that are loading in a parent theme and move them into the child theme so we can make alterations to the files themselves in the child theme.
We will "duplicate" the structure and files into the child theme, but can't yet f... | You can't necessarily replace entire arbitrary files with a child theme.
WordPress will automatically look in the child theme for replacements for the templates in the [template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/), as well as a couple of additional files like searchform.php o... |
309,849 | <p>I am able to get a list of its subcategories in a category archive page using below code in <code>archive-product.php</code> but I want to display the list of the products currently assigned to each subcategory.</p>
<pre><code><?php
$parentid = get_queried_object_id();
$args = array(
'parent' =&g... | [
{
"answer_id": 309859,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 2,
"selected": true,
"text": "<pre><code><?php\n $parentid = get_queried_object_id();\n $args = array(\n 'parent' =>... | 2018/07/29 | [
"https://wordpress.stackexchange.com/questions/309849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147735/"
] | I am able to get a list of its subcategories in a category archive page using below code in `archive-product.php` but I want to display the list of the products currently assigned to each subcategory.
```
<?php
$parentid = get_queried_object_id();
$args = array(
'parent' => $parentid
);
$catego... | ```
<?php
$parentid = get_queried_object_id();
$args = array(
'parent' => $parentid
);
$categories = get_terms(
'product_cat', $args
);
if ( $categories ) :
foreach ( $categories as $category ) :
echo esc_html($category->name);
$products = new WP_Q... |
309,862 | <p>How can I check if the editor that is currently being used is Gutenberg in a WordPress plugin?</p>
<p>I need this because Gutenberg lacks <code>post_submitbox_misc_actions</code>, so I need a fallback which will only be used if the current editor is Gutenberg.</p>
| [
{
"answer_id": 309955,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": false,
"text": "<h2>Necessary API Functions/Methods:</h2>\n<p>You'll need <a href=\"https://developer.wordpress.org/reference/cl... | 2018/07/29 | [
"https://wordpress.stackexchange.com/questions/309862",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123649/"
] | How can I check if the editor that is currently being used is Gutenberg in a WordPress plugin?
I need this because Gutenberg lacks `post_submitbox_misc_actions`, so I need a fallback which will only be used if the current editor is Gutenberg. | Necessary API Functions/Methods:
--------------------------------
You'll need [`WP_Screen::is_block_editor()`](https://developer.wordpress.org/reference/classes/wp_screen/is_block_editor/) method to check if you are currently in the Gutenberg Editor (Since WordPress 5.0).
Also, if you install Gutenberg as a separate ... |
309,883 | <p>Say I have a plugin which fires the <code>plugin_1_action</code> when it initializes.</p>
<p>Now, because I wanna extend that plugin, I'll hook into <code>plugin_1_action</code>, but what if my plugin was installed after that plugin? Won't that plugin run first and so, I'll lose the chance to catch the <code>plugin... | [
{
"answer_id": 309884,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>If the plugin indeed runs <code>plugin_1_action</code> <em>as soon as it's loaded</em>, meaning that th... | 2018/07/30 | [
"https://wordpress.stackexchange.com/questions/309883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143406/"
] | Say I have a plugin which fires the `plugin_1_action` when it initializes.
Now, because I wanna extend that plugin, I'll hook into `plugin_1_action`, but what if my plugin was installed after that plugin? Won't that plugin run first and so, I'll lose the chance to catch the `plugin_1_action` hook?
It's just weird and... | If the plugin indeed runs `plugin_1_action` *as soon as it's loaded*, meaning that the `do_action()` call is just sitting in the plugin file and not inside a function that's hooked later, then yes, you're correct: you won't be able to hook into it if your plugin is loaded later.
This is almost never how plugins work t... |
309,896 | <p>How can i echo product id and product_item_key of each cart item instead of total count ?</p>
<pre><code>function iconic_cart_count_fragments( $fragments ) {
$fragments['div.header-cart-count'] = '<div class="header-cart-count">' . WC()->cart->get_cart_contents_count() . '</div>';
return... | [
{
"answer_id": 309905,
"author": "Techno Deviser",
"author_id": 146401,
"author_profile": "https://wordpress.stackexchange.com/users/146401",
"pm_score": 1,
"selected": false,
"text": "<p>Try something like this</p>\n\n<pre><code>global $woocommerce;\nforeach ( $woocommerce->cart->... | 2018/07/30 | [
"https://wordpress.stackexchange.com/questions/309896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147754/"
] | How can i echo product id and product\_item\_key of each cart item instead of total count ?
```
function iconic_cart_count_fragments( $fragments ) {
$fragments['div.header-cart-count'] = '<div class="header-cart-count">' . WC()->cart->get_cart_contents_count() . '</div>';
return $fragments;
}
```
Thank Y... | Techno Deviser, probably by mistake, in the `foreach` loop set value to `$fragments['div.header-cart-count']` instead append it.
Try this modification:
```
function iconic_cart_count_fragments( $fragments ) {
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$fragments['div.header-c... |
309,907 | <p>I'm fairly new to Wordpress. I'm using the shop-isle theme that has a default navigation menu. I'm trying to override this with a fancy ‘Ubermenu’ plugin but the default collapse symbol keeps overriding the plugin. </p>
<p>The theme header is loaded from directory shop-isle/inc/structure/header.php. </p>
<p>I copi... | [
{
"answer_id": 309908,
"author": "Alex Sancho",
"author_id": 2536,
"author_profile": "https://wordpress.stackexchange.com/users/2536",
"pm_score": 1,
"selected": false,
"text": "<p>You need to copy to your child and edit the function where the file is included, probably ´shop_isle_primar... | 2018/07/30 | [
"https://wordpress.stackexchange.com/questions/309907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147762/"
] | I'm fairly new to Wordpress. I'm using the shop-isle theme that has a default navigation menu. I'm trying to override this with a fancy ‘Ubermenu’ plugin but the default collapse symbol keeps overriding the plugin.
The theme header is loaded from directory shop-isle/inc/structure/header.php.
I copied the entire dir... | You need to copy to your child and edit the function where the file is included, probably ´shop\_isle\_primary\_navigation´, to change the path where the file is located. Wordpress only loads automatically from child the default files, that's the ones defined in template hierarchy. You can read more about this at <http... |
309,938 | <p>i need to insert wp_users -> user_login field to wp_terms name and slugs field,when a new user registering. </p>
<p>my requirement is admin needs to assign posts to specific users, that is admin need to add a post to user1 ,but user2 should not see that.for this i created a custom post and add taxonomy for that.An... | [
{
"answer_id": 309961,
"author": "Souvik Sikdar",
"author_id": 130021,
"author_profile": "https://wordpress.stackexchange.com/users/130021",
"pm_score": 0,
"selected": false,
"text": "<p>There is a simple way to to add username as the term of specific taxonomie.\nYou need to use \"<stron... | 2018/07/30 | [
"https://wordpress.stackexchange.com/questions/309938",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143452/"
] | i need to insert wp\_users -> user\_login field to wp\_terms name and slugs field,when a new user registering.
my requirement is admin needs to assign posts to specific users, that is admin need to add a post to user1 ,but user2 should not see that.for this i created a custom post and add taxonomy for that.And the te... | i got the solution for this
```
add_action('user_register', function ($user_id) {
$user_info = get_userdata($user_id);
$user_name = $user_info->user_login;
wp_insert_term($user_name, 'user1', array());
}, 10, 1);
``` |
309,939 | <p>I'm building a form with Contact Form 7 and I would need to add multiple fields under a single label and I would need to let the user to add more fields under that same label if needed. I'm using 4 fields as a starting point and I'd like to have like a + sign next to the last field which would add another field to t... | [
{
"answer_id": 309961,
"author": "Souvik Sikdar",
"author_id": 130021,
"author_profile": "https://wordpress.stackexchange.com/users/130021",
"pm_score": 0,
"selected": false,
"text": "<p>There is a simple way to to add username as the term of specific taxonomie.\nYou need to use \"<stron... | 2018/07/30 | [
"https://wordpress.stackexchange.com/questions/309939",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147779/"
] | I'm building a form with Contact Form 7 and I would need to add multiple fields under a single label and I would need to let the user to add more fields under that same label if needed. I'm using 4 fields as a starting point and I'd like to have like a + sign next to the last field which would add another field to the ... | i got the solution for this
```
add_action('user_register', function ($user_id) {
$user_info = get_userdata($user_id);
$user_name = $user_info->user_login;
wp_insert_term($user_name, 'user1', array());
}, 10, 1);
``` |
309,972 | <p>I added this bit of code to my header.php file:</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
if( $('div').hasClass('icheckbox') && $('div').hasClass('disabled') ) {
$('div').parent().addClass('hide_empty');
}
});
</script>
</code></pre>
<p>My goa... | [
{
"answer_id": 309974,
"author": "dhirenpatel22",
"author_id": 124380,
"author_profile": "https://wordpress.stackexchange.com/users/124380",
"pm_score": 0,
"selected": false,
"text": "<p>I have just updated your code...</p>\n\n<pre><code><script type=\"text/javascript\">\n$(documen... | 2018/07/30 | [
"https://wordpress.stackexchange.com/questions/309972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142885/"
] | I added this bit of code to my header.php file:
```
<script type="text/javascript">
$(document).ready(function() {
if( $('div').hasClass('icheckbox') && $('div').hasClass('disabled') ) {
$('div').parent().addClass('hide_empty');
}
});
</script>
```
My goal is to add the class .hide\_empty to the pare... | >
> So, the elements should be changed into `<div class="icheckbox disabled hide_empty" style="">`
>
>
>
that's different from the goal stated in the question where you say you want to add class "hide\_empty" to the parent `<li>` of the `<div class="icheckbox">`. The code posted by @dhirenpatel22 should work to ad... |
309,973 | <p>In WordPress I want to schedule an Event which will run my function (hook) at a specific time (let's say at 6PM) and then it will run again after 15 minutes (means at 6:15 PM) and keep running after every 15 minutes for 3 hours (till 9 PM) and then it dies.</p>
<pre><code>// I have the following code which run afte... | [
{
"answer_id": 309988,
"author": "Kaperto",
"author_id": 147795,
"author_profile": "https://wordpress.stackexchange.com/users/147795",
"pm_score": 0,
"selected": false,
"text": "<p>to do that, it's better to have a cron that is fired every 15 minutes and then you test if it's time to do ... | 2018/07/30 | [
"https://wordpress.stackexchange.com/questions/309973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147498/"
] | In WordPress I want to schedule an Event which will run my function (hook) at a specific time (let's say at 6PM) and then it will run again after 15 minutes (means at 6:15 PM) and keep running after every 15 minutes for 3 hours (till 9 PM) and then it dies.
```
// I have the following code which run after every 6 hour... | Setup WordPress Cron Events
---------------------------
Let's say you want to start the cron at 6PM and keep running the cron after every 15 minutes till 9PM (for 3 hours). Then all cron stops.
>
> **Note:** for the simplicity of implementation, all time entry in the CODE is considered to be GMT/UTC.
>
>
>
For t... |
309,981 | <p>It seems by default WordPress provides fields for site-title and tagline.</p>
<p>I understand how to add (for example) the option to chose a logo, adding <code>add_theme_support( 'custom-logo' );</code> to the functions.php file. However, how do I add fields for 'company name' and 'company division' or for any text... | [
{
"answer_id": 309982,
"author": "David Sword",
"author_id": 132362,
"author_profile": "https://wordpress.stackexchange.com/users/132362",
"pm_score": 3,
"selected": false,
"text": "<p>This is all part of the <a href=\"https://codex.wordpress.org/Theme_Customization_API\" rel=\"noreferre... | 2018/07/30 | [
"https://wordpress.stackexchange.com/questions/309981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147800/"
] | It seems by default WordPress provides fields for site-title and tagline.
I understand how to add (for example) the option to chose a logo, adding `add_theme_support( 'custom-logo' );` to the functions.php file. However, how do I add fields for 'company name' and 'company division' or for any text field that is not al... | You'll have to add your own customizer controls to achieve that.
So for example, if you want to add Company Name, you can use this code:
```
function my_register_additional_customizer_settings( $wp_customize ) {
$wp_customize->add_setting(
'my_company_name',
array(
'default' => '',
... |
310,013 | <p><code>wp_delete_user()</code> function requires user ID and [optional] reassign ID if the content is to be reassigned to another user.</p>
<p>All users' user names are also unique as WP doesn't allow duplicate user names. If I know username, is there no way with just one PHP/mysqli query I can delete the user inste... | [
{
"answer_id": 310016,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>There is no way to do this with only one query. But to be honest - deleting user takes more than one q... | 2018/07/31 | [
"https://wordpress.stackexchange.com/questions/310013",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147821/"
] | `wp_delete_user()` function requires user ID and [optional] reassign ID if the content is to be reassigned to another user.
All users' user names are also unique as WP doesn't allow duplicate user names. If I know username, is there no way with just one PHP/mysqli query I can delete the user instead of run one query t... | There is no way to do this with only one query. But to be honest - deleting user takes more than one query itself...
You shouldn’t use custom SQL for that, because there are many things you could break this way... Always use WP functions, if they exists (what if some plugin logs every deleted user, or what if some oth... |
310,026 | <p>I am trying to enqueuer a script after registering it but I am getting an error.</p>
<p>This is the script:</p>
<pre><code>function _test() {
console.log("Test");
}
</code></pre>
<p>That's the PHP:</p>
<pre><code>function fsg_shortURL() {
echo "Funtion Called";
wp_register_script('_test','/wp-content... | [
{
"answer_id": 310029,
"author": "Kaperto",
"author_id": 147795,
"author_profile": "https://wordpress.stackexchange.com/users/147795",
"pm_score": 0,
"selected": false,
"text": "<p>To add a file located in a directory of the active theme, you have to use <a href=\"https://codex.wordpress... | 2018/07/31 | [
"https://wordpress.stackexchange.com/questions/310026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147331/"
] | I am trying to enqueuer a script after registering it but I am getting an error.
This is the script:
```
function _test() {
console.log("Test");
}
```
That's the PHP:
```
function fsg_shortURL() {
echo "Funtion Called";
wp_register_script('_test','/wp-content/themes/theme-child/js/test.js');
wp_enq... | Simply you've to call the function to execute it:
```
function _test() {
console.log("Test");
}
_test();
``` |
310,036 | <p>I have 4 posts and I displaying 2 posts per page.</p>
<pre><code>$ids = array('16085','16088','16083','16091');
$options = array(
'post_type' => $post_type,
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'meta_query' => $meta_query,
'tax_query' => ... | [
{
"answer_id": 310047,
"author": "VinothRaja",
"author_id": 146008,
"author_profile": "https://wordpress.stackexchange.com/users/146008",
"pm_score": 0,
"selected": false,
"text": "<p>Try this below code</p>\n\n<pre><code>$get_properties = new WP_Query( array( 'post_type' => 'page','p... | 2018/07/31 | [
"https://wordpress.stackexchange.com/questions/310036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127648/"
] | I have 4 posts and I displaying 2 posts per page.
```
$ids = array('16085','16088','16083','16091');
$options = array(
'post_type' => $post_type,
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'post__i... | OK, so you want to define posts order by yourself. WP\_Query allows you to do that - you'll have to use `orderby` => `post__in` to achieve it. And that's what you do.
So why isn't it working? Because of a typo ;)
Ordering posts by `post__in` preserves post ID order given in the 'post\_\_in' array. But you don't pass ... |
310,058 | <p>I downloaded my wordpress site and using it on localhost, but I couldn't. I changed my url in mysql db and followed <a href="https://stackoverflow.com/questions/15557718/after-migration-of-wordpress-website-i-cant-access-the-admin-white-page">this</a> . still I do not have access to my website or wp-admin. </p>
<p>... | [
{
"answer_id": 310047,
"author": "VinothRaja",
"author_id": 146008,
"author_profile": "https://wordpress.stackexchange.com/users/146008",
"pm_score": 0,
"selected": false,
"text": "<p>Try this below code</p>\n\n<pre><code>$get_properties = new WP_Query( array( 'post_type' => 'page','p... | 2018/07/31 | [
"https://wordpress.stackexchange.com/questions/310058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147453/"
] | I downloaded my wordpress site and using it on localhost, but I couldn't. I changed my url in mysql db and followed [this](https://stackoverflow.com/questions/15557718/after-migration-of-wordpress-website-i-cant-access-the-admin-white-page) . still I do not have access to my website or wp-admin.
I have <https://local... | OK, so you want to define posts order by yourself. WP\_Query allows you to do that - you'll have to use `orderby` => `post__in` to achieve it. And that's what you do.
So why isn't it working? Because of a typo ;)
Ordering posts by `post__in` preserves post ID order given in the 'post\_\_in' array. But you don't pass ... |
310,064 | <p>When I logged in on my site this morning I noticed that my user can’t publish anything. I am administrator and the only user on the site.</p>
<p>On Posts and Pages instead of “Publish” I have the “Submit for review” button and if I click on it the page is blank and displays “Sorry you are not allowed to modify this... | [
{
"answer_id": 310047,
"author": "VinothRaja",
"author_id": 146008,
"author_profile": "https://wordpress.stackexchange.com/users/146008",
"pm_score": 0,
"selected": false,
"text": "<p>Try this below code</p>\n\n<pre><code>$get_properties = new WP_Query( array( 'post_type' => 'page','p... | 2018/07/31 | [
"https://wordpress.stackexchange.com/questions/310064",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147835/"
] | When I logged in on my site this morning I noticed that my user can’t publish anything. I am administrator and the only user on the site.
On Posts and Pages instead of “Publish” I have the “Submit for review” button and if I click on it the page is blank and displays “Sorry you are not allowed to modify this post”.
I... | OK, so you want to define posts order by yourself. WP\_Query allows you to do that - you'll have to use `orderby` => `post__in` to achieve it. And that's what you do.
So why isn't it working? Because of a typo ;)
Ordering posts by `post__in` preserves post ID order given in the 'post\_\_in' array. But you don't pass ... |
310,074 | <p>I'm trying to concatenate my <strong>site_url</strong> and a string, but it doesn't work. This is what I'm doing:</p>
<pre><code>$myurl = site_url();
var_dump($myurl);
$url = "https" . $myurl . "/inbox/?fepaction=viewmessage&fep_id=" . $inserted_message->ID;
var_dump($url); die;
</code></pre>
<p>The outp... | [
{
"answer_id": 310087,
"author": "helle",
"author_id": 32871,
"author_profile": "https://wordpress.stackexchange.com/users/32871",
"pm_score": 0,
"selected": false,
"text": "<p>What you are lookgin for is <a href=\"https://codex.wordpress.org/Function_Reference/home_url\" rel=\"nofollow ... | 2018/07/31 | [
"https://wordpress.stackexchange.com/questions/310074",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65180/"
] | I'm trying to concatenate my **site\_url** and a string, but it doesn't work. This is what I'm doing:
```
$myurl = site_url();
var_dump($myurl);
$url = "https" . $myurl . "/inbox/?fepaction=viewmessage&fep_id=" . $inserted_message->ID;
var_dump($url); die;
```
The output looks like this:
>
> string(31) "//zgp.m... | Without knowing exactly what you are trying to do, it seems you want to append query variables to the URL. WordPress has methods for handling that properly, without manual string concatenation.
Look at the documentation for `add_query_arg()` for details:
<https://developer.wordpress.org/reference/functions/add_query_... |
310,081 | <p>I am trying to make an ajax call and I am getting the error:</p>
<pre><code>TypeError: $ is undefined
</code></pre>
<p>This is my function.php file:</p>
<pre><code><?php
// Add custom Theme Functions here
//
function gear_guide_product_view( $atts ) {
$a = shortcode_atts( array(
'id' => '0'
... | [
{
"answer_id": 310089,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>As Milo already said in comment, jQuery is in noConflict mode in WordPress. This way other JS librarie... | 2018/07/31 | [
"https://wordpress.stackexchange.com/questions/310081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147331/"
] | I am trying to make an ajax call and I am getting the error:
```
TypeError: $ is undefined
```
This is my function.php file:
```
<?php
// Add custom Theme Functions here
//
function gear_guide_product_view( $atts ) {
$a = shortcode_atts( array(
'id' => '0'
), $atts );
wp_register_script( 'loa... | As Milo already said in comment, jQuery is in noConflict mode in WordPress. This way other JS libraries can also use $ character...
One way to solve it is using jQuery everywhere in your JS files.
Another is to create block and define $ variable in it:
```
jQuery(function ($) {
$.ajax(...); // here you can use ... |
310,101 | <p>I am developing a section on the front of our website. Our users submit properties to our directory. we would like to show how many properties they have listed and what types. I have got this code but it shows all post counts by all users I just want to show their post count so it would be like Residential Propertie... | [
{
"answer_id": 310109,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>It's a little bit hard to guess, what are you trying to do exactly, but let me try to answer...</p>\n... | 2018/07/31 | [
"https://wordpress.stackexchange.com/questions/310101",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147857/"
] | I am developing a section on the front of our website. Our users submit properties to our directory. we would like to show how many properties they have listed and what types. I have got this code but it shows all post counts by all users I just want to show their post count so it would be like Residential Properties: ... | It's a little bit hard to guess, what are you trying to do exactly, but let me try to answer...
My best guess is that you want to tell, how many properties has given user published in given property type.
So first - why your code doesn't work...
----------------------------------------
`get_term` will get the term i... |
310,126 | <p>i need to Delete wp_terms -> name field when a user is delete .</p>
<p>my requirement is admin needs to assign posts to specific users, that is admin need to add a post to user1 ,but user2 should not see that.for this i created a custom post and add taxonomy for that.And the terms are users Usernames .so i need to ... | [
{
"answer_id": 310128,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 1,
"selected": false,
"text": "<p>If I understand well you have a <code>custom_taxonomy</code> and the terms slugs of it correspond to... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143452/"
] | i need to Delete wp\_terms -> name field when a user is delete .
my requirement is admin needs to assign posts to specific users, that is admin need to add a post to user1 ,but user2 should not see that.for this i created a custom post and add taxonomy for that.And the terms are users Usernames .so i need to list the ... | Replace this with yours:
```
add_action( 'delete_user', 'yg_user_delete', 10, 1 );
function yg_user_delete( $user_id ) {
$user_info = get_userdata($user_id);
$user_name = $user_info->user_login;
print_r($user_info);
wp_delete_term( get_term_by('name', $user_name, 'user1')->term_id, 'user1', array(... |
310,127 | <p>I have a user registration form implemented and working correctly on the front end of a website. My main issue is that I would like to redirect a user after completing the profile form. </p>
<p>My idea would be to show a page with some content to let the user know that their account is being reviewed. So this kind ... | [
{
"answer_id": 310128,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 1,
"selected": false,
"text": "<p>If I understand well you have a <code>custom_taxonomy</code> and the terms slugs of it correspond to... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147869/"
] | I have a user registration form implemented and working correctly on the front end of a website. My main issue is that I would like to redirect a user after completing the profile form.
My idea would be to show a page with some content to let the user know that their account is being reviewed. So this kind of users w... | Replace this with yours:
```
add_action( 'delete_user', 'yg_user_delete', 10, 1 );
function yg_user_delete( $user_id ) {
$user_info = get_userdata($user_id);
$user_name = $user_info->user_login;
print_r($user_info);
wp_delete_term( get_term_by('name', $user_name, 'user1')->term_id, 'user1', array(... |
310,138 | <pre><code> <?php
wp_nav_menu(array(
'theme_location' => 'primary',
'container' => 'ul',
'menu_class'=> 'top-menu'
/* 'walker' => new Walker_nav_Primary() */
)
);
... | [
{
"answer_id": 310134,
"author": "Siavash1991",
"author_id": 35070,
"author_profile": "https://wordpress.stackexchange.com/users/35070",
"pm_score": 0,
"selected": false,
"text": "<p>Replace this with your search form and products will show in results:</p>\n\n<pre><code> <form method=... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310138",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | ```
<?php
wp_nav_menu(array(
'theme_location' => 'primary',
'container' => 'ul',
'menu_class'=> 'top-menu'
/* 'walker' => new Walker_nav_Primary() */
)
);
?>
```
This is a... | You have in your query `WHERE p.post_type IN ('post', 'page')`, that is why it shows only the posts and pages. Add post type **product** to query:
`WHERE p.post_type IN ('post', 'page', 'product')` |
310,165 | <p>I am creating a custom user role with the code below in functions.php, however WordPress only allows the user to create draft pages, they can't then edit draft pages or publish pages even though I have set the capabilities to true?</p>
<p>Any help is much appreciated!. Thanks in advance.</p>
<pre><code>add_action(... | [
{
"answer_id": 310134,
"author": "Siavash1991",
"author_id": 35070,
"author_profile": "https://wordpress.stackexchange.com/users/35070",
"pm_score": 0,
"selected": false,
"text": "<p>Replace this with your search form and products will show in results:</p>\n\n<pre><code> <form method=... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310165",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116154/"
] | I am creating a custom user role with the code below in functions.php, however WordPress only allows the user to create draft pages, they can't then edit draft pages or publish pages even though I have set the capabilities to true?
Any help is much appreciated!. Thanks in advance.
```
add_action('admin_init', 'user_c... | You have in your query `WHERE p.post_type IN ('post', 'page')`, that is why it shows only the posts and pages. Add post type **product** to query:
`WHERE p.post_type IN ('post', 'page', 'product')` |
310,173 | <p>I am using <code>woocommerce_admin_order_actions</code> hook to add an additional action like Invoice. But it is repeating many many times whereas others button are repeating once.</p>
<pre class="lang-php prettyprint-override"><code>public function add_new_list_for_action($actions, $the_order) {
if ( $the_order-... | [
{
"answer_id": 310175,
"author": "VinothRaja",
"author_id": 146008,
"author_profile": "https://wordpress.stackexchange.com/users/146008",
"pm_score": 1,
"selected": false,
"text": "<p>Add this below code your current active theme functions.php file</p>\n\n<pre><code>add_filter( 'woocomme... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/141331/"
] | I am using `woocommerce_admin_order_actions` hook to add an additional action like Invoice. But it is repeating many many times whereas others button are repeating once.
```php
public function add_new_list_for_action($actions, $the_order) {
if ( $the_order->has_status( array( 'processing' ) ) ) {
$status = $... | Add this below code your current active theme functions.php file
```
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
if ( $order->has_status( array( 'processing' ) ) ) {
// The key slu... |
310,201 | <p>Simple task, but it isn't working:</p>
<pre><code><?php
$content = apply_filters( 'the_content', get_the_content() );
$contentWithoutHTML = wp_strip_all_tags($content);
$pos = strpos($contentWithoutHTML, " ", 100);
$contentFinal = substr($contentWithoutHTML,0,$pos );
echo $contentFinal . "...";
?>
</code></... | [
{
"answer_id": 310177,
"author": "Martin Jarvis",
"author_id": 147693,
"author_profile": "https://wordpress.stackexchange.com/users/147693",
"pm_score": 2,
"selected": true,
"text": "<p>If you want all of the product meta to be styled in the same way, then add the following to your theme... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77764/"
] | Simple task, but it isn't working:
```
<?php
$content = apply_filters( 'the_content', get_the_content() );
$contentWithoutHTML = wp_strip_all_tags($content);
$pos = strpos($contentWithoutHTML, " ", 100);
$contentFinal = substr($contentWithoutHTML,0,$pos );
echo $contentFinal . "...";
?>
```
My post is way over 100... | If you want all of the product meta to be styled in the same way, then add the following to your theme custom CSS or style.css in your child theme, and edit as required...
.product\_meta {
padding-top: 6px;
border-top: 1px solid #dadada;
color: #666;
font-size: 18px;
}
If you want something different for each of ... |
310,213 | <p>I have a very simple plugin with a javascript file and a PHP file. I want to call the PHP file from my javascript code and get the output. The javascript functions is something like the following:</p>
<pre><code>function img_upload(){
var ajax = new XMLHttpRequest();
ajax.open('GET', 'ht... | [
{
"answer_id": 310215,
"author": "Adam Mellen",
"author_id": 147913,
"author_profile": "https://wordpress.stackexchange.com/users/147913",
"pm_score": -1,
"selected": false,
"text": "<p>Use <code>plugins_url()</code> to get the location of <code>site/wp-content/plugins</code>:</p>\n\n<pr... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122813/"
] | I have a very simple plugin with a javascript file and a PHP file. I want to call the PHP file from my javascript code and get the output. The javascript functions is something like the following:
```
function img_upload(){
var ajax = new XMLHttpRequest();
ajax.open('GET', 'http://My_Domain... | Here's an example:
Use this sample JavaScript code:
```
jQuery(document).on('click', '.some-element', function(e){
var ipc = jQuery(this).data('collection-id');
jQuery('.some-other-element').show();
jQuery.ajax({
method: 'post',
url: ipAjaxVar.ajaxurl,
data: {
collecti... |
310,214 | <p>I have 2 custom post types, <code>project</code> and <code>person</code>. Both have several custom fields.
I'm working on a template for the <code>project</code> custom post type.</p>
<p>In the <code>project</code> custom fields I have several fields of type relation, as seen in this screenshot. Unfortunately I don... | [
{
"answer_id": 310215,
"author": "Adam Mellen",
"author_id": 147913,
"author_profile": "https://wordpress.stackexchange.com/users/147913",
"pm_score": -1,
"selected": false,
"text": "<p>Use <code>plugins_url()</code> to get the location of <code>site/wp-content/plugins</code>:</p>\n\n<pr... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310214",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147919/"
] | I have 2 custom post types, `project` and `person`. Both have several custom fields.
I'm working on a template for the `project` custom post type.
In the `project` custom fields I have several fields of type relation, as seen in this screenshot. Unfortunately I don't really undestand what they mean and how to use them... | Here's an example:
Use this sample JavaScript code:
```
jQuery(document).on('click', '.some-element', function(e){
var ipc = jQuery(this).data('collection-id');
jQuery('.some-other-element').show();
jQuery.ajax({
method: 'post',
url: ipAjaxVar.ajaxurl,
data: {
collecti... |
310,226 | <p>I am using this code and I am not sure why the script is not loaded. I believe the syntax is correct since I am trying to load the script only on the "events" custom post type single posts.</p>
<pre><code>add_action( 'login_enqueue_scripts', 'wpse_login_enqueue_scripts', 10 );
function wpse_login_enqueue_scripts() ... | [
{
"answer_id": 310227,
"author": "Kaperto",
"author_id": 147795,
"author_profile": "https://wordpress.stackexchange.com/users/147795",
"pm_score": 0,
"selected": false,
"text": "<p>this hook is only fired on the login page :<br>\n<a href=\"https://developer.wordpress.org/reference/hooks/... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am using this code and I am not sure why the script is not loaded. I believe the syntax is correct since I am trying to load the script only on the "events" custom post type single posts.
```
add_action( 'login_enqueue_scripts', 'wpse_login_enqueue_scripts', 10 );
function wpse_login_enqueue_scripts() {
if( is_s... | To enqueue scripts on the front-end, the hook should be `wp_enqueue_scripts`, not `login_enqueue_scripts`.
Also, a better way to see if you’re on a single custom post type is to use `is_singular()` and pass the post type you want to check:
```
if ( is_singular( 'events' ) ) {
}
```
`get_post_type()` relies on the g... |
310,243 | <p>I used this code for changing the email sender name from Wordpress to my own title.</p>
<pre><code>function wpb_sender_email($original_email_address)
{
return 'info@mydomain.com';
}
// Function to change sender name
function wpb_sender_name($original_email_from)
{
return 'mydomain.com';
}
// Hooking up ou... | [
{
"answer_id": 310250,
"author": "John Dee",
"author_id": 131224,
"author_profile": "https://wordpress.stackexchange.com/users/131224",
"pm_score": 2,
"selected": false,
"text": "<p>As of version 4.9 there is a dubious \"feature\" that prevents you from changing the site email without a ... | 2018/08/01 | [
"https://wordpress.stackexchange.com/questions/310243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/141105/"
] | I used this code for changing the email sender name from Wordpress to my own title.
```
function wpb_sender_email($original_email_address)
{
return 'info@mydomain.com';
}
// Function to change sender name
function wpb_sender_name($original_email_from)
{
return 'mydomain.com';
}
// Hooking up our functions to... | As of version 4.9 there is a dubious "feature" that prevents you from changing the site email without a confirmation email going out, and the admin confirming his own change. Those filters, as you've discovered, won't work.
For instance, from now on, if you're using WordPress for an IOT device or on localhost, it's im... |
310,264 | <p>I have <code>process_ipn</code> method that runs on <code>init</code> action hook. Looks like it is fired after PayPal returns to merchant. Under this method, I could find out the payment status such as <code>completed</code>, <code>pending</code>, <code>failed</code>
from PayPal. And, save it to the database.</p>
... | [
{
"answer_id": 310447,
"author": "Sanzeeb Aryal",
"author_id": 126847,
"author_profile": "https://wordpress.stackexchange.com/users/126847",
"pm_score": 0,
"selected": false,
"text": "<p><code>sleep()</code> function can be used to delay the execution.</p>\n\n<pre><code>add_filter( 'logi... | 2018/08/02 | [
"https://wordpress.stackexchange.com/questions/310264",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126847/"
] | I have `process_ipn` method that runs on `init` action hook. Looks like it is fired after PayPal returns to merchant. Under this method, I could find out the payment status such as `completed`, `pending`, `failed`
from PayPal. And, save it to the database.
```
update_user_meta( $user_id, 'status', 'completed' );
```... | If I understand your question, the race condition you describe between WordPress knowing the transaction was "complete" and the user returning to your site is the problem.
Regarding a potential solution, what about changing the way you're approaching this such that this race condition is accepted as a real possibility... |
310,298 | <p>I want to show HTML text after the short description on the product page, but only on specific products that are in a specific category (categories).</p>
<p>I think I have to use in_category, but I can't figure out how to display the text right after the short description.</p>
<p>My preference is to work with a fu... | [
{
"answer_id": 310338,
"author": "Peter HvD",
"author_id": 134918,
"author_profile": "https://wordpress.stackexchange.com/users/134918",
"pm_score": 3,
"selected": true,
"text": "<p>Woocommerce's product categories are custom taxonomy terms, so you need to use the taxonomy functions (eg,... | 2018/08/02 | [
"https://wordpress.stackexchange.com/questions/310298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147900/"
] | I want to show HTML text after the short description on the product page, but only on specific products that are in a specific category (categories).
I think I have to use in\_category, but I can't figure out how to display the text right after the short description.
My preference is to work with a function/filter/ac... | Woocommerce's product categories are custom taxonomy terms, so you need to use the taxonomy functions (eg, [`has_term()`](https://codex.wordpress.org/has_term)) rather than WordPress' category ones.
```
function filter_woocommerce_short_description( $post_excerpt ) {
global $post;
if ( has_term( "term-name", "... |
310,301 | <p>I'm working on a design that has different styling if a certain Gutenberg block is present on a page. In other words, if the first block is a custom built Gutenberg block, the post_title is rendered elsewhere due to design choices made.</p>
<p>Is there any function in WordPress to get a list of all Gutenberg blocks... | [
{
"answer_id": 310309,
"author": "Jebble",
"author_id": 81939,
"author_profile": "https://wordpress.stackexchange.com/users/81939",
"pm_score": 2,
"selected": false,
"text": "<p>The solution I'm using as of writing check the post_content for the Gutenberg HTML comments. Due to future Gut... | 2018/08/02 | [
"https://wordpress.stackexchange.com/questions/310301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81939/"
] | I'm working on a design that has different styling if a certain Gutenberg block is present on a page. In other words, if the first block is a custom built Gutenberg block, the post\_title is rendered elsewhere due to design choices made.
Is there any function in WordPress to get a list of all Gutenberg blocks present ... | WordPress 5.0+ has a function for this: `parse_blocks()`. To see if the first block in the post is the Heading block, you'd do this:
```
$post = get_post();
if ( has_blocks( $post->post_content ) ) {
$blocks = parse_blocks( $post->post_content );
if ( $blocks[0]['blockName'] === 'core/heading' ) {
}
}
... |
310,304 | <p>I have this layout I am trying to implement - <a href="https://drive.google.com/file/d/1cP831xAM1F5CT3HEmedCBkINwiCC18Rb/view" rel="nofollow noreferrer">https://drive.google.com/file/d/1cP831xAM1F5CT3HEmedCBkINwiCC18Rb/view</a></p>
<p>And I have created a news template, but I need to get the posts to display like m... | [
{
"answer_id": 310310,
"author": "Lisa",
"author_id": 113452,
"author_profile": "https://wordpress.stackexchange.com/users/113452",
"pm_score": 0,
"selected": false,
"text": "<p>try to take a look at this <a href=\"https://stackoverflow.com/questions/38304093/wordpress-blog-first-row-2-c... | 2018/08/02 | [
"https://wordpress.stackexchange.com/questions/310304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147953/"
] | I have this layout I am trying to implement - <https://drive.google.com/file/d/1cP831xAM1F5CT3HEmedCBkINwiCC18Rb/view>
And I have created a news template, but I need to get the posts to display like my example where the first bootstrap row displays 3 posts then beneath that it displays 4 posts.
Is this possible, I ca... | You can accomplish this by using a counter then updating the class according to your needs. The code below will create a variable `$counter` and assign it to `0` if posts exist. By default a `'col-md-4'` is bound to `$class`, if the `$counter` is less than `3` `$class` will be updated to `'col-md-3'` (making it fill 4 ... |
310,333 | <p>When I click the "Add to cart" button on a variable product, with no variation selected, the WooCommerce pops up an alert: "Please select some product options before adding this product to your cart.".</p>
<p>The problem is, it shows up as an Alert (browser window with Ok button). I would like to display it as a cl... | [
{
"answer_id": 310310,
"author": "Lisa",
"author_id": 113452,
"author_profile": "https://wordpress.stackexchange.com/users/113452",
"pm_score": 0,
"selected": false,
"text": "<p>try to take a look at this <a href=\"https://stackoverflow.com/questions/38304093/wordpress-blog-first-row-2-c... | 2018/08/02 | [
"https://wordpress.stackexchange.com/questions/310333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/138610/"
] | When I click the "Add to cart" button on a variable product, with no variation selected, the WooCommerce pops up an alert: "Please select some product options before adding this product to your cart.".
The problem is, it shows up as an Alert (browser window with Ok button). I would like to display it as a classic WooC... | You can accomplish this by using a counter then updating the class according to your needs. The code below will create a variable `$counter` and assign it to `0` if posts exist. By default a `'col-md-4'` is bound to `$class`, if the `$counter` is less than `3` `$class` will be updated to `'col-md-3'` (making it fill 4 ... |
310,360 | <p>I've read alot, I've tried a bunch of different things, I still can't get my query to order posts by acf's datepicker field. This is what my code looks like:</p>
<pre><code>$args = array(
'post_type' => 'arm_careers',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => '... | [
{
"answer_id": 310361,
"author": "Nicholas Koskowski",
"author_id": 92318,
"author_profile": "https://wordpress.stackexchange.com/users/92318",
"pm_score": 2,
"selected": false,
"text": "<p>You need to convert your saved format to the post_date format which is in </p>\n\n<p><code>Y-m-d H... | 2018/08/02 | [
"https://wordpress.stackexchange.com/questions/310360",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/138558/"
] | I've read alot, I've tried a bunch of different things, I still can't get my query to order posts by acf's datepicker field. This is what my code looks like:
```
$args = array(
'post_type' => 'arm_careers',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'post_date',
'orderby' ... | You need to convert your saved format to the post\_date format which is in
`Y-m-d H:i:s`
Only then will the comparators work properly with automatically generated query objects. |
310,393 | <p>I am trying to build a plugin and at the moment my plugin contains only <code>plugin.php</code> file.</p>
<p>There is not a real code in it yet:</p>
<pre><code><?
/*
Plugin Name: Plugin Name
Plugin URI: https://www.example.info
description: A description about the plugin
Version: 1.0.0
Author: Author Name
Autho... | [
{
"answer_id": 310401,
"author": "Kaperto",
"author_id": 147795,
"author_profile": "https://wordpress.stackexchange.com/users/147795",
"pm_score": 0,
"selected": false,
"text": "<p>You start the PHP code with short tags <code><?</code>.<br>\nIf it is on a server with short tags disabl... | 2018/08/03 | [
"https://wordpress.stackexchange.com/questions/310393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147331/"
] | I am trying to build a plugin and at the moment my plugin contains only `plugin.php` file.
There is not a real code in it yet:
```
<?
/*
Plugin Name: Plugin Name
Plugin URI: https://www.example.info
description: A description about the plugin
Version: 1.0.0
Author: Author Name
Author URI: https://www.example.info
Lic... | You start the PHP code with short tags `<?`.
If it is on a server with short tags disabled, the PHP code is not rendered and is outputted.
Then it's better to use complete tags `<?php`. |
310,394 | <p>I want to get posts of a specific date, I tried the following code but I did not get the result what I wanted.</p>
<pre><code><?php
$mil = 1532996880000;
$seconds = $mil / 1000;
$dt = date( "Y-m-d", $seconds );
$post_by_date = $wpdb->get_row("
SELECT * FROM {$wpdb->posts}
WHERE post_date = $dt
... | [
{
"answer_id": 310396,
"author": "Trilok",
"author_id": 145962,
"author_profile": "https://wordpress.stackexchange.com/users/145962",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Please use date query for that also use below code hope it will work for you</p>\n</blockquo... | 2018/08/03 | [
"https://wordpress.stackexchange.com/questions/310394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129128/"
] | I want to get posts of a specific date, I tried the following code but I did not get the result what I wanted.
```
<?php
$mil = 1532996880000;
$seconds = $mil / 1000;
$dt = date( "Y-m-d", $seconds );
$post_by_date = $wpdb->get_row("
SELECT * FROM {$wpdb->posts}
WHERE post_date = $dt
AND post_status = 'pub... | ```
<?php
// primarily get $year, $month and $day
$args = array(
'date_query' => array(
'year' => $year,
'month' => $month,
'day' => $day,
)
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
// do whatever here
}
}
... |
310,400 | <p>I have an inline SVG tag with an embedded <USE> tag.</p>
<p><strong>HTML:</strong></p>
<pre><code><ul>
<li><svg class="icon-user"><use xlink:href="#icon-user"></use></svg> My Account</li>
</ul>
</code></pre>
<p>I have created a filter function to force the ... | [
{
"answer_id": 310426,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>Unfortunately the colon is <a href=\"https://www.tiny.cloud/docs/configure/content-filtering/#valid_element... | 2018/08/03 | [
"https://wordpress.stackexchange.com/questions/310400",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148020/"
] | I have an inline SVG tag with an embedded <USE> tag.
**HTML:**
```
<ul>
<li><svg class="icon-user"><use xlink:href="#icon-user"></use></svg> My Account</li>
</ul>
```
I have created a filter function to force the Tiny MCE editor to leave SVG tags alone. The code was adapted from post: [use of <svg> tag into word... | Unfortunately the colon is [a TinyMCE control character](https://www.tiny.cloud/docs/configure/content-filtering/#valid_elements)
>
> Forces the attribute to the specified value. For example, 'border:0'
>
>
>
...hence the switch to `xlink=href`. The only apparent solution is the wildcard `use[*]`
Use the control... |
310,411 | <p>I have a function in my functions.php file that is supossed to update my post status once the expiry date has passed. I call this function in a test.php file that is also a template page with url /test-search-results/. If I access this url via my browser the function fires and does what it supposed to do. </p>
<p>... | [
{
"answer_id": 310430,
"author": "Kaperto",
"author_id": 147795,
"author_profile": "https://wordpress.stackexchange.com/users/147795",
"pm_score": 0,
"selected": false,
"text": "<p>With WP cron, you can launch a action daily, twice daily or hourly :<br>\n<a href=\"https://codex.wordpress... | 2018/08/03 | [
"https://wordpress.stackexchange.com/questions/310411",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107025/"
] | I have a function in my functions.php file that is supossed to update my post status once the expiry date has passed. I call this function in a test.php file that is also a template page with url /test-search-results/. If I access this url via my browser the function fires and does what it supposed to do.
I want to c... | When you use \*nix cron to run a PHP file like that it won't have WordPress loaded. You can load it manually, but a better method is to use WordPress' own [cron API](https://developer.wordpress.org/plugins/cron/).
Schedule the event in your `functions.php`:
```
if ( ! wp_next_scheduled( 'expire_posts' ) ) {
wp_sc... |
310,439 | <p>I've created the following pages and hierarchy:</p>
<ul>
<li>Grandparent
<ul>
<li>Parent</li>
<li>Parent</li>
<li>Parent
<ul>
<li>Child</li>
<li>Child</li>
<li>Child</li>
</ul></li>
<li>Parent</li>
<li>Parent</li>
</ul></li>
<li>Grandparent</li>
</ul>
<p>The Grandparent pages have an ACF custom field to pick the... | [
{
"answer_id": 310442,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>As far as I'm aware there's no limit to how many levels of ancestry Pages can have, so any solution shou... | 2018/08/03 | [
"https://wordpress.stackexchange.com/questions/310439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37548/"
] | I've created the following pages and hierarchy:
* Grandparent
+ Parent
+ Parent
+ Parent
- Child
- Child
- Child
+ Parent
+ Parent
* Grandparent
The Grandparent pages have an ACF custom field to pick the colour.
[](https://i.stack.imgur.com/2pBfg.png)
I... | As far as I'm aware there's no limit to how many levels of ancestry Pages can have, so any solution should not depend on specifically referencing a particular ancestor. The best solution would be to get a list of all ancestors for the page and loop over them until you find a value for your field. Then stop looping over... |
310,465 | <p>I'm trying to unregister core block types in WordPress Gutenberg. </p>
<p>I've used the code provided here:
<a href="https://github.com/WordPress/gutenberg/blob/master/docs/extensibility/extending-blocks.md#removing-blocks" rel="noreferrer">https://github.com/WordPress/gutenberg/blob/master/docs/extensibility/exten... | [
{
"answer_id": 311633,
"author": "Misha Rudrastyh",
"author_id": 85985,
"author_profile": "https://wordpress.stackexchange.com/users/85985",
"pm_score": 2,
"selected": false,
"text": "<p>Everything works for me with <code>allowed_block_types</code> hook.</p>\n\n<p>Example:</p>\n\n<pre><c... | 2018/08/03 | [
"https://wordpress.stackexchange.com/questions/310465",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148068/"
] | I'm trying to unregister core block types in WordPress Gutenberg.
I've used the code provided here:
<https://github.com/WordPress/gutenberg/blob/master/docs/extensibility/extending-blocks.md#removing-blocks>
But I can't get it to work. I feel like there may be a simple step I am missing?
1. I created a plugin whic... | Everything works for me with `allowed_block_types` hook.
Example:
```
add_filter( 'allowed_block_types', 'my_function' );
function my_function( $allowed_block_types ) {
return array(
'core/paragraph'
);
}
```
You can insert the above code to your `functions.php` file to a custom plugin. It remove... |
310,508 | <p>I have a radio control in the theme customizer. The code for that control is like below:</p>
<pre><code>$wp_customize->add_setting( 'post_layout', array(
'capability' => 'edit_theme_options',
'default' => 'cover',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( '... | [
{
"answer_id": 310509,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>You're getting the saved value here:</p>\n\n<pre><code>$value = get_post_meta( $post->ID, '_my_meta_... | 2018/08/04 | [
"https://wordpress.stackexchange.com/questions/310508",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67150/"
] | I have a radio control in the theme customizer. The code for that control is like below:
```
$wp_customize->add_setting( 'post_layout', array(
'capability' => 'edit_theme_options',
'default' => 'cover',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'post_layout', array(
'type'... | Before to handle the defaut value, there is a lot of changes that you can do for the hook "save\_post" and the first one is to no more use it.
You add the metabox only on post type `post`, then you can use the hook `save_post_post` to only doing the treatment for this custom post :
<https://developer.wordpress.or... |
310,513 | <p>I'm trying to create a new og:image for author avatar when the users sharing their author profile page to Facebook.</p>
<p>I'm a newbie with WordPress, After searching for more than 6 months but i'm always failing.</p>
<p>My site is multi-authors and all what i need to add og:image meta tag for author.php "author ... | [
{
"answer_id": 310509,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>You're getting the saved value here:</p>\n\n<pre><code>$value = get_post_meta( $post->ID, '_my_meta_... | 2018/08/04 | [
"https://wordpress.stackexchange.com/questions/310513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146329/"
] | I'm trying to create a new og:image for author avatar when the users sharing their author profile page to Facebook.
I'm a newbie with WordPress, After searching for more than 6 months but i'm always failing.
My site is multi-authors and all what i need to add og:image meta tag for author.php "author profile", I'm stu... | Before to handle the defaut value, there is a lot of changes that you can do for the hook "save\_post" and the first one is to no more use it.
You add the metabox only on post type `post`, then you can use the hook `save_post_post` to only doing the treatment for this custom post :
<https://developer.wordpress.or... |
310,524 | <p>There are specific plugins that I want to use my own repo for for updating my sites. How can I identify the plugin to target and what server they should be looking at?</p>
| [
{
"answer_id": 310509,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>You're getting the saved value here:</p>\n\n<pre><code>$value = get_post_meta( $post->ID, '_my_meta_... | 2018/08/04 | [
"https://wordpress.stackexchange.com/questions/310524",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116443/"
] | There are specific plugins that I want to use my own repo for for updating my sites. How can I identify the plugin to target and what server they should be looking at? | Before to handle the defaut value, there is a lot of changes that you can do for the hook "save\_post" and the first one is to no more use it.
You add the metabox only on post type `post`, then you can use the hook `save_post_post` to only doing the treatment for this custom post :
<https://developer.wordpress.or... |
310,535 | <p>I created my own category selection widget. So i used <code><select></code> but i want to use with <code>multiple</code> attribute. </p>
<p>Here is my widget class. It works perfect without <code>multiple</code> attr. But i want to use it. And it must be return category ids in array.</p>
<pre><code><?php
... | [
{
"answer_id": 310595,
"author": "Nilesh Sanura",
"author_id": 148097,
"author_profile": "https://wordpress.stackexchange.com/users/148097",
"pm_score": 2,
"selected": true,
"text": "<p>Hi why don't you used multiple check-box instead of select option field. As well as you have used depr... | 2018/08/04 | [
"https://wordpress.stackexchange.com/questions/310535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/133897/"
] | I created my own category selection widget. So i used `<select>` but i want to use with `multiple` attribute.
Here is my widget class. It works perfect without `multiple` attr. But i want to use it. And it must be return category ids in array.
```
<?php
class myCatWidget extends WP_Widget {
function myCatWidge... | Hi why don't you used multiple check-box instead of select option field. As well as you have used deprecated functions like "create\_function". I have modified your code which replaced select option with multiple check-box selection.
```
function myCatWidget() {
register_widget( 'my_custom_cat_widget' );
}
add_act... |
310,628 | <p>I have created a custom banner image block for Gutenberg, which works great, but
I want to know if it is possible to use the page title as the current banner text
placeholder until it has been edited?</p>
<p><a href="https://i.stack.imgur.com/GRkwW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com... | [
{
"answer_id": 311271,
"author": "Jim-miraidev",
"author_id": 130369,
"author_profile": "https://wordpress.stackexchange.com/users/130369",
"pm_score": 2,
"selected": false,
"text": "<p>Thanks to the answer in this post i have managed to add the title into the banner and it updates as th... | 2018/08/06 | [
"https://wordpress.stackexchange.com/questions/310628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130369/"
] | I have created a custom banner image block for Gutenberg, which works great, but
I want to know if it is possible to use the page title as the current banner text
placeholder until it has been edited?
[](https://i.stack.imgur.com/GRkwW.png)
My Edit ... | Due to the `getDocumentTitle` selector being deprecated as mentioned here <https://stackoverflow.com/questions/51674293/use-page-title-in-gutenberg-custom-banner-block/51792096#comment92130728_51792096>
I managed to get it working with a slight tweak to the code by Jim-miraidev
```
var GetTitle = function GetTitle(pr... |
310,668 | <p>I want to redirect users to account details after registering, by default it is redirecting to my account dashboard.</p>
<p>This is where I want users to be redirected</p>
<blockquote>
<p>mydomain.com/my-account/edit-account/</p>
</blockquote>
<p>I found something like this, but I think it won't work</p>
<pre>... | [
{
"answer_id": 310697,
"author": "Suraj Rathod",
"author_id": 141555,
"author_profile": "https://wordpress.stackexchange.com/users/141555",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function woo_login_redirect( $redirect, $user ) {\n$redirect_page_id = url_to_postid( $redirec... | 2018/08/06 | [
"https://wordpress.stackexchange.com/questions/310668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148207/"
] | I want to redirect users to account details after registering, by default it is redirecting to my account dashboard.
This is where I want users to be redirected
>
> mydomain.com/my-account/edit-account/
>
>
>
I found something like this, but I think it won't work
```
function iconic_register_redirect( $redirect... | To get "*Account details*" permalink (endpoint `edit-account`) you need to use function `wc_get_account_endpoint_url`.
```
function wc_redirect_to_account_details( $redirect ) {
$redirect = wc_get_account_endpoint_url('edit-account');
return $redirect;
}
add_filter( 'woocommerce_registration_redirect', 'wc_re... |
310,685 | <p>I am trying to enqueue a js file (calculator.js) from my theme's functions.php file.</p>
<p>I have a desktop theme and a smartphone theme, and I am using a plugin to switch between the two themes depending on the user's device.</p>
<p>I have the exact same code on my desktop theme and it works perfectly, however w... | [
{
"answer_id": 310690,
"author": "maverick",
"author_id": 132953,
"author_profile": "https://wordpress.stackexchange.com/users/132953",
"pm_score": 1,
"selected": false,
"text": "<p>Just some modifications</p>\n\n<pre><code>function wpb_adding_scripts() {\n wp_enqueue_script( 'calcula... | 2018/08/07 | [
"https://wordpress.stackexchange.com/questions/310685",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148215/"
] | I am trying to enqueue a js file (calculator.js) from my theme's functions.php file.
I have a desktop theme and a smartphone theme, and I am using a plugin to switch between the two themes depending on the user's device.
I have the exact same code on my desktop theme and it works perfectly, however when I copied it t... | ```
You can better try this way and let me know.
function wpb_adding_scripts() {
wp_enqueue_style( 'slider', get_stylesheet_directory_uri() . '/css/calculator.css');
wp_enqueue_script('jquery');
wp_enqueue_script('calculator_script', get_stylesheet_directory_uri() . '/js/calculator.js');
}
add_action( 'w... |
310,698 | <p>I have a <strong>notmytheme</strong>, the original css load order is like so:</p>
<pre><code><link rel='stylesheet' id='something' href='http://localhost/mywp/wp-content/themes/notmytheme/something.css' type='text/css' media='all' />
<link rel='stylesheet' id='notmytheme-style-css' href='http://localhost... | [
{
"answer_id": 310700,
"author": "Nilesh Sanura",
"author_id": 148097,
"author_profile": "https://wordpress.stackexchange.com/users/148097",
"pm_score": -1,
"selected": false,
"text": "<p>Please use get_stylesheet_directory_uri() instead of get_template_directory_uri() when you have to e... | 2018/08/07 | [
"https://wordpress.stackexchange.com/questions/310698",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/117364/"
] | I have a **notmytheme**, the original css load order is like so:
```
<link rel='stylesheet' id='something' href='http://localhost/mywp/wp-content/themes/notmytheme/something.css' type='text/css' media='all' />
<link rel='stylesheet' id='notmytheme-style-css' href='http://localhost/mywp/wp-content/themes/notmytheme/s... | It's very common for themes to enqueue their stylesheet like this:
```
wp_enqueue_style( 'notmytheme-style', get_stylesheet_uri() );
```
When you activate a child theme for a theme that does this, `get_stylesheet_uri()` becomes the *child theme's* stylesheet URL. This means that the parent theme will enqueue the *ch... |
310,761 | <p>I have the following setup in my <code>.htaccess</code> file, but I am still able to go to my site via <code>http:</code></p>
<pre><code># BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} ... | [
{
"answer_id": 310763,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 3,
"selected": true,
"text": "<p>You've put the code in the wrong place. The HTTP to HTTPS directives must go <em>before</em> the WordPress front... | 2018/08/07 | [
"https://wordpress.stackexchange.com/questions/310761",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145165/"
] | I have the following setup in my `.htaccess` file, but I am still able to go to my site via `http:`
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Rewrit... | You've put the code in the wrong place. The HTTP to HTTPS directives must go *before* the WordPress front-controller, otherwise it's simply never going to get processed for anything other than direct file requests.
Your custom directives should also be outside the `# BEGIN WordPress` block, otherwise WordPress itself ... |
310,774 | <p>I have a Custom Post Type all set up. I would like the slug to be the same as a page name, because all of these CPT's will be queried on that particular page (/team-members).</p>
<p>If I set the Custom Post Type slug to the page URL, that particular page doesn't load the page template anymore. It loads a broken pos... | [
{
"answer_id": 310802,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>What is appearing at <a href=\"http://www.example.org/team-members/\" rel=\"nofollow noreferrer\">http:/... | 2018/08/07 | [
"https://wordpress.stackexchange.com/questions/310774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122225/"
] | I have a Custom Post Type all set up. I would like the slug to be the same as a page name, because all of these CPT's will be queried on that particular page (/team-members).
If I set the Custom Post Type slug to the page URL, that particular page doesn't load the page template anymore. It loads a broken post template... | What is appearing at <http://www.example.org/team-members/> is the 'post type archive' for your post type. It's the automatically generated list of posts created by WordPress. If you don't want the post type to have an archive you can disable the archive by setting the `has_archive` argument to false:
```
register_pos... |
310,865 | <p>I am creating a theme and i have added custom hooks to make the developement easier.
when using the code in functions it works in all pages. the code is below</p>
<pre><code>add_action('before_footer','post_prev_nex');
function post_prev_nex(){
the_post_navigation();
}
</code></pre>
<p>But when i try to put a... | [
{
"answer_id": 310867,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 3,
"selected": true,
"text": "<p>Put condition inside your function:</p>\n\n<pre><code>add_action('before_footer','post_prev_nex');\nfunction pos... | 2018/08/08 | [
"https://wordpress.stackexchange.com/questions/310865",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140102/"
] | I am creating a theme and i have added custom hooks to make the developement easier.
when using the code in functions it works in all pages. the code is below
```
add_action('before_footer','post_prev_nex');
function post_prev_nex(){
the_post_navigation();
}
```
But when i try to put a conditional, it doesnt wo... | Put condition inside your function:
```
add_action('before_footer','post_prev_nex');
function post_prev_nex() {
if (is_singular())
the_post_navigation();
}
```
In your version `is_singular()` is executed when `functions.php` file is loaded, not while displaying the page. |
310,866 | <p>I am using contact for 7 to create form. Currently I am auto completing value under text name field from Custom post type title, see below:</p>
<pre><code>$post_ids = new WP_Query(array(
'post_type' => 'Buyers', // replace with CPT name
'fields' => 'fname' // replace with custom field name
));
$name = array(... | [
{
"answer_id": 310867,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 3,
"selected": true,
"text": "<p>Put condition inside your function:</p>\n\n<pre><code>add_action('before_footer','post_prev_nex');\nfunction pos... | 2018/08/08 | [
"https://wordpress.stackexchange.com/questions/310866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123547/"
] | I am using contact for 7 to create form. Currently I am auto completing value under text name field from Custom post type title, see below:
```
$post_ids = new WP_Query(array(
'post_type' => 'Buyers', // replace with CPT name
'fields' => 'fname' // replace with custom field name
));
$name = array();
// go through eac... | Put condition inside your function:
```
add_action('before_footer','post_prev_nex');
function post_prev_nex() {
if (is_singular())
the_post_navigation();
}
```
In your version `is_singular()` is executed when `functions.php` file is loaded, not while displaying the page. |
310,874 | <p>I have created a post taxonomy in functions.php called 'leadership' and then tagged posts with three different labels. I have a team page on which I want to place three links (each slugged to a label in the taxonomy).</p>
<ul>
<li>Corporate</li>
<li>Sales</li>
<li>Support</li>
</ul>
<p>So that when the above word... | [
{
"answer_id": 310896,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 3,
"selected": true,
"text": "<p>Something quite rough that needs improvement but can give you a starting point, if I've understood you... | 2018/08/08 | [
"https://wordpress.stackexchange.com/questions/310874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35991/"
] | I have created a post taxonomy in functions.php called 'leadership' and then tagged posts with three different labels. I have a team page on which I want to place three links (each slugged to a label in the taxonomy).
* Corporate
* Sales
* Support
So that when the above word is clicked, the featured image for each po... | Something quite rough that needs improvement but can give you a starting point, if I've understood your needs: use `[dr]` as shortcode marker where you want
```
function my_dream_shortcode($atts, $content = null) {
ob_start(); ?>
<ul>
<li class="button" onClick="get_data('corporate')">Corporate</li>
<li c... |
310,881 | <p>I have a Custom Post Type called <code>books</code>. This Custom Post Type has a taxonomy called <code>book_category</code>. As of now, and in the foreseeable future, there are 5 categories each book can be filtered under.</p>
<p>Now, each of these categories have their own respective page that will query the books... | [
{
"answer_id": 310882,
"author": "David Sword",
"author_id": 132362,
"author_profile": "https://wordpress.stackexchange.com/users/132362",
"pm_score": 3,
"selected": true,
"text": "<p>To make that more efficient, instead of arguing the current page slug, you just place the current slug a... | 2018/08/08 | [
"https://wordpress.stackexchange.com/questions/310881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122225/"
] | I have a Custom Post Type called `books`. This Custom Post Type has a taxonomy called `book_category`. As of now, and in the foreseeable future, there are 5 categories each book can be filtered under.
Now, each of these categories have their own respective page that will query the books based on respective category (a... | To make that more efficient, instead of arguing the current page slug, you just place the current slug as the tax\_query's terms value. Something like:
```
global $post;
$args = array(
'posts_per_page' => -1,
'post_type' => 'books',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxo... |
310,886 | <p>I'm creating a shipping method where the customer can choose a time for the delivery to happen. This choice can be made on product page, cart and checkout. When chosen, it updates a session value with ajax. </p>
<p>The problem however is that I need to re-calculate shipping on cart and checkout if the time is chang... | [
{
"answer_id": 332944,
"author": "user164084",
"author_id": 164084,
"author_profile": "https://wordpress.stackexchange.com/users/164084",
"pm_score": 2,
"selected": false,
"text": "<p>I also have the same issue when I created a shipping method and what I did is on my function for the aja... | 2018/08/08 | [
"https://wordpress.stackexchange.com/questions/310886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/90442/"
] | I'm creating a shipping method where the customer can choose a time for the delivery to happen. This choice can be made on product page, cart and checkout. When chosen, it updates a session value with ajax.
The problem however is that I need to re-calculate shipping on cart and checkout if the time is changed, but wo... | I also have the same issue when I created a shipping method and what I did is on my function for the ajax call I add something just to have an update on the cart:
```
global $woocommerce;
$packages = $woocommerce->cart->get_shipping_packages();
foreach( $packages as $package_key => $package ) {
$session_key = 'sh... |
310,894 | <p>If you create a post whose title has an accent in it and some other unicode character in it, eg <code>à 漢語 title thing</code>, its slug (permalink) will become <code>a-漢語-title-thing</code>... ie, the <code>à</code> was converted into a regular <code>a</code>, but those unicode Chinese characters were left intact.
W... | [
{
"answer_id": 332944,
"author": "user164084",
"author_id": 164084,
"author_profile": "https://wordpress.stackexchange.com/users/164084",
"pm_score": 2,
"selected": false,
"text": "<p>I also have the same issue when I created a shipping method and what I did is on my function for the aja... | 2018/08/08 | [
"https://wordpress.stackexchange.com/questions/310894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52760/"
] | If you create a post whose title has an accent in it and some other unicode character in it, eg `à 漢語 title thing`, its slug (permalink) will become `a-漢語-title-thing`... ie, the `à` was converted into a regular `a`, but those unicode Chinese characters were left intact.
Why doesn't WordPress leave the accented charact... | I also have the same issue when I created a shipping method and what I did is on my function for the ajax call I add something just to have an update on the cart:
```
global $woocommerce;
$packages = $woocommerce->cart->get_shipping_packages();
foreach( $packages as $package_key => $package ) {
$session_key = 'sh... |
310,943 | <p>I'm looking for a way to open every/any link to a blog post in a lightbox/modal globally and without having to any extra classes or rel attribute to the link element. I know I can access this info from within the page or post itself, but is there a way, through some sort of AJAX call I presume, to get this data befo... | [
{
"answer_id": 311001,
"author": "Balas",
"author_id": 17849,
"author_profile": "https://wordpress.stackexchange.com/users/17849",
"pm_score": 1,
"selected": false,
"text": "<p>The wordpress way solution is</p>\n\n<pre><code> // put this in header.php\nvar ajax_url =\"<?php echo admin... | 2018/08/09 | [
"https://wordpress.stackexchange.com/questions/310943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118789/"
] | I'm looking for a way to open every/any link to a blog post in a lightbox/modal globally and without having to any extra classes or rel attribute to the link element. I know I can access this info from within the page or post itself, but is there a way, through some sort of AJAX call I presume, to get this data before ... | Going with @milo's suggestion in the comments of the OP, I added a function to functions.php that rewrites URLs output by the API with a specific query string key/value when the `post_type` is `post`. This allows me to see this on the front end quite easily and take the appropriate action on the link depending on the a... |
310,953 | <p>I have successfully forbidden access to any kind of author pages whether trough <code>/author/username/</code> or the <code>?author={#id}</code> query string.</p>
<p>I did this with this added to the beginning of my htaccess file:</p>
<pre><code><IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/autho... | [
{
"answer_id": 310955,
"author": "Iceable",
"author_id": 136263,
"author_profile": "https://wordpress.stackexchange.com/users/136263",
"pm_score": 1,
"selected": false,
"text": "<p>The question is about doing this with <code>.htaccess</code>, but why not disabling author pages from withi... | 2018/08/09 | [
"https://wordpress.stackexchange.com/questions/310953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/133528/"
] | I have successfully forbidden access to any kind of author pages whether trough `/author/username/` or the `?author={#id}` query string.
I did this with this added to the beginning of my htaccess file:
```
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/author/
RewriteRule .* - [F]
RewriteCond %{QUE... | The question is about doing this with `.htaccess`, but why not disabling author pages from within WordPress instead?
This would achieve the same result while making the subdirectory concern irrelevant altogether (and also works regardless of permalink structure settings)
Sample code that sets all urls to author pages... |
310,957 | <p>i want to ask a simple question that what to do if i have to check whether a pliugin is installed. for example i want to run a code, which says,</p>
<p>if Gutenberg is installed, then run the following code else not.</p>
<p>i have created this code, but not sure will this work or not</p>
<pre><code> if(defined... | [
{
"answer_id": 310961,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 4,
"selected": true,
"text": "<p>Checking if a plugin is installed is always a bad idea as plugins might be installed but for whatever reas... | 2018/08/09 | [
"https://wordpress.stackexchange.com/questions/310957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140102/"
] | i want to ask a simple question that what to do if i have to check whether a pliugin is installed. for example i want to run a code, which says,
if Gutenberg is installed, then run the following code else not.
i have created this code, but not sure will this work or not
```
if(defined('Gutenberg')) {
}
```
... | Checking if a plugin is installed is always a bad idea as plugins might be installed but for whatever reason not function, or function in different way than you might expect.
Specifically for gutenberg as it stands right now for example, post types that are not exposed in the REST API can not be edited by gutenberg.
... |
310,969 | <p>I need a wordpress function that search all the posts inside my website and if one or multiple posts have the category ID (example 25) <code>echo "yes"</code>, <code>else echo "no"</code> </p>
<p>I was trying to do: </p>
<pre><code>if ( has_category(25) ) {
echo "OK";
} else {
echo "NO OK";
}
</code></pre>... | [
{
"answer_id": 310961,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 4,
"selected": true,
"text": "<p>Checking if a plugin is installed is always a bad idea as plugins might be installed but for whatever reas... | 2018/08/09 | [
"https://wordpress.stackexchange.com/questions/310969",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/135486/"
] | I need a wordpress function that search all the posts inside my website and if one or multiple posts have the category ID (example 25) `echo "yes"`, `else echo "no"`
I was trying to do:
```
if ( has_category(25) ) {
echo "OK";
} else {
echo "NO OK";
}
```
But dont work
EDIT: My goal is to show comments se... | Checking if a plugin is installed is always a bad idea as plugins might be installed but for whatever reason not function, or function in different way than you might expect.
Specifically for gutenberg as it stands right now for example, post types that are not exposed in the REST API can not be edited by gutenberg.
... |
310,980 | <p>I'm trying to use the <code><?php rewind_posts(); ?></code> feature to use two loops on my homepage template. Does anyone know how to stop the first loop after the latest post? </p>
<p>Here is my Code:</p>
<pre><code><?php
if (have_posts()) : while (have_posts()) : the_post(); ?>
... | [
{
"answer_id": 311009,
"author": "Balas",
"author_id": 17849,
"author_profile": "https://wordpress.stackexchange.com/users/17849",
"pm_score": 1,
"selected": true,
"text": "<p>Try like this which fill skip first post:</p>\n\n<pre><code>$i = 0;\nwhile ( have_posts() ) :\n the_post();\n... | 2018/08/09 | [
"https://wordpress.stackexchange.com/questions/310980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148419/"
] | I'm trying to use the `<?php rewind_posts(); ?>` feature to use two loops on my homepage template. Does anyone know how to stop the first loop after the latest post?
Here is my Code:
```
<?php
if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><a href="<?php the_permalink(); ?>">... | Try like this which fill skip first post:
```
$i = 0;
while ( have_posts() ) :
the_post();
if($i > 0)
get_template_part( 'template-parts/content-home', get_post_type() );
else {
// design your first post as you wish with HTML, CSS
the_title();
the_permalink();
the_po... |
311,028 | <p>I'm trying to get the url of an image from a MetaBox (plugin) filed on an archive-page. </p>
<pre><code><?php
if ( rwmb_meta( 'field-id' ) ) {
// Get images
$img_srcset_large = rwmb_meta( 'field-id', array( 'size' => 'image-size', 'limit' => 1 ) );
echo $img_srcset_lar... | [
{
"answer_id": 311009,
"author": "Balas",
"author_id": 17849,
"author_profile": "https://wordpress.stackexchange.com/users/17849",
"pm_score": 1,
"selected": true,
"text": "<p>Try like this which fill skip first post:</p>\n\n<pre><code>$i = 0;\nwhile ( have_posts() ) :\n the_post();\n... | 2018/08/10 | [
"https://wordpress.stackexchange.com/questions/311028",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148458/"
] | I'm trying to get the url of an image from a MetaBox (plugin) filed on an archive-page.
```
<?php
if ( rwmb_meta( 'field-id' ) ) {
// Get images
$img_srcset_large = rwmb_meta( 'field-id', array( 'size' => 'image-size', 'limit' => 1 ) );
echo $img_srcset_large['url']
?>
```
Unfo... | Try like this which fill skip first post:
```
$i = 0;
while ( have_posts() ) :
the_post();
if($i > 0)
get_template_part( 'template-parts/content-home', get_post_type() );
else {
// design your first post as you wish with HTML, CSS
the_title();
the_permalink();
the_po... |
311,035 | <p>He everyone i'm a newbie to wordpress/php and have 1 other problem. I am trying to get the date under the post title and not to display the category tags above the title. I tried it to change thing is the index.php but it would not work. How can I fix this for this page <a href="http://www.quintyvandijk.com/gallery/... | [
{
"answer_id": 311009,
"author": "Balas",
"author_id": 17849,
"author_profile": "https://wordpress.stackexchange.com/users/17849",
"pm_score": 1,
"selected": true,
"text": "<p>Try like this which fill skip first post:</p>\n\n<pre><code>$i = 0;\nwhile ( have_posts() ) :\n the_post();\n... | 2018/08/10 | [
"https://wordpress.stackexchange.com/questions/311035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148457/"
] | He everyone i'm a newbie to wordpress/php and have 1 other problem. I am trying to get the date under the post title and not to display the category tags above the title. I tried it to change thing is the index.php but it would not work. How can I fix this for this page <http://www.quintyvandijk.com/gallery/>.
```
<?p... | Try like this which fill skip first post:
```
$i = 0;
while ( have_posts() ) :
the_post();
if($i > 0)
get_template_part( 'template-parts/content-home', get_post_type() );
else {
// design your first post as you wish with HTML, CSS
the_title();
the_permalink();
the_po... |
311,044 | <p>I am developing a plugin which will show the caller of all the Hooks & Actions on a Page in Wordpress just like QueryMonitor. I know that global $wp_action & $wp_filter has all the information but it does not provide the Caller Component of the Action or Filter.</p>
<p>Can you please help me out with this.<... | [
{
"answer_id": 311049,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 0,
"selected": false,
"text": "<p>Akash, It sounds like you are want to list out all the plugins & themes that have added actions and filte... | 2018/08/10 | [
"https://wordpress.stackexchange.com/questions/311044",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147912/"
] | I am developing a plugin which will show the caller of all the Hooks & Actions on a Page in Wordpress just like QueryMonitor. I know that global $wp\_action & $wp\_filter has all the information but it does not provide the Caller Component of the Action or Filter.
Can you please help me out with this.
If you need the... | As I said in my comment to the question, you can use the PHP internal [ReflectionFunction](https://secure.php.net/manual/en/class.reflectionfunction.php) class to get the filename of the callable. The below code should be a good start to help you. It needs more logic for determining the callbacks and most of that shoul... |
311,076 | <p>I initially had a wordpress installation on a free hosting service. After the hosting suffered an attack I got a backup of all files and the database and am recovering the site on my localhost (using wampserver 3.1.0 on windows 10) before I can update it and upload it to my new hosting service.</p>
<p>The thing is,... | [
{
"answer_id": 311049,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 0,
"selected": false,
"text": "<p>Akash, It sounds like you are want to list out all the plugins & themes that have added actions and filte... | 2018/08/10 | [
"https://wordpress.stackexchange.com/questions/311076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148485/"
] | I initially had a wordpress installation on a free hosting service. After the hosting suffered an attack I got a backup of all files and the database and am recovering the site on my localhost (using wampserver 3.1.0 on windows 10) before I can update it and upload it to my new hosting service.
The thing is, links are... | As I said in my comment to the question, you can use the PHP internal [ReflectionFunction](https://secure.php.net/manual/en/class.reflectionfunction.php) class to get the filename of the callable. The below code should be a good start to help you. It needs more logic for determining the callbacks and most of that shoul... |
311,100 | <p>I'm trying to create a proper 'tel:' link for phone numbers that are added in an ACF text field. So I'm just trying to strip extraneous characters, but the spaces are causing a problem.</p>
<p><strong>Existing code:</strong></p>
<pre><code>$html .= '<p itemprop="telephone" class="member-phone tel">
<a hre... | [
{
"answer_id": 311104,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>If you're trying to escape a phone number link, just using <code>esc_url()</code> with the <code>tel:</... | 2018/08/10 | [
"https://wordpress.stackexchange.com/questions/311100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67697/"
] | I'm trying to create a proper 'tel:' link for phone numbers that are added in an ACF text field. So I'm just trying to strip extraneous characters, but the spaces are causing a problem.
**Existing code:**
```
$html .= '<p itemprop="telephone" class="member-phone tel">
<a href="tel:+1'.preg_replace("/[^0-9]/","",esc_u... | I ended up just changing: `esc_url( $member_phone )` to `esc_attr( $member_phone )`
Not sure of any drawbacks to this, but it does work as the space is not interpreted as '%20'. |
311,116 | <p>i need help. My users register to the website. They type their username <strong>user_login</strong> (see chello) but the Display name (see chello04) is not the same. It has a random two digits at the end.</p>
<p>Is there a way to force Display names to be the same as usernames?</p>
<p><a href="https://i.stack.img... | [
{
"answer_id": 311120,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 0,
"selected": false,
"text": "<p>I would do with jQuery:</p>\n\n<pre><code>add_action('admin_footer','myPlugin_fixed_user_name');\n\nf... | 2018/08/11 | [
"https://wordpress.stackexchange.com/questions/311116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/87667/"
] | i need help. My users register to the website. They type their username **user\_login** (see chello) but the Display name (see chello04) is not the same. It has a random two digits at the end.
Is there a way to force Display names to be the same as usernames?
[ filter.
```
function wpse_filter_user_data( $data, $update, $id) {
if( isset( $data[ 'user_login' ] ) ) {
$data[ 'display_name' ] = $data[ 'user_login' ];
return $data;
}
$user = get_user... |
311,140 | <p>I am using WP-Crontrol and have some CRON jobs running daily to check the age of the posts. If the post is 2 days older, they will be deleted.</p>
<p>This works but for some reason, only some of the three days and older posts get deleted. There are still some that remain published.</p>
<p>It must be because there ... | [
{
"answer_id": 311120,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 0,
"selected": false,
"text": "<p>I would do with jQuery:</p>\n\n<pre><code>add_action('admin_footer','myPlugin_fixed_user_name');\n\nf... | 2018/08/11 | [
"https://wordpress.stackexchange.com/questions/311140",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/139899/"
] | I am using WP-Crontrol and have some CRON jobs running daily to check the age of the posts. If the post is 2 days older, they will be deleted.
This works but for some reason, only some of the three days and older posts get deleted. There are still some that remain published.
It must be because there are a lot of post... | You can use the [`wp_pre_insert_user_data`](https://developer.wordpress.org/reference/hooks/wp_pre_insert_user_data/) filter.
```
function wpse_filter_user_data( $data, $update, $id) {
if( isset( $data[ 'user_login' ] ) ) {
$data[ 'display_name' ] = $data[ 'user_login' ];
return $data;
}
$user = get_user... |
311,154 | <p>Hello i have problem. </p>
<p>I can't view /blog/page/2/ i klick "_posts_link" and error 404 shows me</p>
<p>Blog Page -> home.php</p>
<pre><code> <?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 5, 'page... | [
{
"answer_id": 311187,
"author": "Max",
"author_id": 115933,
"author_profile": "https://wordpress.stackexchange.com/users/115933",
"pm_score": -1,
"selected": false,
"text": "<p>Use this for pagination</p>\n\n<pre><code><?php\n$paged = ( get_query_var( 'page' ) ) ? absint( get_query_v... | 2018/08/11 | [
"https://wordpress.stackexchange.com/questions/311154",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148538/"
] | Hello i have problem.
I can't view /blog/page/2/ i klick "\_posts\_link" and error 404 shows me
Blog Page -> home.php
```
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 5, 'paged' => $currentPage);
... | I guess you don't need to target a taxonomy. You can use the code below:
```
function query_change_function( $query ) {
$query->set( 'posts_per_page', 5 );
}
add_action('pre_get_posts', 'query_change_function');
```
You should wrap the `$query->set( 'posts_per_page', 5 );` around with `if ( ! is_admin() && is_h... |
311,157 | <p>I have serialized post meta values. It looks like this:</p>
<p><a href="https://i.stack.imgur.com/3Aau0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Aau0.png" alt="enter image description here"></a></p>
<p>In array:</p>
<pre><code>$kisiArray = array(
'option1' => 7,
'option2' =>... | [
{
"answer_id": 311216,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 3,
"selected": true,
"text": "<h2>serialised array in a meta_value for query</h2>\n\n<p>It's not a good idea to save serialised array in a <cod... | 2018/08/11 | [
"https://wordpress.stackexchange.com/questions/311157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/133897/"
] | I have serialized post meta values. It looks like this:
[](https://i.stack.imgur.com/3Aau0.png)
In array:
```
$kisiArray = array(
'option1' => 7,
'option2' => 'bar',
'option3' => 'apple',
'option4' => 'orange'
);
```
And I want to make... | serialised array in a meta\_value for query
-------------------------------------------
It's not a good idea to save serialised array in a `meta_value` if you plan to query with any value within that serialized array later. So, the best option is to save meta data as key / value pair.
Query Serialized array
---------... |