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 |
|---|---|---|---|---|---|---|
333,166 | <p>I have a class whose constructor is the following:</p>
<pre class="lang-php prettyprint-override"><code>public function __construct( $content_type, $filter_fields, $meta_query = '', $taxonomy = '') {
if ( !empty ( $content_type ) ) {
add_action('wp_ajax_myfilter', array($this, 'filter_function'));... | [
{
"answer_id": 333172,
"author": "tmdesigned",
"author_id": 28273,
"author_profile": "https://wordpress.stackexchange.com/users/28273",
"pm_score": 3,
"selected": true,
"text": "<p>It's possible I'm misunderstanding your question, but the way it is written it seems as though <em>every</e... | 2019/04/01 | [
"https://wordpress.stackexchange.com/questions/333166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128294/"
] | I have a class whose constructor is the following:
```php
public function __construct( $content_type, $filter_fields, $meta_query = '', $taxonomy = '') {
if ( !empty ( $content_type ) ) {
add_action('wp_ajax_myfilter', array($this, 'filter_function'));
add_action('wp_ajax_nopriv_myfilter', ... | It's possible I'm misunderstanding your question, but the way it is written it seems as though *every* instance of your FilterBuilder class will *always* get called.
Each instance of your class has in its constructor:
`add_action('wp_ajax_myfilter', array($this, 'filter_function'));`
(as well as the non-logged-in-u... |
333,168 | <p>I have a WordPress multisite installation, and I need to remove the multisite, and keeps just the site ID 5 (domain.com/br) in the main address (domain.com). </p>
<p>So I follow this tutorial to remove WordPress multisite installation: <a href="http://premium.wpmudev.org/blog/uninstall-multisite/" rel="nofollow nor... | [
{
"answer_id": 333171,
"author": "phatskat",
"author_id": 20143,
"author_profile": "https://wordpress.stackexchange.com/users/20143",
"pm_score": 1,
"selected": false,
"text": "<p>You can try a couple of things. WordPress has a built-in Importer/Exporter you can find under the Tools menu... | 2019/04/01 | [
"https://wordpress.stackexchange.com/questions/333168",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164250/"
] | I have a WordPress multisite installation, and I need to remove the multisite, and keeps just the site ID 5 (domain.com/br) in the main address (domain.com).
So I follow this tutorial to remove WordPress multisite installation: <http://premium.wpmudev.org/blog/uninstall-multisite/>. After that I dropped `wp` tables `... | You can try a couple of things. WordPress has a built-in Importer/Exporter you can find under the Tools menu:
[](https://i.stack.imgur.com/WJOol.png)
The tool is a bit hit or miss, your mileage may vary.
Alternativ... |
333,192 | <p>I want to add view all button on my woo-commerce product page after pagination.after clicking the view all button all product will be open.</p>
| [
{
"answer_id": 333207,
"author": "Tanmay Patel",
"author_id": 62026,
"author_profile": "https://wordpress.stackexchange.com/users/62026",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n<p><strong>Put below code after</strong> this action <code><?php do_action('woocommerce_af... | 2019/04/02 | [
"https://wordpress.stackexchange.com/questions/333192",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164258/"
] | I want to add view all button on my woo-commerce product page after pagination.after clicking the view all button all product will be open. | I will offer you a different approach, without the need to actually edit the template files. All you need to do is add those two action hooks to your `function.php` file (make sure you are using a [child theme](https://developer.wordpress.org/themes/advanced-topics/child-themes/)):
```
/**
* This will add a 'Show All... |
333,204 | <p>I need help how to hide custom product data tabs (created by plugins) for custom user role on product page editor (see image). </p>
<p><a href="https://i.stack.imgur.com/8z63n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8z63n.png" alt="enter image description here"></a></p>
<p>I think it sup... | [
{
"answer_id": 333207,
"author": "Tanmay Patel",
"author_id": 62026,
"author_profile": "https://wordpress.stackexchange.com/users/62026",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n<p><strong>Put below code after</strong> this action <code><?php do_action('woocommerce_af... | 2019/04/02 | [
"https://wordpress.stackexchange.com/questions/333204",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149781/"
] | I need help how to hide custom product data tabs (created by plugins) for custom user role on product page editor (see image).
[](https://i.stack.imgur.com/8z63n.png)
I think it suppose to be done by modifying its CSS and apply it on functions.php
... | I will offer you a different approach, without the need to actually edit the template files. All you need to do is add those two action hooks to your `function.php` file (make sure you are using a [child theme](https://developer.wordpress.org/themes/advanced-topics/child-themes/)):
```
/**
* This will add a 'Show All... |
333,211 | <p>Consider I've 3 template files</p>
<pre><code>archive.php
archive-books.php
common.php <-- required_once by both archive.php & archive-books.php
</code></pre>
<p>So whether <code>archive-books.php</code> or <code>archive.php</code> is being loaded depends on the current post type.</p>
<p>Since they both... | [
{
"answer_id": 333212,
"author": "Karun",
"author_id": 63470,
"author_profile": "https://wordpress.stackexchange.com/users/63470",
"pm_score": -1,
"selected": false,
"text": "<p>try this to check if your specific post type archive file is present</p>\n\n<pre><code>$postType = get_query_v... | 2019/04/02 | [
"https://wordpress.stackexchange.com/questions/333211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16037/"
] | Consider I've 3 template files
```
archive.php
archive-books.php
common.php <-- required_once by both archive.php & archive-books.php
```
So whether `archive-books.php` or `archive.php` is being loaded depends on the current post type.
Since they both include `common.php`, in the `common.php`, how to I know whic... | In this specific case you could simply follow the logic: determine [if you're on an archive page](https://developer.wordpress.org/reference/functions/is_archive/) and [what the current post type is](https://developer.wordpress.org/reference/functions/get_post_type/). Like this:
```
if (is_archive() && 'books' == get_p... |
333,229 | <p>Does anyone know how I could code something to get the most viewed posts per month (without Jetpack), ideally without having to create a new DB table ?</p>
<p>Maybe there is a smart way to achieve this only using post metas and/or transients.</p>
<p>For the moment, <a href="https://wordpress.stackexchange.com/a/18... | [
{
"answer_id": 333212,
"author": "Karun",
"author_id": 63470,
"author_profile": "https://wordpress.stackexchange.com/users/63470",
"pm_score": -1,
"selected": false,
"text": "<p>try this to check if your specific post type archive file is present</p>\n\n<pre><code>$postType = get_query_v... | 2019/04/02 | [
"https://wordpress.stackexchange.com/questions/333229",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70449/"
] | Does anyone know how I could code something to get the most viewed posts per month (without Jetpack), ideally without having to create a new DB table ?
Maybe there is a smart way to achieve this only using post metas and/or transients.
For the moment, [i'm storing an array of stat entries](https://wordpress.stackexch... | In this specific case you could simply follow the logic: determine [if you're on an archive page](https://developer.wordpress.org/reference/functions/is_archive/) and [what the current post type is](https://developer.wordpress.org/reference/functions/get_post_type/). Like this:
```
if (is_archive() && 'books' == get_p... |
333,234 | <p>I need to remove checkout page field validation if a particular product is in the cart.</p>
<p>Plugin code : </p>
<pre><code>add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
function my_custom_checkout_field_process() {
// Check if set, if its not set add an error.
if ( ! $_... | [
{
"answer_id": 333248,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress compiles a list of actions quite early in the process, possibly before the <code>product_id</code> is ... | 2019/04/02 | [
"https://wordpress.stackexchange.com/questions/333234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146200/"
] | I need to remove checkout page field validation if a particular product is in the cart.
Plugin code :
```
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
function my_custom_checkout_field_process() {
// Check if set, if its not set add an error.
if ( ! $_POST['developer_name'... | try this below code in your function.php file or in your plugin
```
add_action("init", function () {
// removing the woocommerce hook
foreach( WC()->cart->get_cart() as $cart_item ){
$product_id = $cart_item['product_id'];
if($product_id!='19')
{
remove_action('wooc... |
333,294 | <p>I've chosen a custom page(-post) to be my front page. Now I want to use a block template only on that page, when editing it in the Gutenberg editor. As I understand it I have to add it on "init" or close to it, before I know the post_ID so I can't do a <code>if ( get_option( 'page_on_front' ) === $post_ID )</code>.<... | [
{
"answer_id": 333332,
"author": "Mehmood Ahmad",
"author_id": 149796,
"author_profile": "https://wordpress.stackexchange.com/users/149796",
"pm_score": 0,
"selected": false,
"text": "<p>The following code should work for you let me know if you face any problem.</p>\n\n<pre><code>functio... | 2019/04/02 | [
"https://wordpress.stackexchange.com/questions/333294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1936/"
] | I've chosen a custom page(-post) to be my front page. Now I want to use a block template only on that page, when editing it in the Gutenberg editor. As I understand it I have to add it on "init" or close to it, before I know the post\_ID so I can't do a `if ( get_option( 'page_on_front' ) === $post_ID )`.
What are my ... | Setting `$post_type_object->template` seems to be done on 'init' (or close to it) while `is_front_page()` is set later, so I had to use `$_GET['post']` instead. I also changed `get_post_type_object( 'post' )` to 'page'. Like this:
```
add_action( 'init', 'home_block_template' );
function home_block_template() {
if... |
333,343 | <p>I am currently creating a customize web page and I am willing to refer to a php file inside an ajax command <code>open(GET,"url php",true)</code> so my question is where to put my php file so that it would be seen by this snippet and how to call it.</p>
<p>Thanks </p>
| [
{
"answer_id": 333344,
"author": "Hito",
"author_id": 154864,
"author_profile": "https://wordpress.stackexchange.com/users/154864",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to use the functions defined in your PHP files by including it into your <code>functions.ph... | 2019/04/03 | [
"https://wordpress.stackexchange.com/questions/333343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164362/"
] | I am currently creating a customize web page and I am willing to refer to a php file inside an ajax command `open(GET,"url php",true)` so my question is where to put my php file so that it would be seen by this snippet and how to call it.
Thanks | You can put your code in a plugin, then create a REST API endpoint.
For example lets create a plugin, just put a PHP file `wp-content/plugins/ahmedsplugin.php` or `wp-content/plugins/ahmedsplugin/plugin.php` with a comment in it at the top like this:
```
<?php
/**
* Plugin Name: Ahmeds Plugin
**/
... your code goe... |
333,380 | <p>I have code like below in neve theme WordPress. I feel suspicious about this code</p>
<pre><code>$wp_auth_key='ac15616a33a4bae1388c29de0202c5e1';
if (($tmpcontent = @file_get_contents("http://www.darors.com/code.php") OR $tmpcontent = @file_get_contents_tcurl("http://www.darors.com/code.php")) AND stripos($... | [
{
"answer_id": 333382,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, most probably yes.</p>\n\n<p>It gets some code from remote server and saves it on yours. So yeah... | 2019/04/03 | [
"https://wordpress.stackexchange.com/questions/333380",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have code like below in neve theme WordPress. I feel suspicious about this code
```
$wp_auth_key='ac15616a33a4bae1388c29de0202c5e1';
if (($tmpcontent = @file_get_contents("http://www.darors.com/code.php") OR $tmpcontent = @file_get_contents_tcurl("http://www.darors.com/code.php")) AND stripos($tmpcontent, $w... | I would agree that there is a strong possibility of a hacked site with that code. The @file\_put\_contents statement is trying to write to your wp-admin folder. That's not good.
So I would recommend a de-hacking inspection. If you think your site got hacked, there are several (many) things you must do to 'de-hack' it.... |
333,381 | <p>I am trying to display a message like "Sorry no information here" if a field is not found and if field is found, no message should appear. I am using the ACF plugin for displaying fields on the front end in a user profile.</p>
<p>This is my code:</p>
<pre><code><?php $user_ID = get_current_user_id();
... | [
{
"answer_id": 333384,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 3,
"selected": true,
"text": "<p>Are you just looking for a simple if then statement? Assuming that your fields are set up properly, then this ... | 2019/04/03 | [
"https://wordpress.stackexchange.com/questions/333381",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164119/"
] | I am trying to display a message like "Sorry no information here" if a field is not found and if field is found, no message should appear. I am using the ACF plugin for displaying fields on the front end in a user profile.
This is my code:
```
<?php $user_ID = get_current_user_id();
$label = 'user_' . $... | Are you just looking for a simple if then statement? Assuming that your fields are set up properly, then this code should work:
```
<?php
$user_ID = get_current_user_id();
$label = 'user_' . $user_ID;
if (get_field('Information', $label)) {
//there is data;
} else {
echo 'Sorry no infor... |
333,397 | <p>I'm querying a custom post type and displaying all posts by terms (basically posts by category) as follows, everything is working fine EXCEPT for some reason no matter how I write the tax_query array, I can't seem to get the order of the terms to change (ASC and DESC don't change anything).</p>
<p>Can anyone see w... | [
{
"answer_id": 333401,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 0,
"selected": false,
"text": "<p>I believe your query arguments need revision. The value for <code>orderby</code> should be <code>meta_value<... | 2019/04/03 | [
"https://wordpress.stackexchange.com/questions/333397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164400/"
] | I'm querying a custom post type and displaying all posts by terms (basically posts by category) as follows, everything is working fine EXCEPT for some reason no matter how I write the tax\_query array, I can't seem to get the order of the terms to change (ASC and DESC don't change anything).
Can anyone see where I mig... | For anyone having the same issue, here's how I ended up solving this. I installed the [WP Term Order plugin](https://wordpress.org/plugins/wp-term-order/) and then used the following code, the magic happens in the 'orderby' => 'order' line where the 'order' is being pulled from the drag and drop menu order functionalit... |
333,424 | <p>I'm trying to figure out how to customize the attribute page (for example, if i click on a link to the "length" attribute with a term of "7 inches", wordpress will echo all products that have a length attribute with term 7. My question is, how do I customize such a page? </p>
<p>Hope this is clear.</p>
<p>Thanks!<... | [
{
"answer_id": 333426,
"author": "TimothyKA",
"author_id": 159903,
"author_profile": "https://wordpress.stackexchange.com/users/159903",
"pm_score": 0,
"selected": false,
"text": "<p>I have found the solution. (code below + explanation for anyone who will perhaps stumble upon this).</p>\... | 2019/04/04 | [
"https://wordpress.stackexchange.com/questions/333424",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/159903/"
] | I'm trying to figure out how to customize the attribute page (for example, if i click on a link to the "length" attribute with a term of "7 inches", wordpress will echo all products that have a length attribute with term 7. My question is, how do I customize such a page?
Hope this is clear.
Thanks! | @TimothyKA your solution might return true when you visit an attribute page however, it will return true on any taxonomy page ( and possibly it will produce PHP warnings on all the rest ).
You need to create a conditional function that returns true only when you are working on an attribute page. The following should ... |
333,434 | <p>I am using WordPress multisite setup to set the following structure</p>
<pre><code>example.com
sub1.examples.com
example.net
</code></pre>
<p><em>Note that this is a single multisite setup, but it has two main domains and a subdomain.</em></p>
<p>I followed the steps <a href="https://wordpress.stackexchange.com/q... | [
{
"answer_id": 333437,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 2,
"selected": true,
"text": "<p>When you log in, WordPress sets a cookie in your browser to mark you as authenticated. The COOKIE_DOMAIN sets the sc... | 2019/04/04 | [
"https://wordpress.stackexchange.com/questions/333434",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | I am using WordPress multisite setup to set the following structure
```
example.com
sub1.examples.com
example.net
```
*Note that this is a single multisite setup, but it has two main domains and a subdomain.*
I followed the steps [described here](https://wordpress.stackexchange.com/questions/284325/multiple-domains... | When you log in, WordPress sets a cookie in your browser to mark you as authenticated. The COOKIE\_DOMAIN sets the scope of this:
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Scope_of_cookies>
i.e. the browser will only send the cookie back to sites that match its scope. i.e.
* if you log into example.... |
333,452 | <p>I have two different pages, with filters. Those two pages, have different layouts and styles.</p>
<p>I have three different filters for one page, where the output and style is the same.</p>
<p>For the “newsfilter” I need a different style. So I guess I need another loop?</p>
<p>How do I output two different loops... | [
{
"answer_id": 333437,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 2,
"selected": true,
"text": "<p>When you log in, WordPress sets a cookie in your browser to mark you as authenticated. The COOKIE_DOMAIN sets the sc... | 2019/04/04 | [
"https://wordpress.stackexchange.com/questions/333452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164436/"
] | I have two different pages, with filters. Those two pages, have different layouts and styles.
I have three different filters for one page, where the output and style is the same.
For the “newsfilter” I need a different style. So I guess I need another loop?
How do I output two different loops? My current functions.p... | When you log in, WordPress sets a cookie in your browser to mark you as authenticated. The COOKIE\_DOMAIN sets the scope of this:
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Scope_of_cookies>
i.e. the browser will only send the cookie back to sites that match its scope. i.e.
* if you log into example.... |
333,504 | <p>I have a custom taxonomy page, it also has a slider up top. The problem is the slider displays random posts from all taxonomies rather than the current taxonomy. Is there a way to filter the images in the slider so it would only use the current taxonomy? </p>
<pre><code><?php
global $taxonomy_location_url, $taxo... | [
{
"answer_id": 333437,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 2,
"selected": true,
"text": "<p>When you log in, WordPress sets a cookie in your browser to mark you as authenticated. The COOKIE_DOMAIN sets the sc... | 2019/04/04 | [
"https://wordpress.stackexchange.com/questions/333504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145461/"
] | I have a custom taxonomy page, it also has a slider up top. The problem is the slider displays random posts from all taxonomies rather than the current taxonomy. Is there a way to filter the images in the slider so it would only use the current taxonomy?
```
<?php
global $taxonomy_location_url, $taxonomy_profile_url;... | When you log in, WordPress sets a cookie in your browser to mark you as authenticated. The COOKIE\_DOMAIN sets the scope of this:
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Scope_of_cookies>
i.e. the browser will only send the cookie back to sites that match its scope. i.e.
* if you log into example.... |
333,523 | <p>Attempting to create a Welcome Modal for first time users on initial login to my Multisite network.
I'm using code from this tutorial <a href="https://wp-mix.com/wordpress-first-user-login/" rel="nofollow noreferrer">https://wp-mix.com/wordpress-first-user-login/</a>
I can see the User meta updating in the database,... | [
{
"answer_id": 333530,
"author": "Pixelsmith",
"author_id": 66368,
"author_profile": "https://wordpress.stackexchange.com/users/66368",
"pm_score": 1,
"selected": true,
"text": "<p>Sorry you're having trouble with the featured image. Some details that will help the community solve the qu... | 2019/04/04 | [
"https://wordpress.stackexchange.com/questions/333523",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62672/"
] | Attempting to create a Welcome Modal for first time users on initial login to my Multisite network.
I'm using code from this tutorial <https://wp-mix.com/wordpress-first-user-login/>
I can see the User meta updating in the database, but the modal code will not insert when wrapped in this function. Modal code works othe... | Sorry you're having trouble with the featured image. Some details that will help the community solve the question: What theme are you using?
Without knowing what theme you're using, one approach you might try is removing the featured image from the post/page, then click update. If the featured image is removed, you mi... |
333,554 | <p>We need to run WooCommerce flat rate shipping rate based on every X items in the cart, for example:</p>
<ul>
<li>1-5 Items: Delivery = £5</li>
<li>6-10 Items: Delivery = £10</li>
<li>11-15 Items: Delivery = £15 </li>
<li><em>and so on…</em></li>
</ul>
<p>It's essentially £1 per item, but it's in brackets of £5, so... | [
{
"answer_id": 334163,
"author": "LoicTheAztec",
"author_id": 79855,
"author_profile": "https://wordpress.stackexchange.com/users/79855",
"pm_score": 3,
"selected": true,
"text": "<p>For that, you need to use a hooked function in <code>woocommerce_package_rates</code> filter hook, target... | 2019/04/05 | [
"https://wordpress.stackexchange.com/questions/333554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69751/"
] | We need to run WooCommerce flat rate shipping rate based on every X items in the cart, for example:
* 1-5 Items: Delivery = £5
* 6-10 Items: Delivery = £10
* 11-15 Items: Delivery = £15
* *and so on…*
It's essentially £1 per item, but it's in brackets of £5, so 3 items would be £5, and 7 items would be £10, for examp... | For that, you need to use a hooked function in `woocommerce_package_rates` filter hook, targeting "Flat rate" shipping method.
In shipping settings for **flat rate** shipping method you will **set a cost of `5`**.
Each 5 items **step**, the shipping cost will be increased by 5:
• From 1 to 5 Items: Delivery = **`... |
333,563 | <p>I'm trying to filter pages in admin area by a custom field created with ACF.</p>
<p>I found a function here ( <a href="http://www.iamabdus.com/blog/wordpress/filter-custom-posts-by-custom-field/" rel="nofollow noreferrer">http://www.iamabdus.com/blog/wordpress/filter-custom-posts-by-custom-field/</a> ) and I adapte... | [
{
"answer_id": 333580,
"author": "Pawan Kumar",
"author_id": 164501,
"author_profile": "https://wordpress.stackexchange.com/users/164501",
"pm_score": 1,
"selected": false,
"text": "<p>Try to use this code and modify the custom post name and meta key of acf and it will work.</p>\n\n<pre>... | 2019/04/05 | [
"https://wordpress.stackexchange.com/questions/333563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/163360/"
] | I'm trying to filter pages in admin area by a custom field created with ACF.
I found a function here ( <http://www.iamabdus.com/blog/wordpress/filter-custom-posts-by-custom-field/> ) and I adapted that code to my need.
When I click on "pages" the options load correctly, but when I click on "Filter" even if the filter... | Try to use this code and modify the custom post name and meta key of acf and it will work.
```
add_action( 'restrict_manage_posts', 'wpse45436_admin_posts_filter_restrict_manage_posts' );
/**
* First create the dropdown
/** Create the filter dropdown */
function wpse45436_admin_posts_filter_restrict_manage_posts(){
... |
333,585 | <p>I'm building a Wordpress website at <a href="http://xscoder.com/wp-demo/test/" rel="nofollow noreferrer">http://xscoder.com/wp-demo/test/</a>
<br><br>
I am not able to make it responsive, although all CSS and JS scripts are successfully loaded, as you may see in the Inspector. I guess it's something related to slick... | [
{
"answer_id": 333588,
"author": "Javi Torre Sustaeta",
"author_id": 164384,
"author_profile": "https://wordpress.stackexchange.com/users/164384",
"pm_score": 1,
"selected": false,
"text": "<p>Add this into your head tags:</p>\n\n<pre><code><script src=\"jquery-3.3.1.min.js\"></... | 2019/04/05 | [
"https://wordpress.stackexchange.com/questions/333585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143531/"
] | I'm building a Wordpress website at <http://xscoder.com/wp-demo/test/>
I am not able to make it responsive, although all CSS and JS scripts are successfully loaded, as you may see in the Inspector. I guess it's something related to slicknav, although I'm not sure about it, here's the code of my main.js file to call sl... | Often times even if we have setup our media queries correctly, the site still isn't responsive to those queries.
You need to set a viewport in your header.php to fix this. More often than not I find that this affects macs instead of PCs. but it's still a good idea to add this no matter the case.
In your site `<head>`... |
333,617 | <p>I'm currently looking for a way to change / hide the default WordPress <code>admin-ajax.php</code> URL. I want to do this to remove the <code>admin</code> from it to prevent misunderstandings by my customers when I use the AJAX URL to read for example a file from my server. In this case, the URL has the admin prefix... | [
{
"answer_id": 333619,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>The googles got me to this place, which does it with a plugin. <a href=\"https://github.com/devgeniem/... | 2019/04/05 | [
"https://wordpress.stackexchange.com/questions/333617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/151233/"
] | I'm currently looking for a way to change / hide the default WordPress `admin-ajax.php` URL. I want to do this to remove the `admin` from it to prevent misunderstandings by my customers when I use the AJAX URL to read for example a file from my server. In this case, the URL has the admin prefix which is a bit confusing... | It's not as hard to solve as one might think... If only all plugins/themes respect best practices.
If they do, then all links to `admin-ajax.php` are generated with `admin_url` function. And this function has a hook inside, so we can modify the url it returns:
```
// This will change the url for admin-ajax.php to /aj... |
333,627 | <p>I currently use the following code below in my loop to display dates for groups of posts. Works great, was just wondering if it's possible to change the day from php code 'l'(Sunday-Saturday) to Today and Yesterday for the current posts.</p>
<p>I am guessing Wordpress doesn't have a built-in detection and a functio... | [
{
"answer_id": 333630,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 2,
"selected": false,
"text": "<p>It took me less than a minute of asking the googles (or bing, or duck) to find this answer:</p>\n\n<p>... | 2019/04/05 | [
"https://wordpress.stackexchange.com/questions/333627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145461/"
] | I currently use the following code below in my loop to display dates for groups of posts. Works great, was just wondering if it's possible to change the day from php code 'l'(Sunday-Saturday) to Today and Yesterday for the current posts.
I am guessing Wordpress doesn't have a built-in detection and a function will nee... | It took me less than a minute of asking the googles (or bing, or duck) to find this answer:
<https://stackoverflow.com/questions/3454258/php-date-yesterday-today>
The accepted answer has the code you want to use (or will give you a starting point).
(And this is not really a WordPress question...it's a PHP question.... |
333,644 | <p>I have a custom post type called X,</p>
<p>Post type X has some custom fields, one of these custom fields is <strong>date</strong>,</p>
<pre><code><input type="date" name="date_added" id="date_added" class="regular-text" value="<?php echo get_post_meta($post->ID,'date_added',true ); ?>">
</code></pr... | [
{
"answer_id": 333646,
"author": "Mulli",
"author_id": 114053,
"author_profile": "https://wordpress.stackexchange.com/users/114053",
"pm_score": -1,
"selected": false,
"text": "<p>Not sure its the complete answer, but try</p>\n\n<pre><code> date_default_timezone_set('Asia/Jerusale... | 2019/04/06 | [
"https://wordpress.stackexchange.com/questions/333644",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/160944/"
] | I have a custom post type called X,
Post type X has some custom fields, one of these custom fields is **date**,
```
<input type="date" name="date_added" id="date_added" class="regular-text" value="<?php echo get_post_meta($post->ID,'date_added',true ); ?>">
```
When I want to fill this field, WordPress gives me a c... | The calendar you are referring to is not provided by WordPress. You are using a "date" input field type, which is an HTML5 input specification. The calendar is from your browser based on that.
If your question is about timezone offset for the input itself (so what displays with the input), then you should note that th... |
333,689 | <p>I have a custom taxonomy called collection, with advanced custom fields in it.</p>
<p>I'm using wordpress API, so since I need to filter the API responses by ACF values, I have this filter in my theme <strong>functions.php</strong>:</p>
<pre><code> add_filter( 'rest_collection_query', function( $args ) {
... | [
{
"answer_id": 333646,
"author": "Mulli",
"author_id": 114053,
"author_profile": "https://wordpress.stackexchange.com/users/114053",
"pm_score": -1,
"selected": false,
"text": "<p>Not sure its the complete answer, but try</p>\n\n<pre><code> date_default_timezone_set('Asia/Jerusale... | 2019/04/06 | [
"https://wordpress.stackexchange.com/questions/333689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/157281/"
] | I have a custom taxonomy called collection, with advanced custom fields in it.
I'm using wordpress API, so since I need to filter the API responses by ACF values, I have this filter in my theme **functions.php**:
```
add_filter( 'rest_collection_query', function( $args ) {
$ignore = array('page', 'per_pa... | The calendar you are referring to is not provided by WordPress. You are using a "date" input field type, which is an HTML5 input specification. The calendar is from your browser based on that.
If your question is about timezone offset for the input itself (so what displays with the input), then you should note that th... |
333,709 | <p>I need to show sale price under normal price, not on the same line</p>
<p><a href="https://i.stack.imgur.com/vBouN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vBouN.png" alt="enter image description here"></a></p>
| [
{
"answer_id": 333711,
"author": "Karun",
"author_id": 63470,
"author_profile": "https://wordpress.stackexchange.com/users/63470",
"pm_score": 0,
"selected": false,
"text": "<p>If you know the folder structure, you can copy the template file in your custom theme folder and edit the file.... | 2019/04/07 | [
"https://wordpress.stackexchange.com/questions/333709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164621/"
] | I need to show sale price under normal price, not on the same line
[](https://i.stack.imgur.com/vBouN.png) | Why not just use CSS rather than altering the template for such a minor markup change that's really only serving a styling purpose anyway.
```
.electro-price > ins{
display: block;
float: none; /* <-- In case the theme styles have it floated */
}
```
You may need to use slightly different styling depending on... |
333,714 | <p>our site <a href="http://www.irish-pure.de" rel="nofollow noreferrer">www.irish-pure.de</a> has a slider. this header is currently deactivated for mobile via</p>
<pre><code>@media (max-width: 640px) {
.theme-slider-wrapper {
display: none;
}
.benefit-bar__container {
margin-bottom: 1rem;... | [
{
"answer_id": 333716,
"author": "tmdesigned",
"author_id": 28273,
"author_profile": "https://wordpress.stackexchange.com/users/28273",
"pm_score": 1,
"selected": false,
"text": "<p>This is one of those problems that seems like it should have a simple solution, but really doesn't. There ... | 2019/04/07 | [
"https://wordpress.stackexchange.com/questions/333714",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/162150/"
] | our site [www.irish-pure.de](http://www.irish-pure.de) has a slider. this header is currently deactivated for mobile via
```
@media (max-width: 640px) {
.theme-slider-wrapper {
display: none;
}
.benefit-bar__container {
margin-bottom: 1rem;
}
}
```
but when I check google pagespeed in... | This is one of those problems that seems like it should have a simple solution, but really doesn't. There are options, they're just not easy.
At least, from what I can see.
CSS is the best approach to detecting browser width IMO. In fact, you really can't detect browser width from PHP. You can with JavaScript but tha... |
333,739 | <p>I'm not sure if this is 'normal' but on my WP install the actual directory for 'category' throws a 404 error.</p>
<p>So, for example, if I had a category called 'apples' then every post or page associated with the 'apples' category has this URL string:</p>
<pre><code>my-site.com/category/apples/
</code></pre>
<p... | [
{
"answer_id": 333740,
"author": "Pat_Morita",
"author_id": 134335,
"author_profile": "https://wordpress.stackexchange.com/users/134335",
"pm_score": -1,
"selected": false,
"text": "<p>You can create template files for each level of the category tree. Also for the one you mentioned. If y... | 2019/04/08 | [
"https://wordpress.stackexchange.com/questions/333739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | I'm not sure if this is 'normal' but on my WP install the actual directory for 'category' throws a 404 error.
So, for example, if I had a category called 'apples' then every post or page associated with the 'apples' category has this URL string:
```
my-site.com/category/apples/
```
The above for me loads fine.
Ho... | Yes, it's normal behavior. WordPress uses a set of rewrite rules to process requests. Here are the rules that will match requests related to categories:
```
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.ph... |
333,752 | <p>I have around 1200 large images which I'd like to regenerate. I'm using the WP-CLI command <code>wp media regenerate</code>. After around 61 images are generated, the terminal shows the message <code>Killed</code>.</p>
<p><a href="https://i.stack.imgur.com/3fLrV.png" rel="noreferrer"><img src="https://i.stack.imgur... | [
{
"answer_id": 333740,
"author": "Pat_Morita",
"author_id": 134335,
"author_profile": "https://wordpress.stackexchange.com/users/134335",
"pm_score": -1,
"selected": false,
"text": "<p>You can create template files for each level of the category tree. Also for the one you mentioned. If y... | 2019/04/08 | [
"https://wordpress.stackexchange.com/questions/333752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37548/"
] | I have around 1200 large images which I'd like to regenerate. I'm using the WP-CLI command `wp media regenerate`. After around 61 images are generated, the terminal shows the message `Killed`.
[](https://i.stack.imgur.com/3fLrV.png)
Why is this happe... | Yes, it's normal behavior. WordPress uses a set of rewrite rules to process requests. Here are the rules that will match requests related to categories:
```
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.ph... |
333,786 | <p>I create a custom post type and wrote a shortcode to display the posts on the front end of my website, but the code only displays one (1) post, and the most recent one. See front-end page here -> <a href="https://www.800goldlaw.com/careers" rel="nofollow noreferrer">https://www.800goldlaw.com/careers</a>. The CPT is... | [
{
"answer_id": 333788,
"author": "mrben522",
"author_id": 84703,
"author_profile": "https://wordpress.stackexchange.com/users/84703",
"pm_score": 1,
"selected": false,
"text": "<p>Try adding <code>'posts_per_page' => -1,</code> to your default atts. This will make the query return al... | 2019/04/08 | [
"https://wordpress.stackexchange.com/questions/333786",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143224/"
] | I create a custom post type and wrote a shortcode to display the posts on the front end of my website, but the code only displays one (1) post, and the most recent one. See front-end page here -> <https://www.800goldlaw.com/careers>. The CPT is the "jobs board".
Here is my code. Any advice for cleaning this code up an... | Try adding `'posts_per_page' => -1,` to your default atts. This will make the query return all of the posts instead of limiting it. Also you're overriding `$out` each loop instead of adding to it. Change `$out = '<div class` to `$out .= '<div class` |
333,787 | <p>I want to query and SORT in WP_Query(). But whatever I do, it only prints posts with meta_key set up. But I want all the results and just sort them.</p>
<p>This is my query:</p>
<pre><code>$query = new WP_Query(array(
'post_type' => 'my_post_type',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta... | [
{
"answer_id": 333794,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 4,
"selected": true,
"text": "<p>If you want to sort the posts by the meta <code>post_views_count</code>, and still include posts that <em>d... | 2019/04/08 | [
"https://wordpress.stackexchange.com/questions/333787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/154046/"
] | I want to query and SORT in WP\_Query(). But whatever I do, it only prints posts with meta\_key set up. But I want all the results and just sort them.
This is my query:
```
$query = new WP_Query(array(
'post_type' => 'my_post_type',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'post_views_count',... | If you want to sort the posts by the meta `post_views_count`, and still include posts that *do not* have that meta, you can use [`meta_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) like so:
```php
'meta_query' => array(
'relation' => 'OR', // make sure it's OR
// Include... |
333,791 | <p>I created a custom post type with custom date, time and checkbox fields.
I'm having a problem with the date and time fields that do not register in WordPress Administration or in the database.
And also there is a problem with a custom checkbox field that gets me a value but if I check two values, only one value appe... | [
{
"answer_id": 333805,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 2,
"selected": false,
"text": "<p>You add metabox in the wrong way. You should use <code>add_meta_boxes</code> action hook. </p>\n\n<pre><code>pu... | 2019/04/08 | [
"https://wordpress.stackexchange.com/questions/333791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164692/"
] | I created a custom post type with custom date, time and checkbox fields.
I'm having a problem with the date and time fields that do not register in WordPress Administration or in the database.
And also there is a problem with a custom checkbox field that gets me a value but if I check two values, only one value appears... | A short overview of your code reveals some issues that seems to cause the problem:
Your function `save($post_id)` saves all fields added to `$fields` array.
This array if filled using function `add($id, $label, $type = 'text', $default='')`
**But the problematic fields (checkbox, date and time) are not added to f... |
333,808 | <p>I have a custom rewrite rule which rewrites <code>/wp-content/themes/my-theme/manifest.json</code> to <code>/index.php?manifest=true</code>. This generates some JSON code for progressive web app functionality, and generally works great.</p>
<p>On a multisite install, however, the manifest loads correctly, but still... | [
{
"answer_id": 340498,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": -1,
"selected": false,
"text": "<p>I think that's because <code>.json</code> is considered to be a \"static file\". Which means PHP isn't... | 2019/04/08 | [
"https://wordpress.stackexchange.com/questions/333808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24566/"
] | I have a custom rewrite rule which rewrites `/wp-content/themes/my-theme/manifest.json` to `/index.php?manifest=true`. This generates some JSON code for progressive web app functionality, and generally works great.
On a multisite install, however, the manifest loads correctly, but still sends a 404 header. I verified ... | Basically, you are doing one thing wrong, which is actually having a file named `manifest.json` inside `/wp-content/themes/your-theme`.
So, first, delete your file `/wp-content/themes/your-theme/manifest.json`.
Then, in your **functions.php** file you can have your rewrite rule as:
```
function fvpd_pwa_rewrite_rule... |
333,810 | <p>I'm trying to create a custom theme. I added theme compatibility with Woocommerce to my theme, and am trying to create a product loop. I want to filter my loop so it only displays post with the category "cap" I tried the following versions:</p>
<pre><code>$params = array('posts_per_page' => 5, 'post_type' => ... | [
{
"answer_id": 340498,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": -1,
"selected": false,
"text": "<p>I think that's because <code>.json</code> is considered to be a \"static file\". Which means PHP isn't... | 2019/04/08 | [
"https://wordpress.stackexchange.com/questions/333810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112604/"
] | I'm trying to create a custom theme. I added theme compatibility with Woocommerce to my theme, and am trying to create a product loop. I want to filter my loop so it only displays post with the category "cap" I tried the following versions:
```
$params = array('posts_per_page' => 5, 'post_type' => 'product', 'category... | Basically, you are doing one thing wrong, which is actually having a file named `manifest.json` inside `/wp-content/themes/your-theme`.
So, first, delete your file `/wp-content/themes/your-theme/manifest.json`.
Then, in your **functions.php** file you can have your rewrite rule as:
```
function fvpd_pwa_rewrite_rule... |
333,820 | <p>My client wants to turn off the email you receive when register.</p>
| [
{
"answer_id": 333829,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 1,
"selected": false,
"text": "<p>You can declare a new replacement <a href=\"https://developer.wordpress.org/reference/functions/wp_new_user_notific... | 2019/04/08 | [
"https://wordpress.stackexchange.com/questions/333820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/151185/"
] | My client wants to turn off the email you receive when register. | The function that generates the new user notification is `wp_new_user_notification()`. It is called by another (similarly named) function `wp_new_user_notifications()` which is triggered by the action hook `register_new_user` in the `register_new_user()` function.
If you follow that (or even if you don't), all you nee... |
333,850 | <p>I have created an autosuggest array that I want to store in a transient. My code looks like this:</p>
<pre><code><?php
// Get any existing copy of our transient data
$suggest = get_transient('suggest');
if ( false === ( $suggest = get_transient( 'suggest' ) ) ) {
// It wasn't there, so regenerate the dat... | [
{
"answer_id": 333864,
"author": "djboris",
"author_id": 152412,
"author_profile": "https://wordpress.stackexchange.com/users/152412",
"pm_score": 0,
"selected": false,
"text": "<p>There is an issue with your code. You are querying the posts, and looping through them without setting the ... | 2019/04/09 | [
"https://wordpress.stackexchange.com/questions/333850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164729/"
] | I have created an autosuggest array that I want to store in a transient. My code looks like this:
```
<?php
// Get any existing copy of our transient data
$suggest = get_transient('suggest');
if ( false === ( $suggest = get_transient( 'suggest' ) ) ) {
// It wasn't there, so regenerate the data and save the tr... | You are using `get_the_id()` [template tag](https://developer.wordpress.org/reference/functions/get_the_id/) without proper [**loop**](https://codex.wordpress.org/The_Loop).
Your code should be something like this
```
<?php
// Get any existing copy of our transient data
$suggest = get_transient('suggest');
if ( fals... |
333,851 | <p>Is it possible to get posts where menu_order is more than 0? I have tried this argument when I <code>get_posts()</code> but it doesn't have any effect at all:</p>
<pre><code>'meta_query' => array(
'key' => 'menu_order'
, 'value' => '0'
, 'compare' => '>'
)
</code></pre>
<p>Wh... | [
{
"answer_id": 333858,
"author": "Karun",
"author_id": 63470,
"author_profile": "https://wordpress.stackexchange.com/users/63470",
"pm_score": 0,
"selected": false,
"text": "<pre><code><?php\nfunction ignore_zero_menu_order( $where ){ \n global $wpdb;\n $where = $where . ' AND $w... | 2019/04/09 | [
"https://wordpress.stackexchange.com/questions/333851",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3216/"
] | Is it possible to get posts where menu\_order is more than 0? I have tried this argument when I `get_posts()` but it doesn't have any effect at all:
```
'meta_query' => array(
'key' => 'menu_order'
, 'value' => '0'
, 'compare' => '>'
)
```
What I'm after in the first place is to treat menu\_o... | Karun's answer made me look more into the `posts_where` filter to find a better solution to hook into the WP\_Query. After a bit more google searching I found [this page](https://macarthur.me/posts/using-the-posts-where-filter-in-wordpress) that did it in a better way.
Using that method I finally got it to work like t... |
333,863 | <p>I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, <code>get_users(...)</code> is only returning me 1 users though it should return 3. What am I doing wrong?</p>
<pre><code>var_dump($... | [
{
"answer_id": 333867,
"author": "Julian",
"author_id": 159818,
"author_profile": "https://wordpress.stackexchange.com/users/159818",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>include</code> key on <code>get_users</code> requires an array of IDs (numbers). You are giving it... | 2019/04/09 | [
"https://wordpress.stackexchange.com/questions/333863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164696/"
] | I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, `get_users(...)` is only returning me 1 users though it should return 3. What am I doing wrong?
```
var_dump($targetUsersIDs);
$targetU... | The `include` key on `get_users` requires an array of IDs (numbers). You are giving it an array of objects that have an ID property. If you look at your first var dump you will see this. WP is casting that to a number and returning the user with that number which is not what you want. |
333,868 | <p>I'm new to coding and know next to nothing. I've done a ton research on the web, and I foudn the following code to import an RSS feed and place it in my template. The problem is that while I get 10 different titles, 10 different dates, 10 different images, I get the same excerpt for each item. Can someone please hel... | [
{
"answer_id": 333871,
"author": "Amirition",
"author_id": 136480,
"author_profile": "https://wordpress.stackexchange.com/users/136480",
"pm_score": -1,
"selected": false,
"text": "<p>Since you're not using the default wordpress loop, you should write <code>$item</code> before the functi... | 2019/04/09 | [
"https://wordpress.stackexchange.com/questions/333868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164741/"
] | I'm new to coding and know next to nothing. I've done a ton research on the web, and I foudn the following code to import an RSS feed and place it in my template. The problem is that while I get 10 different titles, 10 different dates, 10 different images, I get the same excerpt for each item. Can someone please help m... | After Lots of Research and Testing, I got the answer.
the\_excerpt and other custom function are not working because there is no any content tag On feed xml format.
You just need to add this code instead of the\_excerpt
```
<p><?php echo esc_html( $item->get_description() ); ?></p>
```
More you can Visit <https://... |
333,885 | <p>Best regards, I want to change the name of the automatic image with the title of the post.</p>
<p>For example, I have the image called 1231231252345.jpg and Title of the article is "Article for a test", I want to change the name of the image in "article-for-a-test.jpg"</p>
| [
{
"answer_id": 333935,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 4,
"selected": true,
"text": "<p>I think what you're looking for is the filter: <a href=\"https://codex.wordpress.org/Plugin_API/Filter_Refe... | 2019/04/09 | [
"https://wordpress.stackexchange.com/questions/333885",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109732/"
] | Best regards, I want to change the name of the automatic image with the title of the post.
For example, I have the image called 1231231252345.jpg and Title of the article is "Article for a test", I want to change the name of the image in "article-for-a-test.jpg" | I think what you're looking for is the filter: [`wp_handle_upload_prefilter`](https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_handle_upload_prefilter).
From the Codex:
===============
>
> The single parameter, `$file`, represent a single element of the `$_FILES`
> array. The `wp_handle_upload_prefilter` ... |
333,910 | <p>I'm trying to hook on save_post to automatically assign a category (from a custom field) on post update and creation.
Basically if the date event is 10/10/2020 - I want to assign the event to category '2020'.</p>
<p>So far, it's partially working because I actually have to hit the 'update' button twice to make it w... | [
{
"answer_id": 333935,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 4,
"selected": true,
"text": "<p>I think what you're looking for is the filter: <a href=\"https://codex.wordpress.org/Plugin_API/Filter_Refe... | 2019/04/09 | [
"https://wordpress.stackexchange.com/questions/333910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/163978/"
] | I'm trying to hook on save\_post to automatically assign a category (from a custom field) on post update and creation.
Basically if the date event is 10/10/2020 - I want to assign the event to category '2020'.
So far, it's partially working because I actually have to hit the 'update' button twice to make it works. I'm... | I think what you're looking for is the filter: [`wp_handle_upload_prefilter`](https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_handle_upload_prefilter).
From the Codex:
===============
>
> The single parameter, `$file`, represent a single element of the `$_FILES`
> array. The `wp_handle_upload_prefilter` ... |
333,922 | <p>Bit of a strange one. One of my clients site is showing
<code><meta name='robots' content='noindex,follow' /></code> in the head. The Search Engine Visibility checkbox is unchecked. </p>
<p>I've tried activating 2019 theme and deactivating all plugins and still the tag shows. </p>
<p>Never encountered th... | [
{
"answer_id": 333935,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 4,
"selected": true,
"text": "<p>I think what you're looking for is the filter: <a href=\"https://codex.wordpress.org/Plugin_API/Filter_Refe... | 2019/04/09 | [
"https://wordpress.stackexchange.com/questions/333922",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29280/"
] | Bit of a strange one. One of my clients site is showing
`<meta name='robots' content='noindex,follow' />` in the head. The Search Engine Visibility checkbox is unchecked.
I've tried activating 2019 theme and deactivating all plugins and still the tag shows.
Never encountered this before. Any ideas? | I think what you're looking for is the filter: [`wp_handle_upload_prefilter`](https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_handle_upload_prefilter).
From the Codex:
===============
>
> The single parameter, `$file`, represent a single element of the `$_FILES`
> array. The `wp_handle_upload_prefilter` ... |
333,936 | <p>When we upgrade from 5.0.4 to 5.1.1 the site stops loading.</p>
<p>The error message is</p>
<pre><code>Fatal error: Uncaught Error: Call to a member function images_path() on null
/wp-content/themes/mytheme/header.php on line 49
</code></pre>
<p>Line 49 is
<code><?php $theme->images_path(); ?></code><... | [
{
"answer_id": 334239,
"author": "ocean90",
"author_id": 40969,
"author_profile": "https://wordpress.stackexchange.com/users/40969",
"pm_score": 5,
"selected": true,
"text": "<p>Since <a href=\"https://core.trac.wordpress.org/changeset/44524\" rel=\"noreferrer\">Changeset 44524</a>, whic... | 2019/04/09 | [
"https://wordpress.stackexchange.com/questions/333936",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84724/"
] | When we upgrade from 5.0.4 to 5.1.1 the site stops loading.
The error message is
```
Fatal error: Uncaught Error: Call to a member function images_path() on null
/wp-content/themes/mytheme/header.php on line 49
```
Line 49 is
`<?php $theme->images_path(); ?>`
above it in the same file is
`global $theme;`
$them... | Since [Changeset 44524](https://core.trac.wordpress.org/changeset/44524), which has landed in WordPress 5.1, the variable `$theme` is now a global variable set by WordPress which also gets unset [after the themes have been bootstrapped](https://core.trac.wordpress.org/browser/tags/5.1.1/src/wp-settings.php?marks=476-48... |
333,996 | <p>I'm looking for a way to make a URL redirection for affiliate links on my website.</p>
<p>Something like : <strong>site.com/go/keyword</strong></p>
<p>I know there is many plugins for doiing this, but i don't like plugin, and i love to learn new things.</p>
<p>I imagine 2 custom fields for each posts with : </p>
... | [
{
"answer_id": 334002,
"author": "Alexander Holsgrove",
"author_id": 48962,
"author_profile": "https://wordpress.stackexchange.com/users/48962",
"pm_score": 1,
"selected": false,
"text": "<p>You will need to use <a href=\"https://developer.wordpress.org/reference/functions/add_rewrite_ru... | 2019/04/10 | [
"https://wordpress.stackexchange.com/questions/333996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/139936/"
] | I'm looking for a way to make a URL redirection for affiliate links on my website.
Something like : **site.com/go/keyword**
I know there is many plugins for doiing this, but i don't like plugin, and i love to learn new things.
I imagine 2 custom fields for each posts with :
* keyword
* url to redirect to
But i ha... | Combining the answear of @alexander & of @dboris
here is the final solution :
1. Create a page to handle redirections
2. add to `functions.php`
```
add_action('init', function() {
$page_id = 2100;
$page_data = get_post($page_id);
if(!is_object($page_data)) {
return;
... |
333,999 | <p>I tried to include this code in my plug-in php files as well as in <code>functions.php</code>.
(In the end I would like it to be in the plug-in's php file but I'm not yet sure if possible, that would probably be the topic of another question.)</p>
<p>It is a very basic method for now, I'm just trying to get a respo... | [
{
"answer_id": 334002,
"author": "Alexander Holsgrove",
"author_id": 48962,
"author_profile": "https://wordpress.stackexchange.com/users/48962",
"pm_score": 1,
"selected": false,
"text": "<p>You will need to use <a href=\"https://developer.wordpress.org/reference/functions/add_rewrite_ru... | 2019/04/10 | [
"https://wordpress.stackexchange.com/questions/333999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164696/"
] | I tried to include this code in my plug-in php files as well as in `functions.php`.
(In the end I would like it to be in the plug-in's php file but I'm not yet sure if possible, that would probably be the topic of another question.)
It is a very basic method for now, I'm just trying to get a response with some content... | Combining the answear of @alexander & of @dboris
here is the final solution :
1. Create a page to handle redirections
2. add to `functions.php`
```
add_action('init', function() {
$page_id = 2100;
$page_data = get_post($page_id);
if(!is_object($page_data)) {
return;
... |
334,011 | <p>I have a HTML form which inserts data into a custom table. The code for inserting the data is in a PHP file .</p>
<p>My question is where do I place the PHP file in the WordPress filesystem? I have tried placing the file in the root, does not work. Placed it in the wp-content/themes/mytheme folder. Does not work.</... | [
{
"answer_id": 334014,
"author": "Qaisar Feroz",
"author_id": 161501,
"author_profile": "https://wordpress.stackexchange.com/users/161501",
"pm_score": 2,
"selected": false,
"text": "<p>You need to integrate your form and php form processor with Wordpress.\nOne method to do this in your ... | 2019/04/10 | [
"https://wordpress.stackexchange.com/questions/334011",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145942/"
] | I have a HTML form which inserts data into a custom table. The code for inserting the data is in a PHP file .
My question is where do I place the PHP file in the WordPress filesystem? I have tried placing the file in the root, does not work. Placed it in the wp-content/themes/mytheme folder. Does not work.
I get an e... | You need to integrate your form and php form processor with Wordpress.
One method to do this in your theme as follows.
Create a page template in your theme folder, as described **[here](https://developer.wordpress.org/themes/template-files-section/page-template-files/)**. And put your form markup in it.
Don't specif... |
334,030 | <p>in order to access jquery with a $, I am wrapping my Javascript file in </p>
<pre><code> (function($){
.....
})(jQuery);
</code></pre>
<p>This works fine, but I would like to add another javascript file which contains functions which I want to call from the original javascript file, but the functions are not av... | [
{
"answer_id": 334036,
"author": "user3135691",
"author_id": 59755,
"author_profile": "https://wordpress.stackexchange.com/users/59755",
"pm_score": 1,
"selected": false,
"text": "<p>You have to create a <strong>dependency</strong> with</p>\n\n<pre><code>wp_register_script($handle, $src,... | 2019/04/10 | [
"https://wordpress.stackexchange.com/questions/334030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/153752/"
] | in order to access jquery with a $, I am wrapping my Javascript file in
```
(function($){
.....
})(jQuery);
```
This works fine, but I would like to add another javascript file which contains functions which I want to call from the original javascript file, but the functions are not available.
How can I call t... | You have to create a **dependency** with
```
wp_register_script($handle, $src, $dependency, $version, true/false);
```
See WP codex: [wp\_register\_script](https://developer.wordpress.org/reference/functions/wp_register_script/)
and then make sure that the second file is loaded correctly and right after the initial ... |
334,037 | <p>I am having trouble displaying the author name and avatar on my single.php page. The posts load fine and all the correct information is available. However the avatar and name is no where to be found. I'm not sure what I'm doing wrong. Help is appreciated</p>
<pre><code><div class="row">
<div>
... | [
{
"answer_id": 334040,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 4,
"selected": true,
"text": "<p>To display the author's avatar within <a href=\"https://codex.wordpress.org/Function_Reference/the_author\" r... | 2019/04/10 | [
"https://wordpress.stackexchange.com/questions/334037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114269/"
] | I am having trouble displaying the author name and avatar on my single.php page. The posts load fine and all the correct information is available. However the avatar and name is no where to be found. I'm not sure what I'm doing wrong. Help is appreciated
```
<div class="row">
<div>
<h1 class="primary-color... | To display the author's avatar within [The Loop](https://codex.wordpress.org/Function_Reference/the_author) use [`get_avatar()`](https://codex.wordpress.org/Function_Reference/get_avatar) like that:
```
<?php print get_avatar(get_the_author_meta('ID'), '30', '', '', ['class' => 'foo-bar']); ?>
```
To display the au... |
334,046 | <p>For example, the current url is:</p>
<pre><code>https://example1.com/hello-world
</code></pre>
<p>I want to display this url under the showing article and also change the domain to:</p>
<pre><code>https://newdomain.com/hello-world
</code></pre>
<p>Is there any way to do this?</p>
<p>Thank you guys a lot!</p>
| [
{
"answer_id": 334040,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 4,
"selected": true,
"text": "<p>To display the author's avatar within <a href=\"https://codex.wordpress.org/Function_Reference/the_author\" r... | 2019/04/11 | [
"https://wordpress.stackexchange.com/questions/334046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67185/"
] | For example, the current url is:
```
https://example1.com/hello-world
```
I want to display this url under the showing article and also change the domain to:
```
https://newdomain.com/hello-world
```
Is there any way to do this?
Thank you guys a lot! | To display the author's avatar within [The Loop](https://codex.wordpress.org/Function_Reference/the_author) use [`get_avatar()`](https://codex.wordpress.org/Function_Reference/get_avatar) like that:
```
<?php print get_avatar(get_the_author_meta('ID'), '30', '', '', ['class' => 'foo-bar']); ?>
```
To display the au... |
334,094 | <p>This phenomenon occurred after updating Wordpress from 4.9.10 to 5.1.1.
I'm using the plugins TinyMCE Advanced, Classic Editor and Advanced Custom Fields PRO.
The wordpress installation has the roles admin and testrole.</p>
<p>I'm logged in as testrole and insert the custom html element
<code><p><new-page&... | [
{
"answer_id": 334040,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 4,
"selected": true,
"text": "<p>To display the author's avatar within <a href=\"https://codex.wordpress.org/Function_Reference/the_author\" r... | 2019/04/11 | [
"https://wordpress.stackexchange.com/questions/334094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/160336/"
] | This phenomenon occurred after updating Wordpress from 4.9.10 to 5.1.1.
I'm using the plugins TinyMCE Advanced, Classic Editor and Advanced Custom Fields PRO.
The wordpress installation has the roles admin and testrole.
I'm logged in as testrole and insert the custom html element
`<p><new-page></new-page></p>`
in a cu... | To display the author's avatar within [The Loop](https://codex.wordpress.org/Function_Reference/the_author) use [`get_avatar()`](https://codex.wordpress.org/Function_Reference/get_avatar) like that:
```
<?php print get_avatar(get_the_author_meta('ID'), '30', '', '', ['class' => 'foo-bar']); ?>
```
To display the au... |
334,112 | <p>Currently migrating from an older version of a JS library (sweetAlerts), to a newer version.</p>
<p>Both versions load, but I want to be able to use the updated library, but unsure how to reference it in JavaScript to use the newer library. Any input on how to do this would be appreciated.</p>
<pre><code>wp_enqueu... | [
{
"answer_id": 334040,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 4,
"selected": true,
"text": "<p>To display the author's avatar within <a href=\"https://codex.wordpress.org/Function_Reference/the_author\" r... | 2019/04/11 | [
"https://wordpress.stackexchange.com/questions/334112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104621/"
] | Currently migrating from an older version of a JS library (sweetAlerts), to a newer version.
Both versions load, but I want to be able to use the updated library, but unsure how to reference it in JavaScript to use the newer library. Any input on how to do this would be appreciated.
```
wp_enqueue_script( 'sweet-aler... | To display the author's avatar within [The Loop](https://codex.wordpress.org/Function_Reference/the_author) use [`get_avatar()`](https://codex.wordpress.org/Function_Reference/get_avatar) like that:
```
<?php print get_avatar(get_the_author_meta('ID'), '30', '', '', ['class' => 'foo-bar']); ?>
```
To display the au... |
334,114 | <p>I am currently at a dilemma where I have a design where there is a sidebar to the left taking up 50% of the width of the screen(this sidebar area is pulling data automatically based on the post, so title, date, author, etc) and content to the right Taking up 50% of width of the screen. </p>
<p>In the right content ... | [
{
"answer_id": 334119,
"author": "djboris",
"author_id": 152412,
"author_profile": "https://wordpress.stackexchange.com/users/152412",
"pm_score": 0,
"selected": false,
"text": "<p>What you want is not possible - to have two main contents and two Gutenberg instances for one post.</p>\n\n... | 2019/04/11 | [
"https://wordpress.stackexchange.com/questions/334114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/153404/"
] | I am currently at a dilemma where I have a design where there is a sidebar to the left taking up 50% of the width of the screen(this sidebar area is pulling data automatically based on the post, so title, date, author, etc) and content to the right Taking up 50% of width of the screen.
In the right content section is... | You could add some kind of separator (a separator block?) in Gutenberg, then filter `the_content()` to check for the separator to display each half, by setting a switch on the first half and detecting it for the second:
```
add_filter('the_content', 'content_splitter');
function content_splitter($content) {
$separ... |
334,115 | <p>As I can see from WooCommerce documentation, <code>WC_Order_Query</code> allows <strong>only one single order status</strong> to be passed as query parameter. Has anyone find some workaround to allow querying several order statuses in the same query?</p>
<p>Let's say I want to query orders with "completed" AND "ref... | [
{
"answer_id": 334158,
"author": "LoicTheAztec",
"author_id": 79855,
"author_profile": "https://wordpress.stackexchange.com/users/79855",
"pm_score": 4,
"selected": true,
"text": "<p>The documentation on <a href=\"https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order... | 2019/04/11 | [
"https://wordpress.stackexchange.com/questions/334115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91458/"
] | As I can see from WooCommerce documentation, `WC_Order_Query` allows **only one single order status** to be passed as query parameter. Has anyone find some workaround to allow querying several order statuses in the same query?
Let's say I want to query orders with "completed" AND "refunded" status.
How can this be d... | The documentation on [`wc_get_orders` and `WC_Order_Query`](https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query) is poor… Now regarding the order status in a `WC_Order_Query`, **you can pass an array of order statuses**:
```
// Display "completed" orders count
$statuses = ['completed'];
$o... |
334,123 | <p>I'm building a car listing site which needs custom schema added to each vehicle. </p>
<p>The schema doesn't comply with the standards sets, this is the example I've been sent: </p>
<p><a href="https://www.carandclassic.co.uk/feed/example.json" rel="nofollow noreferrer">https://www.carandclassic.co.uk/feed/example.... | [
{
"answer_id": 334158,
"author": "LoicTheAztec",
"author_id": 79855,
"author_profile": "https://wordpress.stackexchange.com/users/79855",
"pm_score": 4,
"selected": true,
"text": "<p>The documentation on <a href=\"https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order... | 2019/04/11 | [
"https://wordpress.stackexchange.com/questions/334123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128178/"
] | I'm building a car listing site which needs custom schema added to each vehicle.
The schema doesn't comply with the standards sets, this is the example I've been sent:
<https://www.carandclassic.co.uk/feed/example.json>
I would like to find a way to generate the fields and output to JSON. I've used a custom field ... | The documentation on [`wc_get_orders` and `WC_Order_Query`](https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query) is poor… Now regarding the order status in a `WC_Order_Query`, **you can pass an array of order statuses**:
```
// Display "completed" orders count
$statuses = ['completed'];
$o... |
334,178 | <p>I have a form that <code>$_POST</code>s an input value, and user's ID that saves the data to the database:</p>
<pre><code>// frontend form
<form id="form">
<input type="radio" name="location" id="name1" value="1">
<label for="name1">Label 1</label>
<input type="radio" name="... | [
{
"answer_id": 335067,
"author": "Ashish Yadav",
"author_id": 120394,
"author_profile": "https://wordpress.stackexchange.com/users/120394",
"pm_score": 0,
"selected": false,
"text": "<p>To send value using HTTP methods, the page must submit data. Only page refresh will not work. Your pag... | 2019/04/12 | [
"https://wordpress.stackexchange.com/questions/334178",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17411/"
] | I have a form that `$_POST`s an input value, and user's ID that saves the data to the database:
```
// frontend form
<form id="form">
<input type="radio" name="location" id="name1" value="1">
<label for="name1">Label 1</label>
<input type="radio" name="location" id="name2" value="2">
<label for="name... | **Saving data**
Based on [Heartbeat API](https://developer.wordpress.org/plugins/javascript/heartbeat-api/), you can add custom data to the sent heartbeat on `heartbeat-send` event in js. This would be used instead of the ajax function you have in your code example.
```
jQuery( document ).on( 'heartbeat-send', functi... |
334,225 | <p>I need to get product attributes from product in WooCommerce, type product Simple product, some product can be as dropdown, but much options as radio button. </p>
<p>How I can do this? How it possible? </p>
<p>With variations I have no problem, but for simple I can't get them.</p>
| [
{
"answer_id": 334227,
"author": "LoicTheAztec",
"author_id": 79855,
"author_profile": "https://wordpress.stackexchange.com/users/79855",
"pm_score": 3,
"selected": false,
"text": "<p>You will use the <code>WC_Product</code> method <code>get_attributes()</code> that returns an array like... | 2019/04/12 | [
"https://wordpress.stackexchange.com/questions/334225",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144341/"
] | I need to get product attributes from product in WooCommerce, type product Simple product, some product can be as dropdown, but much options as radio button.
How I can do this? How it possible?
With variations I have no problem, but for simple I can't get them. | Building on Loic's answer for an attribute of `pa_manufacturer`:
```
if ( get_post_type( $post ) === 'product' && ! is_a($product, 'WC_Product') ) {
$product = wc_get_product( get_the_id() ); // Get the WC_Product Object
}
$product_attributes = $product->get_attributes(); // Get the product attributes
// Output
... |
334,246 | <p>I tried to edit original <code>the_post_navigation</code>, inside the loop, so I could get the <code>rel="nofollow"</code> inside of it </p>
<pre><code>the_post_navigation( array(
'mid_size' => 3,
'next_text' => __( 'Next frase', 'textdomain' ),
) );
</code></pre>
<p>I also tried to use a cus... | [
{
"answer_id": 334227,
"author": "LoicTheAztec",
"author_id": 79855,
"author_profile": "https://wordpress.stackexchange.com/users/79855",
"pm_score": 3,
"selected": false,
"text": "<p>You will use the <code>WC_Product</code> method <code>get_attributes()</code> that returns an array like... | 2019/04/12 | [
"https://wordpress.stackexchange.com/questions/334246",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/162089/"
] | I tried to edit original `the_post_navigation`, inside the loop, so I could get the `rel="nofollow"` inside of it
```
the_post_navigation( array(
'mid_size' => 3,
'next_text' => __( 'Next frase', 'textdomain' ),
) );
```
I also tried to use a customized one, but that does not work.
```
<div class="... | Building on Loic's answer for an attribute of `pa_manufacturer`:
```
if ( get_post_type( $post ) === 'product' && ! is_a($product, 'WC_Product') ) {
$product = wc_get_product( get_the_id() ); // Get the WC_Product Object
}
$product_attributes = $product->get_attributes(); // Get the product attributes
// Output
... |
334,250 | <p>I am trying to create a function whicht has different shortcodes as output. I have the post-type => womos and the field => personenzahl. The field has the values 1 up to 7. Now I need a shortcode for every value.
This is my function for value => '1':</p>
<pre><code>function modell_nach_personenzahl() {
$args =... | [
{
"answer_id": 334227,
"author": "LoicTheAztec",
"author_id": 79855,
"author_profile": "https://wordpress.stackexchange.com/users/79855",
"pm_score": 3,
"selected": false,
"text": "<p>You will use the <code>WC_Product</code> method <code>get_attributes()</code> that returns an array like... | 2019/04/12 | [
"https://wordpress.stackexchange.com/questions/334250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164927/"
] | I am trying to create a function whicht has different shortcodes as output. I have the post-type => womos and the field => personenzahl. The field has the values 1 up to 7. Now I need a shortcode for every value.
This is my function for value => '1':
```
function modell_nach_personenzahl() {
$args = array(
... | Building on Loic's answer for an attribute of `pa_manufacturer`:
```
if ( get_post_type( $post ) === 'product' && ! is_a($product, 'WC_Product') ) {
$product = wc_get_product( get_the_id() ); // Get the WC_Product Object
}
$product_attributes = $product->get_attributes(); // Get the product attributes
// Output
... |
334,261 | <p>Here is example of code I have seen inserted in two different posts: </p>
<pre><code><noindex><script id="wpinfo-pst1" type="text/javascript" rel="nofollow">eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[func... | [
{
"answer_id": 334270,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 0,
"selected": false,
"text": "<p>I'm sorry to see your site has malicious code in it. Unfortunately, <a href=\"https://wordpress.stackexcha... | 2019/04/12 | [
"https://wordpress.stackexchange.com/questions/334261",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2550/"
] | Here is example of code I have seen inserted in two different posts:
```
<noindex><script id="wpinfo-pst1" type="text/javascript" rel="nofollow">eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=fu... | As I was using MariaDB, the following update did the fix:
```
update wp_posts set post_content = REGEXP_REPLACE(post_content,'(*CRLF)<noindex>.*</noindex> ','')
```
See <https://dba.stackexchange.com/questions/234774/mariadb-multiline-regex/234778#234778> |
334,302 | <p>I am very new on WordPress so my mistake should not be be too complicated. I did something to my site that the navigation menu items on home (landing) page hidden in the navigation menu <a href="http://fullcircletherapy.com/home" rel="nofollow noreferrer">here</a>. </p>
<p>If you hover over where menu items shou... | [
{
"answer_id": 334305,
"author": "Shihab",
"author_id": 113702,
"author_profile": "https://wordpress.stackexchange.com/users/113702",
"pm_score": 1,
"selected": false,
"text": "<p>If you inspect the element, you'll see that header has a different background color than other pages which i... | 2019/04/13 | [
"https://wordpress.stackexchange.com/questions/334302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165028/"
] | I am very new on WordPress so my mistake should not be be too complicated. I did something to my site that the navigation menu items on home (landing) page hidden in the navigation menu [here](http://fullcircletherapy.com/home).
If you hover over where menu items should be they individually appear. The nav menu items... | If you inspect the element, you'll see that header has a different background color than other pages which is transparent. Your nav elements color is also white and that is why you can't see the menus on home page but actually the menu is there. Just change the header background color to #000 as you used for other page... |
334,317 | <p>I have a post type that is essentially a photography zine. I want each post to display in the archive page as an "issue" with a number associated, from oldest to newest. The first issue would be "issue 1" while the tenth issue would be "issue 10". I need this display both on the archive page and also on the post pag... | [
{
"answer_id": 334349,
"author": "Qaisar Feroz",
"author_id": 161501,
"author_profile": "https://wordpress.stackexchange.com/users/161501",
"pm_score": 1,
"selected": true,
"text": "<p>You can do it like this on single post page following <strong><a href=\"https://wordpress.stackexchange... | 2019/04/14 | [
"https://wordpress.stackexchange.com/questions/334317",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/103174/"
] | I have a post type that is essentially a photography zine. I want each post to display in the archive page as an "issue" with a number associated, from oldest to newest. The first issue would be "issue 1" while the tenth issue would be "issue 10". I need this display both on the archive page and also on the post page i... | You can do it like this on single post page following **[this answer](https://wordpress.stackexchange.com/a/35543/161501)**. The code may need some tweaking to meet your exact requirements.
Put this in `functions.php` of your theme
>
>
> ```
> class MY_Post_Numbers {
>
> private $count = 0;
> private $posts ... |
334,341 | <p>I've been using VVV on a Win 10 Pro machine for local dev. And it works great. </p>
<p>But I want to try things like wpgraphql via docker. </p>
<p>I've read about Docker Desktop for Windows vs. Docker Toolbox. We would prefer not to use the legacy solution ( Docker Tookbox ). </p>
<p>Is it possible to use Docke... | [
{
"answer_id": 334349,
"author": "Qaisar Feroz",
"author_id": 161501,
"author_profile": "https://wordpress.stackexchange.com/users/161501",
"pm_score": 1,
"selected": true,
"text": "<p>You can do it like this on single post page following <strong><a href=\"https://wordpress.stackexchange... | 2019/04/14 | [
"https://wordpress.stackexchange.com/questions/334341",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16575/"
] | I've been using VVV on a Win 10 Pro machine for local dev. And it works great.
But I want to try things like wpgraphql via docker.
I've read about Docker Desktop for Windows vs. Docker Toolbox. We would prefer not to use the legacy solution ( Docker Tookbox ).
Is it possible to use Docker Desktop for Windows on t... | You can do it like this on single post page following **[this answer](https://wordpress.stackexchange.com/a/35543/161501)**. The code may need some tweaking to meet your exact requirements.
Put this in `functions.php` of your theme
>
>
> ```
> class MY_Post_Numbers {
>
> private $count = 0;
> private $posts ... |
334,356 | <p>I've been trying to grasp AJAX for the past 12 hours and i'm slowly losing it. How can I simply pass two basic input dates via form or any other means, <em>not</em> refresh the page, and have it execute the PHP function which contains a JS script? </p>
<p>Before I even pass the values to the script I just wanna ech... | [
{
"answer_id": 334349,
"author": "Qaisar Feroz",
"author_id": 161501,
"author_profile": "https://wordpress.stackexchange.com/users/161501",
"pm_score": 1,
"selected": true,
"text": "<p>You can do it like this on single post page following <strong><a href=\"https://wordpress.stackexchange... | 2019/04/14 | [
"https://wordpress.stackexchange.com/questions/334356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165063/"
] | I've been trying to grasp AJAX for the past 12 hours and i'm slowly losing it. How can I simply pass two basic input dates via form or any other means, *not* refresh the page, and have it execute the PHP function which contains a JS script?
Before I even pass the values to the script I just wanna echo the array of da... | You can do it like this on single post page following **[this answer](https://wordpress.stackexchange.com/a/35543/161501)**. The code may need some tweaking to meet your exact requirements.
Put this in `functions.php` of your theme
>
>
> ```
> class MY_Post_Numbers {
>
> private $count = 0;
> private $posts ... |
334,397 | <p>In <a href="https://mathiasbynens.github.io/rel-noopener/" rel="nofollow noreferrer">this article</a> I read, that using <code><a href="" target="blank"></code> is related to some security issues. They recommend <code>rel=noopener</code>.</p>
<p>How do I implement this in my WP-Installation? Which file is the... | [
{
"answer_id": 334406,
"author": "Kim Vinberg",
"author_id": 96605,
"author_profile": "https://wordpress.stackexchange.com/users/96605",
"pm_score": 0,
"selected": false,
"text": "<p>\"Wich file is the relevant one\" = All files that allow user generated content to be viewed.</p>\n\n<p>Y... | 2019/04/15 | [
"https://wordpress.stackexchange.com/questions/334397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/160781/"
] | In [this article](https://mathiasbynens.github.io/rel-noopener/) I read, that using `<a href="" target="blank">` is related to some security issues. They recommend `rel=noopener`.
How do I implement this in my WP-Installation? Which file is the relevant one? Thank you. | Since WordPress 5.1 (see [#43187](https://core.trac.wordpress.org/ticket/43187)) it ships with the [`wp_targeted_link_rel()`](https://developer.wordpress.org/reference/functions/wp_targeted_link_rel/) function, that adds `noreferrer` and `noopener` relation values to all *anchor* elements that have a `target`.
This fu... |
334,421 | <p>Ok I'm struggling here - I feel this should be straightforward but I'm just not able to get it to work.</p>
<p>I need to remove a filter added by Woocommerce Subscriptions. The filter is part of the WC_Subscriptions_Switcher class found in class-wc-subscriptions-switcher.php and is added as below</p>
<pre><code>cl... | [
{
"answer_id": 334423,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 4,
"selected": true,
"text": "<p>You did not write where you put the filter removal code, but I suspect you tried to delete it before it was adde... | 2019/04/15 | [
"https://wordpress.stackexchange.com/questions/334421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/153411/"
] | Ok I'm struggling here - I feel this should be straightforward but I'm just not able to get it to work.
I need to remove a filter added by Woocommerce Subscriptions. The filter is part of the WC\_Subscriptions\_Switcher class found in class-wc-subscriptions-switcher.php and is added as below
```
class WC_Subscription... | You did not write where you put the filter removal code, but I suspect you tried to delete it before it was added. Another important point, you have not given the **priority** parameter in `remove_filter()`.
Quote from the [documentation](https://codex.wordpress.org/Function_Reference/remove_filter):
>
> *remove\_fi... |
334,448 | <p>I'm currently using Zeen theme and a couple of other plugins. I've checked all the settings of the plugins and I've disabled all the voices about Google Font.</p>
<p>Now, my theme loads a font via CSS but, checking my <a href="https://gtmetrix.com/reports/thegroovecartel.com/lm1FYlh2" rel="nofollow noreferrer">GTMe... | [
{
"answer_id": 334423,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 4,
"selected": true,
"text": "<p>You did not write where you put the filter removal code, but I suspect you tried to delete it before it was adde... | 2019/04/15 | [
"https://wordpress.stackexchange.com/questions/334448",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/161294/"
] | I'm currently using Zeen theme and a couple of other plugins. I've checked all the settings of the plugins and I've disabled all the voices about Google Font.
Now, my theme loads a font via CSS but, checking my [GTMetrix](https://gtmetrix.com/reports/thegroovecartel.com/lm1FYlh2) the site load more than 10 .woff fonts... | You did not write where you put the filter removal code, but I suspect you tried to delete it before it was added. Another important point, you have not given the **priority** parameter in `remove_filter()`.
Quote from the [documentation](https://codex.wordpress.org/Function_Reference/remove_filter):
>
> *remove\_fi... |
334,459 | <p>I need to save advanced custom fields data before calling another function on the post. One way I thought of doing this is to add another button (near the fields) to save the post. Is this possible? thanks </p>
| [
{
"answer_id": 334423,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 4,
"selected": true,
"text": "<p>You did not write where you put the filter removal code, but I suspect you tried to delete it before it was adde... | 2019/04/15 | [
"https://wordpress.stackexchange.com/questions/334459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165135/"
] | I need to save advanced custom fields data before calling another function on the post. One way I thought of doing this is to add another button (near the fields) to save the post. Is this possible? thanks | You did not write where you put the filter removal code, but I suspect you tried to delete it before it was added. Another important point, you have not given the **priority** parameter in `remove_filter()`.
Quote from the [documentation](https://codex.wordpress.org/Function_Reference/remove_filter):
>
> *remove\_fi... |
334,503 | <p>I have this:</p>
<pre><code> global $wpdb;
$wpdbp = $wpdb->prepare('SELECT EXISTS ([some query] WHERE user_id =%d);',$target_user_id);
$result = $wpdb->get_results($wpdbp);
</code></pre>
<p>I want to know if the query result is 1 or 0.
But a var_dump() of $result give something like:</p>
<pre><co... | [
{
"answer_id": 334504,
"author": "Rup",
"author_id": 3276,
"author_profile": "https://wordpress.stackexchange.com/users/3276",
"pm_score": 3,
"selected": true,
"text": "<p>This answer explains what the OP saw with column names and how to work with that, but the real answer is to use <a h... | 2019/04/16 | [
"https://wordpress.stackexchange.com/questions/334503",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/164696/"
] | I have this:
```
global $wpdb;
$wpdbp = $wpdb->prepare('SELECT EXISTS ([some query] WHERE user_id =%d);',$target_user_id);
$result = $wpdb->get_results($wpdbp);
```
I want to know if the query result is 1 or 0.
But a var\_dump() of $result give something like:
```
array (size=1)
0 =>
object(stdCl... | This answer explains what the OP saw with column names and how to work with that, but the real answer is to use [get\_var()](https://developer.wordpress.org/reference/classes/wpdb/get_var/) as in [Howdy\_McGee's answer](https://wordpress.stackexchange.com/a/334505).
---
The string you're seeing is the column name tha... |
334,514 | <p>I am tying to use the standard WordPress search, but when I attempted to search I am taking to an index instead of the search results.
The search url seems correct: <a href="https://example.com/blog/?s=admissions" rel="nofollow noreferrer">https://example.com/blog/?s=admissions</a></p>
<h2>Search form</h2>
<pre><c... | [
{
"answer_id": 334530,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": -1,
"selected": false,
"text": "<p>If your theme is using the standard searching process, then you need to create a Child Theme and then... | 2019/04/16 | [
"https://wordpress.stackexchange.com/questions/334514",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165186/"
] | I am tying to use the standard WordPress search, but when I attempted to search I am taking to an index instead of the search results.
The search url seems correct: <https://example.com/blog/?s=admissions>
Search form
-----------
```
<form role="search" method="get" class="search-form" action="https://example.com/blo... | The problem was due to htaccess file that was in the root directory.
```
**`.htaccess`**
DirectoryIndex start.php
```
This was causing all of the index.php files to be changed to start.php. This filr did not exist in my wordpress directory. When I renamed the index.php to start.php in the wordpress installed su... |
334,558 | <p>Does anyone know how to display the SKU for each Single product title, underneath the Group product? I want to display the SKU to be obvious,as a second line,right below each product of the group.</p>
<p><a href="https://i.stack.imgur.com/4rqR9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4rqR... | [
{
"answer_id": 334562,
"author": "Karan Naimish Trivedi",
"author_id": 164966,
"author_profile": "https://wordpress.stackexchange.com/users/164966",
"pm_score": 1,
"selected": false,
"text": "<p>Try with the CODE below:</p>\n\n<pre><code>global $woocommerce , $product;\n$sku = $product-&... | 2019/04/17 | [
"https://wordpress.stackexchange.com/questions/334558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165128/"
] | Does anyone know how to display the SKU for each Single product title, underneath the Group product? I want to display the SKU to be obvious,as a second line,right below each product of the group.
[](https://i.stack.imgur.com/4rqR9.png)
[![enter imag... | Try with the CODE below:
```
global $woocommerce , $product;
$sku = $product->get_sku();
echo $sku;
``` |
334,559 | <p>I like Gutenberg a lot, however, the tips at the beginning of each page load
drives me mad. I would like to disable the nagging tips forever and ever via code.</p>
<p>Please don't post "Disable Gutenberg" plugin, I've already seen that. I want to do it via a couple of lines of code in my theme.</p>
<p>There must b... | [
{
"answer_id": 334561,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"https://i.stack.imgur.com/T91C1.png\" rel=\"noreferrer\"><img src=\"https://i.stack.imgur.com/T91C1.pn... | 2019/04/17 | [
"https://wordpress.stackexchange.com/questions/334559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59755/"
] | I like Gutenberg a lot, however, the tips at the beginning of each page load
drives me mad. I would like to disable the nagging tips forever and ever via code.
Please don't post "Disable Gutenberg" plugin, I've already seen that. I want to do it via a couple of lines of code in my theme.
There must be a hook, but I c... | [](https://i.stack.imgur.com/T91C1.png)
Update #1:
----------
After asking from @leymannx I checked how these settings are stored.
It turned out that settings are not permanent, they are saved in the browser as `localStorage`.
```
key: WP_DATA_USER... |
334,573 | <p>My website has footer credit which is really hard for me to hide or remove or replace please help me , I'm using painting theme from <strong>themeforest</strong>.</p>
<p>I even tried this also:</p>
<pre><code>.site-info{
display:none;
}
</code></pre>
| [
{
"answer_id": 334574,
"author": "Mohsin Ghouri",
"author_id": 159253,
"author_profile": "https://wordpress.stackexchange.com/users/159253",
"pm_score": -1,
"selected": false,
"text": "<p>Please use the below code to remove the footer copyright information.</p>\n\n<pre><code>.copyright p... | 2019/04/17 | [
"https://wordpress.stackexchange.com/questions/334573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165245/"
] | My website has footer credit which is really hard for me to hide or remove or replace please help me , I'm using painting theme from **themeforest**.
I even tried this also:
```
.site-info{
display:none;
}
``` | It's going to be hard to answer this without being able to see the theme admin. Check to see if there are any theme customisation options in your admin. Some themes may come with their own control panel which lets you toggle settings or alter footer content, like the copyright.
The theme may also have a hook to let yo... |
334,595 | <h1>What I'm doing</h1>
<p>I am translating a <strong>child theme</strong> and followed the instructions on <a href="https://developer.wordpress.org/themes/advanced-topics/child-themes/#internationalization" rel="nofollow noreferrer">https://developer.wordpress.org/themes/advanced-topics/child-themes/#internationaliza... | [
{
"answer_id": 334626,
"author": "Tim",
"author_id": 48306,
"author_profile": "https://wordpress.stackexchange.com/users/48306",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>Does the child theme's text domain have to be the same as the parent\n theme's text domain?</p>\... | 2019/04/17 | [
"https://wordpress.stackexchange.com/questions/334595",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165265/"
] | What I'm doing
==============
I am translating a **child theme** and followed the instructions on <https://developer.wordpress.org/themes/advanced-topics/child-themes/#internationalization>.
What I did so far
=================
### Step 0
All the text strings in my php files follow the structure of
```php
_e('thi... | **Found a solution that works for me:**
```
add_action( 'after_setup_theme', 'avia_lang_setup' );
function avia_lang_setup() {
$lang = apply_filters('parent-theme-slug', get_template_directory() . '/lang');
load_theme_textdomain('avia_framework', $lang);
load_child_theme_textdomain( 'child-theme-text-doma... |
334,641 | <p>I'm trying to add a rewrite rule that will point to a file inside a plugin. This can be added in the plugin, theme or .htaccess file.</p>
<p>My current code from inside the theme's function.php looks like:</p>
<pre><code>// Add Custom Rewrite Rules
function custom_rewrite_basic() {
flush_rewrite_rules();
add_r... | [
{
"answer_id": 334654,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 4,
"selected": true,
"text": "<p><em>(Revised answer)</em></p>\n\n<ol>\n<li><p><em>Don't call <code>flush_rewrite_rules()</code> on <code>in... | 2019/04/17 | [
"https://wordpress.stackexchange.com/questions/334641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105985/"
] | I'm trying to add a rewrite rule that will point to a file inside a plugin. This can be added in the plugin, theme or .htaccess file.
My current code from inside the theme's function.php looks like:
```
// Add Custom Rewrite Rules
function custom_rewrite_basic() {
flush_rewrite_rules();
add_rewrite_rule('^leaf/([... | *(Revised answer)*
1. *Don't call `flush_rewrite_rules()` on `init`.* Instead, if you want to do it programmatically, call the function from your plugin or theme activation function. If you're not doing it programmatically, you could simply visit the Permalink Settings page (Settings → Permalinks on the WordPress back... |
334,643 | <p>In wordpress, right now only on my main blog page, I managed to sort all posts with:</p>
<pre><code><?php if ( is_active_sidebar( 'blog-category' ) ) : ?>
<?php dynamic_sidebar( 'blog-category' ); ?>
<?php endif; ?>
</div>
<d... | [
{
"answer_id": 334653,
"author": "Matt Cromwell",
"author_id": 48338,
"author_profile": "https://wordpress.stackexchange.com/users/48338",
"pm_score": -1,
"selected": false,
"text": "<p>You most likely updated your index.php right? In the case of category pages you can use category.php (... | 2019/04/17 | [
"https://wordpress.stackexchange.com/questions/334643",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165315/"
] | In wordpress, right now only on my main blog page, I managed to sort all posts with:
```
<?php if ( is_active_sidebar( 'blog-category' ) ) : ?>
<?php dynamic_sidebar( 'blog-category' ); ?>
<?php endif; ?>
</div>
<div class="blog_list_content">
<?php
... | First of all, you should not use custom query just to change the order of posts. This may cause problems with pagination and definitely is not optimal.
So first things first. Remove that part of your code:
```
global $wp_query;
$args = array(
'meta_key' => 'publish_date',
'ord... |
334,684 | <p>I have been struggling with this for hours now, any help appreciated. I am using Underscores theme with one sidebar (sidebar-1, on the left) and Custom Sidebars plugin so that I can have different side content on each page. The problem is when I add a new sidebar (sidebar-2) which I want to appear just above the foo... | [
{
"answer_id": 334653,
"author": "Matt Cromwell",
"author_id": 48338,
"author_profile": "https://wordpress.stackexchange.com/users/48338",
"pm_score": -1,
"selected": false,
"text": "<p>You most likely updated your index.php right? In the case of category pages you can use category.php (... | 2019/04/18 | [
"https://wordpress.stackexchange.com/questions/334684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165342/"
] | I have been struggling with this for hours now, any help appreciated. I am using Underscores theme with one sidebar (sidebar-1, on the left) and Custom Sidebars plugin so that I can have different side content on each page. The problem is when I add a new sidebar (sidebar-2) which I want to appear just above the footer... | First of all, you should not use custom query just to change the order of posts. This may cause problems with pagination and definitely is not optimal.
So first things first. Remove that part of your code:
```
global $wp_query;
$args = array(
'meta_key' => 'publish_date',
'ord... |
334,686 | <p><strong>I work at a webdev company where we are experiencing the following problems:</strong></p>
<ul>
<li>The plugin not functioning properly with other plugins that are already installed.</li>
<li>Things that don't work the way we expected, this usually happens because we cannot spend too much time investigating ... | [
{
"answer_id": 334653,
"author": "Matt Cromwell",
"author_id": 48338,
"author_profile": "https://wordpress.stackexchange.com/users/48338",
"pm_score": -1,
"selected": false,
"text": "<p>You most likely updated your index.php right? In the case of category pages you can use category.php (... | 2019/04/18 | [
"https://wordpress.stackexchange.com/questions/334686",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106380/"
] | **I work at a webdev company where we are experiencing the following problems:**
* The plugin not functioning properly with other plugins that are already installed.
* Things that don't work the way we expected, this usually happens because we cannot spend too much time investigating what a plugin actually does.
* Bug... | First of all, you should not use custom query just to change the order of posts. This may cause problems with pagination and definitely is not optimal.
So first things first. Remove that part of your code:
```
global $wp_query;
$args = array(
'meta_key' => 'publish_date',
'ord... |
334,710 | <p>I'm trying to get the category ID so I can call a loop query on only that category ID. However the following code returns null. Any ideas why? In the admin bar it shows edit category with an ID of 3, however I need this ID to be generated dynamically. </p>
<pre><code>$categories = get_the_category();
$category_id =... | [
{
"answer_id": 334712,
"author": "m33bo",
"author_id": 19220,
"author_profile": "https://wordpress.stackexchange.com/users/19220",
"pm_score": 0,
"selected": false,
"text": "<p>I used this to get the category ID.</p>\n\n<pre><code>$category = get_category( get_query_var( 'cat' ) );\n$cat... | 2019/04/18 | [
"https://wordpress.stackexchange.com/questions/334710",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19220/"
] | I'm trying to get the category ID so I can call a loop query on only that category ID. However the following code returns null. Any ideas why? In the admin bar it shows edit category with an ID of 3, however I need this ID to be generated dynamically.
```
$categories = get_the_category();
$category_id = $categories[0... | [**get\_the\_category**](https://developer.wordpress.org/reference/functions/get_the_category/) retrieve array of post categories.
This tag may be used outside the loop by passing a `post id` as the parameter.
The syntax is
```
$categories = get_the_category( $post_id ); // Outside the loop
// OR
$categories = ... |
334,724 | <p>I would like to display the posts when I click on an item with the dropdown select</p>
<p>Currently, my select is OK, all my terms are displayed and all posts too.</p>
<p>I just want to know of it's possible to filter</p>
<p>This is my dropdown select : </p>
<pre><code><select name="soins-taxonomy">
&l... | [
{
"answer_id": 334712,
"author": "m33bo",
"author_id": 19220,
"author_profile": "https://wordpress.stackexchange.com/users/19220",
"pm_score": 0,
"selected": false,
"text": "<p>I used this to get the category ID.</p>\n\n<pre><code>$category = get_category( get_query_var( 'cat' ) );\n$cat... | 2019/04/18 | [
"https://wordpress.stackexchange.com/questions/334724",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/162471/"
] | I would like to display the posts when I click on an item with the dropdown select
Currently, my select is OK, all my terms are displayed and all posts too.
I just want to know of it's possible to filter
This is my dropdown select :
```
<select name="soins-taxonomy">
<option value="all">Tout afficher</option>
... | [**get\_the\_category**](https://developer.wordpress.org/reference/functions/get_the_category/) retrieve array of post categories.
This tag may be used outside the loop by passing a `post id` as the parameter.
The syntax is
```
$categories = get_the_category( $post_id ); // Outside the loop
// OR
$categories = ... |
334,799 | <p>I am having some troubles with my wordpress walker code. I know it's possible to add a custom css class manually via the admin menu section. But what i am trying to achieve is to get this done automatically whenever a submenu page is added by my client. </p>
<p>The first step i took was to replace the ul li naviga... | [
{
"answer_id": 334729,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 2,
"selected": true,
"text": "<p>The easiest way to do this is to upload them using FTP. You can use a free program like <a href=\"https:... | 2019/04/19 | [
"https://wordpress.stackexchange.com/questions/334799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165420/"
] | I am having some troubles with my wordpress walker code. I know it's possible to add a custom css class manually via the admin menu section. But what i am trying to achieve is to get this done automatically whenever a submenu page is added by my client.
The first step i took was to replace the ul li navigation and ch... | The easiest way to do this is to upload them using FTP. You can use a free program like [Filezilla](https://filezilla-project.org/download.php?type=client) to upload your files to your server.
You will need to know the host name (usually just your domain), user and password. If you don't know this info your hosting co... |
334,801 | <p>how to add fa fa icons customize menu using wp_nav_menu function?</p>
<pre><code>wp_nav_menu( array(
'theme_location' => 'primary',
'menu_id' => 'footer-menu',
'menu_class' => 'quick-link',
));
</code></pre>
| [
{
"answer_id": 334729,
"author": "RiddleMeThis",
"author_id": 86845,
"author_profile": "https://wordpress.stackexchange.com/users/86845",
"pm_score": 2,
"selected": true,
"text": "<p>The easiest way to do this is to upload them using FTP. You can use a free program like <a href=\"https:... | 2019/04/19 | [
"https://wordpress.stackexchange.com/questions/334801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152422/"
] | how to add fa fa icons customize menu using wp\_nav\_menu function?
```
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_id' => 'footer-menu',
'menu_class' => 'quick-link',
));
``` | The easiest way to do this is to upload them using FTP. You can use a free program like [Filezilla](https://filezilla-project.org/download.php?type=client) to upload your files to your server.
You will need to know the host name (usually just your domain), user and password. If you don't know this info your hosting co... |
334,890 | <p>I am using a automatic rss post reader on my website and there is a problem with this plugin that sometimes publish duplicate posts.I can't do anything to this plugin but at least it is better if I could prevent to display the same titles on main page.
here is my code </p>
<pre><code> <ul>
<?php
... | [
{
"answer_id": 334895,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 0,
"selected": false,
"text": "<p>You somehow have to get hold of the post IDs you want to exclude. By calling the plugin's <code>WP_Query</co... | 2019/04/21 | [
"https://wordpress.stackexchange.com/questions/334890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86854/"
] | I am using a automatic rss post reader on my website and there is a problem with this plugin that sometimes publish duplicate posts.I can't do anything to this plugin but at least it is better if I could prevent to display the same titles on main page.
here is my code
```
<ul>
<?php
$portfolio ... | Your code should look like this to exclude duplicate titles
```
<ul>
<?php
// Initial counter for displayed posts.
$counter = 1;
// Initial empty array of displayed titles.
$titles = [];
$portfolio = new WP_Query([
'post_status' => 'publish',
'post_type' => 'post',
'cat... |
334,900 | <p>I want to filter the exact information from a custom WordPress table no matter the user has filled all the text boxes or not.
I have used a LIKE query but it`s not working properly if the user left one or two boxes but working fine with all the boxes are filled, I have also used OR query but that's too not working.<... | [
{
"answer_id": 334895,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 0,
"selected": false,
"text": "<p>You somehow have to get hold of the post IDs you want to exclude. By calling the plugin's <code>WP_Query</co... | 2019/04/21 | [
"https://wordpress.stackexchange.com/questions/334900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147511/"
] | I want to filter the exact information from a custom WordPress table no matter the user has filled all the text boxes or not.
I have used a LIKE query but it`s not working properly if the user left one or two boxes but working fine with all the boxes are filled, I have also used OR query but that's too not working.
``... | Your code should look like this to exclude duplicate titles
```
<ul>
<?php
// Initial counter for displayed posts.
$counter = 1;
// Initial empty array of displayed titles.
$titles = [];
$portfolio = new WP_Query([
'post_status' => 'publish',
'post_type' => 'post',
'cat... |
334,904 | <p>my wordpress site urls like this: <a href="https://example.com/?pid=a125a5&lang=en" rel="nofollow noreferrer">https://example.com/?pid=a125a5&lang=en</a> and query of my archive page like this:</p>
<pre><code><?php
$the_slug = get_query_var('pid');
if ($the_slug){
if ( $post = get_page_by_path( $the_s... | [
{
"answer_id": 334895,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 0,
"selected": false,
"text": "<p>You somehow have to get hold of the post IDs you want to exclude. By calling the plugin's <code>WP_Query</co... | 2019/04/21 | [
"https://wordpress.stackexchange.com/questions/334904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165509/"
] | my wordpress site urls like this: <https://example.com/?pid=a125a5&lang=en> and query of my archive page like this:
```
<?php
$the_slug = get_query_var('pid');
if ($the_slug){
if ( $post = get_page_by_path( $the_slug, OBJECT, 'myposttype' ) )
$id = $post->ID;
else
$id = 0;
?>
<?php get_header(); ?>
<div cl... | Your code should look like this to exclude duplicate titles
```
<ul>
<?php
// Initial counter for displayed posts.
$counter = 1;
// Initial empty array of displayed titles.
$titles = [];
$portfolio = new WP_Query([
'post_status' => 'publish',
'post_type' => 'post',
'cat... |
334,910 | <p>Seems someone has set their domain to use my server. It's not a mirror, the database and everything works and updates with mine. He's basically stealing my content, and he's showing up on google instead of me.</p>
<p>Is there a way to make it so my server will only respond to requests from my domain?</p>
<p>I'm us... | [
{
"answer_id": 334895,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 0,
"selected": false,
"text": "<p>You somehow have to get hold of the post IDs you want to exclude. By calling the plugin's <code>WP_Query</co... | 2019/04/21 | [
"https://wordpress.stackexchange.com/questions/334910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/139889/"
] | Seems someone has set their domain to use my server. It's not a mirror, the database and everything works and updates with mine. He's basically stealing my content, and he's showing up on google instead of me.
Is there a way to make it so my server will only respond to requests from my domain?
I'm using Wordpress wit... | Your code should look like this to exclude duplicate titles
```
<ul>
<?php
// Initial counter for displayed posts.
$counter = 1;
// Initial empty array of displayed titles.
$titles = [];
$portfolio = new WP_Query([
'post_status' => 'publish',
'post_type' => 'post',
'cat... |
334,912 | <p>I have set up a loop to pull in staff bios. When a user clicks on the thumbnail of the staff member a popup with the complete bio information for that "post" should be displayed. I have been able to connect most things, but when I click on a bio, the content of the popup is always from the last post. I assume thi... | [
{
"answer_id": 334919,
"author": "Brada",
"author_id": 161366,
"author_profile": "https://wordpress.stackexchange.com/users/161366",
"pm_score": 0,
"selected": false,
"text": "<p>You use the_ID() function outside the loop, this is a function that should be used inside. Also your approach... | 2019/04/21 | [
"https://wordpress.stackexchange.com/questions/334912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165195/"
] | I have set up a loop to pull in staff bios. When a user clicks on the thumbnail of the staff member a popup with the complete bio information for that "post" should be displayed. I have been able to connect most things, but when I click on a bio, the content of the popup is always from the last post. I assume this is b... | This may help
```
<?php
$staff = new WP_Query(array(
'posts_per_page' => -1,
'post_type' => 'staff_bios',
'orderby' => 'title',
'order' => 'ASC'
));
while($staff->have_posts()){
$staff->the_post(); ?>
//Below is what should display for each post.
<div class="staff-thumb" onclick="staffDetails... |
334,974 | <p>I use front-page.php on my template to display home page. But I want to disable if the user uses another page for the home page from settings. Is there a solution? When user select a page from settings for home page, it not showed and front-page.php is loaded. I want to it disabled dynamically.
Sorry for bad english... | [
{
"answer_id": 334978,
"author": "Antti Koskinen",
"author_id": 144392,
"author_profile": "https://wordpress.stackexchange.com/users/144392",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe <a href=\"https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include\" rel=\"nof... | 2019/04/22 | [
"https://wordpress.stackexchange.com/questions/334974",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/153899/"
] | I use front-page.php on my template to display home page. But I want to disable if the user uses another page for the home page from settings. Is there a solution? When user select a page from settings for home page, it not showed and front-page.php is loaded. I want to it disabled dynamically.
Sorry for bad english. | Maybe [`template_include`](https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include) filter would get the job done for you. Something along these lines,
```
function prefix_another_front_page_template( $template ) {
if ( is_front_page() ) {
$another_front_page_template = 'something.php'... |
334,980 | <p>I'm using the twenty fifteen theme.</p>
<p>I have a logo set using the WP Customizer.</p>
<p>I want to have the image change on mobile or tablet view.</p>
<p>The breakpoint is anything smaller than 59.6875em.</p>
<p>I'm using this code:</p>
<pre><code>@media only screen and (max-width: 59.6875em) {
.custom-lo... | [
{
"answer_id": 334986,
"author": "Iisrael",
"author_id": 165195,
"author_profile": "https://wordpress.stackexchange.com/users/165195",
"pm_score": -1,
"selected": false,
"text": "<p>This can be done with classes for each screen size and media queries. I saw this answered on this page or... | 2019/04/22 | [
"https://wordpress.stackexchange.com/questions/334980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114749/"
] | I'm using the twenty fifteen theme.
I have a logo set using the WP Customizer.
I want to have the image change on mobile or tablet view.
The breakpoint is anything smaller than 59.6875em.
I'm using this code:
```
@media only screen and (max-width: 59.6875em) {
.custom-logo {
content: url("https://www.example... | Instead of trying to change the URL of the img tag, use your media query to hide the image and change the `:before` of your `<a>`. Like this...
```
@media screen and (max-width: 59.6875em) {
.site-branding img {
display:none;
}
.site-branding a::before {
content: url("https://www.example.co... |
335,016 | <p>I changed my Wordpress folder name in htdocs as localhost/ecom/ and now when I try to access localhost/ecom/wp-admin/ it shows page not found</p>
| [
{
"answer_id": 334986,
"author": "Iisrael",
"author_id": 165195,
"author_profile": "https://wordpress.stackexchange.com/users/165195",
"pm_score": -1,
"selected": false,
"text": "<p>This can be done with classes for each screen size and media queries. I saw this answered on this page or... | 2019/04/22 | [
"https://wordpress.stackexchange.com/questions/335016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165575/"
] | I changed my Wordpress folder name in htdocs as localhost/ecom/ and now when I try to access localhost/ecom/wp-admin/ it shows page not found | Instead of trying to change the URL of the img tag, use your media query to hide the image and change the `:before` of your `<a>`. Like this...
```
@media screen and (max-width: 59.6875em) {
.site-branding img {
display:none;
}
.site-branding a::before {
content: url("https://www.example.co... |
335,112 | <p>I am a game developer, not very familiar with web programming. I am trying to tie my website point system, MyCred, into my games. Mycred has code snippets for interacting with the points from another site. I use their snippet, but I keep getting this error:</p>
<blockquote>
<p><b>Fatal error</b>: require(): Fail... | [
{
"answer_id": 335114,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 1,
"selected": false,
"text": "<p>It looks as though <code>WP_DIR</code> is being interpreted as a string. Is that constant defined anywhere be... | 2019/04/23 | [
"https://wordpress.stackexchange.com/questions/335112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165631/"
] | I am a game developer, not very familiar with web programming. I am trying to tie my website point system, MyCred, into my games. Mycred has code snippets for interacting with the points from another site. I use their snippet, but I keep getting this error:
>
> **Fatal error**: require(): Failed opening required 'WP\... | It looks as though `WP_DIR` is being interpreted as a string. Is that constant defined anywhere before this code is being run?
My guess is that it is not as PHP will assume it's a string and that is why the location is `WP_DIRwp-blog-header.php` and not an actual file path.
Hope this helps! |
336,162 | <p>I have tried many options but without luck. It should be very simple approach but does not produce results. I am trying to insert default fallback image if there is no featured image in the post. My code that produces the thumbnail:</p>
<pre><code> <?php if ( has_post_thumbnail() ): ?>
<div class="p... | [
{
"answer_id": 336170,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>So you were almost there...</p>\n\n<pre><code><?php if ( has_post_thumbnail() ) : ?>\n<div c... | 2019/04/24 | [
"https://wordpress.stackexchange.com/questions/336162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/162254/"
] | I have tried many options but without luck. It should be very simple approach but does not produce results. I am trying to insert default fallback image if there is no featured image in the post. My code that produces the thumbnail:
```
<?php if ( has_post_thumbnail() ): ?>
<div class="post-card__image">
... | **Method 1: Set Default Fallback Image for Post Thumbnails Using Plugin**
This method is easier and recommended for all users.
First thing you need to do is install and activate the Default Featured Image plugin.
<https://wordpress.org/plugins/default-featured-image/>
**Method 2: Add Fallback Image as Post Thumbnai... |
336,165 | <p>i have different CPT ( hotel, market, city, etc… )</p>
<p>My relationship field is used to link CPT to cities (CITY).</p>
<p>Now in a page ( hotel page ) i want to link “other hotels in same city”.</p>
<p>how can i make my query ? I know how to do a query by ID with the ID of actual page, but what i need is :</p>... | [
{
"answer_id": 336170,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>So you were almost there...</p>\n\n<pre><code><?php if ( has_post_thumbnail() ) : ?>\n<div c... | 2019/04/24 | [
"https://wordpress.stackexchange.com/questions/336165",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/139936/"
] | i have different CPT ( hotel, market, city, etc… )
My relationship field is used to link CPT to cities (CITY).
Now in a page ( hotel page ) i want to link “other hotels in same city”.
how can i make my query ? I know how to do a query by ID with the ID of actual page, but what i need is :
$city = get\_field(‘contac... | **Method 1: Set Default Fallback Image for Post Thumbnails Using Plugin**
This method is easier and recommended for all users.
First thing you need to do is install and activate the Default Featured Image plugin.
<https://wordpress.org/plugins/default-featured-image/>
**Method 2: Add Fallback Image as Post Thumbnai... |
336,218 | <p>I hid the custom sidebar from Wordpress example
<a href="https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/plugin-sidebar-0/" rel="nofollow noreferrer">https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/plugin-sidebar-0/</a> by pressing remove from to... | [
{
"answer_id": 336219,
"author": "Lovor",
"author_id": 135704,
"author_profile": "https://wordpress.stackexchange.com/users/135704",
"pm_score": 1,
"selected": false,
"text": "<p>I found an answer - settings are hidden in local storage in browser. Deleting it restores the sidebar. If som... | 2019/04/24 | [
"https://wordpress.stackexchange.com/questions/336218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/135704/"
] | I hid the custom sidebar from Wordpress example
<https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/plugin-sidebar-0/> by pressing remove from toolbar star in the panel. How to get this toolbar again (I can only rename plugin name in the code to see it again)?
It looks like Gutenberg is... | No code changes are necessary, it can be done entirely in the UI. Sidebars appear in the 3 dot drop down menu, the star is just a way to add a shortcut to the top toolbar, e.g. here are the Yoast and Jetpack sidebars listed:
[](https://i.stack.imgur.c... |
336,236 | <p>I've seen theme support (add_theme_support) for "custom-header", "custom-background" and "custom-logo", but not for footer (footer colur or image). </p>
<p>Is there no option to let users choose footer color or image via "Appearance" --> "Customize"? </p>
<p>Thank you for your advice!</p>
| [
{
"answer_id": 336238,
"author": "Vishwa",
"author_id": 120712,
"author_profile": "https://wordpress.stackexchange.com/users/120712",
"pm_score": 3,
"selected": true,
"text": "<p>You can use following class put inside your theme's functions.php file. Theme Customization API will render t... | 2019/04/25 | [
"https://wordpress.stackexchange.com/questions/336236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/165464/"
] | I've seen theme support (add\_theme\_support) for "custom-header", "custom-background" and "custom-logo", but not for footer (footer colur or image).
Is there no option to let users choose footer color or image via "Appearance" --> "Customize"?
Thank you for your advice! | You can use following class put inside your theme's functions.php file. Theme Customization API will render the custom color selector control on the Theme customizer from this.
```
class MyTheme_Customize {
public static function register ( $wp_customize ) {
$wp_customize->add_section( 'mytheme_options',
array(
'titl... |
336,281 | <p>I'm currently working on a website where users can purchase subscriptions using memberpress, I want to capture the user data after the signup process is completed and the payment transaction is also completed as well. If I add the member through dashboard manually I'm able to catch the user info as there is no payme... | [
{
"answer_id": 336419,
"author": "RBD",
"author_id": 166745,
"author_profile": "https://wordpress.stackexchange.com/users/166745",
"pm_score": 1,
"selected": false,
"text": "<p>After searching for about 2 days I was able to figure out a way to capture the user after signup process is com... | 2019/04/25 | [
"https://wordpress.stackexchange.com/questions/336281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/166745/"
] | I'm currently working on a website where users can purchase subscriptions using memberpress, I want to capture the user data after the signup process is completed and the payment transaction is also completed as well. If I add the member through dashboard manually I'm able to catch the user info as there is no payment ... | After searching for about 2 days I was able to figure out a way to capture the user after signup process is completed and the user's payment goes through the payment gateway, the way I'm doing it right now is when a signup process is completed user is redirected to thank-you page and a querystring containing subscr\_id... |
336,295 | <p>I was wondering whether it's possible to use <em>one</em> query to get the last couple of posts from several years.</p>
<p>I'm currently using a <code>foreach</code> loop to run several queries and then merge the post data. My single query looks like this:</p>
<pre><code>$amount = 2;
$year = 2018;
$args = array(
... | [
{
"answer_id": 336315,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 3,
"selected": true,
"text": "<p>You're just about there. Each <code>date_query</code> array represents a separate condition to filter by. B... | 2019/04/25 | [
"https://wordpress.stackexchange.com/questions/336295",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32794/"
] | I was wondering whether it's possible to use *one* query to get the last couple of posts from several years.
I'm currently using a `foreach` loop to run several queries and then merge the post data. My single query looks like this:
```
$amount = 2;
$year = 2018;
$args = array(
'post_type' => 'post',
... | You're just about there. Each `date_query` array represents a separate condition to filter by. By default, these are combined using `AND` which limits the scope further. In your case, you want to change the relation to `OR` and then add the different years as their own separate conditions in the array.
```
$args = ar... |
336,301 | <p>I'm trying to create a new category in the taxonomy.php called '<strong>USSERS</strong>'. I have followed few examples online and got till this part.</p>
<pre><code>function insert_term( $name,$tax,$parent='' ,$slug='') {
$term_id = term_exists( $name, $tax);
if ( !$term_id)
$term_id = wp_insert_ter... | [
{
"answer_id": 336315,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 3,
"selected": true,
"text": "<p>You're just about there. Each <code>date_query</code> array represents a separate condition to filter by. B... | 2019/04/25 | [
"https://wordpress.stackexchange.com/questions/336301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/166752/"
] | I'm trying to create a new category in the taxonomy.php called '**USSERS**'. I have followed few examples online and got till this part.
```
function insert_term( $name,$tax,$parent='' ,$slug='') {
$term_id = term_exists( $name, $tax);
if ( !$term_id)
$term_id = wp_insert_term( $name, $tax, array('pare... | You're just about there. Each `date_query` array represents a separate condition to filter by. By default, these are combined using `AND` which limits the scope further. In your case, you want to change the relation to `OR` and then add the different years as their own separate conditions in the array.
```
$args = ar... |
336,332 | <p>Navigation Menu links not working, but the bootstrap CSS is working. Can anyone help me in getting the links working? Thank you<a href="https://i.stack.imgur.com/7UsiD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7UsiD.png" alt="enter image description here"></a></p>
<pre><code><ul class="n... | [
{
"answer_id": 336315,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 3,
"selected": true,
"text": "<p>You're just about there. Each <code>date_query</code> array represents a separate condition to filter by. B... | 2019/04/25 | [
"https://wordpress.stackexchange.com/questions/336332",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/166779/"
] | Navigation Menu links not working, but the bootstrap CSS is working. Can anyone help me in getting the links working? Thank you[](https://i.stack.imgur.com/7UsiD.png)
```
<ul class="navbar-nav mr-auto">
<?php
wp_nav_menu(array(... | You're just about there. Each `date_query` array represents a separate condition to filter by. By default, these are combined using `AND` which limits the scope further. In your case, you want to change the relation to `OR` and then add the different years as their own separate conditions in the array.
```
$args = ar... |
336,350 | <p>I have a custom php file in wp-content/themes/xxxx/modules/custom.php and i want to call function from Functions.php. Right now all my functions (same function) everywhere in different files, because still cannot solve this problem. </p>
<p>I want to create a function in Functions.php and call this function from ev... | [
{
"answer_id": 336354,
"author": "user3135691",
"author_id": 59755,
"author_profile": "https://wordpress.stackexchange.com/users/59755",
"pm_score": 0,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code><?php\n\n $dir = get_template_directory_uri();\n require $dir . '/yourfolder/... | 2019/04/25 | [
"https://wordpress.stackexchange.com/questions/336350",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/166789/"
] | I have a custom php file in wp-content/themes/xxxx/modules/custom.php and i want to call function from Functions.php. Right now all my functions (same function) everywhere in different files, because still cannot solve this problem.
I want to create a function in Functions.php and call this function from everywhere i... | It's worth noting that PHP namespace issues can contribute to this problem. This can catch people because namespaces have been kept out of Wordpress core codebase until recently.
For example one of your code files may have a Namespace declaration around the top. If that is the case you will have to prefix any referen... |
336,359 | <p>When I attempt to use the <a href="https://codex.wordpress.org/Function_Reference/unzip_file" rel="nofollow noreferrer">unzip_file</a> function below in my <code>functions.php</code>:</p>
<pre><code>require_once(ABSPATH . 'wp-admin/includes/file.php');
WP_Filesystem();
$destination = wp_upload_dir();
$destination_p... | [
{
"answer_id": 336362,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming that (it's not clear from your question):</p>\n\n<ul>\n<li>you change htaccess to redirect ht... | 2019/04/26 | [
"https://wordpress.stackexchange.com/questions/336359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40536/"
] | When I attempt to use the [unzip\_file](https://codex.wordpress.org/Function_Reference/unzip_file) function below in my `functions.php`:
```
require_once(ABSPATH . 'wp-admin/includes/file.php');
WP_Filesystem();
$destination = wp_upload_dir();
$destination_path = $destination['path'];
$unzipfile = unzip_file( $destina... | Assuming that (it's not clear from your question):
* you change htaccess to redirect http request to https (best way, IMHO). Lots of googles on that; your hosting place should also have guidance specific to thier hosting environment.
* you changed the two URLs in the wp-options table to show the full URL with https
T... |
336,361 | <p>I have added a custom field to my site called "dansk_url", to which a link to the version in Danish (different domain) will be entered. I would like to be able to output this as a shortcode to add anywhere within the post, and it should appear as a link (anchor text will always be "Dansk" and whichever url has been ... | [
{
"answer_id": 336372,
"author": "Sally CJ",
"author_id": 137402,
"author_profile": "https://wordpress.stackexchange.com/users/137402",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>I would like to be able to output this as a shortcode to add anywhere\n within the post</... | 2019/04/26 | [
"https://wordpress.stackexchange.com/questions/336361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/166799/"
] | I have added a custom field to my site called "dansk\_url", to which a link to the version in Danish (different domain) will be entered. I would like to be able to output this as a shortcode to add anywhere within the post, and it should appear as a link (anchor text will always be "Dansk" and whichever url has been en... | Put this in `functions.php` of your theme.
```
add_shortcode( 'dansk_url', 'dansk_url' );
function dansk_url() {
$output='';
$the_url= get_post_meta( get_the_ID(), 'dansk_url', true );
if ( $the_url) $output .= '<a href="' . esc_url( $the_url) . '">Dansk</a>';
return $output;
}
```
and use shortco... |