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 |
|---|---|---|---|---|---|---|
284,841 | <p>I'm using a theme that supports WordPress's (relatively new) video header feature. I want to upload a video that's over 8MB big, and I don't want to reduce the size of the video. How can I force it to accept a larger video? Is there a file that I can edit or a plugin that I can download?</p>
| [
{
"answer_id": 284851,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>The limit is enforced by <a href=\"https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate... | 2017/11/03 | [
"https://wordpress.stackexchange.com/questions/284841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119995/"
] | I'm using a theme that supports WordPress's (relatively new) video header feature. I want to upload a video that's over 8MB big, and I don't want to reduce the size of the video. How can I force it to accept a larger video? Is there a file that I can edit or a plugin that I can download? | The limit is enforced by [`_validate_header_video`](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/) method, registered as validation callback on respective Customizer setting.
There is a filter that allows you to hook into the process and manipulate those arguments:
```... |
284,853 | <h1>What I want to achieve</h1>
<p>The editor should be able to add galleries via the native wordpress way <strong>and choose between 3 different gallery types</strong>. These 3 types should all have their custom code-output, defined by me. I'd like to go a step further and give the editor <strong>only</strong> the ga... | [
{
"answer_id": 284851,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>The limit is enforced by <a href=\"https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate... | 2017/11/03 | [
"https://wordpress.stackexchange.com/questions/284853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102487/"
] | What I want to achieve
======================
The editor should be able to add galleries via the native wordpress way **and choose between 3 different gallery types**. These 3 types should all have their custom code-output, defined by me. I'd like to go a step further and give the editor **only** the gallery-type to c... | The limit is enforced by [`_validate_header_video`](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/) method, registered as validation callback on respective Customizer setting.
There is a filter that allows you to hook into the process and manipulate those arguments:
```... |
284,854 | <p>I have a list of competitions for which I set deadlines using Wordpress' built-in custom fields, in a YYYYMMDD format. I want to create a custom loop to display only the competitions that are now closed, meaning that their deadlines are older than today's date. </p>
<p>I tried doing the following, but this displays... | [
{
"answer_id": 284851,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>The limit is enforced by <a href=\"https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate... | 2017/11/03 | [
"https://wordpress.stackexchange.com/questions/284854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129417/"
] | I have a list of competitions for which I set deadlines using Wordpress' built-in custom fields, in a YYYYMMDD format. I want to create a custom loop to display only the competitions that are now closed, meaning that their deadlines are older than today's date.
I tried doing the following, but this displays all compe... | The limit is enforced by [`_validate_header_video`](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/) method, registered as validation callback on respective Customizer setting.
There is a filter that allows you to hook into the process and manipulate those arguments:
```... |
284,859 | <p>I have noticed that when i navigate to a product in my woocommerce site the URL is</p>
<pre><code>https://mydomain.co.uk/product/procrastination-facebook-font-parody-graphic-quality-t-shirt-tee-mens-unisex/
</code></pre>
<p>and for the category it is:</p>
<pre><code>https://mydomain.co.uk/product-category/t-shirt... | [
{
"answer_id": 284851,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>The limit is enforced by <a href=\"https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate... | 2017/11/03 | [
"https://wordpress.stackexchange.com/questions/284859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129316/"
] | I have noticed that when i navigate to a product in my woocommerce site the URL is
```
https://mydomain.co.uk/product/procrastination-facebook-font-parody-graphic-quality-t-shirt-tee-mens-unisex/
```
and for the category it is:
```
https://mydomain.co.uk/product-category/t-shirts/mensunisex-t-shirts/social-networki... | The limit is enforced by [`_validate_header_video`](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/) method, registered as validation callback on respective Customizer setting.
There is a filter that allows you to hook into the process and manipulate those arguments:
```... |
284,877 | <p>I decided to namespace my plugin, and I got it all to work, except in my main plugin file.</p>
<p>I added two actions in that plugin, before calling the init method of the plugin.</p>
<pre><code><?php
namespace myPlugin;
add_action( 'admin_init', 'add_activation_notice' );
function add_activation_notice() {
... | [
{
"answer_id": 284883,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 2,
"selected": false,
"text": "<p>The easiest way would be to enclose your code in curly brackets:</p>\n\n<pre><code>namespace m... | 2017/11/03 | [
"https://wordpress.stackexchange.com/questions/284877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58895/"
] | I decided to namespace my plugin, and I got it all to work, except in my main plugin file.
I added two actions in that plugin, before calling the init method of the plugin.
```
<?php
namespace myPlugin;
add_action( 'admin_init', 'add_activation_notice' );
function add_activation_notice() {
add_action( 'admin_no... | Before going too far down this path I would suggest that you familiarize yourself with [PHP name resolution rules](https://secure.php.net/manual/en/language.namespaces.rules.php).
To answer your actual question -
When you namespace functions, the fully qualified name of those functions includes the namespace.
In you... |
284,882 | <p>I'm trying to add a 'muted' option to the video tag output with the content of a post using the built in wp video shortcode. I found this answer <a href="https://wordpress.stackexchange.com/questions/220572/how-can-i-get-the-video-shortcode-to-allow-query-string-parameters">How can I get the [video] shortcode to all... | [
{
"answer_id": 284892,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>I get Undefined variable: for $video, $post_id and $library and the\n video's in the page are... | 2017/11/03 | [
"https://wordpress.stackexchange.com/questions/284882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122525/"
] | I'm trying to add a 'muted' option to the video tag output with the content of a post using the built in wp video shortcode. I found this answer [How can I get the [video] shortcode to allow query string parameters?](https://wordpress.stackexchange.com/questions/220572/how-can-i-get-the-video-shortcode-to-allow-query-s... | >
> I get Undefined variable: for $video, $post\_id and $library and the
> video's in the page are blank.
>
>
>
Replace:
```
add_filter( 'wp_video_shortcode', 'my_video_shortcode', 10, 2 );
```
with:
```
add_filter( 'wp_video_shortcode', 'my_video_shortcode', 10, 5 );
```
to access all five input arguments ... |
284,905 | <p>Bonsoir, I want to pass shortcode attributes to my class in a form of an array and the name of my shorcode but in the wordpress codex doesn't says how could i do that, this is my code</p>
<pre><code> $atributos=array('url' => ' ','text' => ' ');
$shortcode_name="myshortcode";
class MyLittleClass {
publ... | [
{
"answer_id": 284892,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>I get Undefined variable: for $video, $post_id and $library and the\n video's in the page are... | 2017/11/03 | [
"https://wordpress.stackexchange.com/questions/284905",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130802/"
] | Bonsoir, I want to pass shortcode attributes to my class in a form of an array and the name of my shorcode but in the wordpress codex doesn't says how could i do that, this is my code
```
$atributos=array('url' => ' ','text' => ' ');
$shortcode_name="myshortcode";
class MyLittleClass {
public static function e... | >
> I get Undefined variable: for $video, $post\_id and $library and the
> video's in the page are blank.
>
>
>
Replace:
```
add_filter( 'wp_video_shortcode', 'my_video_shortcode', 10, 2 );
```
with:
```
add_filter( 'wp_video_shortcode', 'my_video_shortcode', 10, 5 );
```
to access all five input arguments ... |
284,960 | <p>I'm brand new at theme development. My css stylesheet is not loading, and I'm not sure if the problem is in the functions.php, style.css, index.php, header.php, or footer.php file. I've added a div class "post-title" in index.php, which should change the font color of my posts, but right now it's not doing that. ... | [
{
"answer_id": 284972,
"author": "Venkatesh",
"author_id": 124538,
"author_profile": "https://wordpress.stackexchange.com/users/124538",
"pm_score": 2,
"selected": false,
"text": "<p>I have tried to create WordPress theme using your functions.php, style.css and index.php and for me, the ... | 2017/11/04 | [
"https://wordpress.stackexchange.com/questions/284960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130864/"
] | I'm brand new at theme development. My css stylesheet is not loading, and I'm not sure if the problem is in the functions.php, style.css, index.php, header.php, or footer.php file. I've added a div class "post-title" in index.php, which should change the font color of my posts, but right now it's not doing that. My cod... | I have tried to create WordPress theme using your functions.php, style.css and index.php and for me, the stylesheet is loading correctly. Please make sure you have added your header.php and footer.php for the theme.
Please study some tutorials for theme development on WordPress.You can look at this link <https://codex.... |
284,961 | <p>Prior to version 3.5 (or thereabouts), WP had a checkbox to select if all uploaded media went into sub-folders of /uploads, named by month and year. If checkbox was unchecked, all media ended up in one folder - no subfolders.</p>
<p>How can I restore that feature? I.e., I want all my media to go into one folder and... | [
{
"answer_id": 284970,
"author": "jaswrks",
"author_id": 81760,
"author_profile": "https://wordpress.stackexchange.com/users/81760",
"pm_score": 3,
"selected": true,
"text": "<p>Pop this tiny code snippet into a file located here:<br>\n<code>wp-content/mu-plugins/upload-dir.php</code> (a... | 2017/11/04 | [
"https://wordpress.stackexchange.com/questions/284961",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130896/"
] | Prior to version 3.5 (or thereabouts), WP had a checkbox to select if all uploaded media went into sub-folders of /uploads, named by month and year. If checkbox was unchecked, all media ended up in one folder - no subfolders.
How can I restore that feature? I.e., I want all my media to go into one folder and NOT be fu... | Pop this tiny code snippet into a file located here:
`wp-content/mu-plugins/upload-dir.php` (a [must use plugin](https://codex.wordpress.org/Must_Use_Plugins) file).
*Create the `mu-plugins` directory if it does not exist already.*
```
<?php
add_filter( 'pre_option_uploads_use_yearmonth_folders', '__return_zero'... |
284,975 | <p>Is there a way to simply have a form in a page that the user can fill in and on submit continually populate a table directly underneath the the submit button.</p>
<p>This information must also be saved/stored so that when the user comes back the previous posts are there</p>
<p>Im not sure I know how to do what was... | [
{
"answer_id": 284977,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 1,
"selected": false,
"text": "<p>You can have an <strong>ajax</strong> action that sent the data to the <strong>backend</strong> populat... | 2017/11/04 | [
"https://wordpress.stackexchange.com/questions/284975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130887/"
] | Is there a way to simply have a form in a page that the user can fill in and on submit continually populate a table directly underneath the the submit button.
This information must also be saved/stored so that when the user comes back the previous posts are there
Im not sure I know how to do what was explained.
This... | You can have an **ajax** action that sent the data to the **backend** populate the table and return the success or the errors back.
You can use this actions
```
add_action('wp_ajax_*', 'custom_table_insert');
add_action('wp_ajax_nopriv_*', 'custom_table_insert'); // anonymous users
```
This will give you more cont... |
284,997 | <p>EDIT - This is solved thank you for your help after the suggestions below didn't solve the problem I refreshed my browser cashe and now my functions work... However I then realized they only work on the home page. creating a separate thread for that. Thank you for you help!!!</p>
<p>the new thread is here <a href="... | [
{
"answer_id": 284977,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 1,
"selected": false,
"text": "<p>You can have an <strong>ajax</strong> action that sent the data to the <strong>backend</strong> populat... | 2017/11/05 | [
"https://wordpress.stackexchange.com/questions/284997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130812/"
] | EDIT - This is solved thank you for your help after the suggestions below didn't solve the problem I refreshed my browser cashe and now my functions work... However I then realized they only work on the home page. creating a separate thread for that. Thank you for you help!!!
the new thread is here [jQuery functions o... | You can have an **ajax** action that sent the data to the **backend** populate the table and return the success or the errors back.
You can use this actions
```
add_action('wp_ajax_*', 'custom_table_insert');
add_action('wp_ajax_nopriv_*', 'custom_table_insert'); // anonymous users
```
This will give you more cont... |
285,021 | <p>I use the get_post_term code from <a href="https://codex.wordpress.org/Function_Reference/wp_get_post_terms" rel="nofollow noreferrer">https://codex.wordpress.org/Function_Reference/wp_get_post_terms</a>.
I can retrieve the selected taxonomy term from the current post but the displayed value looks like this: Array ... | [
{
"answer_id": 285098,
"author": "Moe",
"author_id": 130914,
"author_profile": "https://wordpress.stackexchange.com/users/130914",
"pm_score": 0,
"selected": false,
"text": "<p>It works with this code to show only the name, however the output is displayed in small characters so I only ne... | 2017/11/05 | [
"https://wordpress.stackexchange.com/questions/285021",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130914/"
] | I use the get\_post\_term code from <https://codex.wordpress.org/Function_Reference/wp_get_post_terms>.
I can retrieve the selected taxonomy term from the current post but the displayed value looks like this: Array ( [0] => Taxonomy Term).
I only want the taxonomy term in the frontend.
`//Returns Array of Term Names ... | Assuming the taxonomy name is "animals"
```
<?php
//This will show all the terms in taxonomy whether they have posts or not thus the "hide_empty"
$terms = get_terms( array ( 'taxonomy' => 'animals', 'hide_empty' => false, 'parent' => 0, 'orderby' => 'description', 'order' => 'ASC' ));
foreach ($terms as $... |
285,022 | <p>I am using 2017 theme and I want to thumbnail to the posts which appears on my site homepage, thumbnail appearing when we visit post but doesn't appear on homepage<a href="https://i.stack.imgur.com/rcRwy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rcRwy.jpg" alt="enter image description here">... | [
{
"answer_id": 285098,
"author": "Moe",
"author_id": 130914,
"author_profile": "https://wordpress.stackexchange.com/users/130914",
"pm_score": 0,
"selected": false,
"text": "<p>It works with this code to show only the name, however the output is displayed in small characters so I only ne... | 2017/11/05 | [
"https://wordpress.stackexchange.com/questions/285022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130919/"
] | I am using 2017 theme and I want to thumbnail to the posts which appears on my site homepage, thumbnail appearing when we visit post but doesn't appear on homepage[](https://i.stack.imgur.com/rcRwy.jpg) | Assuming the taxonomy name is "animals"
```
<?php
//This will show all the terms in taxonomy whether they have posts or not thus the "hide_empty"
$terms = get_terms( array ( 'taxonomy' => 'animals', 'hide_empty' => false, 'parent' => 0, 'orderby' => 'description', 'order' => 'ASC' ));
foreach ($terms as $... |
285,050 | <p>Simplifying how I currently show featured posts, when a post is submitted by a full member, a post_meta value is added to the post which is then styled differently. </p>
<p>But Id like to do it based on the post authors, user role instead. </p>
<p>So if a the user who submitted the post is a "full_member", their ... | [
{
"answer_id": 285098,
"author": "Moe",
"author_id": 130914,
"author_profile": "https://wordpress.stackexchange.com/users/130914",
"pm_score": 0,
"selected": false,
"text": "<p>It works with this code to show only the name, however the output is displayed in small characters so I only ne... | 2017/11/05 | [
"https://wordpress.stackexchange.com/questions/285050",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62291/"
] | Simplifying how I currently show featured posts, when a post is submitted by a full member, a post\_meta value is added to the post which is then styled differently.
But Id like to do it based on the post authors, user role instead.
So if a the user who submitted the post is a "full\_member", their post is automati... | Assuming the taxonomy name is "animals"
```
<?php
//This will show all the terms in taxonomy whether they have posts or not thus the "hide_empty"
$terms = get_terms( array ( 'taxonomy' => 'animals', 'hide_empty' => false, 'parent' => 0, 'orderby' => 'description', 'order' => 'ASC' ));
foreach ($terms as $... |
285,066 | <p>Have an issue where I have a series of pages loaded into a websites index using code shown bellow:</p>
<pre><code><?php $id = 1767; $p = get_page($id); echo apply_filters('the_content', $p->post_content); ?>
</code></pre>
<p>But the information from these pages are not respecting Private and Draft status.... | [
{
"answer_id": 285098,
"author": "Moe",
"author_id": 130914,
"author_profile": "https://wordpress.stackexchange.com/users/130914",
"pm_score": 0,
"selected": false,
"text": "<p>It works with this code to show only the name, however the output is displayed in small characters so I only ne... | 2017/11/06 | [
"https://wordpress.stackexchange.com/questions/285066",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130948/"
] | Have an issue where I have a series of pages loaded into a websites index using code shown bellow:
```
<?php $id = 1767; $p = get_page($id); echo apply_filters('the_content', $p->post_content); ?>
```
But the information from these pages are not respecting Private and Draft status. Normally this is fine with me. But... | Assuming the taxonomy name is "animals"
```
<?php
//This will show all the terms in taxonomy whether they have posts or not thus the "hide_empty"
$terms = get_terms( array ( 'taxonomy' => 'animals', 'hide_empty' => false, 'parent' => 0, 'orderby' => 'description', 'order' => 'ASC' ));
foreach ($terms as $... |
285,068 | <p>I am using the postman for the check the REST API Call in WooCommerce.
When I call the Woocommerce Defaults API. It displays the error like.</p>
<pre><code>{
"code": "woocommerce_rest_cannot_create",
"message": "Sorry, you are not allowed to create resources.",
"data": {
"status": 401
}
}
</code></pre>
<p>... | [
{
"answer_id": 306770,
"author": "Ajay Ghaghretiya",
"author_id": 125557,
"author_profile": "https://wordpress.stackexchange.com/users/125557",
"pm_score": 2,
"selected": true,
"text": "<p>I got the solution for it. Use the Basic Authentication from the Postman.</p>\n\n<p>Thanks</p>\n"
... | 2017/11/06 | [
"https://wordpress.stackexchange.com/questions/285068",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125557/"
] | I am using the postman for the check the REST API Call in WooCommerce.
When I call the Woocommerce Defaults API. It displays the error like.
```
{
"code": "woocommerce_rest_cannot_create",
"message": "Sorry, you are not allowed to create resources.",
"data": {
"status": 401
}
}
```
The above error displays w... | I got the solution for it. Use the Basic Authentication from the Postman.
Thanks |
285,093 | <p>I am trying to display the terms from a taxonomy on my archive page but I am struggling to display the terms name, here is what I have so far:</p>
<pre><code>if ($post->post_type == 'cpt_saving') {
$categories = get_the_terms($post->ID, 'cpt_saving-type');
if ($categories) {
$categories['name'];
... | [
{
"answer_id": 285089,
"author": "janh",
"author_id": 129206,
"author_profile": "https://wordpress.stackexchange.com/users/129206",
"pm_score": 2,
"selected": false,
"text": "<p>Apache only runs the index.php of WordPress, and serves static files (images, css, js etc). WP does all the re... | 2017/11/06 | [
"https://wordpress.stackexchange.com/questions/285093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38592/"
] | I am trying to display the terms from a taxonomy on my archive page but I am struggling to display the terms name, here is what I have so far:
```
if ($post->post_type == 'cpt_saving') {
$categories = get_the_terms($post->ID, 'cpt_saving-type');
if ($categories) {
$categories['name'];
}
$stack = [
... | Apache only runs the index.php of WordPress, and serves static files (images, css, js etc). WP does all the rest, including parsing the request to find out what content to show the user. Apache does not (and needs not) know that there is communication with a data base in PHP, and doesn't interact with that database its... |
285,105 | <p>Is it possible to use multiple years with a date query like this -</p>
<pre><code>$args = array(
'posts_per_page' => '-1',
'date_query' => array(
array(
'year' => array( 2016, 2017 )
),
),
);
$posts = new WP_Query(array( $args ) );
</code></pre>
<p>I tried this b... | [
{
"answer_id": 285108,
"author": "jaswrks",
"author_id": 81760,
"author_profile": "https://wordpress.stackexchange.com/users/81760",
"pm_score": 3,
"selected": true,
"text": "<p>You can use <code>before</code> and <code>after</code>, see <a href=\"https://developer.wordpress.org/referenc... | 2017/11/06 | [
"https://wordpress.stackexchange.com/questions/285105",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104464/"
] | Is it possible to use multiple years with a date query like this -
```
$args = array(
'posts_per_page' => '-1',
'date_query' => array(
array(
'year' => array( 2016, 2017 )
),
),
);
$posts = new WP_Query(array( $args ) );
```
I tried this but it doesn't work
```
'year' => a... | You can use `before` and `after`, see [date arguments](https://developer.wordpress.org/reference/classes/wp_query/#date-parameters).
```
$args = array(
'posts_per_page' => '-1',
'date_query' => array(
array(
'after' => 'December 31st, 2015', // i.e., 2016+.
'before' => 'Jan... |
285,113 | <p>I'm retrieving event data from ajax load more plugin using hooks. The requirement is I need to validate the days needed to retrieve. That events 10 days after their end date, they will not be shown in result.</p>
<pre><code>$args = [
'post_status' => 'publish',
'post_type' => array(TribeEvents... | [
{
"answer_id": 285121,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>Use an <code>array</code> for <code>value</code>, so <code>[ $begin, $end ]</code>. For <code>compa... | 2017/11/06 | [
"https://wordpress.stackexchange.com/questions/285113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44259/"
] | I'm retrieving event data from ajax load more plugin using hooks. The requirement is I need to validate the days needed to retrieve. That events 10 days after their end date, they will not be shown in result.
```
$args = [
'post_status' => 'publish',
'post_type' => array(TribeEvents::POSTTYPE),
'po... | On top of my head this should be something like:
```
'meta_query' => [
'key' => '_EventEndDate',
'value' => [ $start, $end ],
'compare' => 'BETWEEN',
'type' => 'DATETIME'
]
```
You would need to calculate boundaries yourself before passing to the query in this case.
See ... |
285,119 | <p>I've got this query:</p>
<pre><code>$tenantsInfo = $wpdb->get_results("SELECT * FROM exp_ten WHERE tenant_number = " . (int) $user->ID);
</code></pre>
<p>I use some echo to show data on frontend:</p>
<pre><code>if ($tenantsInfo) {
foreach ($tenantsInfo as $tenant) {
echo "<h2>Welco... | [
{
"answer_id": 285122,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 0,
"selected": false,
"text": "<p>As this is not clear how you get the data inside the <code>exp_ten</code> table I would suggest use the... | 2017/11/06 | [
"https://wordpress.stackexchange.com/questions/285119",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125541/"
] | I've got this query:
```
$tenantsInfo = $wpdb->get_results("SELECT * FROM exp_ten WHERE tenant_number = " . (int) $user->ID);
```
I use some echo to show data on frontend:
```
if ($tenantsInfo) {
foreach ($tenantsInfo as $tenant) {
echo "<h2>Welcome," . " " .$tenant->tenant_name. "</h2>";
```
... | Use [`esc_html()`](https://developer.wordpress.org/reference/functions/esc_html/) when outputting a string value inside tags. Use [`esc_attr()`](https://developer.wordpress.org/reference/functions/esc_attr/) when you're outputting a string value inside an `attribute=""`. If you're outputting a URL, use [`esc_url()`](ht... |
285,147 | <p>I have few transient options in my plugin with an expiry time of 45 minutes. After that, they hit an API to get the response. Now in some cases, the server throws an exception or throttles the user in case there is a limit on request per second. Now in such, scenario I still want to render the response and the only ... | [
{
"answer_id": 285122,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 0,
"selected": false,
"text": "<p>As this is not clear how you get the data inside the <code>exp_ten</code> table I would suggest use the... | 2017/11/06 | [
"https://wordpress.stackexchange.com/questions/285147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116770/"
] | I have few transient options in my plugin with an expiry time of 45 minutes. After that, they hit an API to get the response. Now in some cases, the server throws an exception or throttles the user in case there is a limit on request per second. Now in such, scenario I still want to render the response and the only way... | Use [`esc_html()`](https://developer.wordpress.org/reference/functions/esc_html/) when outputting a string value inside tags. Use [`esc_attr()`](https://developer.wordpress.org/reference/functions/esc_attr/) when you're outputting a string value inside an `attribute=""`. If you're outputting a URL, use [`esc_url()`](ht... |
285,192 | <p>I have a custom theme in which I have a woocommerce.php file to display the shop homepage. This is simply:</p>
<pre><code>get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<div id="page-header-image">
<?php the_post_thumbnai... | [
{
"answer_id": 285292,
"author": "Steviehype",
"author_id": 67612,
"author_profile": "https://wordpress.stackexchange.com/users/67612",
"pm_score": 0,
"selected": false,
"text": "<p>Well, in case it's of use to anyone else heres what I did. </p>\n\n<p>I couldn't find an obvious way so I ... | 2017/11/07 | [
"https://wordpress.stackexchange.com/questions/285192",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67612/"
] | I have a custom theme in which I have a woocommerce.php file to display the shop homepage. This is simply:
```
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<div id="page-header-image">
<?php the_post_thumbnail(); ?>
</div>
<?php ... | Thanks to you I tried this on my functions.php
It worked, but also had to get the ID of the page, in my case 4.
```
add_action( 'woocommerce_before_main_content', 'woocommerce_category_image', 2 );
function woocommerce_category_image() {
if ( is_product_category() ){
global $wp_query;
$cat = $wp_qu... |
285,209 | <p>I've been working with a child theme and functions.php file to add an Image to the posts that have a specific Tag (<code>Videos</code> in the code). I was trying to create the function but I have some issues, one is that in the site, when I load a Post with that tag, it crashes, looks like it stays in a loop, and af... | [
{
"answer_id": 285211,
"author": "GDY",
"author_id": 52227,
"author_profile": "https://wordpress.stackexchange.com/users/52227",
"pm_score": 1,
"selected": false,
"text": "<p>Heres a more simple version of your function:</p>\n\n<pre><code><?php\n\n add_filter( 'the_content', 'theme... | 2017/11/07 | [
"https://wordpress.stackexchange.com/questions/285209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124577/"
] | I've been working with a child theme and functions.php file to add an Image to the posts that have a specific Tag (`Videos` in the code). I was trying to create the function but I have some issues, one is that in the site, when I load a Post with that tag, it crashes, looks like it stays in a loop, and after that I hav... | Heres a more simple version of your function:
```
<?php
add_filter( 'the_content', 'theme_videos_append_image' );
function theme_videos_append_image( $content ) {
global $post;
$upload_dir_arr = wp_upload_dir();
$static_image_url = $upload_dir_arr['baseurl'] . '/2017/11/uplift... |
285,218 | <p>I'm trying to build in a feature using ACF where a user picks an option to have the hero image change to one of three options. 1) A static hero image 2) A youtube video 3) A mp4 on loop. I have the backend end set up with a conditional to show which one depending on the option, however, I want the user to be able to... | [
{
"answer_id": 285211,
"author": "GDY",
"author_id": 52227,
"author_profile": "https://wordpress.stackexchange.com/users/52227",
"pm_score": 1,
"selected": false,
"text": "<p>Heres a more simple version of your function:</p>\n\n<pre><code><?php\n\n add_filter( 'the_content', 'theme... | 2017/11/07 | [
"https://wordpress.stackexchange.com/questions/285218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123891/"
] | I'm trying to build in a feature using ACF where a user picks an option to have the hero image change to one of three options. 1) A static hero image 2) A youtube video 3) A mp4 on loop. I have the backend end set up with a conditional to show which one depending on the option, however, I want the user to be able to se... | Heres a more simple version of your function:
```
<?php
add_filter( 'the_content', 'theme_videos_append_image' );
function theme_videos_append_image( $content ) {
global $post;
$upload_dir_arr = wp_upload_dir();
$static_image_url = $upload_dir_arr['baseurl'] . '/2017/11/uplift... |
285,234 | <p>I have a site with multiple custom taxonomies which are used for filtering posts.</p>
<p>One of the taxonomies has a <code>taxonomy-%term%.php</code> template file.</p>
<p><code>/?country=the_country</code> shows the country taxonomy template</p>
<p>but <code>/?topic=the_topic&country=the_country</code> uses ... | [
{
"answer_id": 285211,
"author": "GDY",
"author_id": 52227,
"author_profile": "https://wordpress.stackexchange.com/users/52227",
"pm_score": 1,
"selected": false,
"text": "<p>Heres a more simple version of your function:</p>\n\n<pre><code><?php\n\n add_filter( 'the_content', 'theme... | 2017/11/07 | [
"https://wordpress.stackexchange.com/questions/285234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123674/"
] | I have a site with multiple custom taxonomies which are used for filtering posts.
One of the taxonomies has a `taxonomy-%term%.php` template file.
`/?country=the_country` shows the country taxonomy template
but `/?topic=the_topic&country=the_country` uses the country taxonomy template as well.
Is there a simple way... | Heres a more simple version of your function:
```
<?php
add_filter( 'the_content', 'theme_videos_append_image' );
function theme_videos_append_image( $content ) {
global $post;
$upload_dir_arr = wp_upload_dir();
$static_image_url = $upload_dir_arr['baseurl'] . '/2017/11/uplift... |
285,265 | <p>I have a script I want to place in my site's footer. It's not actually a file, just a single line of code (the script source is located at an external URL).
So my question is, should I enqueue the script or just copy and paste it into the footer?</p>
| [
{
"answer_id": 285269,
"author": "jaswrks",
"author_id": 81760,
"author_profile": "https://wordpress.stackexchange.com/users/81760",
"pm_score": 2,
"selected": false,
"text": "<p>See <a href=\"https://developer.wordpress.org/reference/functions/wp_enqueue_script/\" rel=\"nofollow norefer... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285265",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68414/"
] | I have a script I want to place in my site's footer. It's not actually a file, just a single line of code (the script source is located at an external URL).
So my question is, should I enqueue the script or just copy and paste it into the footer? | If you want to output a single line of javascript, you might not need to put it in a js file and go through enqueuing it and stuff. Simply output it by using the `wp_footer()` action hook:
```
add_action('wp_footer','print_my_script');
function print_my_script(){
echo '<script> // Your script here </script>';
}
`... |
285,275 | <p>I have a domain with a subdomain. </p>
<p>Each of those has a different install of WordPress.</p>
<p>When I created the databases I made the following:</p>
<p>Main Domain = database called: maindomain
Sub Domain = database called: subdomain</p>
<p>I applied the SAME database username to both databases....</p>
<... | [
{
"answer_id": 285269,
"author": "jaswrks",
"author_id": 81760,
"author_profile": "https://wordpress.stackexchange.com/users/81760",
"pm_score": 2,
"selected": false,
"text": "<p>See <a href=\"https://developer.wordpress.org/reference/functions/wp_enqueue_script/\" rel=\"nofollow norefer... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | I have a domain with a subdomain.
Each of those has a different install of WordPress.
When I created the databases I made the following:
Main Domain = database called: maindomain
Sub Domain = database called: subdomain
I applied the SAME database username to both databases....
So all nice and simple....
However,... | If you want to output a single line of javascript, you might not need to put it in a js file and go through enqueuing it and stuff. Simply output it by using the `wp_footer()` action hook:
```
add_action('wp_footer','print_my_script');
function print_my_script(){
echo '<script> // Your script here </script>';
}
`... |
285,296 | <p>can you help me with little problem.</p>
<p>I need to find a solution, how to redirect user to login page when he wants to download file over link in post content, so, I have some files and I want them to be available only for users that are logged in, otherwise they should be redirected on login page, for example ... | [
{
"answer_id": 285299,
"author": "Marcelo Henriques Cortez",
"author_id": 44437,
"author_profile": "https://wordpress.stackexchange.com/users/44437",
"pm_score": 2,
"selected": false,
"text": "<p>I wouldn't use htaccess for that.</p>\n\n<p>What I would do is make a 'download page' templa... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121777/"
] | can you help me with little problem.
I need to find a solution, how to redirect user to login page when he wants to download file over link in post content, so, I have some files and I want them to be available only for users that are logged in, otherwise they should be redirected on login page, for example I want to ... | Thanks to [Marcelo Henriques](https://wordpress.stackexchange.com/users/44437/marcelo-henriques-cortez) answer i figured out how to make this work with `.htaccess` file and here is the code:
```
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^.*(mp3|m4a|pdf|doc|xlsx|docx|xls)$
RewriteCond %{HTTP_COOKIE... |
285,333 | <p>I am trying to prevent from Cross Site Scripting vulnerabilities. For that I have to make sure that it is not possible to insert JavaScript code directly via the editing functionality on Text editor.
I want to be able to add only HTML and CSS content on text editor.
have you an idea how to disable javascript code in... | [
{
"answer_id": 285340,
"author": "TurtleTread",
"author_id": 117263,
"author_profile": "https://wordpress.stackexchange.com/users/117263",
"pm_score": 0,
"selected": false,
"text": "<p>Hook into <code>wp_insert_post_data</code> to either filter out <code><script></code> content or ... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119785/"
] | I am trying to prevent from Cross Site Scripting vulnerabilities. For that I have to make sure that it is not possible to insert JavaScript code directly via the editing functionality on Text editor.
I want to be able to add only HTML and CSS content on text editor.
have you an idea how to disable javascript code inser... | WordPress already disallows the use of JavaScript in the editor for users without the `unfiltered_html` capability. By default, [only the Administrator and Editor roles](https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table) have this capability. If necessary, you could remove this capability fro... |
285,334 | <p>We have a totally custom theme that we have built in house, recently the WordPress updater has started saying the theme is out of date. </p>
<p><a href="https://i.stack.imgur.com/e3FvV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e3FvV.png" alt="Update suggestion"></a></p>
<p>When I investiga... | [
{
"answer_id": 285341,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress infrastructure and default core code assumptions are really <em>really</em> unfriendly to private bespoke... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62753/"
] | We have a totally custom theme that we have built in house, recently the WordPress updater has started saying the theme is out of date.
[](https://i.stack.imgur.com/e3FvV.png)
When I investigated this supposed update it links me to a similarly named theme in t... | When it comes to developing your own stuff, it is always the best to make the code yours too, not just the copyright and such.
As @Rarst already pointed out, the first thing to check if the theme's folder. I faced the same issue before and changing the theme's folder fixed the issue for me.
But for future goods, you ... |
285,350 | <p>I'm currently working on creating my own templates with custom content to my wordpress site.</p>
<p>But I'm now struggling with getting the get_header(); function to work? </p>
<p>THIS IS WHAT I'M CALLING </p>
<pre><code><?php
/**
* Template Name: Register fangst
*
* @package WordPress
* @subpackage Salient
* ... | [
{
"answer_id": 285352,
"author": "ghoul",
"author_id": 131136,
"author_profile": "https://wordpress.stackexchange.com/users/131136",
"pm_score": 1,
"selected": false,
"text": "<p>First turn on debuggin by dropping the following code in your wp-config.php file </p>\n\n<pre><code>define( '... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285350",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129518/"
] | I'm currently working on creating my own templates with custom content to my wordpress site.
But I'm now struggling with getting the get\_header(); function to work?
THIS IS WHAT I'M CALLING
```
<?php
/**
* Template Name: Register fangst
*
* @package WordPress
* @subpackage Salient
* @since Salient-child
*/
get_he... | If you remove the exit; call on line 176, does it load? It seems that the footer.php file will never be loaded because you are exiting before reaching that file. |
285,353 | <p>If I submit a form with an action of <code>/wp-admin/admin-post.php</code>, is there a way to return form errors to the originating page?</p>
<p>My form has an input with the action set:</p>
<pre><code><input name="action" value="enquiry_form" />
</code></pre>
<p>I have an actions setup to manage the valida... | [
{
"answer_id": 309931,
"author": "Radovan Bezak",
"author_id": 38435,
"author_profile": "https://wordpress.stackexchange.com/users/38435",
"pm_score": 1,
"selected": false,
"text": "<p>You can send GET variables in the URL using wp_redirect.\nFor example:</p>\n\n<pre><code>wp_redirect( h... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285353",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48962/"
] | If I submit a form with an action of `/wp-admin/admin-post.php`, is there a way to return form errors to the originating page?
My form has an input with the action set:
```
<input name="action" value="enquiry_form" />
```
I have an actions setup to manage the validation:
```
add_action('admin_post_enquiry_form', '... | You can send GET variables in the URL using wp\_redirect.
For example:
```
wp_redirect( home_url() .'/form?result=error&reason=3');
```
As far as I know, yes, `admin-post` is the best-practices way to handle POST data in WordPress. |
285,359 | <p>I am pretty new to all things Wordpress and seem to be really confused by what I have read.</p>
<p>What I am doing is creating a plugin for a specific job and I need to simply change the menu once logged in. Now I am using DIVI 2 as a theme and I have this in the functions.php of the plugin:</p>
<pre><code>functi... | [
{
"answer_id": 285366,
"author": "BadAddy",
"author_id": 131139,
"author_profile": "https://wordpress.stackexchange.com/users/131139",
"pm_score": 1,
"selected": false,
"text": "<p>I managed to figure out what was causing it. But I find it odd that there is such little information on it... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131139/"
] | I am pretty new to all things Wordpress and seem to be really confused by what I have read.
What I am doing is creating a plugin for a specific job and I need to simply change the menu once logged in. Now I am using DIVI 2 as a theme and I have this in the functions.php of the plugin:
```
function my_wp_nav_menu_args... | `wp_authenticate()` just checks user data, but not actually authenticating - [docs](https://developer.wordpress.org/reference/functions/wp_authenticate/).
You can use `wp_signon`, which uses and `wp_authenticate`: [source](https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes/user.php#L33), like this:
```
... |
285,369 | <p>I am new to wordpress and StackExchange. I need to add alt attribute to all existing images for screen readers. But I have no idea which php file I need to work on.</p>
<p>Also, how does wordpress make pics? which php file do this job? Thanks!</p>
| [
{
"answer_id": 285366,
"author": "BadAddy",
"author_id": 131139,
"author_profile": "https://wordpress.stackexchange.com/users/131139",
"pm_score": 1,
"selected": false,
"text": "<p>I managed to figure out what was causing it. But I find it odd that there is such little information on it... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131151/"
] | I am new to wordpress and StackExchange. I need to add alt attribute to all existing images for screen readers. But I have no idea which php file I need to work on.
Also, how does wordpress make pics? which php file do this job? Thanks! | `wp_authenticate()` just checks user data, but not actually authenticating - [docs](https://developer.wordpress.org/reference/functions/wp_authenticate/).
You can use `wp_signon`, which uses and `wp_authenticate`: [source](https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes/user.php#L33), like this:
```
... |
285,370 | <p>Screenshot below says it all. I want to remove/hide this field from view so the user is unable to edit it. It comes from the User Role Editor plugin and I want to make the changes in functions.php in the child theme.</p>
<p>As far as I can tell the code that creates the option comes from plugin folder in ./include... | [
{
"answer_id": 286383,
"author": "Jason",
"author_id": 131150,
"author_profile": "https://wordpress.stackexchange.com/users/131150",
"pm_score": 2,
"selected": true,
"text": "<p>I figured it out and this may help others who may also be trying to remove options from within the dashboard. ... | 2017/11/08 | [
"https://wordpress.stackexchange.com/questions/285370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131150/"
] | Screenshot below says it all. I want to remove/hide this field from view so the user is unable to edit it. It comes from the User Role Editor plugin and I want to make the changes in functions.php in the child theme.
As far as I can tell the code that creates the option comes from plugin folder in ./includes/classes/u... | I figured it out and this may help others who may also be trying to remove options from within the dashboard. The concept is the same for any other item you may wish to remove. First you need to add a filter to your functions.php in your child theme. Then you set the function to false.
Here is the code:
```
// remove... |
285,382 | <p>My problem is one that i can't seem to find a solution to.</p>
<p>I have 2 Custom Post Types, <code>Mangas</code> and <code>Chapters</code>, every chapter published will <strong>always</strong> be connected to a manga via the ACF relationship field.</p>
<p>The current permalink structure for the chapter is <code>s... | [
{
"answer_id": 285400,
"author": "Amr Mohamed",
"author_id": 131027,
"author_profile": "https://wordpress.stackexchange.com/users/131027",
"pm_score": 0,
"selected": false,
"text": "<p>I think you need to use plugin <strong><a href=\"https://wordpress.org/plugins/custom-post-type-permali... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285382",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131003/"
] | My problem is one that i can't seem to find a solution to.
I have 2 Custom Post Types, `Mangas` and `Chapters`, every chapter published will **always** be connected to a manga via the ACF relationship field.
The current permalink structure for the chapter is `site.com/chapters/chapter-title` and what i want is `site.... | The following you could add as a plugin or into your themes `functions.php` file. What we need to do is add a rewrite tag, custom query var, and finally replace the rewrite tag with the related post slug. Some things may vary from my code to yours. I assume `chapters` is the post type slug and that the relational field... |
285,383 | <p>so, I am making progress on a button that disappears after a certain amount of time after being clicked like so: <a href="https://codepen.io/mso122591/pen/qVZYNN" rel="nofollow noreferrer">https://codepen.io/mso122591/pen/qVZYNN</a></p>
<p>The problem is that this approach uses jquery, which I can't seem to get to ... | [
{
"answer_id": 285400,
"author": "Amr Mohamed",
"author_id": 131027,
"author_profile": "https://wordpress.stackexchange.com/users/131027",
"pm_score": 0,
"selected": false,
"text": "<p>I think you need to use plugin <strong><a href=\"https://wordpress.org/plugins/custom-post-type-permali... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131157/"
] | so, I am making progress on a button that disappears after a certain amount of time after being clicked like so: <https://codepen.io/mso122591/pen/qVZYNN>
The problem is that this approach uses jquery, which I can't seem to get to work in wordpress.
Here are some resources to get jquery to work in wordpress (I notice... | The following you could add as a plugin or into your themes `functions.php` file. What we need to do is add a rewrite tag, custom query var, and finally replace the rewrite tag with the related post slug. Some things may vary from my code to yours. I assume `chapters` is the post type slug and that the relational field... |
285,391 | <p>I need to insert about 300 posts into the DB programmatically.</p>
<p>Usually i use wp_insert_post to do this job with one record each time, but this time I don't think it'll work well with hundreds of rows. </p>
<p>According to <a href="https://dev.mysql.com/doc/refman/5.7/en/insert-optimization.html" rel="nofoll... | [
{
"answer_id": 285423,
"author": "Jim-miraidev",
"author_id": 130369,
"author_profile": "https://wordpress.stackexchange.com/users/130369",
"pm_score": 2,
"selected": false,
"text": "<p>I would advise using wp_insert_post() and putting you text files into a CSV</p>\n\n<p>CSV</p>\n\n<pre>... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285391",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124860/"
] | I need to insert about 300 posts into the DB programmatically.
Usually i use wp\_insert\_post to do this job with one record each time, but this time I don't think it'll work well with hundreds of rows.
According to [this](https://dev.mysql.com/doc/refman/5.7/en/insert-optimization.html), it will probably be faster ... | I would advise using wp\_insert\_post() and putting you text files into a CSV
CSV
```
Post Title,Post Content,
"title", "content",
"title", "content"...
```
PHP
```
$path = "/posts.csv";
//require __DIR__ . "$path";
$file = fopen(__DIR__ . $path, 'r');
while (($line = fgetcsv($file)) !== ... |
285,410 | <p>I would like to hide the contents of a specific post from showing. <code>remove_post_type_support</code>does not seem to work.</p>
<pre><code>add_action('template_redirect',array($this,'hide_post_contents'));
public funcion hide_post_contents()
{
if(is_single(3))
{
remove_post_type_support( 'post... | [
{
"answer_id": 285704,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": false,
"text": "<p>Your code doesn't seem to be trying to hide the content, but you can use <a href=\"https://developer.wordpr... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126924/"
] | I would like to hide the contents of a specific post from showing. `remove_post_type_support`does not seem to work.
```
add_action('template_redirect',array($this,'hide_post_contents'));
public funcion hide_post_contents()
{
if(is_single(3))
{
remove_post_type_support( 'post', 'title' );
}
}
``... | Your code doesn't seem to be trying to hide the content, but you can use [`the_content`](https://developer.wordpress.org/reference/functions/the_content/) filter to return an empty content if you are on a specific post page. For example:
```
add_filter('the_content', 'hide_post_contents');
function hide_post_contents... |
285,426 | <p>I want to change the woocommerce email header template with a new one so that I could add conditions in header template to get value from the dashboard (To change the color of header based on user input from the dashboard). I have created a plugin file to do so.</p>
<p>I have followed several tutorials and all I re... | [
{
"answer_id": 285704,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": false,
"text": "<p>Your code doesn't seem to be trying to hide the content, but you can use <a href=\"https://developer.wordpr... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285426",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130740/"
] | I want to change the woocommerce email header template with a new one so that I could add conditions in header template to get value from the dashboard (To change the color of header based on user input from the dashboard). I have created a plugin file to do so.
I have followed several tutorials and all I received is ... | Your code doesn't seem to be trying to hide the content, but you can use [`the_content`](https://developer.wordpress.org/reference/functions/the_content/) filter to return an empty content if you are on a specific post page. For example:
```
add_filter('the_content', 'hide_post_contents');
function hide_post_contents... |
285,435 | <p>I've added a template in my theme, I want to change page title using following code. but its change my menu titles also.
I'm unable to fix this issue. Please help.</p>
<pre><code>function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else ... | [
{
"answer_id": 285704,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": false,
"text": "<p>Your code doesn't seem to be trying to hide the content, but you can use <a href=\"https://developer.wordpr... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285435",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108953/"
] | I've added a template in my theme, I want to change page title using following code. but its change my menu titles also.
I'm unable to fix this issue. Please help.
```
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return ... | Your code doesn't seem to be trying to hide the content, but you can use [`the_content`](https://developer.wordpress.org/reference/functions/the_content/) filter to return an empty content if you are on a specific post page. For example:
```
add_filter('the_content', 'hide_post_contents');
function hide_post_contents... |
285,441 | <p>I have little experience with creating a Child Theme.
Just want to make some changes to css on the website.</p>
<p>When I use the inspect mode to see which CSS was being used, I saw it was still linking to the parent css. Do I have the right code for my functions.php?</p>
<p><a href="https://i.stack.imgur.com/BrhL... | [
{
"answer_id": 285704,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": false,
"text": "<p>Your code doesn't seem to be trying to hide the content, but you can use <a href=\"https://developer.wordpr... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131203/"
] | I have little experience with creating a Child Theme.
Just want to make some changes to css on the website.
When I use the inspect mode to see which CSS was being used, I saw it was still linking to the parent css. Do I have the right code for my functions.php?
[](h... | Your code doesn't seem to be trying to hide the content, but you can use [`the_content`](https://developer.wordpress.org/reference/functions/the_content/) filter to return an empty content if you are on a specific post page. For example:
```
add_filter('the_content', 'hide_post_contents');
function hide_post_contents... |
285,445 | <p>It appears that, on uploading, WP media library looks for certain spammy-looking filenames, and prevents these files from displaying. Is this a feature? Is it documented anywhere? Can it be disabled? (Googling turns up nothing.)</p>
<p>Explanation. Using a fresh installation of WordPress 4.8.3 on a new domain, I am... | [
{
"answer_id": 285704,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": false,
"text": "<p>Your code doesn't seem to be trying to hide the content, but you can use <a href=\"https://developer.wordpr... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131204/"
] | It appears that, on uploading, WP media library looks for certain spammy-looking filenames, and prevents these files from displaying. Is this a feature? Is it documented anywhere? Can it be disabled? (Googling turns up nothing.)
Explanation. Using a fresh installation of WordPress 4.8.3 on a new domain, I am publishin... | Your code doesn't seem to be trying to hide the content, but you can use [`the_content`](https://developer.wordpress.org/reference/functions/the_content/) filter to return an empty content if you are on a specific post page. For example:
```
add_filter('the_content', 'hide_post_contents');
function hide_post_contents... |
285,448 | <p>I am looking to add an extra ID to the output: <code><div id="NEWID" class="kalec"></code> if the shortcode is called with the value <code>no=0</code> i.e. <code>[photo no="0"]</code></p>
<p>I need to use an IF statement within my output but can't figure out the correct syntax.</p>
<pre><code> function phot... | [
{
"answer_id": 285704,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": false,
"text": "<p>Your code doesn't seem to be trying to hide the content, but you can use <a href=\"https://developer.wordpr... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285448",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am looking to add an extra ID to the output: `<div id="NEWID" class="kalec">` if the shortcode is called with the value `no=0` i.e. `[photo no="0"]`
I need to use an IF statement within my output but can't figure out the correct syntax.
```
function photo_shortcode($atts){
extract(shortcode_atts(array(
... | Your code doesn't seem to be trying to hide the content, but you can use [`the_content`](https://developer.wordpress.org/reference/functions/the_content/) filter to return an empty content if you are on a specific post page. For example:
```
add_filter('the_content', 'hide_post_contents');
function hide_post_contents... |
285,459 | <p>I want to extend my website in a way that is parallel to the wordpress theme.</p>
<p>Example:</p>
<p>My website with wordpress is at: <code>www.mywebsite.com</code>
By ftp I added a directory named <code>test</code>, in which there is a php file <code>test.php</code></p>
<p>The problem is that if I write in the u... | [
{
"answer_id": 285481,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>IIRC, you cannot execute 'plain' (non-WP-code) PHP code on a WordPress site. WP will use the URL as a ... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131211/"
] | I want to extend my website in a way that is parallel to the wordpress theme.
Example:
My website with wordpress is at: `www.mywebsite.com`
By ftp I added a directory named `test`, in which there is a php file `test.php`
The problem is that if I write in the url: `www.mywebsite.com/test/test.php` it redirects me to ... | Native WordPress rules are designed to ignore any existing files and directories, including arbitrary PHP scripts. This is literally what this part of directives mean:
```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
```
So under normal circumstances WP just shouldn't be involved with your... |
285,464 | <p>Today while working, I had tried to install <strong>Go Pricing</strong> Plugin from this website.</p>
<pre><code>https://www.downloadfreethemes.download/go-pricing-v3-3-8-wordpress-responsive-pricing-tables/
</code></pre>
<p>It was unsuccessful at the first time then I tried for several times but no result. then a... | [
{
"answer_id": 285468,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 3,
"selected": true,
"text": "<p>It's good that you've regained access to your website, but without any further action, you'll g... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285464",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128689/"
] | Today while working, I had tried to install **Go Pricing** Plugin from this website.
```
https://www.downloadfreethemes.download/go-pricing-v3-3-8-wordpress-responsive-pricing-tables/
```
It was unsuccessful at the first time then I tried for several times but no result. then after some time, my website went blank. ... | It's good that you've regained access to your website, but without any further action, you'll get hacked again. These are steps to take, in order to clean, and secure your site:
1. do not panic ( very important )
2. do not remove anything yourself
3. install and activate [WordFence Security](https://wordpress.org/plug... |
285,472 | <p>How do I run a get_posts query on an individual options page for my plugin and send those results to another function to populate the select fields?</p>
<p>I'm building a custom plugin that builds a vcard from custom fields on various post types. </p>
<p>On my options page, generated by CMB2, loaded on cmb2_admin... | [
{
"answer_id": 285468,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 3,
"selected": true,
"text": "<p>It's good that you've regained access to your website, but without any further action, you'll g... | 2017/11/09 | [
"https://wordpress.stackexchange.com/questions/285472",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131219/"
] | How do I run a get\_posts query on an individual options page for my plugin and send those results to another function to populate the select fields?
I'm building a custom plugin that builds a vcard from custom fields on various post types.
On my options page, generated by CMB2, loaded on cmb2\_admin\_init, I have v... | It's good that you've regained access to your website, but without any further action, you'll get hacked again. These are steps to take, in order to clean, and secure your site:
1. do not panic ( very important )
2. do not remove anything yourself
3. install and activate [WordFence Security](https://wordpress.org/plug... |
285,497 | <p>My parent theme has a do_shortcode function that automatically generates and displays content on the sidebar. i want to edit it and put some custom content there.. How to do it?</p>
| [
{
"answer_id": 285498,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 0,
"selected": false,
"text": "<p><code>do_shortcode</code> outputs shortcode which is created using <code>add_shortcode</code>, so find out ... | 2017/11/10 | [
"https://wordpress.stackexchange.com/questions/285497",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131241/"
] | My parent theme has a do\_shortcode function that automatically generates and displays content on the sidebar. i want to edit it and put some custom content there.. How to do it? | you can remove shortcode output using below function
```
remove_shortcode('shortcode_name')
```
<https://developer.wordpress.org/reference/functions/remove_shortcode/> |
285,522 | <p>I am very new to WordPress and I want to filter a list by gender.</p>
<p>Selecting a male option should filter the list to show only males with the relative information.</p>
<p>How can I achieve that?</p>
<pre><code>$list = array(
(object) array( 'name' => 'John', 'gender' => 'male', 'job' => 'Farmer' ),... | [
{
"answer_id": 285524,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p>There is a convenient helper function in WP core called <code>wp_list_filter()</code>.</p>\n\n<p>Easy as:</p>\n\n<pr... | 2017/11/10 | [
"https://wordpress.stackexchange.com/questions/285522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131258/"
] | I am very new to WordPress and I want to filter a list by gender.
Selecting a male option should filter the list to show only males with the relative information.
How can I achieve that?
```
$list = array(
(object) array( 'name' => 'John', 'gender' => 'male', 'job' => 'Farmer' ),
(object) array( 'name' => 'Paul', 'g... | There is a convenient helper function in WP core called `wp_list_filter()`.
Easy as:
```
$male = wp_list_filter( $list, [ 'gender' => 'male' ] );
``` |
285,532 | <p>I have the following code </p>
<pre><code> function stock_agenda() {
$days = json_decode(file_get_contents('json_file'));
unset($days[0]);
return '<table class="table">
<thead>
<tr>
<th> Title </th>
<th>Content</th>
<... | [
{
"answer_id": 285545,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 0,
"selected": false,
"text": "<p>You can use:</p>\n\n<pre><code>function stock_agenda() {\n\n $days = json_decode(file_get_contents('... | 2017/11/10 | [
"https://wordpress.stackexchange.com/questions/285532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92046/"
] | I have the following code
```
function stock_agenda() {
$days = json_decode(file_get_contents('json_file'));
unset($days[0]);
return '<table class="table">
<thead>
<tr>
<th> Title </th>
<th>Content</th>
<th>Date</th>
</tr>
</thead>
<tbody>
'. fo... | As I said in the comment you can use buffering like this
```
function stock_agenda() {
$days = json_decode(file_get_contents('json_file'));
unset($days[0]);
ob_start(); // start buffer
?>
<table class="table">
<thead>
<tr>
<th> Title </th>
<th>Con... |
285,569 | <p>I'm using 'Simply Show Hooks' plugin to spot various filters on a page. </p>
<p>I'm trying to remove the following filter's function (method): <code>UM_User_posts–>add_tab</code></p>
<p>Here's my <code>remove_filter</code> code so far:</p>
<pre><code>remove_filter( 'um_profile_tabs', '_____', 100);
</code></pr... | [
{
"answer_id": 285570,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>You need to know the name of the function that was hooked to the filter via the <code>add_filter()</code> comma... | 2017/11/10 | [
"https://wordpress.stackexchange.com/questions/285569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36830/"
] | I'm using 'Simply Show Hooks' plugin to spot various filters on a page.
I'm trying to remove the following filter's function (method): `UM_User_posts–>add_tab`
Here's my `remove_filter` code so far:
```
remove_filter( 'um_profile_tabs', '_____', 100);
```
How exactly would I include that function (method)? | When you see a hook callback described as `UM_User_posts–>add_tab`, you know there must be an `UM_User_posts` object somewhere. If `add_tab()` had been called statically, the callback description would be `UM_User_posts::add_tab`.
Now you need access to the same instance of the `UM_User_posts` class that the plugin is... |
285,583 | <p>Im currently working on a front end form using some code found here - <a href="https://wordpress.stackexchange.com/questions/7134/front-end-register-form">orginal</a></p>
<pre><code>add_action('template_redirect', 'register_a_user');
function register_a_user(){
if(isset($_GET['do']) && $_GET['do'] == 'reg... | [
{
"answer_id": 285630,
"author": "TurtleTread",
"author_id": 117263,
"author_profile": "https://wordpress.stackexchange.com/users/117263",
"pm_score": 0,
"selected": false,
"text": "<p>I see you are a designer, so you may not have had much experience with coding and database. From the is... | 2017/11/11 | [
"https://wordpress.stackexchange.com/questions/285583",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | Im currently working on a front end form using some code found here - [orginal](https://wordpress.stackexchange.com/questions/7134/front-end-register-form)
```
add_action('template_redirect', 'register_a_user');
function register_a_user(){
if(isset($_GET['do']) && $_GET['do'] == 'register'):
$errors = array();
... | With the help of something @TurtleTread said, I managed to get it working. My code was fine except had to change two things. I removed the custom field from my **$user\_data**, and added this after right after **wp\_insert\_user** --
```
add_user_meta($user_id, 'broker_email', $b_email);
```
Here's my final code ... |
285,586 | <p>I'm stuck in a strange situation right now. So I have my wordpress posts which belong to multiple categories. e.g one of my post belongs to two categories. One is 'News' category, and the other one is 'Top Bar'. (I use it to assign posts to the header posts area which fetches its articles from 'Top Bar' category.</p... | [
{
"answer_id": 285630,
"author": "TurtleTread",
"author_id": 117263,
"author_profile": "https://wordpress.stackexchange.com/users/117263",
"pm_score": 0,
"selected": false,
"text": "<p>I see you are a designer, so you may not have had much experience with coding and database. From the is... | 2017/11/11 | [
"https://wordpress.stackexchange.com/questions/285586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131209/"
] | I'm stuck in a strange situation right now. So I have my wordpress posts which belong to multiple categories. e.g one of my post belongs to two categories. One is 'News' category, and the other one is 'Top Bar'. (I use it to assign posts to the header posts area which fetches its articles from 'Top Bar' category.
The ... | With the help of something @TurtleTread said, I managed to get it working. My code was fine except had to change two things. I removed the custom field from my **$user\_data**, and added this after right after **wp\_insert\_user** --
```
add_user_meta($user_id, 'broker_email', $b_email);
```
Here's my final code ... |
285,593 | <p>I need to display all tag names in front end,I have tried </p>
<p><code>$terms=get_terms('product_tag');</code></p>
<p>But it returns null.</p>
<p>Can anyone please help me How to get it?</p>
| [
{
"answer_id": 285606,
"author": "Shamsur Rahman",
"author_id": 92258,
"author_profile": "https://wordpress.stackexchange.com/users/92258",
"pm_score": 3,
"selected": true,
"text": "<p>You need to loop through the array and create a separate array to check in_array because get_terms retu... | 2017/11/11 | [
"https://wordpress.stackexchange.com/questions/285593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116618/"
] | I need to display all tag names in front end,I have tried
`$terms=get_terms('product_tag');`
But it returns null.
Can anyone please help me How to get it? | You need to loop through the array and create a separate array to check in\_array because get\_terms return object with in array.
```
$terms = get_terms( 'product_tag' );
$term_array = array();
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
$term_array[] = $term->name;
... |
285,598 | <p>I want to show my new post published live in page without refresh. something like breaking news in blog websites.</p>
<p>How can i do this?
anybody knows?</p>
| [
{
"answer_id": 285606,
"author": "Shamsur Rahman",
"author_id": 92258,
"author_profile": "https://wordpress.stackexchange.com/users/92258",
"pm_score": 3,
"selected": true,
"text": "<p>You need to loop through the array and create a separate array to check in_array because get_terms retu... | 2017/11/11 | [
"https://wordpress.stackexchange.com/questions/285598",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89477/"
] | I want to show my new post published live in page without refresh. something like breaking news in blog websites.
How can i do this?
anybody knows? | You need to loop through the array and create a separate array to check in\_array because get\_terms return object with in array.
```
$terms = get_terms( 'product_tag' );
$term_array = array();
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
$term_array[] = $term->name;
... |
285,676 | <p>I recently set up a live WordPress site on my local environment through Duplicator. I can access the <code>wp-admin</code> but I cannot access the main site as wp redirects the site from <code>http</code> to <code>https</code> automatically. I checked the <code>.htaccess</code>, but no luck. I checked the <code>wp_o... | [
{
"answer_id": 285678,
"author": "Misha Rudrastyh",
"author_id": 85985,
"author_profile": "https://wordpress.stackexchange.com/users/85985",
"pm_score": 0,
"selected": false,
"text": "<p>Well, if you can access /wp-admin/, the solution is pretty simple - clean your browser cache or try t... | 2017/11/12 | [
"https://wordpress.stackexchange.com/questions/285676",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130633/"
] | I recently set up a live WordPress site on my local environment through Duplicator. I can access the `wp-admin` but I cannot access the main site as wp redirects the site from `http` to `https` automatically. I checked the `.htaccess`, but no luck. I checked the `wp_options` table and it has an entry of the site with `... | Well, at my situation... I downloaded the company website from production to localhost because I was needed to prepare a development environment for some developers. The production is using https:// and at localhost http://, and when I ran it the first time on localhost, it always redirected me to the https://.
And, I... |
285,682 | <p>The theme I am creating is not working correctly. The menu is not collapsing into mobile view with the hamburger icon when I decrease screen size. I can see all the classes when using the inspect tool on Chrome.</p>
<p>What I have tried:</p>
<ol>
<li>Compared the code to a theme I made as exercise and it looks exa... | [
{
"answer_id": 285678,
"author": "Misha Rudrastyh",
"author_id": 85985,
"author_profile": "https://wordpress.stackexchange.com/users/85985",
"pm_score": 0,
"selected": false,
"text": "<p>Well, if you can access /wp-admin/, the solution is pretty simple - clean your browser cache or try t... | 2017/11/12 | [
"https://wordpress.stackexchange.com/questions/285682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130103/"
] | The theme I am creating is not working correctly. The menu is not collapsing into mobile view with the hamburger icon when I decrease screen size. I can see all the classes when using the inspect tool on Chrome.
What I have tried:
1. Compared the code to a theme I made as exercise and it looks exactly the same.
2. Pa... | Well, at my situation... I downloaded the company website from production to localhost because I was needed to prepare a development environment for some developers. The production is using https:// and at localhost http://, and when I ran it the first time on localhost, it always redirected me to the https://.
And, I... |
285,699 | <p>I would like to implement a solution for fighting comment spam and the approach is simple. I would like that every comment that has the "website" field filled to be automatically marked as spam.</p>
<p>In addition, a small warning should be displayed before or after submission telling the user that his message will... | [
{
"answer_id": 285720,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 2,
"selected": false,
"text": "<p>If you don't want people filling website field, simply remove it from the form. Put this code ... | 2017/11/13 | [
"https://wordpress.stackexchange.com/questions/285699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131319/"
] | I would like to implement a solution for fighting comment spam and the approach is simple. I would like that every comment that has the "website" field filled to be automatically marked as spam.
In addition, a small warning should be displayed before or after submission telling the user that his message will be marked... | If you don't want people filling website field, simply remove it from the form. Put this code in `functions.php` of your current theme:
```
function wpse_remove_comment_url($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields', 'wpse_remove_comment_url');
```
It is mor... |
285,705 | <p>im trying to understand how Action Hooks and Filters work and have this example i want to edit</p>
<p>This function is in a parent theme framework php file:</p>
<pre><code>public function formatArticleCat01( $show_category = false, $shorten_text_chars = 300, $show_date = true, $show_comments = false, $show_author ... | [
{
"answer_id": 285707,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>Filters are for modifying the data, but actions are like bus stops where you can attach your functions to t... | 2017/11/13 | [
"https://wordpress.stackexchange.com/questions/285705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131383/"
] | im trying to understand how Action Hooks and Filters work and have this example i want to edit
This function is in a parent theme framework php file:
```
public function formatArticleCat01( $show_category = false, $shorten_text_chars = 300, $show_date = true, $show_comments = false, $show_author = false, $show_views ... | Filters are for modifying the data, but actions are like bus stops where you can attach your functions to theme and they will be run when the script reaches an specific state.
To use any of the above, they must be first declared somewhere. Let's take a look at this example from the codex page of [`apply_filters`](http... |
285,731 | <p>I have a small shortcode which basically takes data from a JSON file and displays it on a page. The data in JSON is updated weekly, how can I use a transient so the data for the current week is cached?</p>
<p>Here is my shortcode</p>
<pre><code>function week_agenda() {
$days = json_decode(file_get_contents... | [
{
"answer_id": 285733,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 3,
"selected": false,
"text": "<p>I add it the transient name to a variable to handle it easier.</p>\n\n<p>Next, I check if the return va... | 2017/11/13 | [
"https://wordpress.stackexchange.com/questions/285731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92046/"
] | I have a small shortcode which basically takes data from a JSON file and displays it on a page. The data in JSON is updated weekly, how can I use a transient so the data for the current week is cached?
Here is my shortcode
```
function week_agenda() {
$days = json_decode(file_get_contents('json_file'));
... | Use this instead of the line in wich you define `$days` (your second line):
```
$transient = get_transient( 'your_transient_key' );
if( !$transient ):
$days = file_get_contents( 'json_file' );
set_transient( 'your_transient_key', $days, DAY_IN_SECONDS*7 );
else:
$days = $transient;
endif;
$days = js... |
285,774 | <p><a href="http://fitclaw.com" rel="nofollow noreferrer">Fitclaw</a></p>
<p>I have problem with loading my css/js files. They're uploaded on ftp but i had to direct them with the whole path including domain because with ../ it didn't worked. That's for CSS. JS doesn't works i don't know why i please you to see the pa... | [
{
"answer_id": 285776,
"author": "socki03",
"author_id": 43511,
"author_profile": "https://wordpress.stackexchange.com/users/43511",
"pm_score": 2,
"selected": false,
"text": "<p>You seem to be loading both file/folder names into the queue.</p>\n\n<p><code>get_template_directory_uri() . ... | 2017/11/13 | [
"https://wordpress.stackexchange.com/questions/285774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131425/"
] | [Fitclaw](http://fitclaw.com)
I have problem with loading my css/js files. They're uploaded on ftp but i had to direct them with the whole path including domain because with ../ it didn't worked. That's for CSS. JS doesn't works i don't know why i please you to see the page source and i will upload here the functions.... | You seem to be loading both file/folder names into the queue.
`get_template_directory_uri() . 'http://fitclaw.com/wp-content/themes/Coming%20Soon/js/jquery.js`
should only be:
`get_template_directory_uri() . '/js/jquery.js'`
And so-on and so-forth.
because `get_template_directory_uri` returns, or should be returni... |
285,782 | <p>In several post titles I have "years" (eg: "Lorem ipsum - 2018"), it's not a problem. But in another part of the blog I call these titles in PHP:</p>
<p><code>$shortitle = wp_html_excerpt( get_the_title(), 23, '...' );
<div class="col-md-9">' . $shortitle . '</div></code>. </p>
<p>How could I remove th... | [
{
"answer_id": 285797,
"author": "Piyush Rawat",
"author_id": 73600,
"author_profile": "https://wordpress.stackexchange.com/users/73600",
"pm_score": 0,
"selected": false,
"text": "<p>I am making an assumption that all the titles have same pattern, i.e hyphen followed by the year.</p>\n\... | 2017/11/13 | [
"https://wordpress.stackexchange.com/questions/285782",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131396/"
] | In several post titles I have "years" (eg: "Lorem ipsum - 2018"), it's not a problem. But in another part of the blog I call these titles in PHP:
`$shortitle = wp_html_excerpt( get_the_title(), 23, '...' );
<div class="col-md-9">' . $shortitle . '</div>`.
How could I remove the display of years in titles ?
Thank yo... | Yes the problem is with the hyphen. WordPress converts hyphens with with spaces to en-dash. Following is the conversion with hyphens with WordPress:
>
> 1. Foo {3 hyphens, spaced} Bar → Foo — Bar (em-dash)
> 2. Foo{3 hyphens, no space}Bar → Foo—Bar (em-dash)
> 3. Foo {2 hyphens, spaced} Bar → Foo — Bar (em-dash)
> 4.... |
285,788 | <p>I've read an infinite (yes there seems to be more than I care to read) same articles on how to apply a classes to the anchor not the link element using <code>nav_menu_link_attributes</code> and a walker.</p>
<p>However, none of them implement the custom class option in the menu to be utilized on the anchor. Seems ... | [
{
"answer_id": 285797,
"author": "Piyush Rawat",
"author_id": 73600,
"author_profile": "https://wordpress.stackexchange.com/users/73600",
"pm_score": 0,
"selected": false,
"text": "<p>I am making an assumption that all the titles have same pattern, i.e hyphen followed by the year.</p>\n\... | 2017/11/13 | [
"https://wordpress.stackexchange.com/questions/285788",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131432/"
] | I've read an infinite (yes there seems to be more than I care to read) same articles on how to apply a classes to the anchor not the link element using `nav_menu_link_attributes` and a walker.
However, none of them implement the custom class option in the menu to be utilized on the anchor. Seems like a nice feature to... | Yes the problem is with the hyphen. WordPress converts hyphens with with spaces to en-dash. Following is the conversion with hyphens with WordPress:
>
> 1. Foo {3 hyphens, spaced} Bar → Foo — Bar (em-dash)
> 2. Foo{3 hyphens, no space}Bar → Foo—Bar (em-dash)
> 3. Foo {2 hyphens, spaced} Bar → Foo — Bar (em-dash)
> 4.... |
285,798 | <p>How to get last updated row or ID in wordpress.</p>
<p>Like : <code>$wpdb->insert_id;</code></p>
| [
{
"answer_id": 292439,
"author": "J.BizMai",
"author_id": 128094,
"author_profile": "https://wordpress.stackexchange.com/users/128094",
"pm_score": 1,
"selected": false,
"text": "<p>I had the same problem.</p>\n\n<blockquote>\n <p>There is no equivalent function. <code>$wpdb->insert_... | 2017/11/14 | [
"https://wordpress.stackexchange.com/questions/285798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108991/"
] | How to get last updated row or ID in wordpress.
Like : `$wpdb->insert_id;` | I had the same problem.
>
> There is no equivalent function. `$wpdb->insert_id` works only after `$wpdb->insert`
>
>
>
**Alternative way**
If it's an update, you can either get the id with a query based on the data you have got, or most of the time, you should have already got the id before update it.
```
glob... |
285,807 | <p>I'm creating a plugin where user can download files. Currently I display download links like:</p>
<pre><code><a href="plugin/directory/some/path/download.php?file_to_download_id=1">Some Download</a>
</code></pre>
<p><strong>Problem:</strong></p>
<p>I need to use wordpress core functionality like <code... | [
{
"answer_id": 285809,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": -1,
"selected": false,
"text": "<p>As you have mentioned the file is located in your plugins folder you do not need to add the wp-load.php... | 2017/11/14 | [
"https://wordpress.stackexchange.com/questions/285807",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129760/"
] | I'm creating a plugin where user can download files. Currently I display download links like:
```
<a href="plugin/directory/some/path/download.php?file_to_download_id=1">Some Download</a>
```
**Problem:**
I need to use wordpress core functionality like `is_user_logged_in()` or `get_current_user_id()` in the downloa... | You should create a function in your plugin where you listen to a specific URL or watch for specific parameters. For example to generate the download link:
```
<?php
$nonce = wp_create_nonce( 'download-' . $filename );
echo '<a href="/?_wp_nonce="' . $nonce . '&download=' . $filename . '">Some Download</a>';
?... |
285,844 | <p>I have the following form</p>
<pre><code><form name="interest_calculator" id="interest_calculator">
<input type="hidden" name="action" value="calculate_investor_interest" />
<div class="tab">
<h4><span class="badge">01<... | [
{
"answer_id": 285809,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": -1,
"selected": false,
"text": "<p>As you have mentioned the file is located in your plugins folder you do not need to add the wp-load.php... | 2017/11/14 | [
"https://wordpress.stackexchange.com/questions/285844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62852/"
] | I have the following form
```
<form name="interest_calculator" id="interest_calculator">
<input type="hidden" name="action" value="calculate_investor_interest" />
<div class="tab">
<h4><span class="badge">01</span> Investment Details</h4>
... | You should create a function in your plugin where you listen to a specific URL or watch for specific parameters. For example to generate the download link:
```
<?php
$nonce = wp_create_nonce( 'download-' . $filename );
echo '<a href="/?_wp_nonce="' . $nonce . '&download=' . $filename . '">Some Download</a>';
?... |
285,856 | <p>My need is to check if a page is subpage of a page (with ID).</p>
<p>I try to get this code working but it doesn't.</p>
<pre><code>function is_child($pageID) {
global $post;
echo $post->post_parent; // display the right ID!
if( is_page() && $post->post_parent == $pageID ) {
return true;
}... | [
{
"answer_id": 285866,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 3,
"selected": true,
"text": "<pre><code>/**\n * Return whether the current page is a child of $id\n *\n * Note: this function must be... | 2017/11/14 | [
"https://wordpress.stackexchange.com/questions/285856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85151/"
] | My need is to check if a page is subpage of a page (with ID).
I try to get this code working but it doesn't.
```
function is_child($pageID) {
global $post;
echo $post->post_parent; // display the right ID!
if( is_page() && $post->post_parent == $pageID ) {
return true;
} else {
return false;
}
}
``... | ```
/**
* Return whether the current page is a child of $id
*
* Note: this function must be run after the `wp` hook.
* Otherwise, the WP_Post object is not set up, and
* is_page() will return false.
*
* @param int $id The post ID of the parent page
* @return bool Whether the current page is a child page o... |
285,878 | <p>Let me begin by saying I know this is generally advised against but I'm in a tough spot at work where this is essentially being demanded and to my understanding it's theoretically possible.</p>
<p>I am tasked with transferring all user data from one WordPress site to another, and one of the stipulations is nobody w... | [
{
"answer_id": 285866,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 3,
"selected": true,
"text": "<pre><code>/**\n * Return whether the current page is a child of $id\n *\n * Note: this function must be... | 2017/11/14 | [
"https://wordpress.stackexchange.com/questions/285878",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131489/"
] | Let me begin by saying I know this is generally advised against but I'm in a tough spot at work where this is essentially being demanded and to my understanding it's theoretically possible.
I am tasked with transferring all user data from one WordPress site to another, and one of the stipulations is nobody would have ... | ```
/**
* Return whether the current page is a child of $id
*
* Note: this function must be run after the `wp` hook.
* Otherwise, the WP_Post object is not set up, and
* is_page() will return false.
*
* @param int $id The post ID of the parent page
* @return bool Whether the current page is a child page o... |
285,879 | <p>I have a question similar to <a href="https://wordpress.stackexchange.com/questions/274786/how-can-i-run-a-php-file-located-in-my-sites-root-folder">this one</a>: </p>
<p>I have created a small PHP program that I want to call as a rest web service to return some data from custom MySQL tables. </p>
<p>I can put it ... | [
{
"answer_id": 285883,
"author": "Lovin Nagi",
"author_id": 102970,
"author_profile": "https://wordpress.stackexchange.com/users/102970",
"pm_score": 1,
"selected": false,
"text": "<p>Move Wordpress from root folder into subdirectory and create a <code>.htaccess</code> file in root folde... | 2017/11/14 | [
"https://wordpress.stackexchange.com/questions/285879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2550/"
] | I have a question similar to [this one](https://wordpress.stackexchange.com/questions/274786/how-can-i-run-a-php-file-located-in-my-sites-root-folder):
I have created a small PHP program that I want to call as a rest web service to return some data from custom MySQL tables.
I can put it anywhere, but I've tried the... | Okay, I think I was mislead by this... I didn't read the code thoroughly that I cloned. It sets a 404 if the SQL fails. Duh! I also discovered a file called /custom/error\_log that I think is going to help debug that.
```
// die if SQL statement failed
if (!$result) {
http_response_code(404);
die(mysqli_error());... |
285,911 | <p>I am using a plugin which has the following code for a button:</p>
<pre><code><a class="bwg_load_btn_1 bwg_load_btn" href="javascript:void(0);">Load More...</a>
</code></pre>
<p>I would like to increase the size of the font used for the text to be 16x. How do I do this? I believe I need to add code to ... | [
{
"answer_id": 285915,
"author": "HeroWeb512",
"author_id": 102280,
"author_profile": "https://wordpress.stackexchange.com/users/102280",
"pm_score": 3,
"selected": true,
"text": "<p>You can solve this in two ways</p>\n\n<h1>No.1 to find the 'a' tag with class name ' bwg_load_btn_1 bwg_l... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/285911",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80040/"
] | I am using a plugin which has the following code for a button:
```
<a class="bwg_load_btn_1 bwg_load_btn" href="javascript:void(0);">Load More...</a>
```
I would like to increase the size of the font used for the text to be 16x. How do I do this? I believe I need to add code to my style.css for my theme but I am not... | You can solve this in two ways
No.1 to find the 'a' tag with class name ' bwg\_load\_btn\_1 bwg\_load\_btn ' in your plugin and add inline style like this
===========================================================================================================================
```
<a class="bwg_load_btn_1 bwg_load_b... |
285,942 | <p>How can I override add_filter of a plugin?</p>
<p><strong>like</strong> </p>
<pre><code>add_filter( 'wcml_switch_currency_exception', 'cart_switching_currency', 10, 4 );
</code></pre>
<p>I want to use my custom function instead "cart_switching_currency" function.</p>
| [
{
"answer_id": 285943,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"https://developer.wordpress.org/reference/functions/remove_filter/\" rel=\"nofollow n... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/285942",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128045/"
] | How can I override add\_filter of a plugin?
**like**
```
add_filter( 'wcml_switch_currency_exception', 'cart_switching_currency', 10, 4 );
```
I want to use my custom function instead "cart\_switching\_currency" function. | Filters come with a priority parameter, the default is 10, so to override a function you need to increase the priority:
```
add_filter( 'wcml_switch_currency_exception', 'cart_switching_currency', 99, 4 );
```
>
> add\_filter( string $tag, callable $function\_to\_add, int $priority =
> 10, int $accepted\_args = 1 ... |
285,955 | <p>So, what I am trying to do is creating a slideshow plugin that won't require end user to write a single line of code.
I can't use custom posts because I need to keep it simple for the end user.</p>
<p>Is there a hook or a filter that would let me include my php generated code right after the </p>
<blockquote>
<p... | [
{
"answer_id": 285943,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"https://developer.wordpress.org/reference/functions/remove_filter/\" rel=\"nofollow n... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/285955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4107/"
] | So, what I am trying to do is creating a slideshow plugin that won't require end user to write a single line of code.
I can't use custom posts because I need to keep it simple for the end user.
Is there a hook or a filter that would let me include my php generated code right after the
>
> body\_class() ?
>
>
>
... | Filters come with a priority parameter, the default is 10, so to override a function you need to increase the priority:
```
add_filter( 'wcml_switch_currency_exception', 'cart_switching_currency', 99, 4 );
```
>
> add\_filter( string $tag, callable $function\_to\_add, int $priority =
> 10, int $accepted\_args = 1 ... |
285,961 | <p>I have some trouble with Divi plugin. I need to change icon using content in css.
I add font awesome by cdn(it works on website e.g. <code><i class="fa fa-eercast" aria-hidden="true"></i></code> displays properly) but now I want to change existing icon from rss to instagram by changing a:before content t... | [
{
"answer_id": 285962,
"author": "Lovin Nagi",
"author_id": 102970,
"author_profile": "https://wordpress.stackexchange.com/users/102970",
"pm_score": -1,
"selected": false,
"text": "<p>you don't need to change css code, you can simply change the class to \"fa fa-instagram\" e.g:<code><... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/285961",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131177/"
] | I have some trouble with Divi plugin. I need to change icon using content in css.
I add font awesome by cdn(it works on website e.g. `<i class="fa fa-eercast" aria-hidden="true"></i>` displays properly) but now I want to change existing icon from rss to instagram by changing a:before content to instagram code: `et-soci... | In addition to content, you also need to specify font family. Otherwise the browser will use whatever font Divi has assigned to that icon, which is probably not Font Awesome.
```
.get-social-rss .icon:before {
content: '\f16d';
font-family: FontAwesome;
}
``` |
285,967 | <p>I've created a custom post type called 'award': </p>
<pre><code>function award_post_type() {
$labels = array(
'name' => 'Awards',
'singular_name' => 'Award'
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
's... | [
{
"answer_id": 285968,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 0,
"selected": false,
"text": "<p>Try initializing the post with <code>$next_posts->the_post()</code> instead of just <code>the_post()</code... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/285967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129417/"
] | I've created a custom post type called 'award':
```
function award_post_type() {
$labels = array(
'name' => 'Awards',
'singular_name' => 'Award'
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'supports' => array( 'title', '... | I've found the solution. The problem was I had a different number set for the `posts_per_page` parameter in the initial query and in the custom query I make via AJAX. In the code I provided `posts_per_page` is not even there because I'm using a few nested classes, so I've posted a stripped-down version of the code for ... |
285,994 | <p>My website keeps showing <strong>HTTP ERROR 500</strong> and I'm not sure what's causing it</p>
<p><strong><a href="http://igtsservice.com/" rel="nofollow noreferrer">Website URL</a></strong></p>
<p>I tried a couple of debugging ideas like removed my .htaccess and renaming the Plugins folder, but still no luck</p>... | [
{
"answer_id": 285968,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 0,
"selected": false,
"text": "<p>Try initializing the post with <code>$next_posts->the_post()</code> instead of just <code>the_post()</code... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/285994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131563/"
] | My website keeps showing **HTTP ERROR 500** and I'm not sure what's causing it
**[Website URL](http://igtsservice.com/)**
I tried a couple of debugging ideas like removed my .htaccess and renaming the Plugins folder, but still no luck
I check the **error\_log** file and here's what i found
```
[15-Nov-2017 17:47:35... | I've found the solution. The problem was I had a different number set for the `posts_per_page` parameter in the initial query and in the custom query I make via AJAX. In the code I provided `posts_per_page` is not even there because I'm using a few nested classes, so I've posted a stripped-down version of the code for ... |
285,998 | <p>I've used several tutorials and tried to apply various "solutions", but I'm still unable to get a custom role to edit their own posts for a custom type. </p>
<p>I created the role, which shows fine...</p>
<pre><code>function mymodule_create_role() {
add_role( 'resident', 'New Role', array(
'read' => true... | [
{
"answer_id": 285968,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 0,
"selected": false,
"text": "<p>Try initializing the post with <code>$next_posts->the_post()</code> instead of just <code>the_post()</code... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/285998",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131567/"
] | I've used several tutorials and tried to apply various "solutions", but I'm still unable to get a custom role to edit their own posts for a custom type.
I created the role, which shows fine...
```
function mymodule_create_role() {
add_role( 'resident', 'New Role', array(
'read' => true, // True allows that ca... | I've found the solution. The problem was I had a different number set for the `posts_per_page` parameter in the initial query and in the custom query I make via AJAX. In the code I provided `posts_per_page` is not even there because I'm using a few nested classes, so I've posted a stripped-down version of the code for ... |
286,004 | <p>I'm using Composer to install plugins with the wpackagist repository. I've added all the relevant lines to my <code>composer.json</code> file in my main <code>wp/</code> directory.</p>
<p>The plugin installed as expected (it's <a href="https://wordpress.org/plugins/members/" rel="nofollow noreferrer">this one</a> i... | [
{
"answer_id": 286009,
"author": "websupporter",
"author_id": 48693,
"author_profile": "https://wordpress.stackexchange.com/users/48693",
"pm_score": 2,
"selected": false,
"text": "<p>In order for WordPress to recognize a plugin it needs to be in the correct plugins folder.</p>\n\n<p>In ... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/286004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81297/"
] | I'm using Composer to install plugins with the wpackagist repository. I've added all the relevant lines to my `composer.json` file in my main `wp/` directory.
The plugin installed as expected (it's [this one](https://wordpress.org/plugins/members/) if it makes any difference) to its own folder within `wp/plugins/`.
T... | In order for WordPress to recognize a plugin it needs to be in the correct plugins folder.
In an usual installation this is wp-content/plugins/
If you use wpackagist.org, a working example would be this composer.json:
```
{
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
... |
286,014 | <p>I'd like to create a shortcode that would display the post count for a specific category within a custom post type. I've been trying to alter the code below but need some help. Could anyone let me know how to tweak so that the shortcode is for a specific custom post type.</p>
<pre>// Add Shortcode to show posts cou... | [
{
"answer_id": 286009,
"author": "websupporter",
"author_id": 48693,
"author_profile": "https://wordpress.stackexchange.com/users/48693",
"pm_score": 2,
"selected": false,
"text": "<p>In order for WordPress to recognize a plugin it needs to be in the correct plugins folder.</p>\n\n<p>In ... | 2017/11/15 | [
"https://wordpress.stackexchange.com/questions/286014",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39052/"
] | I'd like to create a shortcode that would display the post count for a specific category within a custom post type. I've been trying to alter the code below but need some help. Could anyone let me know how to tweak so that the shortcode is for a specific custom post type.
```
// Add Shortcode to show posts count insid... | In order for WordPress to recognize a plugin it needs to be in the correct plugins folder.
In an usual installation this is wp-content/plugins/
If you use wpackagist.org, a working example would be this composer.json:
```
{
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
... |
286,052 | <p>i add some custom meta field to product taxonomy "artist"
they work well and save to taxonomy</p>
<pre><code> /**
add meta data to artist taxonomy */
function artist_add_meta_fields( $taxonomy ) {
?>
<div class="form-field term-group">
<label for="artist_nickname"><?php _e( 'Ni... | [
{
"answer_id": 286056,
"author": "JoseLazo",
"author_id": 58041,
"author_profile": "https://wordpress.stackexchange.com/users/58041",
"pm_score": 3,
"selected": true,
"text": "<p>If you want to display in archive or category (taxonomy) template, try this:</p>\n\n<pre><code>$artist_nickna... | 2017/11/16 | [
"https://wordpress.stackexchange.com/questions/286052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131589/"
] | i add some custom meta field to product taxonomy "artist"
they work well and save to taxonomy
```
/**
add meta data to artist taxonomy */
function artist_add_meta_fields( $taxonomy ) {
?>
<div class="form-field term-group">
<label for="artist_nickname"><?php _e( 'Nickname', 'my-plugin' ); ?></labe... | If you want to display in archive or category (taxonomy) template, try this:
```
$artist_nickname = get_term_meta( get_queried_object_id(), 'artist_nickname', true);
echo $artist_nickname;
``` |
286,053 | <p>how do you create this customize menu using wp_nav_menu function? </p>
<p><strong>function.php file</strong></p>
<pre><code>register_nav_menus( array(
'header-menu' => 'Header Menu',
'footer-menu' => 'Footer Menu'
) );
</code></pre>
<p><strong>header.php file</strong></p>
<pre><code> <?php... | [
{
"answer_id": 286056,
"author": "JoseLazo",
"author_id": 58041,
"author_profile": "https://wordpress.stackexchange.com/users/58041",
"pm_score": 3,
"selected": true,
"text": "<p>If you want to display in archive or category (taxonomy) template, try this:</p>\n\n<pre><code>$artist_nickna... | 2017/11/16 | [
"https://wordpress.stackexchange.com/questions/286053",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | how do you create this customize menu using wp\_nav\_menu function?
**function.php file**
```
register_nav_menus( array(
'header-menu' => 'Header Menu',
'footer-menu' => 'Footer Menu'
) );
```
**header.php file**
```
<?php wp_nav_menu( array( 'theme_location' => 'header-menu', 'container' => '', ) ... | If you want to display in archive or category (taxonomy) template, try this:
```
$artist_nickname = get_term_meta( get_queried_object_id(), 'artist_nickname', true);
echo $artist_nickname;
``` |
286,061 | <p>Can anyone tell How to check User Role and redirect to specific page according to Role when login in Wordpress?</p>
<p>Thanks.</p>
| [
{
"answer_id": 286056,
"author": "JoseLazo",
"author_id": 58041,
"author_profile": "https://wordpress.stackexchange.com/users/58041",
"pm_score": 3,
"selected": true,
"text": "<p>If you want to display in archive or category (taxonomy) template, try this:</p>\n\n<pre><code>$artist_nickna... | 2017/11/16 | [
"https://wordpress.stackexchange.com/questions/286061",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131596/"
] | Can anyone tell How to check User Role and redirect to specific page according to Role when login in Wordpress?
Thanks. | If you want to display in archive or category (taxonomy) template, try this:
```
$artist_nickname = get_term_meta( get_queried_object_id(), 'artist_nickname', true);
echo $artist_nickname;
``` |
286,072 | <p>I want to set WP_MEMORY_LIMIT for my WordPress site. I use from shared hosting and CPanel. I have access to change something like max memory limit on my host. I attached related image in the following that you can see it:</p>
<p><a href="https://i.stack.imgur.com/iiI8H.jpg" rel="nofollow noreferrer"><img src="https... | [
{
"answer_id": 286076,
"author": "Piyush Rawat",
"author_id": 73600,
"author_profile": "https://wordpress.stackexchange.com/users/73600",
"pm_score": 4,
"selected": true,
"text": "<p>Need to set both the constants before ABSPATH is defined. Right after this line in wp-config.php</p>\n\n<... | 2017/11/16 | [
"https://wordpress.stackexchange.com/questions/286072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109454/"
] | I want to set WP\_MEMORY\_LIMIT for my WordPress site. I use from shared hosting and CPanel. I have access to change something like max memory limit on my host. I attached related image in the following that you can see it:
[](https://i.stack.imgur.co... | Need to set both the constants before ABSPATH is defined. Right after this line in wp-config.php
```
define( 'WP_DEBUG_LOG', true );
``` |
286,090 | <p>I'm trying to pull through a custom post with a custom categories and show only a specific slug.</p>
<p>e.g.
Custom Post (Job Board) - Custom Category (Job Sector) - Specific Slug (Industrial)</p>
<p>What I have show far is;</p>
<pre><code>$args = array(
'post_type' => 'post',
'tax_query' => array(... | [
{
"answer_id": 286094,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 1,
"selected": true,
"text": "<p>Try something like this:\nWith the post_type the name of your CPT</p>\n\n<pre><code>$args = array(\n ... | 2017/11/16 | [
"https://wordpress.stackexchange.com/questions/286090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124233/"
] | I'm trying to pull through a custom post with a custom categories and show only a specific slug.
e.g.
Custom Post (Job Board) - Custom Category (Job Sector) - Specific Slug (Industrial)
What I have show far is;
```
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxon... | Try something like this:
With the post\_type the name of your CPT
```
$args = array(
'post_type' => 'your_cpt_name',
'tax_query' => array(
array(
'taxonomy' => 'job-sector',
'field' => 'slug',
'terms' => 'industrial',
)
)
);
$query = new WP_Query( $args )... |
286,116 | <p>I want to give the backend-users only 4 text styles to choose from. Headline, Subheadline, Paragraph and a style we called <code>.statement</code>.</p>
<p>Searching for terms like "custom styles in TinyMCE" always ended up with this article from wordpress itself. <a href="https://codex.wordpress.org/TinyMCE_Custom_... | [
{
"answer_id": 286374,
"author": "Vlad K.",
"author_id": 109146,
"author_profile": "https://wordpress.stackexchange.com/users/109146",
"pm_score": 4,
"selected": true,
"text": "<p>I was having the same issue and here is what you can do. The code below disables the h1 tag from the block f... | 2017/11/16 | [
"https://wordpress.stackexchange.com/questions/286116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102487/"
] | I want to give the backend-users only 4 text styles to choose from. Headline, Subheadline, Paragraph and a style we called `.statement`.
Searching for terms like "custom styles in TinyMCE" always ended up with this article from wordpress itself. <https://codex.wordpress.org/TinyMCE_Custom_Styles>
[![enter image descr... | I was having the same issue and here is what you can do. The code below disables the h1 tag from the block formats section. The same way you can disable other tags and also add your own. But I'm not sure about how to add custom CSS styles to them. Hope this code will give you a hint in which way to dig.
```
//Modify T... |
286,126 | <p>According to the codex, to query posts that can belong to any of a collection of categories, we need to do something like this:</p>
<pre><code>$query = new WP_Query( array( 'cat' => '2,6,17,38' ) );
</code></pre>
<p><a href="https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters" rel="nofollow... | [
{
"answer_id": 286127,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 3,
"selected": true,
"text": "<p>I understand your confusion but you haven't something to worry about as behinds the scenes Wordpress mak... | 2017/11/16 | [
"https://wordpress.stackexchange.com/questions/286126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94213/"
] | According to the codex, to query posts that can belong to any of a collection of categories, we need to do something like this:
```
$query = new WP_Query( array( 'cat' => '2,6,17,38' ) );
```
<https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters>
However, I have the following, which works, and I... | I understand your confusion but you haven't something to worry about as behinds the scenes Wordpress make all the necessary steps to make it work.
For example, take the following code from the `class-wp-query.php`
```
// If querystring 'cat' is an array, implode it.
if ( is_array( $q['cat'] ) ) {
$q['cat'] = impl... |
286,142 | <p>I upgraded my dev environment to 4.9, and the customizer chokes on my _underscores-based theme. The customizer works fine on TwentySixteen, so I think there is a problem with my theme.</p>
<p>The tell was that the Customizer's Save & Publish button is missing entirely from the UI. Some other strange things happ... | [
{
"answer_id": 286146,
"author": "rg89",
"author_id": 13090,
"author_profile": "https://wordpress.stackexchange.com/users/13090",
"pm_score": 2,
"selected": true,
"text": "<p>I found the line of code in my theme that is breaking the customizer in 4.9. Behold!</p>\n\n<pre><code>$wp_custom... | 2017/11/16 | [
"https://wordpress.stackexchange.com/questions/286142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13090/"
] | I upgraded my dev environment to 4.9, and the customizer chokes on my \_underscores-based theme. The customizer works fine on TwentySixteen, so I think there is a problem with my theme.
The tell was that the Customizer's Save & Publish button is missing entirely from the UI. Some other strange things happen, like the ... | I found the line of code in my theme that is breaking the customizer in 4.9. Behold!
```
$wp_customize->remove_setting( 'header_textcolor' );
``` |
286,193 | <p>I am currently despairing on a for me very strange behaviour when echoing php values to html table cells.</p>
<p>I simply want to loop through an array and print out the values into a table but only some information is shown under special conditions.</p>
<p>Outside of the table the values are shown.</p>
<pre><cod... | [
{
"answer_id": 286194,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 0,
"selected": false,
"text": "<p>You have an error here <code>echo '<td>' . $tab4_arr->username; .'</td>';</code></p>\n\n... | 2017/11/17 | [
"https://wordpress.stackexchange.com/questions/286193",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131668/"
] | I am currently despairing on a for me very strange behaviour when echoing php values to html table cells.
I simply want to loop through an array and print out the values into a table but only some information is shown under special conditions.
Outside of the table the values are shown.
```
<?php
foreach ($mpbs_over... | You have an error here `echo '<td>' . $tab4_arr->username; .'</td>';`
Remove the **;** |
286,234 | <p>In the Header Image panel, there is a description that says:</p>
<p><em>Click “Add new image” to upload an image file from your computer. Your theme works best with an image with a header size of 1200 × 280 pixels — you’ll be able to crop your image once you upload it for a perfect fit.</em></p>
<p>I'm trying to c... | [
{
"answer_id": 286263,
"author": "Lovin Nagi",
"author_id": 102970,
"author_profile": "https://wordpress.stackexchange.com/users/102970",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function change_header_image_desc( $translated_text ) {\n if ( $translated_text == 'While you... | 2017/11/17 | [
"https://wordpress.stackexchange.com/questions/286234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40536/"
] | In the Header Image panel, there is a description that says:
*Click “Add new image” to upload an image file from your computer. Your theme works best with an image with a header size of 1200 × 280 pixels — you’ll be able to crop your image once you upload it for a perfect fit.*
I'm trying to change this text with thi... | The `description` param unfortunately is not used in this control. You can see that the message is [hard-coded in the control's template](https://github.com/WordPress/wordpress-develop/blob/4af1237176c326e7840361fd580fdc3f97841e6a/src/wp-includes/customize/class-wp-customize-header-image-control.php#L174). That should ... |
286,241 | <p>My english is not very good looking.<br>
I have several custom post types, 'noticias' (news) 'articulos' (articles), etc.
In my functions.php i enqueue scripts and styles by post_id or post_type using a code like this:</p>
<pre><code>function mahg_scripts_by_page() {
global $post;
$page_id = $post->ID;
... | [
{
"answer_id": 286247,
"author": "mhuenchul",
"author_id": 131691,
"author_profile": "https://wordpress.stackexchange.com/users/131691",
"pm_score": -1,
"selected": false,
"text": "<p>Well, i found a solution in order to load scripts and styles in custom post types archive page, using <c... | 2017/11/17 | [
"https://wordpress.stackexchange.com/questions/286241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131691/"
] | My english is not very good looking.
I have several custom post types, 'noticias' (news) 'articulos' (articles), etc.
In my functions.php i enqueue scripts and styles by post\_id or post\_type using a code like this:
```
function mahg_scripts_by_page() {
global $post;
$page_id = $post->ID;
$post_type = ... | The global `$post` object represents the current post within [The Loop](https://codex.wordpress.org/The_Loop) and is created by the `the_post()` function. It enables functions like `the_title()`, `the_content()` etc. to show the title and content for the current post without needing to pass IDs or anything.
This is wh... |
286,262 | <p>I am using a Repeater of Advance custom field for the content of the my additional custom WooCommerce Tab. The repeater is inside a group field. I manage to display the custom fields that is outside the repeater field. Now the problem is the field inside my repeater field. The repeater field is not displaying. Here ... | [
{
"answer_id": 286247,
"author": "mhuenchul",
"author_id": 131691,
"author_profile": "https://wordpress.stackexchange.com/users/131691",
"pm_score": -1,
"selected": false,
"text": "<p>Well, i found a solution in order to load scripts and styles in custom post types archive page, using <c... | 2017/11/18 | [
"https://wordpress.stackexchange.com/questions/286262",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130624/"
] | I am using a Repeater of Advance custom field for the content of the my additional custom WooCommerce Tab. The repeater is inside a group field. I manage to display the custom fields that is outside the repeater field. Now the problem is the field inside my repeater field. The repeater field is not displaying. Here is ... | The global `$post` object represents the current post within [The Loop](https://codex.wordpress.org/The_Loop) and is created by the `the_post()` function. It enables functions like `the_title()`, `the_content()` etc. to show the title and content for the current post without needing to pass IDs or anything.
This is wh... |
286,268 | <p>I am working on a WordPress theme and need to allow theme users to set different values for some controls for each device (desktop, tablet, mobile) I am thinking to show/hide device specific variant of some controls on the basis of what device/size user is previewing in customizer (desktop, tablet, mobile).</p>
<p>... | [
{
"answer_id": 286294,
"author": "Weston Ruter",
"author_id": 8521,
"author_profile": "https://wordpress.stackexchange.com/users/8521",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not familiar working with Kikri, but I've made a <a href=\"https://gist.github.com/westonruter/26ea572... | 2017/11/18 | [
"https://wordpress.stackexchange.com/questions/286268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42696/"
] | I am working on a WordPress theme and need to allow theme users to set different values for some controls for each device (desktop, tablet, mobile) I am thinking to show/hide device specific variant of some controls on the basis of what device/size user is previewing in customizer (desktop, tablet, mobile).
Is there a... | I'm not familiar working with Kikri, but I've made a [standalone example plugin](https://gist.github.com/westonruter/26ea57217efc074b2a948e32a61897f9) that shows the approach I'd use to get controls to be contextual based on the previewed device.
The plugin adds colored outlines around each element in the site, with ... |
286,271 | <p>I have two machines: local and deployment.</p>
<p>On my local machine I have the code: </p>
<pre><code>$all_prods = array(
'posts_per_page' => -1,
'post_type' => 'product',
);
dump(query_posts($all_prods));
</code></pre>
<p>The result I'm getting is my three products, that I've created earlier... | [
{
"answer_id": 286273,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 2,
"selected": false,
"text": "<p>First I would state that in most cases the <code>query_posts</code> should be avoided!</p>\n\n<blockquo... | 2017/11/18 | [
"https://wordpress.stackexchange.com/questions/286271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130777/"
] | I have two machines: local and deployment.
On my local machine I have the code:
```
$all_prods = array(
'posts_per_page' => -1,
'post_type' => 'product',
);
dump(query_posts($all_prods));
```
The result I'm getting is my three products, that I've created earlier.
But the same code on deployment machi... | I've found the solution.
```
$query = new WP_Query();
$all_prods = array(
'posts_per_page' => -1,
'post_type' => 'product',
);
$query = new WP_Query($all_prods);
echo $query->request . '<BR>';
```
The output was different on 2 machines, there was a problem with a multilanguage plugin that automatically ... |
286,320 | <p>I'm planning on enforcing a rule in my project to write the codes for a single filter or hook in a single function for easier code maintenance, so instead of having</p>
<pre><code>add_filter('wp','function_a');
function_a() {
//code A goes here
}
add_filter('wp','function_b');
function_b() {
//code B goes ... | [
{
"answer_id": 286273,
"author": "Drupalizeme",
"author_id": 115005,
"author_profile": "https://wordpress.stackexchange.com/users/115005",
"pm_score": 2,
"selected": false,
"text": "<p>First I would state that in most cases the <code>query_posts</code> should be avoided!</p>\n\n<blockquo... | 2017/11/19 | [
"https://wordpress.stackexchange.com/questions/286320",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131733/"
] | I'm planning on enforcing a rule in my project to write the codes for a single filter or hook in a single function for easier code maintenance, so instead of having
```
add_filter('wp','function_a');
function_a() {
//code A goes here
}
add_filter('wp','function_b');
function_b() {
//code B goes here
}
```
I... | I've found the solution.
```
$query = new WP_Query();
$all_prods = array(
'posts_per_page' => -1,
'post_type' => 'product',
);
$query = new WP_Query($all_prods);
echo $query->request . '<BR>';
```
The output was different on 2 machines, there was a problem with a multilanguage plugin that automatically ... |
286,332 | <p>My debug.log has the following message that points to /wp-includes/shortcodes.php on line 319, which is part of WordPress core and probably isn't where the real error is in the code.</p>
<pre><code>PHP Deprecated: Non-static method RSSjbClass::RSSjb_funct() should not be called statically in /.../wp-includes/short... | [
{
"answer_id": 286333,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 4,
"selected": true,
"text": "<p>Shortcodes are a WordPress thing, hence not being in the PHP manual. What you <em>do</em> want to look a... | 2017/11/19 | [
"https://wordpress.stackexchange.com/questions/286332",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/130475/"
] | My debug.log has the following message that points to /wp-includes/shortcodes.php on line 319, which is part of WordPress core and probably isn't where the real error is in the code.
```
PHP Deprecated: Non-static method RSSjbClass::RSSjb_funct() should not be called statically in /.../wp-includes/shortcodes.php on l... | Shortcodes are a WordPress thing, hence not being in the PHP manual. What you *do* want to look at in the PHP manual is the [section on callbacks](http://php.net/manual/en/language.types.callable.php). `add_shortcode()` accepts a shortcode name, and a *callback*. In that section of the PHP manual you can see the 3 main... |
286,334 | <p>I've recently uploaded my wordpress project to my web hosting and images arent showing properly, the source for the images is adding a %20 suffix to my theme directory.</p>
<p>this is the error thats thrown in console</p>
<pre><code> GET http://sixten.thrillcode.com/wp-content/themes/shapely%20/img/slideshow1.jp... | [
{
"answer_id": 286335,
"author": "Jefferson Silva",
"author_id": 130008,
"author_profile": "https://wordpress.stackexchange.com/users/130008",
"pm_score": 3,
"selected": true,
"text": "<p>There's a space after the word \"shapely\". You must remove that, spaces and special characters are ... | 2017/11/19 | [
"https://wordpress.stackexchange.com/questions/286334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131740/"
] | I've recently uploaded my wordpress project to my web hosting and images arent showing properly, the source for the images is adding a %20 suffix to my theme directory.
this is the error thats thrown in console
```
GET http://sixten.thrillcode.com/wp-content/themes/shapely%20/img/slideshow1.jpg 404 (Not Found)
``... | There's a space after the word "shapely". You must remove that, spaces and special characters are encoded when used in URL's.
Most probably this space is in the directory name, rename it and it will solve the problem |
286,346 | <p>I'm using the following to enqueu an admin style:</p>
<pre><code>wp_enqueue_style('pk-admin-css', PULUGIN_URL . 'css/admin.css');
</code></pre>
<p>This outputs the style file appended with the ?=ver parameter which results in the file loading with no content.</p>
<p>I can fix this by removing that parameter like ... | [
{
"answer_id": 286345,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": true,
"text": "<p>You don't have to use the <code>register_activation_hook</code> or <code>register_deactivation_hook</code> h... | 2017/11/19 | [
"https://wordpress.stackexchange.com/questions/286346",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131331/"
] | I'm using the following to enqueu an admin style:
```
wp_enqueue_style('pk-admin-css', PULUGIN_URL . 'css/admin.css');
```
This outputs the style file appended with the ?=ver parameter which results in the file loading with no content.
I can fix this by removing that parameter like so:
```
wp_enqueue_style('pk-adm... | You don't have to use the `register_activation_hook` or `register_deactivation_hook` hook, they are optional. As their name suggests, they are hooks planned to run a task on plugin's activation/deactivation, such as updating the status of all users for some purpose.
So, if your plugin doesn't require such tasks, then ... |
286,382 | <p>I want to create a table show all post, I use WP_query to get all iformatio and create table template to list my post. But my problem is only one post inside the table.. I want to include all in table.</p>
<pre><code>$wpb_all_query = new WP_Query(array('post_type'=>'vendor_management', 'post_status'=>'new', '... | [
{
"answer_id": 286351,
"author": "Apurba Podder",
"author_id": 113734,
"author_profile": "https://wordpress.stackexchange.com/users/113734",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, Absolutely you can switch themes on a fully built website. All data remain same. No need to rese... | 2017/11/20 | [
"https://wordpress.stackexchange.com/questions/286382",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126689/"
] | I want to create a table show all post, I use WP\_query to get all iformatio and create table template to list my post. But my problem is only one post inside the table.. I want to include all in table.
```
$wpb_all_query = new WP_Query(array('post_type'=>'vendor_management', 'post_status'=>'new', 'posts_per_page'=>-1... | The rule of thumb is that the more complex your theme is, the harder it will be to replace it with another. Themes should be only about styling your content, nothing more, and everything relating to content itself should be handled in plugins.
Unfortunately, most people think that all themes should come with everythin... |
286,411 | <pre><code>function blog_post_home_shortcode() {
$query = new WP_Query( array(
'post_type' => 'post',
'order' => 'DESC',
'post_status' => ' publish',
'posts_per_page' => 3
));
while ($query->have_posts()): $query->the_post();
$blog = get_the_title();
re... | [
{
"answer_id": 286413,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": -1,
"selected": true,
"text": "<p>You may please update your code as follows </p>\n\n<pre><code> function blog_post_home_shortcode() {\n... | 2017/11/20 | [
"https://wordpress.stackexchange.com/questions/286411",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128369/"
] | ```
function blog_post_home_shortcode() {
$query = new WP_Query( array(
'post_type' => 'post',
'order' => 'DESC',
'post_status' => ' publish',
'posts_per_page' => 3
));
while ($query->have_posts()): $query->the_post();
$blog = get_the_title();
return $blog;
endwhile;
... | You may please update your code as follows
```
function blog_post_home_shortcode() {
$query = new WP_Query( array(
'post_type' => 'post',
'order' => 'DESC',
'post_status' => ' publish',
'posts_per_page' => 3
));
while ($query->have_posts()): $query->the_post();
$blog ... |
286,416 | <p>Please refer to website: <a href="https://virginiafrank.com" rel="nofollow noreferrer">https://virginiafrank.com</a>
I cannot get the top header background color (or phone numbers) to change color. I would prefer the background gold and text black. I can't make that work either. Please someone help me. </p>
| [
{
"answer_id": 286413,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": -1,
"selected": true,
"text": "<p>You may please update your code as follows </p>\n\n<pre><code> function blog_post_home_shortcode() {\n... | 2017/11/20 | [
"https://wordpress.stackexchange.com/questions/286416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131784/"
] | Please refer to website: <https://virginiafrank.com>
I cannot get the top header background color (or phone numbers) to change color. I would prefer the background gold and text black. I can't make that work either. Please someone help me. | You may please update your code as follows
```
function blog_post_home_shortcode() {
$query = new WP_Query( array(
'post_type' => 'post',
'order' => 'DESC',
'post_status' => ' publish',
'posts_per_page' => 3
));
while ($query->have_posts()): $query->the_post();
$blog ... |
286,419 | <p>I created a wp cron event with a custom interval of 5 minutes, but it is only executed hourly instead of every 5 minutes. (The callback is properly executed.)</p>
<p><a href="https://i.stack.imgur.com/hDeUJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hDeUJ.jpg" alt="screenshot from wp crontro... | [
{
"answer_id": 305977,
"author": "Shwky Fareed",
"author_id": 143913,
"author_profile": "https://wordpress.stackexchange.com/users/143913",
"pm_score": -1,
"selected": false,
"text": "<p>I know that this answer may not help you now because it's too late :)\nBut here's a full example for ... | 2017/11/20 | [
"https://wordpress.stackexchange.com/questions/286419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124308/"
] | I created a wp cron event with a custom interval of 5 minutes, but it is only executed hourly instead of every 5 minutes. (The callback is properly executed.)
[](https://i.stack.imgur.com/hDeUJ.jpg)
The DISABLE\_WP\_CRON constant is set to true... | Maybe someone will make use of it, I had a similar problem and the solution was to call `time()` instead of `current_time( 'timestamp' )` as the first argument of `wp_schedule_event()`.
So it should look like this: `wp_schedule_event( time(), 'custom_interval', 'custom_hook' );`
I tried to find a difference between t... |