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 |
|---|---|---|---|---|---|---|
364,959 | <p>I am trying to create a custom block for text input field.</p>
<p>I managed to create a simple block that produces the <code><p></code> tag. When I change it to produce the <code><input></code> tag and refresh I am getting <em>Block validation failed</em> and the only solution is to remove the block and... | [
{
"answer_id": 364963,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": false,
"text": "<p>You have two choices.</p>\n\n<p>The first one you've discovered: change the block's underlying code, and ... | 2020/04/24 | [
"https://wordpress.stackexchange.com/questions/364959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125744/"
] | I am trying to create a custom block for text input field.
I managed to create a simple block that produces the `<p>` tag. When I change it to produce the `<input>` tag and refresh I am getting *Block validation failed* and the only solution is to remove the block and re-insert it.
It is ok if you have few blocks on ... | You have two choices.
The first one you've discovered: change the block's underlying code, and you will trigger validation errors. The benefit is, you're only including the JS currently required for your block - so it keeps the code as lightweight as possible.
The second option: add [deprecated code](https://develope... |
364,982 | <p>I have a Wordpress site functioning as a blog site on a website. The main website is just basic HTML it is only www.example.com/blog which has the WordPress site.</p>
<p>I have installed an SSL certificate for the domain and it is working fine. I have a .htaccess file in the root folder redirecting from HTTP to htt... | [
{
"answer_id": 364963,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": false,
"text": "<p>You have two choices.</p>\n\n<p>The first one you've discovered: change the block's underlying code, and ... | 2020/04/24 | [
"https://wordpress.stackexchange.com/questions/364982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186817/"
] | I have a Wordpress site functioning as a blog site on a website. The main website is just basic HTML it is only www.example.com/blog which has the WordPress site.
I have installed an SSL certificate for the domain and it is working fine. I have a .htaccess file in the root folder redirecting from HTTP to https for the... | You have two choices.
The first one you've discovered: change the block's underlying code, and you will trigger validation errors. The benefit is, you're only including the JS currently required for your block - so it keeps the code as lightweight as possible.
The second option: add [deprecated code](https://develope... |
365,032 | <p>I've found another questions regarding on how to <code>set</code> cookies on wp/wc but i cannot find how to properly get those cookies, i created a hook on the <code>init</code> function like this;</p>
<pre><code>add_action('init', function () {
$utm_source = get_request_parameter('utm_source');
if (!empty(... | [
{
"answer_id": 364963,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": false,
"text": "<p>You have two choices.</p>\n\n<p>The first one you've discovered: change the block's underlying code, and ... | 2020/04/25 | [
"https://wordpress.stackexchange.com/questions/365032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124888/"
] | I've found another questions regarding on how to `set` cookies on wp/wc but i cannot find how to properly get those cookies, i created a hook on the `init` function like this;
```
add_action('init', function () {
$utm_source = get_request_parameter('utm_source');
if (!empty($utm_source)) {
wc_setcookie... | You have two choices.
The first one you've discovered: change the block's underlying code, and you will trigger validation errors. The benefit is, you're only including the JS currently required for your block - so it keeps the code as lightweight as possible.
The second option: add [deprecated code](https://develope... |
365,058 | <p>Hi I'm looking all over but I don't find the solution: I have an infobox with: Hi, welcome to our "some text"</p>
<p>Now I'd like to add posibility for logged in users "Hello <strong>Tony</strong>, welcome to our "some text"</p>
<p>I tried following code snippet: </p>
<pre><code><div id="infoBox">
<but... | [
{
"answer_id": 364963,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 3,
"selected": false,
"text": "<p>You have two choices.</p>\n\n<p>The first one you've discovered: change the block's underlying code, and ... | 2020/04/25 | [
"https://wordpress.stackexchange.com/questions/365058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186880/"
] | Hi I'm looking all over but I don't find the solution: I have an infobox with: Hi, welcome to our "some text"
Now I'd like to add posibility for logged in users "Hello **Tony**, welcome to our "some text"
I tried following code snippet:
```
<div id="infoBox">
<button class="cross" type="button">X</button>
<p> Hel... | You have two choices.
The first one you've discovered: change the block's underlying code, and you will trigger validation errors. The benefit is, you're only including the JS currently required for your block - so it keeps the code as lightweight as possible.
The second option: add [deprecated code](https://develope... |
365,071 | <p>Just looking for a bit of advice on how to handle this:</p>
<p>In the past (many moons ago) when I did the occasional php/mysql work, it was relatively easy to pull/display data from a table using the table header in the "WHERE" query. (i.e. SELECT * FROM 'table' WHERE 'column-name' = 'query').
The tables would hav... | [
{
"answer_id": 365268,
"author": "Daniel Florian",
"author_id": 183442,
"author_profile": "https://wordpress.stackexchange.com/users/183442",
"pm_score": 0,
"selected": false,
"text": "<p>OK, so maybe the above wasn't worded very well?</p>\n\n<p>I have since made some progress as follows... | 2020/04/26 | [
"https://wordpress.stackexchange.com/questions/365071",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/183442/"
] | Just looking for a bit of advice on how to handle this:
In the past (many moons ago) when I did the occasional php/mysql work, it was relatively easy to pull/display data from a table using the table header in the "WHERE" query. (i.e. SELECT \* FROM 'table' WHERE 'column-name' = 'query').
The tables would have columns... | So, the following works:
```
$result = $wpdb->get_results ( "SELECT * FROM $studentTable WHERE `user_id` = $uid AND `um_key` LIKE 'student_number' ");
foreach($result as $studentNumber){
echo $studentNumber->um_value.'<br/>';
}
```
though I feel that 'foreach' is not really the correct syntax/terminology to be ... |
365,094 | <p>This below script works great and redirects logged-out users to login page if they try to access the my-account page</p>
<pre><code>/**************************************START*******************************************
*********** Redirect account page to login page if user is logged out ****************
********... | [
{
"answer_id": 365268,
"author": "Daniel Florian",
"author_id": 183442,
"author_profile": "https://wordpress.stackexchange.com/users/183442",
"pm_score": 0,
"selected": false,
"text": "<p>OK, so maybe the above wasn't worded very well?</p>\n\n<p>I have since made some progress as follows... | 2020/04/26 | [
"https://wordpress.stackexchange.com/questions/365094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110570/"
] | This below script works great and redirects logged-out users to login page if they try to access the my-account page
```
/**************************************START*******************************************
*********** Redirect account page to login page if user is logged out ****************
**********************... | So, the following works:
```
$result = $wpdb->get_results ( "SELECT * FROM $studentTable WHERE `user_id` = $uid AND `um_key` LIKE 'student_number' ");
foreach($result as $studentNumber){
echo $studentNumber->um_value.'<br/>';
}
```
though I feel that 'foreach' is not really the correct syntax/terminology to be ... |
365,131 | <p>We are two managers for one website , each of us have an AdSense account</p>
<p>Can our ad code display in the articles we write, based on the author slug or id?</p>
<p>I tried to use this code in head section , but it did not work :</p>
<p><code><?php if (is_author('author 1');) : ?>
<script data-ad-cli... | [
{
"answer_id": 365268,
"author": "Daniel Florian",
"author_id": 183442,
"author_profile": "https://wordpress.stackexchange.com/users/183442",
"pm_score": 0,
"selected": false,
"text": "<p>OK, so maybe the above wasn't worded very well?</p>\n\n<p>I have since made some progress as follows... | 2020/04/26 | [
"https://wordpress.stackexchange.com/questions/365131",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186918/"
] | We are two managers for one website , each of us have an AdSense account
Can our ad code display in the articles we write, based on the author slug or id?
I tried to use this code in head section , but it did not work :
`<?php if (is_author('author 1');) : ?>
<script data-ad-client="ca-pub-ءءءءء1ءءءء" async src="htt... | So, the following works:
```
$result = $wpdb->get_results ( "SELECT * FROM $studentTable WHERE `user_id` = $uid AND `um_key` LIKE 'student_number' ");
foreach($result as $studentNumber){
echo $studentNumber->um_value.'<br/>';
}
```
though I feel that 'foreach' is not really the correct syntax/terminology to be ... |
365,150 | <p>How can I add a new column to quick edit and put a custom field in it? I read <a href="https://wordpress.stackexchange.com/a/199758">this question</a> but one of the links lead to an error 404. I need a new column for my custom meta key, "<code>summary</code>" and post types, "<code>post</code>" and "<code>episode</... | [
{
"answer_id": 365166,
"author": "西門 正 Code Guy",
"author_id": 35701,
"author_profile": "https://wordpress.stackexchange.com/users/35701",
"pm_score": 5,
"selected": true,
"text": "<p>There are a few steps to create the custom quick edit box and custom column</p>\n<ol>\n<li>create a cust... | 2020/04/27 | [
"https://wordpress.stackexchange.com/questions/365150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187384/"
] | How can I add a new column to quick edit and put a custom field in it? I read [this question](https://wordpress.stackexchange.com/a/199758) but one of the links lead to an error 404. I need a new column for my custom meta key, "`summary`" and post types, "`post`" and "`episode`". | There are a few steps to create the custom quick edit box and custom column
1. create a custom meta key (assumed that you have 1 already)
2. add custom admin column title and data (assumed that you want to shows the custom meta key in the column, if not, you may also modify a bit of the logic to accomplish the same ef... |
365,162 | <p>I need to limit the number of posts that can be created.</p>
<p>I'd like any variation of total posts, posts per time period (month), by author (ID) or by role.</p>
<p>off-the-shelf plugins found so far in the repository are no longer supported.</p>
<p>is there a functions.php snippet or other approach that works... | [
{
"answer_id": 365166,
"author": "西門 正 Code Guy",
"author_id": 35701,
"author_profile": "https://wordpress.stackexchange.com/users/35701",
"pm_score": 5,
"selected": true,
"text": "<p>There are a few steps to create the custom quick edit box and custom column</p>\n<ol>\n<li>create a cust... | 2020/04/27 | [
"https://wordpress.stackexchange.com/questions/365162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121961/"
] | I need to limit the number of posts that can be created.
I'd like any variation of total posts, posts per time period (month), by author (ID) or by role.
off-the-shelf plugins found so far in the repository are no longer supported.
is there a functions.php snippet or other approach that works consistently?
any sugg... | There are a few steps to create the custom quick edit box and custom column
1. create a custom meta key (assumed that you have 1 already)
2. add custom admin column title and data (assumed that you want to shows the custom meta key in the column, if not, you may also modify a bit of the logic to accomplish the same ef... |
365,281 | <p>i create ajax request in
<strong>functions.php</strong></p>
<pre><code>function my_enqueue() {
wp_enqueue_script( 'ajax-script', get_template_directory_uri() . '/js/script.js', array('jquery') );
wp_localize_script( 'ajax-script', 'cc_ajax_object',
array( 'ajax_url' => admin_url( 'ajaxrequest.p... | [
{
"answer_id": 365287,
"author": "sialfa",
"author_id": 177581,
"author_profile": "https://wordpress.stackexchange.com/users/177581",
"pm_score": 0,
"selected": false,
"text": "<p>Forget about the separate <code>ajaxrequest.php</code> file. Your error is in the <code>wp_localize_script</... | 2020/04/28 | [
"https://wordpress.stackexchange.com/questions/365281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186508/"
] | i create ajax request in
**functions.php**
```
function my_enqueue() {
wp_enqueue_script( 'ajax-script', get_template_directory_uri() . '/js/script.js', array('jquery') );
wp_localize_script( 'ajax-script', 'cc_ajax_object',
array( 'ajax_url' => admin_url( 'ajaxrequest.php' ) ) );
}
add_action( 'wp_... | You can take reference from below code. Remove your ajaxrequest.php file, no need of that file because i have added ajaxrequest.php file's code in active theme's functions.php file.
I have changed ajax url and add js script code in script.js file. I have tested and it is working for me. let me know if this works for y... |
365,303 | <p>I am getting below error in Admin Panel.</p>
<p><strong>Deprecated : contextual_help has been deprecated since version 3.3.0. Use get_current_screen () -> add_help_tab (), get_current_screen () -> remove_help_tab () instead. in /var/www/html/invertir/wp-includes/functions.php on line 5088</strong></p>
<p><a href="... | [
{
"answer_id": 365306,
"author": "Nate",
"author_id": 186686,
"author_profile": "https://wordpress.stackexchange.com/users/186686",
"pm_score": 3,
"selected": true,
"text": "<p>I see that you have a lot of updates, first, update everything, then you update the plugins, themes, then if th... | 2020/04/28 | [
"https://wordpress.stackexchange.com/questions/365303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65189/"
] | I am getting below error in Admin Panel.
**Deprecated : contextual\_help has been deprecated since version 3.3.0. Use get\_current\_screen () -> add\_help\_tab (), get\_current\_screen () -> remove\_help\_tab () instead. in /var/www/html/invertir/wp-includes/functions.php on line 5088**
[![enter image description her... | I see that you have a lot of updates, first, update everything, then you update the plugins, themes, then if that does not work then disable all your plugins and themes and see if that fixes the issue. If it does then you enable one plugin at a time until you have all your plugins enabled, if it appears again then you ... |
365,308 | <p>How do I add a shortcode without plugins? I am going to add a shortcode that will give a count of views on a page. </p>
| [
{
"answer_id": 365311,
"author": "Drmzindec",
"author_id": 74335,
"author_profile": "https://wordpress.stackexchange.com/users/74335",
"pm_score": 2,
"selected": false,
"text": "<p>There is a whole section on the WordPress Codex on this: <a href=\"https://codex.wordpress.org/Shortcode_AP... | 2020/04/28 | [
"https://wordpress.stackexchange.com/questions/365308",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186686/"
] | How do I add a shortcode without plugins? I am going to add a shortcode that will give a count of views on a page. | You'll probably need to modify this a bit to ensure things get placed where you want them but here's something I wrote that counts views on `posts` and displays the view counts for administrators:
```
//ADD TRACKER FUNCTION TO ALL SINGLE VIEWS
function custom_hook_tracker( $post_id ) {
if( !is_single()... |
365,394 | <p>I have custom fields to display in a post. But all of the custom fields are displaying in a single continuous line, while i want them in separate lines. I am not a coder. I tried <code><br>, <li></code> but still no luck. I also searched in stack exchange and web for similar problem, but could not get a... | [
{
"answer_id": 365311,
"author": "Drmzindec",
"author_id": 74335,
"author_profile": "https://wordpress.stackexchange.com/users/74335",
"pm_score": 2,
"selected": false,
"text": "<p>There is a whole section on the WordPress Codex on this: <a href=\"https://codex.wordpress.org/Shortcode_AP... | 2020/04/29 | [
"https://wordpress.stackexchange.com/questions/365394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187122/"
] | I have custom fields to display in a post. But all of the custom fields are displaying in a single continuous line, while i want them in separate lines. I am not a coder. I tried `<br>, <li>` but still no luck. I also searched in stack exchange and web for similar problem, but could not get answer. Please help.
Below ... | You'll probably need to modify this a bit to ensure things get placed where you want them but here's something I wrote that counts views on `posts` and displays the view counts for administrators:
```
//ADD TRACKER FUNCTION TO ALL SINGLE VIEWS
function custom_hook_tracker( $post_id ) {
if( !is_single()... |
365,476 | <p>I have a multi-site Wordpress setup. Each sub-site uses it's own child theme, but there is one stylesheet that has CSS rules that should be used on several of these sub-sites. I do not want to have multiple identical stylesheet files for each sub-site, because when I make changes to it, I would have to make these ch... | [
{
"answer_id": 365477,
"author": "Bevan",
"author_id": 187183,
"author_profile": "https://wordpress.stackexchange.com/users/187183",
"pm_score": -1,
"selected": false,
"text": "<p>Use the wp_enqueue_style function, and put the path to the master CSS sheet in the source <code>src=\"full-p... | 2020/04/30 | [
"https://wordpress.stackexchange.com/questions/365476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187182/"
] | I have a multi-site Wordpress setup. Each sub-site uses it's own child theme, but there is one stylesheet that has CSS rules that should be used on several of these sub-sites. I do not want to have multiple identical stylesheet files for each sub-site, because when I make changes to it, I would have to make these chang... | First off, you'll obviously need to be using the same parent theme for all sites. You then set up each sub-site with a child-theme for that parent theme.
To use the same stylesheet on multiple sites, add the following code to the `functions.php` file of each sub-site:
```
function import_shared_style_sheet() {
w... |
365,530 | <p>I want to create the a link like <a href="https://mywordpresssite.com/mypage" rel="nofollow noreferrer">https://mywordpresssite.com/mypage</a>, that should call my function and execute the code. I am doing this for my backend script call that link and send some parameters to save data in database, I want to create t... | [
{
"answer_id": 365497,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>The reason you are advised to put a custom post type in a plugin rather than your theme is that in this way the ... | 2020/05/01 | [
"https://wordpress.stackexchange.com/questions/365530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/174404/"
] | I want to create the a link like <https://mywordpresssite.com/mypage>, that should call my function and execute the code. I am doing this for my backend script call that link and send some parameters to save data in database, I want to create that link by plugin only so it will use any of other wordpress websites
I tr... | The reason you are advised to put a custom post type in a plugin rather than your theme is that in this way the user can keep the cpt even if he decides to switch to another theme. In five years or so, design trends may change significantly and you don't want to be stuck with a theme, just because it also holds your cu... |
365,547 | <p>I'm looking for a way to pass post meta data to each of the blocks in the editor for the purpose of styling the content. My actual use case is hard to explain briefly, but for the sake of example, pretend it's the ability to display the post either in dark or light mode depending on a post meta value that the user s... | [
{
"answer_id": 365588,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": -1,
"selected": false,
"text": "<p><strong>Your proposed solution is not possible.</strong> There is no hook or filter that would allow you to... | 2020/05/01 | [
"https://wordpress.stackexchange.com/questions/365547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21290/"
] | I'm looking for a way to pass post meta data to each of the blocks in the editor for the purpose of styling the content. My actual use case is hard to explain briefly, but for the sake of example, pretend it's the ability to display the post either in dark or light mode depending on a post meta value that the user sets... | I was able to solve this problem by using the `admin_body_class` filter to add a class name to the `<body>` element of the admin page, and writing selectors for that class in my stylesheet.
```php
add_filter( 'admin_body_class', 'add_status_classes' );
```
```php
function add_status_classes( $classes ) {
$post_met... |
365,557 | <p>I'm looking for a way to remove the eye icon that shows visibility on login screen (wp-admin and wp-login) and reset password screen (/wp-login.php?action=rp).</p>
<p>As you can see on the screenshot below :</p>
<p>Login Page :</p>
<p><a href="https://i.stack.imgur.com/NRANB.png" rel="nofollow noreferrer"><img sr... | [
{
"answer_id": 365566,
"author": "dyg",
"author_id": 150607,
"author_profile": "https://wordpress.stackexchange.com/users/150607",
"pm_score": 1,
"selected": false,
"text": "<p>This is one way</p>\n\n<pre><code>add_action('login_head', 'my_remove_eye');\n\nfunction my_remove_eye() {\n e... | 2020/05/01 | [
"https://wordpress.stackexchange.com/questions/365557",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119785/"
] | I'm looking for a way to remove the eye icon that shows visibility on login screen (wp-admin and wp-login) and reset password screen (/wp-login.php?action=rp).
As you can see on the screenshot below :
Login Page :
[](https://i.stack.imgur.com/NRANB.... | This is one way
```
add_action('login_head', 'my_remove_eye');
function my_remove_eye() {
echo
'<style>
span.dashicons-visibility:before {
content: "";
}
</style>';
}
``` |
365,594 | <p>I am new with wordpress en I try to build a website for soccer teams. this is what I like to have:</p>
<p>team name (Arsenal) 1 role: player1 can see the following pages (Test1 - Test2 - team1 score)</p>
<p>Team name (Chelsea) 2 role: player2 can see the following pages (test1 - test2 - team2 score)</p>
<p>Role p... | [
{
"answer_id": 365566,
"author": "dyg",
"author_id": 150607,
"author_profile": "https://wordpress.stackexchange.com/users/150607",
"pm_score": 1,
"selected": false,
"text": "<p>This is one way</p>\n\n<pre><code>add_action('login_head', 'my_remove_eye');\n\nfunction my_remove_eye() {\n e... | 2020/05/01 | [
"https://wordpress.stackexchange.com/questions/365594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187277/"
] | I am new with wordpress en I try to build a website for soccer teams. this is what I like to have:
team name (Arsenal) 1 role: player1 can see the following pages (Test1 - Test2 - team1 score)
Team name (Chelsea) 2 role: player2 can see the following pages (test1 - test2 - team2 score)
Role palyer1 should not be abl... | This is one way
```
add_action('login_head', 'my_remove_eye');
function my_remove_eye() {
echo
'<style>
span.dashicons-visibility:before {
content: "";
}
</style>';
}
``` |
365,619 | <p>Can someone assist with a function code that displays children on a parent page. </p>
<p>I have breadcrumbs for when standing on child page going back to parent but,</p>
<p>I need standing on parent page to display all children in UL/li list below the page title</p>
| [
{
"answer_id": 365566,
"author": "dyg",
"author_id": 150607,
"author_profile": "https://wordpress.stackexchange.com/users/150607",
"pm_score": 1,
"selected": false,
"text": "<p>This is one way</p>\n\n<pre><code>add_action('login_head', 'my_remove_eye');\n\nfunction my_remove_eye() {\n e... | 2020/05/01 | [
"https://wordpress.stackexchange.com/questions/365619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186632/"
] | Can someone assist with a function code that displays children on a parent page.
I have breadcrumbs for when standing on child page going back to parent but,
I need standing on parent page to display all children in UL/li list below the page title | This is one way
```
add_action('login_head', 'my_remove_eye');
function my_remove_eye() {
echo
'<style>
span.dashicons-visibility:before {
content: "";
}
</style>';
}
``` |
365,632 | <p>I need help in getting this to work, i want to pass the site url in a jquery window.location.replace("URL")
And i want it to work like this window.location.replace("site_url/contact-us")
My whole concept is to redirect to www.mysite.com/contact-us but am getting www.mysite.com/login/contact-us</p>
<p>Here is my fu... | [
{
"answer_id": 365566,
"author": "dyg",
"author_id": 150607,
"author_profile": "https://wordpress.stackexchange.com/users/150607",
"pm_score": 1,
"selected": false,
"text": "<p>This is one way</p>\n\n<pre><code>add_action('login_head', 'my_remove_eye');\n\nfunction my_remove_eye() {\n e... | 2020/05/02 | [
"https://wordpress.stackexchange.com/questions/365632",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152456/"
] | I need help in getting this to work, i want to pass the site url in a jquery window.location.replace("URL")
And i want it to work like this window.location.replace("site\_url/contact-us")
My whole concept is to redirect to www.mysite.com/contact-us but am getting www.mysite.com/login/contact-us
Here is my full code
... | This is one way
```
add_action('login_head', 'my_remove_eye');
function my_remove_eye() {
echo
'<style>
span.dashicons-visibility:before {
content: "";
}
</style>';
}
``` |
365,647 | <p>WooCommerce has a built in <code>product_tag</code> url filter as such:</p>
<pre><code>https://my-url.com/my-page/?product_tag=my-slug
</code></pre>
<p>Bringing back all the <code>product_tag</code>s with the given slug in the url.</p>
<p>I am trying to do something relatively simple, retrieve the name of the <co... | [
{
"answer_id": 365650,
"author": "Joe",
"author_id": 183929,
"author_profile": "https://wordpress.stackexchange.com/users/183929",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure if I'm understanding you correctly, but why don't you just use $_GET['product_tag'] at the moment wher... | 2020/05/02 | [
"https://wordpress.stackexchange.com/questions/365647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102212/"
] | WooCommerce has a built in `product_tag` url filter as such:
```
https://my-url.com/my-page/?product_tag=my-slug
```
Bringing back all the `product_tag`s with the given slug in the url.
I am trying to do something relatively simple, retrieve the name of the `product_tag` and put it in a text heading block so the vi... | I suppose this works.
Still not sure if it is the best method. If someone knows of a better way to do this please chime in, I'll gladly adjust the answer.
```
function slugToName($slug) {
global $wpdb;
$query = 'SELECT name FROM `wp_terms` WHERE slug = "' . $slug . '"';
$getname = $wpdb->get_results($query... |
365,712 | <p>I have php.ini files in the following directories of my WordPress installation:</p>
<ul>
<li>/wp-admin</li>
<li>/wp-content</li>
<li>/ (where there wp-config.php lies)</li>
</ul>
<p>In all of them I set <code>upload_max_filesize = 640M;</code> - <strong>640MB</strong> is the maximum value that is allowed by my pro... | [
{
"answer_id": 365713,
"author": "jasie",
"author_id": 124308,
"author_profile": "https://wordpress.stackexchange.com/users/124308",
"pm_score": 1,
"selected": true,
"text": "<p>UPDATED:</p>\n\n<p>I figured out the following by playing with the numbers in the php.ini in /wp-admin:</p>\n\... | 2020/05/03 | [
"https://wordpress.stackexchange.com/questions/365712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124308/"
] | I have php.ini files in the following directories of my WordPress installation:
* /wp-admin
* /wp-content
* / (where there wp-config.php lies)
In all of them I set `upload_max_filesize = 640M;` - **640MB** is the maximum value that is allowed by my provider in my package (I called).
```
memory_limit = 268435456;
pos... | UPDATED:
I figured out the following by playing with the numbers in the php.ini in /wp-admin:
The add upload page in the admin area seems to always **display the lower value** of either `post_max_size` and `upload_max_filesize`.
In my case, `post_max_size` was lower than `upload_max_filesize` which is the reason for... |
365,743 | <p>I will really appreciate your help to create a function that will check by a given <code>$my_custom_post_type_name</code> and <code>$post_name</code> and return <code>true</code> if the current page / post is a <code>$post_name</code> or <code>$post_name_child</code> or <code>$post_name_grandchild</code> and so on b... | [
{
"answer_id": 365713,
"author": "jasie",
"author_id": 124308,
"author_profile": "https://wordpress.stackexchange.com/users/124308",
"pm_score": 1,
"selected": true,
"text": "<p>UPDATED:</p>\n\n<p>I figured out the following by playing with the numbers in the php.ini in /wp-admin:</p>\n\... | 2020/05/03 | [
"https://wordpress.stackexchange.com/questions/365743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/180722/"
] | I will really appreciate your help to create a function that will check by a given `$my_custom_post_type_name` and `$post_name` and return `true` if the current page / post is a `$post_name` or `$post_name_child` or `$post_name_grandchild` and so on based on the provided parent slug and custom post type.
Let's say thi... | UPDATED:
I figured out the following by playing with the numbers in the php.ini in /wp-admin:
The add upload page in the admin area seems to always **display the lower value** of either `post_max_size` and `upload_max_filesize`.
In my case, `post_max_size` was lower than `upload_max_filesize` which is the reason for... |
365,766 | <p>I am trying to make a custom loop that will display the latest 5 posts from select categories, all using a single query. I want the loop to display the category name followed by the 5 posts, and then the next category, etc.</p>
<p>I followed <a href="https://wordpress.stackexchange.com/questions/43426/get-all-categ... | [
{
"answer_id": 365852,
"author": "Karthick",
"author_id": 186872,
"author_profile": "https://wordpress.stackexchange.com/users/186872",
"pm_score": 2,
"selected": true,
"text": "<p>I have used <a href=\"https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query\" rel=\"nofo... | 2020/05/04 | [
"https://wordpress.stackexchange.com/questions/365766",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/151735/"
] | I am trying to make a custom loop that will display the latest 5 posts from select categories, all using a single query. I want the loop to display the category name followed by the 5 posts, and then the next category, etc.
I followed [this answer](https://wordpress.stackexchange.com/questions/43426/get-all-categories... | I have used [Custom Select Query](https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query) to gather all information in a single call and hope it may work out.
```
global $wpdb;
$selected_cat_id = '6,7,8,9';
$post_count = 5;
$custom_query = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->ter... |
365,787 | <p>In category display type u can choose between (default, products, subcategories, both) options.
Is there any way to make an if statement that uses those values?</p>
<p>I would like todo something like the below but i'm having a hard time figuring out how u can check for those values.</p>
<p>Now i have something li... | [
{
"answer_id": 365852,
"author": "Karthick",
"author_id": 186872,
"author_profile": "https://wordpress.stackexchange.com/users/186872",
"pm_score": 2,
"selected": true,
"text": "<p>I have used <a href=\"https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query\" rel=\"nofo... | 2020/05/04 | [
"https://wordpress.stackexchange.com/questions/365787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/184144/"
] | In category display type u can choose between (default, products, subcategories, both) options.
Is there any way to make an if statement that uses those values?
I would like todo something like the below but i'm having a hard time figuring out how u can check for those values.
Now i have something like the below but ... | I have used [Custom Select Query](https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query) to gather all information in a single call and hope it may work out.
```
global $wpdb;
$selected_cat_id = '6,7,8,9';
$post_count = 5;
$custom_query = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->ter... |
365,788 | <p>I really new in Wordpress development and have a little bit of knowledge of jquery.
I was trying to understand a WordPress plugin and also trying to understand the js code they wrote for the plugin.
I don't understand what does the following code mean.</p>
<pre><code>(function( api, wp, $ ) {
'use strict';
})( wp.... | [
{
"answer_id": 365792,
"author": "Joe",
"author_id": 183929,
"author_profile": "https://wordpress.stackexchange.com/users/183929",
"pm_score": -1,
"selected": false,
"text": "<p>As I understand it, this function just tells you that strict mode (<a href=\"https://www.w3schools.com/js/js_s... | 2020/05/04 | [
"https://wordpress.stackexchange.com/questions/365788",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/186128/"
] | I really new in Wordpress development and have a little bit of knowledge of jquery.
I was trying to understand a WordPress plugin and also trying to understand the js code they wrote for the plugin.
I don't understand what does the following code mean.
```
(function( api, wp, $ ) {
'use strict';
})( wp.customize, wp,... | It's an Immediately Invoked Function Expression (IIFE) - an anonymous function that executes itself after it has been defined.
The variables at the bottom are taken from the global scope and are passed as parameters to the anonymous function.
So `api` represents `wp.customize`,
`wp` represents `wp` and
`$` repre... |
365,814 | <p>I am trying to create a post when my <a href="https://www.gravityforms.com/" rel="nofollow noreferrer">Gravity Form</a> submits and redirect to the post permalink on form confirmation.</p>
<p>See below the function which creates my post/order when my form submits using the <a href="https://docs.gravityforms.com/gfo... | [
{
"answer_id": 365817,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": true,
"text": "<p>The entry object is available in both hooks, so how about saving the created post ID as meta on the entr... | 2020/05/04 | [
"https://wordpress.stackexchange.com/questions/365814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111152/"
] | I am trying to create a post when my [Gravity Form](https://www.gravityforms.com/) submits and redirect to the post permalink on form confirmation.
See below the function which creates my post/order when my form submits using the [`gform_after_submission`](https://docs.gravityforms.com/gform_after_submission/) action.... | The entry object is available in both hooks, so how about saving the created post ID as meta on the entry with [`gform_update_meta()`](https://docs.gravityforms.com/gform_update_meta/):
```
gform_update_meta( $entry->id, 'order_id', $post_id );
```
Then retrieving it in the confirmation, using [`gform_get_meta()`](h... |
365,848 | <p>I am using the Shamrock theme and I am happy with link colours on the main page however when you go into a blog post and hover over any links within the body they are red. </p>
<p>I have tried multiple things with CSS (after hours of googling as I do not know CSS) and without using !important and therefore changing... | [
{
"answer_id": 365817,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": true,
"text": "<p>The entry object is available in both hooks, so how about saving the created post ID as meta on the entr... | 2020/05/04 | [
"https://wordpress.stackexchange.com/questions/365848",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187431/"
] | I am using the Shamrock theme and I am happy with link colours on the main page however when you go into a blog post and hover over any links within the body they are red.
I have tried multiple things with CSS (after hours of googling as I do not know CSS) and without using !important and therefore changing ALL links... | The entry object is available in both hooks, so how about saving the created post ID as meta on the entry with [`gform_update_meta()`](https://docs.gravityforms.com/gform_update_meta/):
```
gform_update_meta( $entry->id, 'order_id', $post_id );
```
Then retrieving it in the confirmation, using [`gform_get_meta()`](h... |
365,860 | <p>Was just checking the error logs on a new install of 5.4.1 and see a lot:</p>
<pre><code>Got error 'PHP message: PHP Deprecated: media_buttons_context is <strong>deprecated</strong> since version 3.5.0! Use media_buttons instead. in /var/www/susites/evozyne/htdocs/wp-includes/functions.php on line 5088... | [
{
"answer_id": 365868,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 0,
"selected": false,
"text": "<p>According to the developer documentation, <a href=\"https://developer.wordpress.org/reference/hooks/media_butto... | 2020/05/05 | [
"https://wordpress.stackexchange.com/questions/365860",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/153797/"
] | Was just checking the error logs on a new install of 5.4.1 and see a lot:
```
Got error 'PHP message: PHP Deprecated: media_buttons_context is <strong>deprecated</strong> since version 3.5.0! Use media_buttons instead. in /var/www/susites/evozyne/htdocs/wp-includes/functions.php on line 5088', referer: https://evozyn... | Try this media\_buttons instead of media\_buttons\_context
Please refer these URL:
<https://developer.wordpress.org/reference/hooks/media_buttons_context/>
<https://developer.wordpress.org/reference/hooks/media_buttons/> |
365,863 | <p>I am having an issue with using global variables to get values inserted into my custom database table:</p>
<pre><code>// example that does not work
$user = wp_get_current_user();
$mega = $user->user_login; // this values will return blank when
// inserted into database especially ... | [
{
"answer_id": 365868,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 0,
"selected": false,
"text": "<p>According to the developer documentation, <a href=\"https://developer.wordpress.org/reference/hooks/media_butto... | 2020/05/05 | [
"https://wordpress.stackexchange.com/questions/365863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152456/"
] | I am having an issue with using global variables to get values inserted into my custom database table:
```
// example that does not work
$user = wp_get_current_user();
$mega = $user->user_login; // this values will return blank when
// inserted into database especially
... | Try this media\_buttons instead of media\_buttons\_context
Please refer these URL:
<https://developer.wordpress.org/reference/hooks/media_buttons_context/>
<https://developer.wordpress.org/reference/hooks/media_buttons/> |
365,980 | <p>I'm trying to find a way to add repeatable fields inside a custom admin page that I've made.</p>
<p>Code:</p>
<pre><code> /*WordPress Menus API.*/
function add_new_menu_items()
{
add_menu_page(
"Theme Options",
"Theme Options",
"manage_options",
"th... | [
{
"answer_id": 365999,
"author": "Ejaz UL Haq",
"author_id": 178714,
"author_profile": "https://wordpress.stackexchange.com/users/178714",
"pm_score": 0,
"selected": false,
"text": "<p>Add at the top of the page after PHP opening tag \nlike <br>\n<code><?php \n$advertising_code = 'adv... | 2020/05/06 | [
"https://wordpress.stackexchange.com/questions/365980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187466/"
] | I'm trying to find a way to add repeatable fields inside a custom admin page that I've made.
Code:
```
/*WordPress Menus API.*/
function add_new_menu_items()
{
add_menu_page(
"Theme Options",
"Theme Options",
"manage_options",
"theme-options",
... | It`s not the best solution but maybe it is helpful for you to create your own solution.
```
function display_ads_form_element()
{
// get the total number of "advertising codes" from the database
// the default value is 1
$codes = array('1' => '' );
if( get_option('advertising_code') !== FALSE ) {
... |
365,986 | <p>I am trying to redirect non-existing woocommerce product's url's to worpdress page.</p>
<p>Example:</p>
<p><a href="https://testname.com/product/abc" rel="nofollow noreferrer">https://testname.com/product/abc</a> to <a href="https://testname.com/sample-page" rel="nofollow noreferrer">https://testname.com/sample-pa... | [
{
"answer_id": 366072,
"author": "Yash Tiwari",
"author_id": 185348,
"author_profile": "https://wordpress.stackexchange.com/users/185348",
"pm_score": 0,
"selected": false,
"text": "<p>It is possible with the .htaccess file, add the below rule in the .htaccess:</p>\n\n<p>Redirect 301 <a ... | 2020/05/06 | [
"https://wordpress.stackexchange.com/questions/365986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5669/"
] | I am trying to redirect non-existing woocommerce product's url's to worpdress page.
Example:
<https://testname.com/product/abc> to <https://testname.com/sample-page>
here there is no product published as abc.
also i have few working products at <https://testname.com/product/def>.
i tried with .htaccess but looks l... | If you prefer more control in coding, you may use
* [request hook](https://developer.wordpress.org/reference/hooks/request/) - test the WordPress query after it is being setup
* [preg\_match()](https://www.php.net/manual/en/function.preg-match.php) - match `/product/` keyword
* [url\_to\_postid()](https://developer.wo... |
365,998 | <p>I'm trying to add products using data gathered from a Caldera form. I'm successful in creating the product and adding other attributes, but 'reviews_allowed' is proving to be elusive.</p>
<pre><code>$post_id = wp_insert_post(array(
'post_title' => 'ProductName '.$data['uniquenumber'],
'post_type' => ... | [
{
"answer_id": 366072,
"author": "Yash Tiwari",
"author_id": 185348,
"author_profile": "https://wordpress.stackexchange.com/users/185348",
"pm_score": 0,
"selected": false,
"text": "<p>It is possible with the .htaccess file, add the below rule in the .htaccess:</p>\n\n<p>Redirect 301 <a ... | 2020/05/06 | [
"https://wordpress.stackexchange.com/questions/365998",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187547/"
] | I'm trying to add products using data gathered from a Caldera form. I'm successful in creating the product and adding other attributes, but 'reviews\_allowed' is proving to be elusive.
```
$post_id = wp_insert_post(array(
'post_title' => 'ProductName '.$data['uniquenumber'],
'post_type' => 'product',
'post... | If you prefer more control in coding, you may use
* [request hook](https://developer.wordpress.org/reference/hooks/request/) - test the WordPress query after it is being setup
* [preg\_match()](https://www.php.net/manual/en/function.preg-match.php) - match `/product/` keyword
* [url\_to\_postid()](https://developer.wo... |
366,017 | <p>I want to set post title for alt and title Attribute in this code</p>
<p>what should I do?</p>
<pre><code><?php
if ( true == get_theme_mod( 'archive_featured_images', true ) ) :
if ( has_post_thumbnail() && ( get_the_post_thumbnail() != '' ) ) :
echo '<a class="featured-image" href="'. es... | [
{
"answer_id": 366034,
"author": "Aboelabbas",
"author_id": 119142,
"author_profile": "https://wordpress.stackexchange.com/users/119142",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the second parameter of <a href=\"https://developer.wordpress.org/reference/functions/the_po... | 2020/05/07 | [
"https://wordpress.stackexchange.com/questions/366017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115412/"
] | I want to set post title for alt and title Attribute in this code
what should I do?
```
<?php
if ( true == get_theme_mod( 'archive_featured_images', true ) ) :
if ( has_post_thumbnail() && ( get_the_post_thumbnail() != '' ) ) :
echo '<a class="featured-image" href="'. esc_url( get_permalink() ) .'" title=... | You can use the second parameter of [the\_post\_thumbnail()](https://developer.wordpress.org/reference/functions/the_post_thumbnail/) function.
```
the_post_thumbnail( 'mudra-featured-image', ['alt' => get_the_title()] );
```
Another option, you can do this using the filter [wp\_get\_attachment\_image\_attributes](h... |
366,033 | <p>How do I change a parameter/text that are specified in the core without editing the core?</p>
<p>For example, this is a part of of comment-template.php from the wp-includes directory:</p>
<pre><code>$fields = apply_filters( 'comment_form_default_fields', $fields );
$defaults = array(
'fields' ... | [
{
"answer_id": 366147,
"author": "Antti Koskinen",
"author_id": 144392,
"author_profile": "https://wordpress.stackexchange.com/users/144392",
"pm_score": 2,
"selected": true,
"text": "<p>If you scroll further down the comment-template.php file, you'll notice that the next available filte... | 2020/05/07 | [
"https://wordpress.stackexchange.com/questions/366033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/185417/"
] | How do I change a parameter/text that are specified in the core without editing the core?
For example, this is a part of of comment-template.php from the wp-includes directory:
```
$fields = apply_filters( 'comment_form_default_fields', $fields );
$defaults = array(
'fields' => $fields,
... | If you scroll further down the comment-template.php file, you'll notice that the next available filter you can use is [`comment_form_defaults`](https://developer.wordpress.org/reference/hooks/comment_form_defaults/). With this filter you can change the default comment form configuration.
```
add_filter( 'comment_form... |
366,037 | <p>i'm working on a music plugin.</p>
<p>It uses a custom table <em>tracklist_items</em> to store every tracks of a playlist; which has a structure like this :</p>
<pre><code>|id| |track_id| |tracklist_id| |order| |time|
</code></pre>
<p>So if I want to count the total tracks of a tracklist, I have this function :</... | [
{
"answer_id": 366039,
"author": "Sanjay Gupta",
"author_id": 185502,
"author_profile": "https://wordpress.stackexchange.com/users/185502",
"pm_score": -1,
"selected": false,
"text": "<p>Try this</p>\n\n<pre><code>function get_subtracks_count(){\n global $wpdb;\n if (!$this->post_id... | 2020/05/07 | [
"https://wordpress.stackexchange.com/questions/366037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70449/"
] | i'm working on a music plugin.
It uses a custom table *tracklist\_items* to store every tracks of a playlist; which has a structure like this :
```
|id| |track_id| |tracklist_id| |order| |time|
```
So if I want to count the total tracks of a tracklist, I have this function :
```
function get_subtracks_count(){
g... | The way to go is apply custom filters to the `WP_Query` you are running.
```php
add_filter('posts_clauses', function ($clauses, $query) {
global $wpdb;
// only run the filter for a given query
// do your checks and return early
if (!$query->is_main_query() || !$query->is_post_type_archive('tracklist')... |
366,046 | <p>When I use Advanced Custom Fields I can return the full image array of an upload. Is there a native WordPress way to get the full image array for any image in the Media Library by image ID? I can find ways to get the alt text and a specific image size, but not the array itself... </p>
| [
{
"answer_id": 366051,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>The \"full array\" is constructed by Advanced Custom Fields from various sources. It's not a format that... | 2020/05/07 | [
"https://wordpress.stackexchange.com/questions/366046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121694/"
] | When I use Advanced Custom Fields I can return the full image array of an upload. Is there a native WordPress way to get the full image array for any image in the Media Library by image ID? I can find ways to get the alt text and a specific image size, but not the array itself... | The "full array" is constructed by Advanced Custom Fields from various sources. It's not a format that occurs natively in WordPress.
If you want to output an image tag for an image with all the correct attributes, just use the ID with [`wp_get_attachment_image()`](https://developer.wordpress.org/reference/functions/wp... |
366,055 | <p>Is there any hook for when any plugin update is found to trigger a mail using PHP?
I found reference to upgrader_process_complete hook, but that is called after plugins are updated and not before.</p>
<p>Also, how can I fetch the list of plugins which have updates pending at a given time?</p>
| [
{
"answer_id": 366067,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 1,
"selected": false,
"text": "<p>The relevant code is <a href=\"https://github.com/WordPress/WordPress/blob/5.4.1/wp-includes/update.php#L258\" rel=... | 2020/05/07 | [
"https://wordpress.stackexchange.com/questions/366055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143161/"
] | Is there any hook for when any plugin update is found to trigger a mail using PHP?
I found reference to upgrader\_process\_complete hook, but that is called after plugins are updated and not before.
Also, how can I fetch the list of plugins which have updates pending at a given time? | The relevant code is [wp\_update\_plugins()](https://github.com/WordPress/WordPress/blob/5.4.1/wp-includes/update.php#L258). You can see that it stores its state in a site transient called 'update\_plugins':
```
set_site_transient( 'update_plugins', $new_option );
```
and [we can hook that](https://github.com/WordPr... |
366,118 | <p>I am adding a "Conversations" endpoint so that it appears in my account in woocommerce</p>
<pre><code>add_action( 'init', array($this, 'custom_endpoints') );
function custom_endpoints() {
add_rewrite_endpoint( 'conversations', EP_PERMALINK | EP_PAGES );
}
</code></pre>
<p>It will work just fine with a "plain" ... | [
{
"answer_id": 366120,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>I would avoid using <code>add_rewrite_endpoint()</code> directly to register account page endpoints in ... | 2020/05/08 | [
"https://wordpress.stackexchange.com/questions/366118",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/184978/"
] | I am adding a "Conversations" endpoint so that it appears in my account in woocommerce
```
add_action( 'init', array($this, 'custom_endpoints') );
function custom_endpoints() {
add_rewrite_endpoint( 'conversations', EP_PERMALINK | EP_PAGES );
}
```
It will work just fine with a "plain" permalink structure, but w... | I would avoid using `add_rewrite_endpoint()` directly to register account page endpoints in WooCommerce. WooCommerce has a filter that you can use that make sure everything else works properly, like the endpoint title filter and calls to `is_wc_endpoint_url()`.
So add the endpoint with the `woocommerce_get_query_vars`... |
366,125 | <p>I created an installation of my multisite ecommerce to differentiate the men's and women's departments. Often, however, it happens that in the men's department they do research related to women's articles or vice versa. Consequently, my site says it cannot find an article, obviously it is not so.
How can I implement... | [
{
"answer_id": 366120,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>I would avoid using <code>add_rewrite_endpoint()</code> directly to register account page endpoints in ... | 2020/05/08 | [
"https://wordpress.stackexchange.com/questions/366125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/167366/"
] | I created an installation of my multisite ecommerce to differentiate the men's and women's departments. Often, however, it happens that in the men's department they do research related to women's articles or vice versa. Consequently, my site says it cannot find an article, obviously it is not so.
How can I implement a ... | I would avoid using `add_rewrite_endpoint()` directly to register account page endpoints in WooCommerce. WooCommerce has a filter that you can use that make sure everything else works properly, like the endpoint title filter and calls to `is_wc_endpoint_url()`.
So add the endpoint with the `woocommerce_get_query_vars`... |
366,142 | <p>Is there any filter or hook to print a script or add in the footer some content? I'm not talking about <code>wp_enqueue_</code> function, I'm creating a plugin that will show a banner for privacy and cookie info and I want to append it to the footer. I'm using at the moment this code, but I hope that there is a more... | [
{
"answer_id": 366120,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>I would avoid using <code>add_rewrite_endpoint()</code> directly to register account page endpoints in ... | 2020/05/08 | [
"https://wordpress.stackexchange.com/questions/366142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/177581/"
] | Is there any filter or hook to print a script or add in the footer some content? I'm not talking about `wp_enqueue_` function, I'm creating a plugin that will show a banner for privacy and cookie info and I want to append it to the footer. I'm using at the moment this code, but I hope that there is a more clean wey to ... | I would avoid using `add_rewrite_endpoint()` directly to register account page endpoints in WooCommerce. WooCommerce has a filter that you can use that make sure everything else works properly, like the endpoint title filter and calls to `is_wc_endpoint_url()`.
So add the endpoint with the `woocommerce_get_query_vars`... |
366,150 | <p>I am working with a child theme from 'Astra'. I am editing 'style.css' of my child theme for styling my website. I added this code to my child's functions.php' file to enqueue the father-child styles.</p>
<pre><code><?php
add_action('wp_enqueue_scripts', 'example_enqueue_styles');
add_action( 'wp_enqueue_scrip... | [
{
"answer_id": 366152,
"author": "Sanjay Gupta",
"author_id": 185502,
"author_profile": "https://wordpress.stackexchange.com/users/185502",
"pm_score": -1,
"selected": false,
"text": "<p>Need to remove this first : add_action('wp_enqueue_scripts', 'example_enqueue_styles');</p>\n\n<p>And... | 2020/05/08 | [
"https://wordpress.stackexchange.com/questions/366150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/163826/"
] | I am working with a child theme from 'Astra'. I am editing 'style.css' of my child theme for styling my website. I added this code to my child's functions.php' file to enqueue the father-child styles.
```
<?php
add_action('wp_enqueue_scripts', 'example_enqueue_styles');
add_action( 'wp_enqueue_scripts', 'my_theme_en... | The problem comes from that the parent style is loaded twice :
1. one with version ('?ver=1.0 etc, first on your picture and loaded by your parent theme with versionning on [wp\_enqueue\_style](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) ),
2. another without (the second on your picture, ca... |
366,160 | <p>Basically I am struggling to display the author list in a grid: </p>
<pre><code><div class="container">
<div class="row">
<div class="col-lg-4">
<?php
wp_list_authors( array(
'show_fullname' => 1,
'optioncount' => 1,
'exclude' => 4,
'orderby' => 'post_count... | [
{
"answer_id": 366152,
"author": "Sanjay Gupta",
"author_id": 185502,
"author_profile": "https://wordpress.stackexchange.com/users/185502",
"pm_score": -1,
"selected": false,
"text": "<p>Need to remove this first : add_action('wp_enqueue_scripts', 'example_enqueue_styles');</p>\n\n<p>And... | 2020/05/08 | [
"https://wordpress.stackexchange.com/questions/366160",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187686/"
] | Basically I am struggling to display the author list in a grid:
```
<div class="container">
<div class="row">
<div class="col-lg-4">
<?php
wp_list_authors( array(
'show_fullname' => 1,
'optioncount' => 1,
'exclude' => 4,
'orderby' => 'post_count',
'order' => 'DESC',
'number' ... | The problem comes from that the parent style is loaded twice :
1. one with version ('?ver=1.0 etc, first on your picture and loaded by your parent theme with versionning on [wp\_enqueue\_style](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) ),
2. another without (the second on your picture, ca... |
366,167 | <p>I have searched for lot of stuff but could not get any help.</p>
<p>I am new to WP.</p>
<p>I am working with the ‘DremeTheme – the7’ theme for the past 4 weeks. I have had set the front page since the beginning, but today my front page is not showing.</p>
<p>If I set any one of the pages as a front page, it does ... | [
{
"answer_id": 366152,
"author": "Sanjay Gupta",
"author_id": 185502,
"author_profile": "https://wordpress.stackexchange.com/users/185502",
"pm_score": -1,
"selected": false,
"text": "<p>Need to remove this first : add_action('wp_enqueue_scripts', 'example_enqueue_styles');</p>\n\n<p>And... | 2020/05/08 | [
"https://wordpress.stackexchange.com/questions/366167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187691/"
] | I have searched for lot of stuff but could not get any help.
I am new to WP.
I am working with the ‘DremeTheme – the7’ theme for the past 4 weeks. I have had set the front page since the beginning, but today my front page is not showing.
If I set any one of the pages as a front page, it does not work.
When I view o... | The problem comes from that the parent style is loaded twice :
1. one with version ('?ver=1.0 etc, first on your picture and loaded by your parent theme with versionning on [wp\_enqueue\_style](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) ),
2. another without (the second on your picture, ca... |
366,184 | <p>I've inherited a wordpress site using the Avada theme and page loads seems to be exceptionally slow, anywhere from seven seconds to 30 seconds. It looks to me like one or more of the queries are doing something very strange, since there's a long list in the slow query monitor.</p>
<p>It's WordPress 5.2.6 running Av... | [
{
"answer_id": 366152,
"author": "Sanjay Gupta",
"author_id": 185502,
"author_profile": "https://wordpress.stackexchange.com/users/185502",
"pm_score": -1,
"selected": false,
"text": "<p>Need to remove this first : add_action('wp_enqueue_scripts', 'example_enqueue_styles');</p>\n\n<p>And... | 2020/05/08 | [
"https://wordpress.stackexchange.com/questions/366184",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187704/"
] | I've inherited a wordpress site using the Avada theme and page loads seems to be exceptionally slow, anywhere from seven seconds to 30 seconds. It looks to me like one or more of the queries are doing something very strange, since there's a long list in the slow query monitor.
It's WordPress 5.2.6 running Avada theme.... | The problem comes from that the parent style is loaded twice :
1. one with version ('?ver=1.0 etc, first on your picture and loaded by your parent theme with versionning on [wp\_enqueue\_style](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) ),
2. another without (the second on your picture, ca... |
366,282 | <p>I wish to limit the possibility to use a specific template page only for post id x</p>
<p>I have created a page-blog.php template and I want it usable only for the post id 115 (id of my blog page).</p>
<p>Actually, in administration, all posts have the template on the models list native metabox, so perhaps we can ... | [
{
"answer_id": 366284,
"author": "Himad",
"author_id": 158512,
"author_profile": "https://wordpress.stackexchange.com/users/158512",
"pm_score": 1,
"selected": false,
"text": "<pre><code>/**\n * Filters list of page templates for a theme.\n * @param string[] $post_templates Arr... | 2020/05/10 | [
"https://wordpress.stackexchange.com/questions/366282",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187802/"
] | I wish to limit the possibility to use a specific template page only for post id x
I have created a page-blog.php template and I want it usable only for the post id 115 (id of my blog page).
Actually, in administration, all posts have the template on the models list native metabox, so perhaps we can limit or filter t... | ```
/**
* Filters list of page templates for a theme.
* @param string[] $post_templates Array of template header names keyed by the template file name.
* @param WP_Theme $this The theme object.
* @param WP_Post|null $post The post being edited, provided for context, or null.
... |
366,371 | <p>I am using Wordpress and Buddypress and i am trying to remove or hide the username that is being displayed in the autocomplete field of messages in Buddypress. Tried some tests from <a href="https://buddypress.org/support/topic/autocomplete-shows-both-names/" rel="nofollow noreferrer">this</a> post and also <a href=... | [
{
"answer_id": 366386,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 1,
"selected": false,
"text": "<p>Try this but note that it may not send the message:</p>\n\n<pre><code>'<span id=\"%s\" href=\"#\"></... | 2020/05/11 | [
"https://wordpress.stackexchange.com/questions/366371",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129972/"
] | I am using Wordpress and Buddypress and i am trying to remove or hide the username that is being displayed in the autocomplete field of messages in Buddypress. Tried some tests from [this](https://buddypress.org/support/topic/autocomplete-shows-both-names/) post and also [this](https://buddypress.org/support/topic/hide... | Try this but note that it may not send the message:
```
'<span id="%s" href="#"></span><img src="%s" style="width: 15px"> %s %s' . "\n",
esc_attr( 'link-' . $user->ID ),
esc_url( $user->image ),
esc_html( $user->name ),
' '
```
Or this:
```
'<span id="%s" hr... |
366,380 | <p>I am using this function to notify users when their post is published. However, repeated emails are being sent when the post is updated. I only want to send 1 email when the post is published first and then not sent more emails if the post is subsequently updated. </p>
<pre><code>function notifyauthor($post_id) {
... | [
{
"answer_id": 366386,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 1,
"selected": false,
"text": "<p>Try this but note that it may not send the message:</p>\n\n<pre><code>'<span id=\"%s\" href=\"#\"></... | 2020/05/11 | [
"https://wordpress.stackexchange.com/questions/366380",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am using this function to notify users when their post is published. However, repeated emails are being sent when the post is updated. I only want to send 1 email when the post is published first and then not sent more emails if the post is subsequently updated.
```
function notifyauthor($post_id) {
$post = get_po... | Try this but note that it may not send the message:
```
'<span id="%s" href="#"></span><img src="%s" style="width: 15px"> %s %s' . "\n",
esc_attr( 'link-' . $user->ID ),
esc_url( $user->image ),
esc_html( $user->name ),
' '
```
Or this:
```
'<span id="%s" hr... |
366,431 | <p>I'm new to CSS so forgive me if this is obvious.</p>
<p>I have the following code for aligning my site logo to the left-hand side. And it works exactly as I want it to.</p>
<pre><code> /* Align site logo to the left */
.site-logo {
float: left !important;
padding-top: 15px;
}
</code></pre>
... | [
{
"answer_id": 366386,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 1,
"selected": false,
"text": "<p>Try this but note that it may not send the message:</p>\n\n<pre><code>'<span id=\"%s\" href=\"#\"></... | 2020/05/12 | [
"https://wordpress.stackexchange.com/questions/366431",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187719/"
] | I'm new to CSS so forgive me if this is obvious.
I have the following code for aligning my site logo to the left-hand side. And it works exactly as I want it to.
```
/* Align site logo to the left */
.site-logo {
float: left !important;
padding-top: 15px;
}
```
However, I have read that it i... | Try this but note that it may not send the message:
```
'<span id="%s" href="#"></span><img src="%s" style="width: 15px"> %s %s' . "\n",
esc_attr( 'link-' . $user->ID ),
esc_url( $user->image ),
esc_html( $user->name ),
' '
```
Or this:
```
'<span id="%s" hr... |
366,489 | <p>For a marketing reason, my client needs a standalone HTML Page as the "temporary homepage" </p>
<p>What I would like to do is redirect the homepage to a page OUTSIDE of the WordPress ecosystem - I guess this is done using HTACCESS rules...</p>
<p>Can I even do this without breaking WordPress? </p>
<p>Thanks</p>
| [
{
"answer_id": 366507,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>As @JacobPeattie suggested in comments:</p>\n\n<blockquote>\n <p>If you just add <code>index.html</code> to th... | 2020/05/13 | [
"https://wordpress.stackexchange.com/questions/366489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | For a marketing reason, my client needs a standalone HTML Page as the "temporary homepage"
What I would like to do is redirect the homepage to a page OUTSIDE of the WordPress ecosystem - I guess this is done using HTACCESS rules...
Can I even do this without breaking WordPress?
Thanks | As @JacobPeattie suggested in comments:
>
> If you just add `index.html` to the root of your WordPress installation that should become the homepage.
>
>
>
This does, however, require that the `DirectoryIndex` is set appropriately. For example:
```
DirectoryIndex index.html
```
The `DirectoryIndex` is the docum... |
366,493 | <p>I'm looking for a way to disable Rest API for a user role called 'external_user' (disable wp-json queries.)</p>
<p>This user role can see right now alot of posts and pages information with when we put wp-json on the URL (users, pages, posts...)</p>
<p>I use actually the plugin <a href="https://fr.wordpress.org/plu... | [
{
"answer_id": 366507,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>As @JacobPeattie suggested in comments:</p>\n\n<blockquote>\n <p>If you just add <code>index.html</code> to th... | 2020/05/13 | [
"https://wordpress.stackexchange.com/questions/366493",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119785/"
] | I'm looking for a way to disable Rest API for a user role called 'external\_user' (disable wp-json queries.)
This user role can see right now alot of posts and pages information with when we put wp-json on the URL (users, pages, posts...)
I use actually the plugin [DISABLE REST API](https://fr.wordpress.org/plugins/d... | As @JacobPeattie suggested in comments:
>
> If you just add `index.html` to the root of your WordPress installation that should become the homepage.
>
>
>
This does, however, require that the `DirectoryIndex` is set appropriately. For example:
```
DirectoryIndex index.html
```
The `DirectoryIndex` is the docum... |
366,509 | <p>I'm making a review widget that comes as a shortcode and Gutenberg block. The shortcode part was easy as I have built many shortcodes before, but I'm stuck on building my first Gutenberg block.</p>
<p>More specifically, I've learned how to build a block that outputs div with custom class, but I can't find how to ad... | [
{
"answer_id": 366507,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>As @JacobPeattie suggested in comments:</p>\n\n<blockquote>\n <p>If you just add <code>index.html</code> to th... | 2020/05/13 | [
"https://wordpress.stackexchange.com/questions/366509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/173962/"
] | I'm making a review widget that comes as a shortcode and Gutenberg block. The shortcode part was easy as I have built many shortcodes before, but I'm stuck on building my first Gutenberg block.
More specifically, I've learned how to build a block that outputs div with custom class, but I can't find how to add a custom... | As @JacobPeattie suggested in comments:
>
> If you just add `index.html` to the root of your WordPress installation that should become the homepage.
>
>
>
This does, however, require that the `DirectoryIndex` is set appropriately. For example:
```
DirectoryIndex index.html
```
The `DirectoryIndex` is the docum... |
366,530 | <p>I am using this code for a meta_query</p>
<pre><code> $values = shortcode_atts( array('category' => 'Test',), $atts );
$args = array(
'post_type' => 'mytype',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'br_type',
'value' =>... | [
{
"answer_id": 366507,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>As @JacobPeattie suggested in comments:</p>\n\n<blockquote>\n <p>If you just add <code>index.html</code> to th... | 2020/05/13 | [
"https://wordpress.stackexchange.com/questions/366530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am using this code for a meta\_query
```
$values = shortcode_atts( array('category' => 'Test',), $atts );
$args = array(
'post_type' => 'mytype',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'br_type',
'value' => esc_attr($values['category']),... | As @JacobPeattie suggested in comments:
>
> If you just add `index.html` to the root of your WordPress installation that should become the homepage.
>
>
>
This does, however, require that the `DirectoryIndex` is set appropriately. For example:
```
DirectoryIndex index.html
```
The `DirectoryIndex` is the docum... |
366,563 | <p>I'm adding a custom column to the admin display for a custom post type. The custom column should display the selected options from an ACF Pro select field. Instead, it always triggers as containing the value, which suggests to me that instead of pulling only the selected options for each post, it's pulling all avail... | [
{
"answer_id": 366507,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>As @JacobPeattie suggested in comments:</p>\n\n<blockquote>\n <p>If you just add <code>index.html</code> to th... | 2020/05/14 | [
"https://wordpress.stackexchange.com/questions/366563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/160880/"
] | I'm adding a custom column to the admin display for a custom post type. The custom column should display the selected options from an ACF Pro select field. Instead, it always triggers as containing the value, which suggests to me that instead of pulling only the selected options for each post, it's pulling all availabl... | As @JacobPeattie suggested in comments:
>
> If you just add `index.html` to the root of your WordPress installation that should become the homepage.
>
>
>
This does, however, require that the `DirectoryIndex` is set appropriately. For example:
```
DirectoryIndex index.html
```
The `DirectoryIndex` is the docum... |
366,570 | <p>I have a custom post type called 'Inspections'</p>
<p>Doing this, you can access an inspection record by going to <code>example.com/inspections/inspection-slug-here</code></p>
<p>However, I want to add some 'sub-pages' if you will:</p>
<pre><code>/inspections/<inspection-slug-here>/sub-page1
/inspections/&l... | [
{
"answer_id": 366507,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>As @JacobPeattie suggested in comments:</p>\n\n<blockquote>\n <p>If you just add <code>index.html</code> to th... | 2020/05/14 | [
"https://wordpress.stackexchange.com/questions/366570",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123076/"
] | I have a custom post type called 'Inspections'
Doing this, you can access an inspection record by going to `example.com/inspections/inspection-slug-here`
However, I want to add some 'sub-pages' if you will:
```
/inspections/<inspection-slug-here>/sub-page1
/inspections/<inspection-slug-here>/sub-page2
```
In this ... | As @JacobPeattie suggested in comments:
>
> If you just add `index.html` to the root of your WordPress installation that should become the homepage.
>
>
>
This does, however, require that the `DirectoryIndex` is set appropriately. For example:
```
DirectoryIndex index.html
```
The `DirectoryIndex` is the docum... |
366,574 | <p>I do have a problem on my WordPress site. In the frontend there is a spam post (not a comment, a post) visible to everybody. I don't know where it comes from and all malware scans were negative so far. However, in order to solve this problem I will need to delete this post. But it can't be seen in the backend.</p>
... | [
{
"answer_id": 366507,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>As @JacobPeattie suggested in comments:</p>\n\n<blockquote>\n <p>If you just add <code>index.html</code> to th... | 2020/05/14 | [
"https://wordpress.stackexchange.com/questions/366574",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136979/"
] | I do have a problem on my WordPress site. In the frontend there is a spam post (not a comment, a post) visible to everybody. I don't know where it comes from and all malware scans were negative so far. However, in order to solve this problem I will need to delete this post. But it can't be seen in the backend.
[![ente... | As @JacobPeattie suggested in comments:
>
> If you just add `index.html` to the root of your WordPress installation that should become the homepage.
>
>
>
This does, however, require that the `DirectoryIndex` is set appropriately. For example:
```
DirectoryIndex index.html
```
The `DirectoryIndex` is the docum... |
366,584 | <p>I am new to wp, fair warning :) </p>
<p>I have added a new blank page by adding a php file in the twentytwenty theme folder with: </p>
<pre><code><?php
/* Template Name: charles */
?>
</code></pre>
<p>Then, I have created a new page by choosing the charles template in the admin. </p>
<p>Now In my new bla... | [
{
"answer_id": 366590,
"author": "made2popular",
"author_id": 173347,
"author_profile": "https://wordpress.stackexchange.com/users/173347",
"pm_score": -1,
"selected": false,
"text": "<p>You should try this function. This will run only when the page template is charles.</p>\n\n<pre><code... | 2020/05/14 | [
"https://wordpress.stackexchange.com/questions/366584",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188063/"
] | I am new to wp, fair warning :)
I have added a new blank page by adding a php file in the twentytwenty theme folder with:
```
<?php
/* Template Name: charles */
?>
```
Then, I have created a new page by choosing the charles template in the admin.
Now In my new blank page I can see the contents of the new plug... | In my theme functions.php at the end works for me:
```
function themesCharles_enqueue_style() {
wp_enqueue_style( 'my-theme', get_template_directory_uri() .'/myFiles/myStyle.css', false );
}
function themesCharles_enqueue_script() {
wp_enqueue_script( 'my-js', get_template_directory_uri() .'/myFiles/myScript... |
366,595 | <p>Thanks to the German language, I happen to have some really long words in my WordPress 5.4.1 content.
I need to decide <strong>where exactly to hyphenate</strong>, as the standard hyphenation is dumb.<br></p>
<p>If I enter <code>Wachstums&shy;förderung</code> in the Gutenberg block editor in a headline (e.g. h... | [
{
"answer_id": 372154,
"author": "Buglover",
"author_id": 192501,
"author_profile": "https://wordpress.stackexchange.com/users/192501",
"pm_score": 1,
"selected": false,
"text": "<p>You can change the block to "edit as html" via "more options" and set the soft hyphen,... | 2020/05/14 | [
"https://wordpress.stackexchange.com/questions/366595",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124308/"
] | Thanks to the German language, I happen to have some really long words in my WordPress 5.4.1 content.
I need to decide **where exactly to hyphenate**, as the standard hyphenation is dumb.
If I enter `Wachstums­förderung` in the Gutenberg block editor in a headline (e.g. h2), I do not get the expected `Wachstums... | With the 'new' Gutenberg editor the previously working solution using the *tiny\_mce\_before\_init* hook does not work anymore, but there is the possibility to define a new shortcode in your theme / plugin as a workaround.
**Solution for Gutenberg**
```
add_shortcode('shy', 'my_shy_shortcode');
function my_shy_shortc... |
366,680 | <p>I'm using <code>wp_get_archives</code> but I cannot prepend any text inside the links. I want code like this:</p>
<pre><code><a href="archive link">[my custom prepend] 2020<a/>
</code></pre>
<p>But the 'before' option will prepend the passed string before the <code><a></code> tag.</p>
<p>Current... | [
{
"answer_id": 366702,
"author": "Bob",
"author_id": 188151,
"author_profile": "https://wordpress.stackexchange.com/users/188151",
"pm_score": 1,
"selected": false,
"text": "<p>I was going to suggest creating a regex to parse it but if you look at <a href=\"https://developer.wordpress.or... | 2020/05/15 | [
"https://wordpress.stackexchange.com/questions/366680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | I'm using `wp_get_archives` but I cannot prepend any text inside the links. I want code like this:
```
<a href="archive link">[my custom prepend] 2020<a/>
```
But the 'before' option will prepend the passed string before the `<a>` tag.
Current code is the following:
```
$archives = wp_get_archives(array(
'type' ... | I maneged to do like this:
First, get simply the years:
```
// this is a multipurpose function I made, and it's quite self explanatory
function get_years($post_type, $order = "ASC", $exclude = array(), $future = true, $taxonomy = null, $term = null){
global $wpdb;
$type = ($post_type) ? $post_type : 'post';
$st... |
366,689 | <p>I have a query string added to some urls which isn't pretty:</p>
<pre><code>?city=Amsterdam
</code></pre>
<p>So i'd like to structure the url like: <strong><a href="https://example.com/realpage1/realpage2/amsterdam/" rel="nofollow noreferrer">https://example.com/realpage1/realpage2/amsterdam/</a> or <a href="https... | [
{
"answer_id": 366759,
"author": "西門 正 Code Guy",
"author_id": 35701,
"author_profile": "https://wordpress.stackexchange.com/users/35701",
"pm_score": 1,
"selected": false,
"text": "<p>There are a few points to share because I could foresee that the comment will be very long and I post s... | 2020/05/15 | [
"https://wordpress.stackexchange.com/questions/366689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188144/"
] | I have a query string added to some urls which isn't pretty:
```
?city=Amsterdam
```
So i'd like to structure the url like: **<https://example.com/realpage1/realpage2/amsterdam/> or <https://example.com/realpage1/amsterdam/>** depending on the type of content.
And then get the variable with some htaccess like:
```... | Oke, so after days of digging I finally found the answer. The problem was:
```
index.php?pagename=$matches[1]/$matches[2]&city=$matches[3]
```
The 'pagename' parameter had to be set and filled too, with both 'slugs'.
The complete code I ended up with:
```
function custom_rewrite_rule() {
add_rewrite_rule( '(.*... |
366,708 | <p>I am using this code but it seems that ordering by meta_keys <code>br_category</code> first and <code>br_name</code> second, doesn't produce the correct results</p>
<pre><code>$args = array(
'post_type' => 'brands',
'meta_query' => array(
array(
'key' => 'br_type',
'value' =&... | [
{
"answer_id": 366733,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried:</p>\n\n<pre><code>'orderby' => array( 'br_category' => 'ASC', 'br_name' => 'ASC' ), ... | 2020/05/15 | [
"https://wordpress.stackexchange.com/questions/366708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am using this code but it seems that ordering by meta\_keys `br_category` first and `br_name` second, doesn't produce the correct results
```
$args = array(
'post_type' => 'brands',
'meta_query' => array(
array(
'key' => 'br_type',
'value' => 'Aviation'
),
array(
... | ### Current Query
```
$args = array(
'post_type' => 'brands',
'meta_query' => array(
array(
'key' => 'br_type',
'value' => 'Aviation'
),
array(
'key' => 'br_category'
),
array(
'key' => 'br_name'
)
),
'posts_per_page' => -1,
... |
366,715 | <p>I’m wondering if you could help with some code I’m struggling with.</p>
<p>I’ve got an ACF Image Field on the Post Category Taxonomy. I need to add it into the post loop so the category image shows up instead of the featured image. Here’s the code that I have in:</p>
<pre><code>$current_term = get_queried_object()... | [
{
"answer_id": 366733,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried:</p>\n\n<pre><code>'orderby' => array( 'br_category' => 'ASC', 'br_name' => 'ASC' ), ... | 2020/05/15 | [
"https://wordpress.stackexchange.com/questions/366715",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73096/"
] | I’m wondering if you could help with some code I’m struggling with.
I’ve got an ACF Image Field on the Post Category Taxonomy. I need to add it into the post loop so the category image shows up instead of the featured image. Here’s the code that I have in:
```
$current_term = get_queried_object();
$author_image = get... | ### Current Query
```
$args = array(
'post_type' => 'brands',
'meta_query' => array(
array(
'key' => 'br_type',
'value' => 'Aviation'
),
array(
'key' => 'br_category'
),
array(
'key' => 'br_name'
)
),
'posts_per_page' => -1,
... |
366,719 | <p>This is my code:</p>
<pre><code> $wpdb->insert(
'wpbi_contacts',
array(
'regname' => $formData['regname'],
'razon' => $formData['razon'],
'email-1' => $formData['email-1'],
'descripcion' => $formData['de... | [
{
"answer_id": 366720,
"author": "Bob",
"author_id": 188151,
"author_profile": "https://wordpress.stackexchange.com/users/188151",
"pm_score": -1,
"selected": false,
"text": "<p>Firstly what does it return? 0 for no rows inserted? or <a href=\"https://developer.wordpress.org/reference/cl... | 2020/05/15 | [
"https://wordpress.stackexchange.com/questions/366719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188172/"
] | This is my code:
```
$wpdb->insert(
'wpbi_contacts',
array(
'regname' => $formData['regname'],
'razon' => $formData['razon'],
'email-1' => $formData['email-1'],
'descripcion' => $formData['descripcion'],
'catego... | It could also be the result of this known bug:
<https://core.trac.wordpress.org/ticket/32315>
If your data is larger than the varchar field length then $wpdb->insert will fail and produce no errors.
If you don't mind data being truncated if it's larger than the field length, switch to $wpdb->query($wpdb->prepare(..)... |
366,737 | <p>I have two functions displaying a term list of the selected taxonomy:</p>
<p>First function:</p>
<pre><code>$terms = get_the_terms(get_the_ID(), 'MY_TAXONOMY');
if (!is_wp_error($terms) && !empty($terms)) {
foreach ($terms AS $term) {
$name = $term->name;
$link = add_query_arg('fwp_t... | [
{
"answer_id": 366742,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 1,
"selected": false,
"text": "<p>This can be achieved multiple ways. One of them is to filter term link with your desired structure.</p>\n\n<p... | 2020/05/15 | [
"https://wordpress.stackexchange.com/questions/366737",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/178440/"
] | I have two functions displaying a term list of the selected taxonomy:
First function:
```
$terms = get_the_terms(get_the_ID(), 'MY_TAXONOMY');
if (!is_wp_error($terms) && !empty($terms)) {
foreach ($terms AS $term) {
$name = $term->name;
$link = add_query_arg('fwp_typ', FWP()->helper->safe_value($... | Solved ugly, but works. General form of the filter:
```
<?php
add_filter('term_link', function ($termlink, $term, $taxonomy) {
if ('CPT-TAXONOMY-NAME' == $taxonomy) {
$termlink = trailingslashit(get_home_url()) . '?FACETWP-FACET-NAME=' . $term->slug;
}
return $termlink;
}, 10, 3);
```
The functio... |
366,772 | <p>I have custom template and i need get og:image url in header.
Class image location in DB wp_postmeta - meta_value
i try with functions.php</p>
<pre><code>function getOgImage()
{
global $wpdb;
$ogimage = $wpdb->get_results("SELECT DISTINCT post_id FROM wp_postmeta WHERE meta_value", OBJECT);
echo '&... | [
{
"answer_id": 366742,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 1,
"selected": false,
"text": "<p>This can be achieved multiple ways. One of them is to filter term link with your desired structure.</p>\n\n<p... | 2020/05/16 | [
"https://wordpress.stackexchange.com/questions/366772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188203/"
] | I have custom template and i need get og:image url in header.
Class image location in DB wp\_postmeta - meta\_value
i try with functions.php
```
function getOgImage()
{
global $wpdb;
$ogimage = $wpdb->get_results("SELECT DISTINCT post_id FROM wp_postmeta WHERE meta_value", OBJECT);
echo '<meta property="o... | Solved ugly, but works. General form of the filter:
```
<?php
add_filter('term_link', function ($termlink, $term, $taxonomy) {
if ('CPT-TAXONOMY-NAME' == $taxonomy) {
$termlink = trailingslashit(get_home_url()) . '?FACETWP-FACET-NAME=' . $term->slug;
}
return $termlink;
}, 10, 3);
```
The functio... |
366,792 | <p>I'm trying to give guest users "not logged in" a role.</p>
<p>I searched everywhere and I could not find a single solution that can make that happen. All what I found is to make an if statement in the <code>functions.php</code> file to give access to certain things, like for example post a comment without logging i... | [
{
"answer_id": 366742,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 1,
"selected": false,
"text": "<p>This can be achieved multiple ways. One of them is to filter term link with your desired structure.</p>\n\n<p... | 2020/05/16 | [
"https://wordpress.stackexchange.com/questions/366792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188227/"
] | I'm trying to give guest users "not logged in" a role.
I searched everywhere and I could not find a single solution that can make that happen. All what I found is to make an if statement in the `functions.php` file to give access to certain things, like for example post a comment without logging in.
However when ther... | Solved ugly, but works. General form of the filter:
```
<?php
add_filter('term_link', function ($termlink, $term, $taxonomy) {
if ('CPT-TAXONOMY-NAME' == $taxonomy) {
$termlink = trailingslashit(get_home_url()) . '?FACETWP-FACET-NAME=' . $term->slug;
}
return $termlink;
}, 10, 3);
```
The functio... |
366,798 | <p><strong>What I'm trying to do</strong></p>
<ol>
<li>Changing the login-URL from <code>https://example.org/wp-login</code> to <code>https://example.org/mellon</code></li>
<li>Making <code>https://example.org/wp-login</code> redirect to the 404-page. </li>
</ol>
<hr>
<p><strong>Considerations</strong></p>
<p>If I ... | [
{
"answer_id": 366803,
"author": "rank",
"author_id": 178642,
"author_profile": "https://wordpress.stackexchange.com/users/178642",
"pm_score": 0,
"selected": false,
"text": "<p>It is not a good idea to change your login url without a plugin, because you will need to have to mess around ... | 2020/05/16 | [
"https://wordpress.stackexchange.com/questions/366798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128304/"
] | **What I'm trying to do**
1. Changing the login-URL from `https://example.org/wp-login` to `https://example.org/mellon`
2. Making `https://example.org/wp-login` redirect to the 404-page.
---
**Considerations**
If I Google it, then I find a [couple of suggestions](https://www.elegantthemes.com/blog/resources/how-to-... | You should change the login url from default than it'll hard for hackers to find the login page so it'll be safe for you.
Here is the code to change the url.
```
// Add rewrite rule and flush on plugin activation
register_activation_hook( __FILE__, 'NLURL_activate' );
function NLURL_activate() {
NLURL_rewrite();... |
366,867 | <p>How do I add some guiding text under the 'Featured Image'. </p>
<p>Right here: </p>
<p><a href="https://i.stack.imgur.com/02KfA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/02KfA.png" alt="Guiding text for featured image"></a></p>
<p>I have experienced several times now that people don't get... | [
{
"answer_id": 366870,
"author": "rank",
"author_id": 178642,
"author_profile": "https://wordpress.stackexchange.com/users/178642",
"pm_score": 0,
"selected": false,
"text": "<p>If you are using the Classic Editor of wordpress, there is a function for this:\n<a href=\"https://developer.w... | 2020/05/17 | [
"https://wordpress.stackexchange.com/questions/366867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128304/"
] | How do I add some guiding text under the 'Featured Image'.
Right here:
[](https://i.stack.imgur.com/02KfA.png)
I have experienced several times now that people don't get where and what this is. So it could be nice to be able to add a line or tw... | Are you using the classic editor you could try this function:
```
function custom_admin_post_thumbnail_html( $content ) {
return $content = str_replace( __( 'Set featured image' ), __( 'better feature image guide text' ), $content);
}
add_filter( 'admin_post_thumbnail_html', 'custom_admin_post_thumbnail_html' );
... |
366,881 | <p>I have followed the instructions for internationalization on: <a href="https://developer.wordpress.org/block-editor/developers/internationalization/" rel="nofollow noreferrer">https://developer.wordpress.org/block-editor/developers/internationalization/</a>, but it doesn't seem to play well with the development tool... | [
{
"answer_id": 367910,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 4,
"selected": true,
"text": "<p><em>(I revised this answer mainly to let other readers and you know the issues I originally noticed in your... | 2020/05/17 | [
"https://wordpress.stackexchange.com/questions/366881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8757/"
] | I have followed the instructions for internationalization on: <https://developer.wordpress.org/block-editor/developers/internationalization/>, but it doesn't seem to play well with the development tools for Gutenberg. It will find all the translations in the `src` directory in the multiple `js` files and will use that ... | *(I revised this answer mainly to let other readers and you know the issues I originally noticed in your steps as shown in the question.)*
So in my original answer, I was focused on suggesting you to just go with the multiple script translation files, but I thought I should clarify the three things below:
>
> It wil... |
366,938 | <p>I've tried to setup my wordpress using 1 domain name and 1 ip address,
after this, all the css is missing, but the site still can be accessible using both domain and ip address.</p>
<p><a href="https://i.stack.imgur.com/zuonp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zuonp.png" alt="enter ... | [
{
"answer_id": 366947,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": -1,
"selected": false,
"text": "<p>You can't put multiple addresses in those options fields, that's not how it works. Anything other than a si... | 2020/05/18 | [
"https://wordpress.stackexchange.com/questions/366938",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188347/"
] | I've tried to setup my wordpress using 1 domain name and 1 ip address,
after this, all the css is missing, but the site still can be accessible using both domain and ip address.
[](https://i.stack.imgur.com/zuonp.png)
[](https://i.stack.imgur.com/OXoEC.png)
**Path ... |
366,946 | <p>I have a question. I want to get all my post but when I visit <a href="http://example.com/feed/atom/" rel="nofollow noreferrer">http://example.com/feed/atom/</a> I have only three post. In my website there are much more than three. How to update this file?</p>
<p>Kind regards </p>
| [
{
"answer_id": 366947,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": -1,
"selected": false,
"text": "<p>You can't put multiple addresses in those options fields, that's not how it works. Anything other than a si... | 2020/05/18 | [
"https://wordpress.stackexchange.com/questions/366946",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188359/"
] | I have a question. I want to get all my post but when I visit <http://example.com/feed/atom/> I have only three post. In my website there are much more than three. How to update this file?
Kind regards | After testing for hours, finally get it done.
Here the solution:
In database `wp_options` change the value for `siteurl` and `home` from `your wordpress url` to `/path/to/wordpress`
**Wordpress URL**
[](https://i.stack.imgur.com/OXoEC.png)
**Path ... |
366,989 | <p>Currently, the way I do it is, on the <code>plugins_loaded</code> hook, I let the world know that my plugin has loaded:</p>
<pre><code>add_action( 'plugins_loaded', function() {
do_action( 'my_plugin_has_loaded' );
}, 10 );
</code></pre>
<p>And so, others can depend/only run when <code>my_plugin_has_loaded</co... | [
{
"answer_id": 367527,
"author": "Mort 1305",
"author_id": 188811,
"author_profile": "https://wordpress.stackexchange.com/users/188811",
"pm_score": 2,
"selected": false,
"text": "<p>Consider plugin A:</p>\n\n<pre>\n$A_message;\n\nadd_action('plugins_loaded', function() {\n do_action(... | 2020/05/19 | [
"https://wordpress.stackexchange.com/questions/366989",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/185900/"
] | Currently, the way I do it is, on the `plugins_loaded` hook, I let the world know that my plugin has loaded:
```
add_action( 'plugins_loaded', function() {
do_action( 'my_plugin_has_loaded' );
}, 10 );
```
And so, others can depend/only run when `my_plugin_has_loaded` fires, however, I see a lot of hooks `plugin... | Consider plugin A:
```
$A_message;
add_action('plugins_loaded', function() {
do_action('plugin-A:init');
});
// Hooks allow B to access A (both during initialization of A and elsewhere in WordPress) without having to check if A exists.
add_filter('plugin-A:set', function($msg) {
$A_message = $msg;
}, PHP_I... |
367,004 | <p>I need to redirect about 200 post into category "ricette","svezzamento" and "alimentazione" to url without category. I have this code but not work.</p>
<pre><code>add_action('template_redirect', 'post_redirect_by_custom_filters');
function post_redirect_by_custom_filters() {
global $post;
$catArray = ['ricette','... | [
{
"answer_id": 367017,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming your URLs are of the form <code>/<category>/<post-name>/</code> (trailing slash optional) ... | 2020/05/19 | [
"https://wordpress.stackexchange.com/questions/367004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/185581/"
] | I need to redirect about 200 post into category "ricette","svezzamento" and "alimentazione" to url without category. I have this code but not work.
```
add_action('template_redirect', 'post_redirect_by_custom_filters');
function post_redirect_by_custom_filters() {
global $post;
$catArray = ['ricette','svezzamento','... | Assuming your URLs are of the form `/<category>/<post-name>/` (trailing slash optional) then an `.htaccess` only solution would look something like the following, at the *top* of your `.htaccess` file:
```
# Remove some categories from the URL
RewriteRule ^(ricette|svezzamento|alimentazione)/([^/]+)/?$ /$2/ [R=301,L]
... |
367,034 | <p>In WordPress I have a post with URL <code>https://www.example.com/article.html</code>.</p>
<p>I renamed its permalink to <code>https://www.example.com/article-new.html</code>.</p>
<p>Now if I open the old URL <code>https://www.example.com/article.html</code> then it auto 301 redirects to <code>https://www.example.... | [
{
"answer_id": 367017,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming your URLs are of the form <code>/<category>/<post-name>/</code> (trailing slash optional) ... | 2020/05/19 | [
"https://wordpress.stackexchange.com/questions/367034",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/176970/"
] | In WordPress I have a post with URL `https://www.example.com/article.html`.
I renamed its permalink to `https://www.example.com/article-new.html`.
Now if I open the old URL `https://www.example.com/article.html` then it auto 301 redirects to `https://www.example.com/article-new.html`
due to the WordPress built-in fe... | Assuming your URLs are of the form `/<category>/<post-name>/` (trailing slash optional) then an `.htaccess` only solution would look something like the following, at the *top* of your `.htaccess` file:
```
# Remove some categories from the URL
RewriteRule ^(ricette|svezzamento|alimentazione)/([^/]+)/?$ /$2/ [R=301,L]
... |
367,062 | <p>I'm working on my first wordpress site, and moving it online. I have been adding some extra templates to design a simple booking engine, that was working perfectly on my offline localhost server.</p>
<p>However, I've been having trouble with getting these templates and other .php-files to work on the live website. ... | [
{
"answer_id": 367063,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 2,
"selected": true,
"text": "<p>What you're looking for is <a href=\"https://developer.wordpress.org/reference/functions/get_stylesheet_direc... | 2020/05/19 | [
"https://wordpress.stackexchange.com/questions/367062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/182507/"
] | I'm working on my first wordpress site, and moving it online. I have been adding some extra templates to design a simple booking engine, that was working perfectly on my offline localhost server.
However, I've been having trouble with getting these templates and other .php-files to work on the live website. It seems t... | What you're looking for is [get\_stylesheet\_directory()](https://developer.wordpress.org/reference/functions/get_stylesheet_directory/).
```
get_template_part( get_stylesheet_directory() . '/modules/content/bevestiging.php');
```
This gives you the file path for the current theme. |
367,129 | <p>I'm quite new to doing api calls using Wordpress so bear with me.</p>
<p>I have this function:</p>
<pre><code>function foo() {
$userinfo = [
"number" => "26246426",
"secondnumber" => "43634643"
];
$api_url = 'https://api.url.com';
$response = wp_remote_post( $api_url, array(
// Set the Content-... | [
{
"answer_id": 367158,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": -1,
"selected": false,
"text": "<p>Your ajax url is incorrect. </p>\n\n<p>Try changing: </p>\n\n<pre><code>var ajaxscript = { ajax_url : 'myweb... | 2020/05/20 | [
"https://wordpress.stackexchange.com/questions/367129",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188504/"
] | I'm quite new to doing api calls using Wordpress so bear with me.
I have this function:
```
function foo() {
$userinfo = [
"number" => "26246426",
"secondnumber" => "43634643"
];
$api_url = 'https://api.url.com';
$response = wp_remote_post( $api_url, array(
// Set the Content-Type header.
'headers' ... | I figured this out after a night sleep. Sometimes our brains function like that.
The problem was actually my call here, It should've been "add\_foo" not "\_add\_foo"
```
data: {
// the value of data.action is the part AFTER 'wp_ajax_' in
// the add_action ('wp_ajax_xxx', 'yyy') in the PHP ... |
367,200 | <p>Ok, so I am using WordPress rest API to fetch the data using front-end. I am having the plain permalinks and unfortunately, I am not allowed to change the permalinks.
So, for </p>
<pre><code>https://www.example.com
</code></pre>
<p>I am using the route option:</p>
<pre><code>https://www.example.com/?rest_route=/... | [
{
"answer_id": 367202,
"author": "rank",
"author_id": 178642,
"author_profile": "https://wordpress.stackexchange.com/users/178642",
"pm_score": -1,
"selected": false,
"text": "<p>You have to add the parameters at the end, so it is defined which data should be affected. You add it after t... | 2020/05/21 | [
"https://wordpress.stackexchange.com/questions/367200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188555/"
] | Ok, so I am using WordPress rest API to fetch the data using front-end. I am having the plain permalinks and unfortunately, I am not allowed to change the permalinks.
So, for
```
https://www.example.com
```
I am using the route option:
```
https://www.example.com/?rest_route=/wp/v2/posts
```
And this is working... | Actually I was able to figure out with a little modification to Rank's answer:
```
https://www.example.com/?rest_route=/wp/v2/posts&categories=12
``` |
367,255 | <p>I am trying to make my theme compatible with <a href="https://wordpress.org/plugins/co-authors-plus/" rel="nofollow noreferrer">Co-Authors Plus plugin</a> and show the co-authors of a post if had any.
I spent about 30 minutes trying to convince myself that I understood the following code to display post author and d... | [
{
"answer_id": 367202,
"author": "rank",
"author_id": 178642,
"author_profile": "https://wordpress.stackexchange.com/users/178642",
"pm_score": -1,
"selected": false,
"text": "<p>You have to add the parameters at the end, so it is defined which data should be affected. You add it after t... | 2020/05/21 | [
"https://wordpress.stackexchange.com/questions/367255",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/187384/"
] | I am trying to make my theme compatible with [Co-Authors Plus plugin](https://wordpress.org/plugins/co-authors-plus/) and show the co-authors of a post if had any.
I spent about 30 minutes trying to convince myself that I understood the following code to display post author and date:
```php
function posted_on() {
... | Actually I was able to figure out with a little modification to Rank's answer:
```
https://www.example.com/?rest_route=/wp/v2/posts&categories=12
``` |
367,320 | <p>I have a blog site. And I found a suspicious access to my blog post from log.
The url format is like this.</p>
<pre><code>https://example.com/my-post/?unapproved=420&moderation-hash=847492149d817bf7e08d81457bf9952f
</code></pre>
<p>And they access from several ips. What is their purpose?</p>
| [
{
"answer_id": 367202,
"author": "rank",
"author_id": 178642,
"author_profile": "https://wordpress.stackexchange.com/users/178642",
"pm_score": -1,
"selected": false,
"text": "<p>You have to add the parameters at the end, so it is defined which data should be affected. You add it after t... | 2020/05/22 | [
"https://wordpress.stackexchange.com/questions/367320",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188643/"
] | I have a blog site. And I found a suspicious access to my blog post from log.
The url format is like this.
```
https://example.com/my-post/?unapproved=420&moderation-hash=847492149d817bf7e08d81457bf9952f
```
And they access from several ips. What is their purpose? | Actually I was able to figure out with a little modification to Rank's answer:
```
https://www.example.com/?rest_route=/wp/v2/posts&categories=12
``` |
367,340 | <p>Nobody has touched <code>wp-admin</code> for this site in weeks. Suddenly, URLs are being sanitized in ways that break <em>everything</em>. The question marks of query parameters are being replaced with URL escape code <code>%3F</code>, which is obviously breaking nearly every script and stylesheet include that's af... | [
{
"answer_id": 367334,
"author": "Faye",
"author_id": 76600,
"author_profile": "https://wordpress.stackexchange.com/users/76600",
"pm_score": 1,
"selected": false,
"text": "<p>Sounds like your theme is dependant on one of those plugins and disabling it is causing grief. You'll need to sw... | 2020/05/23 | [
"https://wordpress.stackexchange.com/questions/367340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188656/"
] | Nobody has touched `wp-admin` for this site in weeks. Suddenly, URLs are being sanitized in ways that break *everything*. The question marks of query parameters are being replaced with URL escape code `%3F`, which is obviously breaking nearly every script and stylesheet include that's affected. The result is content li... | Well I agree with @Faye. It might be due to the activated theme which is depending on one of the plugin you deactivated. But rather than doing all of the steps you can simply rename the active theme in the wp-content/themes folder via FTP or cPanel. This will deactivate the theme and if it's the theme problem then you ... |
367,374 | <p>I have 3 users roles on my platform with no access to the WordPress backoffice <strong>"external_user1"</strong> , <strong>"external_user2"</strong>, <strong>"external_user3"</strong>.</p>
<p>I need to force every user with one of this roles to change his password at the first login. by the way i use the WordPress ... | [
{
"answer_id": 367786,
"author": "Steven Green",
"author_id": 188990,
"author_profile": "https://wordpress.stackexchange.com/users/188990",
"pm_score": -1,
"selected": false,
"text": "<p>There are a number of useful plugins that do just this. They even have extra features you didn't ment... | 2020/05/23 | [
"https://wordpress.stackexchange.com/questions/367374",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119785/"
] | I have 3 users roles on my platform with no access to the WordPress backoffice **"external\_user1"** , **"external\_user2"**, **"external\_user3"**.
I need to force every user with one of this roles to change his password at the first login. by the way i use the WordPress login form.
So if the user enter the correct ... | This is a multi-faceted issue that probably seems (well, to me at least) easy at first. Not sure if the code works, however, it's close to working **but most importantly, showcases the flow of how things need to happen:**
```
/**
* First of all, hook up to the login process.
*/
add_action( 'wp_login', function( $use... |
367,376 | <p>I am new to plugin development and I am fairly okay with development by following all the plugin development best practices set by WordPress Codex. Following code describes on how Role: Administrator of WordPress gains access to the plugin. </p>
<p>Administrator access to plugin in settings: SettingsApi.php</p>
<p... | [
{
"answer_id": 367786,
"author": "Steven Green",
"author_id": 188990,
"author_profile": "https://wordpress.stackexchange.com/users/188990",
"pm_score": -1,
"selected": false,
"text": "<p>There are a number of useful plugins that do just this. They even have extra features you didn't ment... | 2020/05/23 | [
"https://wordpress.stackexchange.com/questions/367376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188686/"
] | I am new to plugin development and I am fairly okay with development by following all the plugin development best practices set by WordPress Codex. Following code describes on how Role: Administrator of WordPress gains access to the plugin.
Administrator access to plugin in settings: SettingsApi.php
```
public funct... | This is a multi-faceted issue that probably seems (well, to me at least) easy at first. Not sure if the code works, however, it's close to working **but most importantly, showcases the flow of how things need to happen:**
```
/**
* First of all, hook up to the login process.
*/
add_action( 'wp_login', function( $use... |
367,383 | <p>I'm going round in circles with trying to include several custom fields in my search results. The custom fields are managed via ACF.</p>
<p>At first I want this for the admin. /wp-admin/edit.php?post_type=location.</p>
<p>I can't see why this wont work. I have tried variations of it and different orders. I've also... | [
{
"answer_id": 367388,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried it with <code>add_action</code> instead of <code>add_filter</code> ? </p>\n\n<pre><code>add_ac... | 2020/05/23 | [
"https://wordpress.stackexchange.com/questions/367383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | I'm going round in circles with trying to include several custom fields in my search results. The custom fields are managed via ACF.
At first I want this for the admin. /wp-admin/edit.php?post\_type=location.
I can't see why this wont work. I have tried variations of it and different orders. I've also gone through th... | So turns out you can't actually add ACF / custom fields to the search query in this way. It seems to force and AND into the query.
I've used a mixture of sources to create the below which now works really well.
```
/* ADD META FIELD TO SEARCH QUERY */
// fields for Ajax search, admin and normal search
if (!isset($GLO... |
367,396 | <p>I wish to set up 2 smtp accounts on my wordpress site:</p>
<p>1 for woocommerce orders
1 for all other forms</p>
<p>i have the following code, but i am having trouble filtering the woocommmerce order. I am missing somthing. Here is the code:</p>
<pre><code>add_action( 'phpmailer_init', 'send_smtp' );
function s... | [
{
"answer_id": 367491,
"author": "Leon William",
"author_id": 103968,
"author_profile": "https://wordpress.stackexchange.com/users/103968",
"pm_score": 0,
"selected": false,
"text": "<p>Right now, it is not possible to add multiple SMTP addresses. However, if you still need to send email... | 2020/05/24 | [
"https://wordpress.stackexchange.com/questions/367396",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188708/"
] | I wish to set up 2 smtp accounts on my wordpress site:
1 for woocommerce orders
1 for all other forms
i have the following code, but i am having trouble filtering the woocommmerce order. I am missing somthing. Here is the code:
```
add_action( 'phpmailer_init', 'send_smtp' );
function send_smtp( $phpmailer ) {
... | Your premise is correct - you can connect to different STMP accounts based on whatever criteria you can build into your action function.
It's a little tricky with WooCommerce because it has two email objects that it uses, one for creating emails and the other for sending. Also, hooking into the WC send process require... |
367,414 | <p>I want to apply styling only to a page with a specific URL(not id) in Wordpress.
for example to .../something/events
kindly suggest only PHP solutions, via funtion.php (not CSS id or class)
I've tried different things but nothing has worked. thanks.</p>
| [
{
"answer_id": 367421,
"author": "FilT",
"author_id": 106585,
"author_profile": "https://wordpress.stackexchange.com/users/106585",
"pm_score": 1,
"selected": false,
"text": "<p>Why don't you add a class to body via functions if you are on that url, so you can use that class on css, like... | 2020/05/24 | [
"https://wordpress.stackexchange.com/questions/367414",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140383/"
] | I want to apply styling only to a page with a specific URL(not id) in Wordpress.
for example to .../something/events
kindly suggest only PHP solutions, via funtion.php (not CSS id or class)
I've tried different things but nothing has worked. thanks. | Why don't you add a class to body via functions if you are on that url, so you can use that class on css, like so:
```
function add_class_to_body($classes) {
if(is_page('events')){
$classes[] = 'page-events';
return $classes;
}
}
add_filter('body_class','add_class_to_body');
```
Then you are ... |
367,417 | <p>I would like to ask you guys questions.
Already set up custom css for mobile</p>
<pre><code> @media only screen and (min-device-width: 601px) and (max-device-width: 736px)
@media only screen and (min-device-width: 300px) and (max-device-width: 600px)
@media only screen and (min-device-width: 300px) and (max-dev... | [
{
"answer_id": 367421,
"author": "FilT",
"author_id": 106585,
"author_profile": "https://wordpress.stackexchange.com/users/106585",
"pm_score": 1,
"selected": false,
"text": "<p>Why don't you add a class to body via functions if you are on that url, so you can use that class on css, like... | 2020/05/24 | [
"https://wordpress.stackexchange.com/questions/367417",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188728/"
] | I would like to ask you guys questions.
Already set up custom css for mobile
```
@media only screen and (min-device-width: 601px) and (max-device-width: 736px)
@media only screen and (min-device-width: 300px) and (max-device-width: 600px)
@media only screen and (min-device-width: 300px) and (max-device-width: 600... | Why don't you add a class to body via functions if you are on that url, so you can use that class on css, like so:
```
function add_class_to_body($classes) {
if(is_page('events')){
$classes[] = 'page-events';
return $classes;
}
}
add_filter('body_class','add_class_to_body');
```
Then you are ... |
367,454 | <p>I noticed that in every single folder of my wordpress there's a file called .theme-name.php.</p>
<p>For example, in the theme folder twentynineteen.php there is this file called .twentynineteen.php</p>
<p>This is the content of every single one of them:</p>
<p>if ( !class_exists( 'WPTemplatesOptions' ) ) {</p>
<... | [
{
"answer_id": 367534,
"author": "Gold",
"author_id": 188822,
"author_profile": "https://wordpress.stackexchange.com/users/188822",
"pm_score": 0,
"selected": false,
"text": "<p>Yes it's malware injected via XSS \nDo you have Plugin GRPD COOKIE CONSENT installed on your site ? \nIf you h... | 2020/05/25 | [
"https://wordpress.stackexchange.com/questions/367454",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188756/"
] | I noticed that in every single folder of my wordpress there's a file called .theme-name.php.
For example, in the theme folder twentynineteen.php there is this file called .twentynineteen.php
This is the content of every single one of them:
if ( !class\_exists( 'WPTemplatesOptions' ) ) {
```
class WPTemplatesOptions... | Ok, it took me a while to figure it out, but at the end I fixed the problem.
The malware infected 99% of the wordpress files. It generated files in 99% of the folders and subfolders and in almost every single files it added the following:
```
if (file_exists($filename = dirname(FILE) . DIRECTORY_SEPARATOR . '.' . bas... |
367,466 | <p>I have a wordpress multisite with one site to <strong>domain.com</strong> and another to <strong>materials.domain.com</strong></p>
<p>At the domain site I have a page <strong>domain.com/materials</strong></p>
<p>I'd like to redirect the <strong>materials.domain.com</strong> homepage to the <strong>domain.com/mater... | [
{
"answer_id": 367534,
"author": "Gold",
"author_id": 188822,
"author_profile": "https://wordpress.stackexchange.com/users/188822",
"pm_score": 0,
"selected": false,
"text": "<p>Yes it's malware injected via XSS \nDo you have Plugin GRPD COOKIE CONSENT installed on your site ? \nIf you h... | 2020/05/25 | [
"https://wordpress.stackexchange.com/questions/367466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188765/"
] | I have a wordpress multisite with one site to **domain.com** and another to **materials.domain.com**
At the domain site I have a page **domain.com/materials**
I'd like to redirect the **materials.domain.com** homepage to the **domain.com/materials**
I'm using a child theme to my subdomain instalation and trying the ... | Ok, it took me a while to figure it out, but at the end I fixed the problem.
The malware infected 99% of the wordpress files. It generated files in 99% of the folders and subfolders and in almost every single files it added the following:
```
if (file_exists($filename = dirname(FILE) . DIRECTORY_SEPARATOR . '.' . bas... |
367,471 | <p>in a cpt i can check some values (checkboxes) in a metabox. i can access this values by </p>
<pre><code>$meta = get_post_meta(get_the_ID(), '_custom-meta-box', true );
</code></pre>
<p>after that, i do a foreach loop:</p>
<pre><code>foreach ($meta as $key11 => $value11) {
if($meta[$key11] > 1) {
$my_p... | [
{
"answer_id": 367534,
"author": "Gold",
"author_id": 188822,
"author_profile": "https://wordpress.stackexchange.com/users/188822",
"pm_score": 0,
"selected": false,
"text": "<p>Yes it's malware injected via XSS \nDo you have Plugin GRPD COOKIE CONSENT installed on your site ? \nIf you h... | 2020/05/25 | [
"https://wordpress.stackexchange.com/questions/367471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84353/"
] | in a cpt i can check some values (checkboxes) in a metabox. i can access this values by
```
$meta = get_post_meta(get_the_ID(), '_custom-meta-box', true );
```
after that, i do a foreach loop:
```
foreach ($meta as $key11 => $value11) {
if($meta[$key11] > 1) {
$my_postid11 = $value11;
$funktion11 = get_... | Ok, it took me a while to figure it out, but at the end I fixed the problem.
The malware infected 99% of the wordpress files. It generated files in 99% of the folders and subfolders and in almost every single files it added the following:
```
if (file_exists($filename = dirname(FILE) . DIRECTORY_SEPARATOR . '.' . bas... |
367,504 | <p>The Twenty Nineteen theme uses SVG for its social icons. For example, this is the code for the Google icon:</p>
<pre><code><svg viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path d="M12.02,10.18v3.72v0.01h5.51c-0.26,1.57-1.67,4.22-5.5,... | [
{
"answer_id": 367523,
"author": "FilT",
"author_id": 106585,
"author_profile": "https://wordpress.stackexchange.com/users/106585",
"pm_score": 1,
"selected": false,
"text": "<p>It seems like you have pluign updates as well, have you tried them and see if it changes?</p>\n\n<p>Also you c... | 2020/05/25 | [
"https://wordpress.stackexchange.com/questions/367504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33049/"
] | The Twenty Nineteen theme uses SVG for its social icons. For example, this is the code for the Google icon:
```
<svg viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path d="M12.02,10.18v3.72v0.01h5.51c-0.26,1.57-1.67,4.22-5.5,4.22c-3.31,0-6.01-2.75-... | It seems like you have pluign updates as well, have you tried them and see if it changes?
Also you can inspect the html code and see which css is causing the size of the images, on the browser's dev console, usually available on right click on any page. |
367,505 | <p>I'm slowly building my own WordPress theme and want to have a related posts section at the bottom of each post (for example <a href="https://www.davidhazeel.com/2020/05/19/creating-a-bootstrap-nav/" rel="nofollow noreferrer">here</a> on my site).</p>
<p>I am using the following code to generate the related posts:</... | [
{
"answer_id": 367523,
"author": "FilT",
"author_id": 106585,
"author_profile": "https://wordpress.stackexchange.com/users/106585",
"pm_score": 1,
"selected": false,
"text": "<p>It seems like you have pluign updates as well, have you tried them and see if it changes?</p>\n\n<p>Also you c... | 2020/05/25 | [
"https://wordpress.stackexchange.com/questions/367505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188786/"
] | I'm slowly building my own WordPress theme and want to have a related posts section at the bottom of each post (for example [here](https://www.davidhazeel.com/2020/05/19/creating-a-bootstrap-nav/) on my site).
I am using the following code to generate the related posts:
```
<footer>
<div class="container-fluid re... | It seems like you have pluign updates as well, have you tried them and see if it changes?
Also you can inspect the html code and see which css is causing the size of the images, on the browser's dev console, usually available on right click on any page. |
367,561 | <p>I have made little shortcodes to insert data to my home screen. I loop over total number of posts and output pre-styled html.</p>
<p>My question is, is it possible to also make pagination for that kind of loops? For example if I have 10 posts and I would like to display 5 and then under these are link to another 5.... | [
{
"answer_id": 367523,
"author": "FilT",
"author_id": 106585,
"author_profile": "https://wordpress.stackexchange.com/users/106585",
"pm_score": 1,
"selected": false,
"text": "<p>It seems like you have pluign updates as well, have you tried them and see if it changes?</p>\n\n<p>Also you c... | 2020/05/26 | [
"https://wordpress.stackexchange.com/questions/367561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188569/"
] | I have made little shortcodes to insert data to my home screen. I loop over total number of posts and output pre-styled html.
My question is, is it possible to also make pagination for that kind of loops? For example if I have 10 posts and I would like to display 5 and then under these are link to another 5. Or if thi... | It seems like you have pluign updates as well, have you tried them and see if it changes?
Also you can inspect the html code and see which css is causing the size of the images, on the browser's dev console, usually available on right click on any page. |
367,594 | <p>I am using WordPress and I have style page link</p>
<pre><code>https://example.com/blog/wp-content/themes/themename/style.css?ver=5.4.1
</code></pre>
<p>I have to change from <code>style.css?ver=5.4.1</code> to <code>style.css?v=<?=time();?></code> </p>
<p>Is it possible to change it?</p>
<p><strong>Why I ... | [
{
"answer_id": 367603,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>When you enqueue the style, you can use <code>filemtime()</code> as the version:</p>\n\n<pre><code><?p... | 2020/05/26 | [
"https://wordpress.stackexchange.com/questions/367594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/177715/"
] | I am using WordPress and I have style page link
```
https://example.com/blog/wp-content/themes/themename/style.css?ver=5.4.1
```
I have to change from `style.css?ver=5.4.1` to `style.css?v=<?=time();?>`
Is it possible to change it?
**Why I am doing this**
I don't know How can I explain my issue with style. Why I... | Finally, I got my solution, I don't know it's the best way or not but it's solved my issue.
What I did, I checked function.php file and found below code
```
function themename_scripts() {
wp_enqueue_style( 'themename-style', get_stylesheet_uri(), array(), _S_VERSION );
wp_style_add_data( 'themename-style', 'r... |
367,597 | <p>I know how to count how many posts has a certain tag, or category</p>
<p>For example:</p>
<pre><code>$term_slug = 'some-post-tag';
$term = get_term_by('slug', $term_slug, $post_tag);
echo $term->count;
</code></pre>
<p><strong>BUT!</strong>
Is there anyway to count how many posts that have a tag <strong>AND</s... | [
{
"answer_id": 367603,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>When you enqueue the style, you can use <code>filemtime()</code> as the version:</p>\n\n<pre><code><?p... | 2020/05/26 | [
"https://wordpress.stackexchange.com/questions/367597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/185417/"
] | I know how to count how many posts has a certain tag, or category
For example:
```
$term_slug = 'some-post-tag';
$term = get_term_by('slug', $term_slug, $post_tag);
echo $term->count;
```
**BUT!**
Is there anyway to count how many posts that have a tag **AND** a specified category?
I want to count how many posts t... | Finally, I got my solution, I don't know it's the best way or not but it's solved my issue.
What I did, I checked function.php file and found below code
```
function themename_scripts() {
wp_enqueue_style( 'themename-style', get_stylesheet_uri(), array(), _S_VERSION );
wp_style_add_data( 'themename-style', 'r... |
367,622 | <p>I'm trying to find some specific plugin for Accordion (FAQ), but to be in a form of Gutenberg Block. There is a group of "block enabled" plugins on <a href="https://wordpress.org/plugins/browse/blocks/" rel="nofollow noreferrer">https://wordpress.org/plugins/browse/blocks/</a></p>
<p>There should be a simple way of... | [
{
"answer_id": 367603,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>When you enqueue the style, you can use <code>filemtime()</code> as the version:</p>\n\n<pre><code><?p... | 2020/05/27 | [
"https://wordpress.stackexchange.com/questions/367622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188889/"
] | I'm trying to find some specific plugin for Accordion (FAQ), but to be in a form of Gutenberg Block. There is a group of "block enabled" plugins on <https://wordpress.org/plugins/browse/blocks/>
There should be a simple way of achieving this task. I've done a lot of experimenting, but none of the results were satisfac... | Finally, I got my solution, I don't know it's the best way or not but it's solved my issue.
What I did, I checked function.php file and found below code
```
function themename_scripts() {
wp_enqueue_style( 'themename-style', get_stylesheet_uri(), array(), _S_VERSION );
wp_style_add_data( 'themename-style', 'r... |
367,644 | <p>Please i want to know if it is posible to use one sql query to insert into multiple columns and rows using array in php <br> <code>$sql = "INSERT INTO MyGuests (firstname, lastname, email) <br> VALUES ('John', 'Doe', 'john@example.com');";</code><br> but i want to represent column names in array as arrays a... | [
{
"answer_id": 367603,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>When you enqueue the style, you can use <code>filemtime()</code> as the version:</p>\n\n<pre><code><?p... | 2020/05/27 | [
"https://wordpress.stackexchange.com/questions/367644",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152456/"
] | Please i want to know if it is posible to use one sql query to insert into multiple columns and rows using array in php
`$sql = "INSERT INTO MyGuests (firstname, lastname, email) <br> VALUES ('John', 'Doe', 'john@example.com');";`
but i want to represent column names in array as arrays and then values as array v... | Finally, I got my solution, I don't know it's the best way or not but it's solved my issue.
What I did, I checked function.php file and found below code
```
function themename_scripts() {
wp_enqueue_style( 'themename-style', get_stylesheet_uri(), array(), _S_VERSION );
wp_style_add_data( 'themename-style', 'r... |
367,685 | <p>I have been looking at this for hours but can't get it to work.</p>
<pre><code> $newsItems2 = get_posts([
"post_type" => "post",
"post_status" => "publish",
"posts_per_page" => 3,
"orderby" ... | [
{
"answer_id": 367686,
"author": "T Paone",
"author_id": 179013,
"author_profile": "https://wordpress.stackexchange.com/users/179013",
"pm_score": -1,
"selected": false,
"text": "<p>Try adding <code>'suppress_filters' => true</code> as a part of the query. There may be a filter operat... | 2020/05/27 | [
"https://wordpress.stackexchange.com/questions/367685",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109044/"
] | I have been looking at this for hours but can't get it to work.
```
$newsItems2 = get_posts([
"post_type" => "post",
"post_status" => "publish",
"posts_per_page" => 3,
"orderby" => "date",
... | I figured it out, just posting it here for anyone else having this kind of problem: there was a too greedy pre\_posts function firing that always changed the sorting order to menu\_order. Changed that and now it's working great. |
367,733 | <p>So I have the following structure in my theme:</p>
<blockquote>
<p>Themes/<br>
- theme-name/<br>
-- functions.php<br>
-- style.css<br>
-- page-directories.php</p>
</blockquote>
<p>For some reason, I'm unable to link the <code>style.css</code> to be included for my <code>page-directories.php</code> file.<... | [
{
"answer_id": 367736,
"author": "mtedwards",
"author_id": 144820,
"author_profile": "https://wordpress.stackexchange.com/users/144820",
"pm_score": 1,
"selected": false,
"text": "<p><code>get_template_directory_uri()</code> just returns the directory of the current theme, not the link t... | 2020/05/28 | [
"https://wordpress.stackexchange.com/questions/367733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188955/"
] | So I have the following structure in my theme:
>
> Themes/
>
> - theme-name/
>
> -- functions.php
>
> -- style.css
>
> -- page-directories.php
>
>
>
For some reason, I'm unable to link the `style.css` to be included for my `page-directories.php` file.
Here is what I have inside the `functions.php... | `get_template_directory_uri()` just returns the directory of the current theme, not the link to the actual stylesheet.
In `functions.php` try:
```
function register_directories_style() {
wp_register_style('style', get_template_directory_uri().'/style.css', [], 1);
wp_enqueue_style('style');
}
add_action( 'wp_... |
367,821 | <p>I'm creating a plugin to add a custom post type.
For every custom post type, I also create custom single template.
The custom single template is not using get_header(); or wp_head() functions, it is coded from scratch manually.
I've enqueued the style like this:</p>
<pre><code><link rel="stylesheet" href="<?p... | [
{
"answer_id": 367824,
"author": "Tommy Pradana",
"author_id": 73978,
"author_profile": "https://wordpress.stackexchange.com/users/73978",
"pm_score": -1,
"selected": false,
"text": "<p>You can create your own hook using <code>do_action( 'your_hook_name' );</code></p>\n\n<p>In your cpt t... | 2020/05/29 | [
"https://wordpress.stackexchange.com/questions/367821",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65317/"
] | I'm creating a plugin to add a custom post type.
For every custom post type, I also create custom single template.
The custom single template is not using get\_header(); or wp\_head() functions, it is coded from scratch manually.
I've enqueued the style like this:
```
<link rel="stylesheet" href="<?php echo esc_url( p... | First, you've got a heck of an obvious coding error in every one of your `wp_enqueue_style` calls: you have spaces in your quotations. Furthermore, because you are choosing not to call the `wp_head()` method, the [hook](https://developer.wordpress.org/reference/hooks/wp_head/) of the same name will not be called. That ... |
367,822 | <p>(<em>Edit:</em> going for the "Student" badge, and wondering if anyone out there could up vote this question?)</p>
<p>I answered <a href="https://wordpress.stackexchange.com/questions/367518/how-do-i-code-access-to-the-built-in-ui-of-a-cpt-when-its-placed-as-submenu-of">a question</a> about capabilities, but now I... | [
{
"answer_id": 367892,
"author": "Himad",
"author_id": 158512,
"author_profile": "https://wordpress.stackexchange.com/users/158512",
"pm_score": -1,
"selected": false,
"text": "<p>I came across this some time ago, I'll try to find time to correctly debug the origin of the issue but in th... | 2020/05/29 | [
"https://wordpress.stackexchange.com/questions/367822",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/188811/"
] | (*Edit:* going for the "Student" badge, and wondering if anyone out there could up vote this question?)
I answered [a question](https://wordpress.stackexchange.com/questions/367518/how-do-i-code-access-to-the-built-in-ui-of-a-cpt-when-its-placed-as-submenu-of) about capabilities, but now I'm in need of help on the sub... | The problem is that when the special subscriber tries to **Add New** a sub-cpt post, it is denied permission. However, when the CPT menu is a top-admin-menu, then everything works out fine. The issue is related to the placement of the CPT's UI menu in the back-end: if it's top-level (`show_in_menu=TRUE`), all is well; ... |