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 |
|---|---|---|---|---|---|---|
228,588 | <p>My theme is a very small one page theme which really doesn't need all the scripts, so I've created a few options to remove <code>wp_head()</code> and <code>wp_footer()</code> so the user can choose if they want to enable or disable those.</p>
<p>However, my site does use the <code>custom_background()</code> feature... | [
{
"answer_id": 228592,
"author": "Ismail",
"author_id": 70833,
"author_profile": "https://wordpress.stackexchange.com/users/70833",
"pm_score": 3,
"selected": true,
"text": "<p><code>custom_background()</code> places the CSS to <code>wp_head()</code> as you mentioned so to get those CSS ... | 2016/06/02 | [
"https://wordpress.stackexchange.com/questions/228588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94984/"
] | My theme is a very small one page theme which really doesn't need all the scripts, so I've created a few options to remove `wp_head()` and `wp_footer()` so the user can choose if they want to enable or disable those.
However, my site does use the `custom_background()` feature which is placed in the `wp_head()` so when... | `custom_background()` places the CSS to `wp_head()` as you mentioned so to get those CSS as if you don't have `wp_head()` in your header, these tweaks from the core files would help:
```
function wpse_228588_background_image_css() {
$background_styles = '';
if ( $bgcolor = get_background_color() )
$bac... |
228,589 | <p>I would like to link a user to a custom post type (college). Does anyone know a good way to do this?</p>
<p>The ultimate goal is to display links to view and edit their college</p>
<p>I've been using Advanced Custom Fields but none of the Relational fields seem to support linking users</p>
| [
{
"answer_id": 228721,
"author": "kcbluewave890",
"author_id": 95196,
"author_profile": "https://wordpress.stackexchange.com/users/95196",
"pm_score": 2,
"selected": false,
"text": "<p>if you are trying to link up the post in the user profile area, the code below might be a good starting... | 2016/06/02 | [
"https://wordpress.stackexchange.com/questions/228589",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51830/"
] | I would like to link a user to a custom post type (college). Does anyone know a good way to do this?
The ultimate goal is to display links to view and edit their college
I've been using Advanced Custom Fields but none of the Relational fields seem to support linking users | if you are trying to link up the post in the user profile area, the code below might be a good starting point. You could put this in your functions.php file. The first function displays a select tag with all the posts from your custom post type in the user profile section. The option value is the post id, and the title... |
228,591 | <p>I'm following <a href="http://codex.wordpress.org/Changing_File_Permissions#Permission_Scheme_for_WordPress" rel="noreferrer">Changing File Permissions « WordPress Codex</a>, yet when I'm try to update and/or install <code>plugin</code> and/or <code>theme</code> through <code>wp-admin</code>, I'm getting following:<... | [
{
"answer_id": 228643,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>Not a direct answer, but probably has to be said - this is one problem you should avoid solving unless yo... | 2016/06/02 | [
"https://wordpress.stackexchange.com/questions/228591",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3255/"
] | I'm following [Changing File Permissions « WordPress Codex](http://codex.wordpress.org/Changing_File_Permissions#Permission_Scheme_for_WordPress), yet when I'm try to update and/or install `plugin` and/or `theme` through `wp-admin`, I'm getting following:
>
> To perform the requested action, WordPress needs to access... | Add the following to wp-config.php:
```
define( 'FS_METHOD', 'direct' );
```
Let me know how it works for you. |
228,595 | <p>The scenario is that I need to add an HTML banner under a slideshow which is a shortcode in the homepage content. I personally hate adding a bunch of <code>div</code> tags to the TinyMCE editor so I'm trying to filter <code>the_content</code> and add my HTML after the specific shortcode. Below is a solution but I wa... | [
{
"answer_id": 228596,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": false,
"text": "<p>This is a solution I've come up with after refining it a bit. The below <em>should</em> only run if the sho... | 2016/06/02 | [
"https://wordpress.stackexchange.com/questions/228595",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | The scenario is that I need to add an HTML banner under a slideshow which is a shortcode in the homepage content. I personally hate adding a bunch of `div` tags to the TinyMCE editor so I'm trying to filter `the_content` and add my HTML after the specific shortcode. Below is a solution but I wasn't sure if there was a ... | I wonder if you could override the `[rev_slider]` with this kind of wrapper:
```php
add_shortcode( 'rev_slider', function( $atts = array(), $content = '' )
{
$html = '';
// Your custom banner HTML
$banner = '<div id="bannerHTML"><!-- banner HTML goes here --></div>';
// Append your banner HTML to the... |
228,633 | <p>I'm using a customized wordpress loop which allows me to style the post a certain way after a certain amount of post. For example, The first three post will be styled the same, the next 4 post will styled differently from the first three and so forth. It also allows me to add <code><div></code> sections betwee... | [
{
"answer_id": 228596,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": false,
"text": "<p>This is a solution I've come up with after refining it a bit. The below <em>should</em> only run if the sho... | 2016/06/03 | [
"https://wordpress.stackexchange.com/questions/228633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/95154/"
] | I'm using a customized wordpress loop which allows me to style the post a certain way after a certain amount of post. For example, The first three post will be styled the same, the next 4 post will styled differently from the first three and so forth. It also allows me to add `<div>` sections between the post.
Here is... | I wonder if you could override the `[rev_slider]` with this kind of wrapper:
```php
add_shortcode( 'rev_slider', function( $atts = array(), $content = '' )
{
$html = '';
// Your custom banner HTML
$banner = '<div id="bannerHTML"><!-- banner HTML goes here --></div>';
// Append your banner HTML to the... |
228,639 | <p>I can't figure out the the code for - How to retain the values from dropdown category lists after wrong form submission? Any suggesstions, thanx in advance.</p>
<pre><code><select class="selectpicker btn-block" name="coupon_cat" id="category" >
<o... | [
{
"answer_id": 228644,
"author": "Ashok Dhaduk",
"author_id": 81215,
"author_profile": "https://wordpress.stackexchange.com/users/81215",
"pm_score": 0,
"selected": false,
"text": "<p>You can check with $_REQUEST['coupon_cat'], Which gives value of selected category then compare it with ... | 2016/06/03 | [
"https://wordpress.stackexchange.com/questions/228639",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93692/"
] | I can't figure out the the code for - How to retain the values from dropdown category lists after wrong form submission? Any suggesstions, thanx in advance.
```
<select class="selectpicker btn-block" name="coupon_cat" id="category" >
<option selected value=""... | Like Ash was saying, something like this using $\_REQUEST or $\_POST will do it.
```
<?php
$args['exclude'] = "12,20"; // omit these two categories
$categories = get_categories($args);
?>
<select class="selectpicker btn-block" name="coupon_cat" id="category">
<option value="">Категори Сонгох</option> <!-- if not... |
228,668 | <p>I must disable a discount plugin for certain user role, I have wrote this and put in the child-theme <code>functions.php</code></p>
<pre><code>global $woocommerce;
get_currentuserinfo();
global $current_user;
if ($current_user->ID) {
$user_roles = $current_user->roles;
$user_role = array_shift($user... | [
{
"answer_id": 228684,
"author": "TomC",
"author_id": 36980,
"author_profile": "https://wordpress.stackexchange.com/users/36980",
"pm_score": 2,
"selected": true,
"text": "<p>You should use the <code>wc_payment_discounts_apply_discount filter</code>. </p>\n\n<p>Try something like the fol... | 2016/06/03 | [
"https://wordpress.stackexchange.com/questions/228668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94422/"
] | I must disable a discount plugin for certain user role, I have wrote this and put in the child-theme `functions.php`
```
global $woocommerce;
get_currentuserinfo();
global $current_user;
if ($current_user->ID) {
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
if ($user_role ==... | You should use the `wc_payment_discounts_apply_discount filter`.
Try something like the following:
```
function remove_privato_discounts() {
global $woocommerce;
get_currentuserinfo();
global $current_user;
if ($current_user->ID) {
$user_roles = $current_user->roles;
$user_role ... |
228,686 | <p>I'm trying to show a text area in my customizer, only when a checkbox is selected.
I followed instruction at this post, but my textarea stays hidden.
Any help will be super appreciated!
Thank you</p>
<pre><code>function map_enabled(){
$tsum_options = get_theme_mod( 'tsum_options');
if( empty( $tsum_options['map_co... | [
{
"answer_id": 228684,
"author": "TomC",
"author_id": 36980,
"author_profile": "https://wordpress.stackexchange.com/users/36980",
"pm_score": 2,
"selected": true,
"text": "<p>You should use the <code>wc_payment_discounts_apply_discount filter</code>. </p>\n\n<p>Try something like the fol... | 2016/06/03 | [
"https://wordpress.stackexchange.com/questions/228686",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/95181/"
] | I'm trying to show a text area in my customizer, only when a checkbox is selected.
I followed instruction at this post, but my textarea stays hidden.
Any help will be super appreciated!
Thank you
```
function map_enabled(){
$tsum_options = get_theme_mod( 'tsum_options');
if( empty( $tsum_options['map_code'] ) ) {
... | You should use the `wc_payment_discounts_apply_discount filter`.
Try something like the following:
```
function remove_privato_discounts() {
global $woocommerce;
get_currentuserinfo();
global $current_user;
if ($current_user->ID) {
$user_roles = $current_user->roles;
$user_role ... |
228,690 | <p><strong>Intro</strong></p>
<p>I have a settings page which includes a setting with a more complicated callback function to save.</p>
<p><strong>Save data</strong></p>
<p>To save the data I use the <code>register_setting()</code> function with a custom sanitize callback. I implemented it exactly as the WordPress s... | [
{
"answer_id": 228711,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>This is just a hunch, but it seems to me that this problem has something to do with the order in which the opera... | 2016/06/03 | [
"https://wordpress.stackexchange.com/questions/228690",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25834/"
] | **Intro**
I have a settings page which includes a setting with a more complicated callback function to save.
**Save data**
To save the data I use the `register_setting()` function with a custom sanitize callback. I implemented it exactly as the WordPress settings API explains so this works fine.
**Remove data from ... | Note what happens when you provide sanitize callback in `register_setting()`. It register a filter to sanitize your options
```
add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
```
Now when you do `update_option()` then trigger your own function to prevent saving :D
Because `update_option()` call... |
228,701 | <p>I found code to show a notification bar on menu and customize it a little. It is working and shown on main menu (primary menu) and footer menu (secondary menu) but I want to show it only main menu. How to do that? Here's what I have:</p>
<pre><code>function my_counter_nav_menu( $menu ) {
$notif_url = bp_cor... | [
{
"answer_id": 228703,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"https://developer.wordpress.org/reference/hooks/wp_nav_menu_items/\" rel=\"nofollow\"><code>w... | 2016/06/03 | [
"https://wordpress.stackexchange.com/questions/228701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/95193/"
] | I found code to show a notification bar on menu and customize it a little. It is working and shown on main menu (primary menu) and footer menu (secondary menu) but I want to show it only main menu. How to do that? Here's what I have:
```
function my_counter_nav_menu( $menu ) {
$notif_url = bp_core_get_user_dom... | The [`wp_nav_menu_items`](https://developer.wordpress.org/reference/hooks/wp_nav_menu_items/) filter has a secondary parameter that it passes: `$args`. What we need to do is set up our filter to accept second args by passing a priority `10` and the number of args `2`:
```
add_filter( 'wp_nav_menu_items', 'my_counter_n... |
228,752 | <p>I would like to sort posts by tags in category and archive pages. (Unfortunately there isn’t an <code>orderby</code> parameter for tags. That would make things so easy!)</p>
<p>So a category page would be like this:</p>
<blockquote>
<h1>Category name</h1>
<ul>
<li>Post 1 (Tag 1)</li>
<li>Post 2 (Tag 1)<... | [
{
"answer_id": 228887,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>There really is no sane way to accomplish this, specially if you have posts that are assigned to more t... | 2016/06/04 | [
"https://wordpress.stackexchange.com/questions/228752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/95222/"
] | I would like to sort posts by tags in category and archive pages. (Unfortunately there isn’t an `orderby` parameter for tags. That would make things so easy!)
So a category page would be like this:
>
> Category name
> =============
>
>
> * Post 1 (Tag 1)
> * Post 2 (Tag 1)
> * Post 3 (Tag 1)
> * Post 4 (Tag 2)
> *... | There really is no sane way to accomplish this, specially if you have posts that are assigned to more than one tag (*which is almost always the case*). What is very sure, you have you work cut out for you.
Here are some thought and ideas you can persue:
POSTS WITH MULTIPLE TERMS
-------------------------
If posts ha... |
228,754 | <p>I have <code>taxonomy.php</code> template file for post_type "posts" but I'd like to use another taxonomy.php but just use/apply it to a custom post type. Is this somehow possible to make another taxonomy.php file just for a specific custom post type?</p>
| [
{
"answer_id": 228887,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>There really is no sane way to accomplish this, specially if you have posts that are assigned to more t... | 2016/06/04 | [
"https://wordpress.stackexchange.com/questions/228754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37346/"
] | I have `taxonomy.php` template file for post\_type "posts" but I'd like to use another taxonomy.php but just use/apply it to a custom post type. Is this somehow possible to make another taxonomy.php file just for a specific custom post type? | There really is no sane way to accomplish this, specially if you have posts that are assigned to more than one tag (*which is almost always the case*). What is very sure, you have you work cut out for you.
Here are some thought and ideas you can persue:
POSTS WITH MULTIPLE TERMS
-------------------------
If posts ha... |
228,778 | <p>I was wondering if there is any way to combine a custom field (in custom post type) with an embed shortcode? Long story short - a user type into a field called videox and an url for a video (youtube, vimeo) or audio (e.g. soundcloud). When I render this field, of course it displays as it was in the field. How do I c... | [
{
"answer_id": 228781,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 3,
"selected": true,
"text": "<p>As you are using URLs from oEmbed provides (YouTube, Vimeo, Soundcloud, etc), I would use <a href=\"https://de... | 2016/06/04 | [
"https://wordpress.stackexchange.com/questions/228778",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/95240/"
] | I was wondering if there is any way to combine a custom field (in custom post type) with an embed shortcode? Long story short - a user type into a field called videox and an url for a video (youtube, vimeo) or audio (e.g. soundcloud). When I render this field, of course it displays as it was in the field. How do I conv... | As you are using URLs from oEmbed provides (YouTube, Vimeo, Soundcloud, etc), I would use [`wp_oembed_get()`](https://developer.wordpress.org/reference/functions/wp_oembed_get/) function. This function uses oEmbed and tries to get the embed HTML of the provided URL.
```
$embed = wp_oembed_get( $some_url );
if( $embed ... |
228,797 | <p>So I am using the code below to retrieve the latest 5 posts from 5 different categories. </p>
<p>The problem is that it outputs the latest 5 posts from only the first category in the array, even if there are newer posts in the other 4 categories.</p>
<p>If I remove the first category from the array, then it simply... | [
{
"answer_id": 228802,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 1,
"selected": false,
"text": "<p>You have a problem in the array construction.\nYou have that :</p>\n\n<pre><code>$args = array(\n 'posts_per_p... | 2016/06/04 | [
"https://wordpress.stackexchange.com/questions/228797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/90205/"
] | So I am using the code below to retrieve the latest 5 posts from 5 different categories.
The problem is that it outputs the latest 5 posts from only the first category in the array, even if there are newer posts in the other 4 categories.
If I remove the first category from the array, then it simply outputs the late... | 2 choices here, you either need to set the category as an array e.g.
```
$args = array(
'posts_per_page' => 5,
'category' => array(15,16,17,18,19)
);
```
You can't just add the numbers in a list but I can't find any documentation that the category element allows multiples (as the name is category)
The other opti... |
228,821 | <p>There is a new feature in wordpress introducing primary category.
When you select a category, primary category can be specified.</p>
<p>My question is how can I get that primary category name using Wordpress Core functions?</p>
<p>if there is no function, can you help me to get the first child of main category?</p... | [
{
"answer_id": 228846,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>To answer your second question: <a href=\"https://developer.wordpress.org/reference/functions/get_categories/\" ... | 2016/06/05 | [
"https://wordpress.stackexchange.com/questions/228821",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76334/"
] | There is a new feature in wordpress introducing primary category.
When you select a category, primary category can be specified.
My question is how can I get that primary category name using Wordpress Core functions?
if there is no function, can you help me to get the first child of main category?
for example:
- ... | I see that this question is getting a lot of attentions since the past year, I thought to answer this question in the right way.
There is not primary category in wordpress if you have installed **Yoast SEO** plugin then a new feature will be appear on **Single Posts** category selection in admin area in order to choos... |
228,833 | <p>Is default functions like <code>update_post_meta()</code> safe to use user inputs?</p>
<p>e.g.</p>
<pre><code>update_post_meta(76, 'my_key', $_GET['value'])
</code></pre>
<p>Or should I use </p>
<pre><code>$_GET['value'] = sanitize_text_field($_GET['value']);
</code></pre>
<p>before using</p>
<pre><code>update... | [
{
"answer_id": 228835,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>Never leave anything to chance, always sanitize, escape and validate <strong>all</strong> data coming f... | 2016/06/05 | [
"https://wordpress.stackexchange.com/questions/228833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96263/"
] | Is default functions like `update_post_meta()` safe to use user inputs?
e.g.
```
update_post_meta(76, 'my_key', $_GET['value'])
```
Or should I use
```
$_GET['value'] = sanitize_text_field($_GET['value']);
```
before using
```
update_post_meta(76, 'my_key', $_GET['value'])
``` | Never leave anything to chance, always sanitize, escape and validate **all** data coming from forms and super globals like `$_GET` and `$_POST` according to your requirements and the data type you are expecting.
It is always good to set your code up in a way so that should your validation fail, you do not unnecessari... |
228,834 | <p>Is there an <code>add_filter</code> where you can see/modify all the <code>$_POST</code> data submitted for a new user registration before the user is created?</p>
<p>Thanks</p>
| [
{
"answer_id": 228840,
"author": "thebigtine",
"author_id": 76059,
"author_profile": "https://wordpress.stackexchange.com/users/76059",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/register_post\" rel=\"no... | 2016/06/05 | [
"https://wordpress.stackexchange.com/questions/228834",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/95088/"
] | Is there an `add_filter` where you can see/modify all the `$_POST` data submitted for a new user registration before the user is created?
Thanks | Well once I looked into it, it is quite simple. `$_POST` is global variable and contains all the POSTed data that was sent from the form.
For example, to email yourself all the posted data submitted in the form, you you could use something like this:
```
function email_me_post_data() {
global $_POST;
... |
228,870 | <p>By default, Wordpress uses Gravatar for user avatars.</p>
<p>I've created a custom field for avatar uploads, and I'm using this as users' avatars on various pages in the theme.</p>
<p>In the admin - on the all users page - there is a column that would normally display the user's avatar (see below). Is there a way ... | [
{
"answer_id": 228872,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 1,
"selected": false,
"text": "<p><strong>EDIT:</strong> My original solution is below, but <a href=\"https://wordpress.stackexchange.com/us... | 2016/06/06 | [
"https://wordpress.stackexchange.com/questions/228870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96286/"
] | By default, Wordpress uses Gravatar for user avatars.
I've created a custom field for avatar uploads, and I'm using this as users' avatars on various pages in the theme.
In the admin - on the all users page - there is a column that would normally display the user's avatar (see below). Is there a way to use my custom ... | As an alternative to my other answer, you can also use the `get_avatar` filter. Props to [Sumit](https://wordpress.stackexchange.com/users/32475/sumit) to alerting me to this one.
The benefit of using the `get_avatar` filter is your custom avatar should be applied *anywhere* Wordpress uses it, rather than just in this... |
228,875 | <p>I'm having trouble getting my shortcode to output all of the markup - for some reason it's only outputting part of it.</p>
<p>I have the following function:</p>
<pre><code>function shortcode_container($atts, $content = null) {
$type = isset($atts['type']) ? $atts['type'] : '';
$margintop =... | [
{
"answer_id": 228872,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 1,
"selected": false,
"text": "<p><strong>EDIT:</strong> My original solution is below, but <a href=\"https://wordpress.stackexchange.com/us... | 2016/06/06 | [
"https://wordpress.stackexchange.com/questions/228875",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96257/"
] | I'm having trouble getting my shortcode to output all of the markup - for some reason it's only outputting part of it.
I have the following function:
```
function shortcode_container($atts, $content = null) {
$type = isset($atts['type']) ? $atts['type'] : '';
$margintop = isset($atts['margint... | As an alternative to my other answer, you can also use the `get_avatar` filter. Props to [Sumit](https://wordpress.stackexchange.com/users/32475/sumit) to alerting me to this one.
The benefit of using the `get_avatar` filter is your custom avatar should be applied *anywhere* Wordpress uses it, rather than just in this... |
228,889 | <p>I am creating a website. There is a column for latest updates.
This is the code that i have now. I don't really good in php coding. Would like to get guidance from someone.</p>
<pre><code><?php
$postslist = get_posts('numberposts=1&order=DESC&orderby=date');
foreach ($postslist as $post) :
setup_p... | [
{
"answer_id": 228891,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 2,
"selected": false,
"text": "<p>From a quick look at the <a href=\"https://developer.wordpress.org/reference/functions/get_posts/\" rel=\"... | 2016/06/06 | [
"https://wordpress.stackexchange.com/questions/228889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23036/"
] | I am creating a website. There is a column for latest updates.
This is the code that i have now. I don't really good in php coding. Would like to get guidance from someone.
```
<?php
$postslist = get_posts('numberposts=1&order=DESC&orderby=date');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<?php... | In addition to the answer by Tim, one can always use a proper [`tax_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters). All the build in tag and category parameters gets converted to a proper `tax_query` before being passed to the `WP_Tax_Query` class to build the `JOIN` clause for the SQ... |
228,917 | <p>I have created a WordPress plugin to create a widget area to display category names (total nmbr of post) and description.Now I want to show the category image just after the category name and after the image I want to show category description. Although category names and description display successfully I just want... | [
{
"answer_id": 228979,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": -1,
"selected": false,
"text": "<p>I'd say register a custom post type, eg. <code>cat_image</code>, so the images can be uploaded to a post usin... | 2016/06/06 | [
"https://wordpress.stackexchange.com/questions/228917",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96314/"
] | I have created a WordPress plugin to create a widget area to display category names (total nmbr of post) and description.Now I want to show the category image just after the category name and after the image I want to show category description. Although category names and description display successfully I just want th... | In general there is no such thing as a "featured image" for categories or other types of terms. The easiest thing to do is to integrate with existing plugins and themes that support this kind of functionality and/or supply an easy to use filter that for site owners to be able to customize where to get the information f... |
228,941 | <p>i have a meta box for some email address and i save value in save_post hook</p>
<pre><code>add_action( 'save_post', 'sm12_save_post' );
function sm12_save_post( $postid ){
update_post_meta( $postid, '_some_email_address', $_POST['some_email_address'] );
}
</code></pre>
<p>Now i want to send email to this email... | [
{
"answer_id": 228979,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": -1,
"selected": false,
"text": "<p>I'd say register a custom post type, eg. <code>cat_image</code>, so the images can be uploaded to a post usin... | 2016/06/06 | [
"https://wordpress.stackexchange.com/questions/228941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70211/"
] | i have a meta box for some email address and i save value in save\_post hook
```
add_action( 'save_post', 'sm12_save_post' );
function sm12_save_post( $postid ){
update_post_meta( $postid, '_some_email_address', $_POST['some_email_address'] );
}
```
Now i want to send email to this email address only when this p... | In general there is no such thing as a "featured image" for categories or other types of terms. The easiest thing to do is to integrate with existing plugins and themes that support this kind of functionality and/or supply an easy to use filter that for site owners to be able to customize where to get the information f... |
229,003 | <p>Using:</p>
<pre><code>$query = new WP_Query();
</code></pre>
<p>How do I filter to get records with titles OR content OR meta keys which contain a part of a string.</p>
<p>I currently have</p>
<pre><code>$args=array(
'order'=>'asc',
'post_type' => $type,
'post_status' => 'p... | [
{
"answer_id": 229006,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Such condition is impossible to express in current WP API. You can use search for title/content matches and meta qu... | 2016/06/07 | [
"https://wordpress.stackexchange.com/questions/229003",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91596/"
] | Using:
```
$query = new WP_Query();
```
How do I filter to get records with titles OR content OR meta keys which contain a part of a string.
I currently have
```
$args=array(
'order'=>'asc',
'post_type' => $type,
'post_status' => 'publish',
'meta_query' => array(
... | Such condition is impossible to express in current WP API. You can use search for title/content matches and meta query for LIKE matches on post meta, but there is no way to establish OR relationship between the two.
The closest API way would be two–stage query where you query IDs for two sets of results (one for searc... |
229,032 | <p>For some reason I cannot output the color. Everything works, but <code>text_color</code> just doesn't want to output its value.</p>
<p>What is going wrong?</p>
<p>Back end code (functions.php):</p>
<pre><code>$wp_customize->add_setting('text_color', array(
'default' => '#fff',
'sanitize_ca... | [
{
"answer_id": 229257,
"author": "mistertaylor",
"author_id": 64117,
"author_profile": "https://wordpress.stackexchange.com/users/64117",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>'type'=>'option'</code> parameter is not required for the colour picker, instead use:</p>\n... | 2016/06/07 | [
"https://wordpress.stackexchange.com/questions/229032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94984/"
] | For some reason I cannot output the color. Everything works, but `text_color` just doesn't want to output its value.
What is going wrong?
Back end code (functions.php):
```
$wp_customize->add_setting('text_color', array(
'default' => '#fff',
'sanitize_callback' => 'sanitize_hex_color',
'type' ... | The `'type'=>'option'` parameter is not required for the colour picker, instead use:
```
$wp_customize->add_setting('text_color', array(
'default' => '#fff',
'sanitize_callback' => 'sanitize_hex_color',
));
``` |
229,060 | <p>In my WordPress workflow I use Gulp and have a task that runs my PHP files through PHPCS using the WordPress coding standards tests (<a href="https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards" rel="nofollow">https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards</a>).</p>
<p... | [
{
"answer_id": 229052,
"author": "Raviraj Deora",
"author_id": 42652,
"author_profile": "https://wordpress.stackexchange.com/users/42652",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like you have not imported the backup of database (sql file) to new database you have created ... | 2016/06/07 | [
"https://wordpress.stackexchange.com/questions/229060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80069/"
] | In my WordPress workflow I use Gulp and have a task that runs my PHP files through PHPCS using the WordPress coding standards tests (<https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards>).
While writing my `comments.php` file, I have run across the following error:
>
> Expected next thing to be ... | It looks like you have not imported the backup of database (sql file) to new database you have created in your localhost. Also after importing the database to local server you will need to replace the live site URL with new localhost URL at all instances in local database. |
229,094 | <p>I want to write unit tests for a plugin. I have used WP-CLI to scaffold the test WordPress instance and can successfully run tests.</p>
<p>The plugin I'm writing unit tests for is a site specific plugin rather than a stand-alone plugin destined for the wordpress.org repository. Being a site specific plugin, some fu... | [
{
"answer_id": 229098,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": true,
"text": "<p>What you are trying to do is not unit testing but integration testing, and as integration usually requires... | 2016/06/08 | [
"https://wordpress.stackexchange.com/questions/229094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50767/"
] | I want to write unit tests for a plugin. I have used WP-CLI to scaffold the test WordPress instance and can successfully run tests.
The plugin I'm writing unit tests for is a site specific plugin rather than a stand-alone plugin destined for the wordpress.org repository. Being a site specific plugin, some functions us... | What you are trying to do is not unit testing but integration testing, and as integration usually requires some initialization which will be specific to the relevant plugin it is hard to give a general answer which is more then the obvious"include the plugin file"
The idea of unit testing is to check that your APIs do... |
229,139 | <p>I've a listing post page where all posts are shown. On each post's row I can perform actions like delete, archive etc. So imagine that:</p>
<ul>
<li>I have an "archive" button;</li>
<li>I push on it and I get a modal (form) saying "Do you want archive this post?"</li>
<li>Into the modal I have the submit button, wh... | [
{
"answer_id": 229143,
"author": "Bruno Cantuaria",
"author_id": 65717,
"author_profile": "https://wordpress.stackexchange.com/users/65717",
"pm_score": 1,
"selected": false,
"text": "<p>It's because your function <code>archive_action</code> is executed when the loop was already made. Tr... | 2016/06/08 | [
"https://wordpress.stackexchange.com/questions/229139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93927/"
] | I've a listing post page where all posts are shown. On each post's row I can perform actions like delete, archive etc. So imagine that:
* I have an "archive" button;
* I push on it and I get a modal (form) saying "Do you want archive this post?"
* Into the modal I have the submit button, which should perform the form ... | Searching around and not being able to implement the action through `init` hook I've found this workaround which for sure isn't the best but does the job nicely.
```
echo "<script type='text/javascript'>
window.location=document.location.href;
</script>";
```
at the end of `$_POST` instructions.
If s... |
229,154 | <p>How can I add a Customizer widget to add social media icons with links to their social media profiles? To clear it up, I have created a few images with the inspect element.</p>
<p><strong>I want to have a section like this, with an <em>add widget</em> button:</strong></p>
<p><a href="https://i.stack.imgur.com/emPV... | [
{
"answer_id": 229143,
"author": "Bruno Cantuaria",
"author_id": 65717,
"author_profile": "https://wordpress.stackexchange.com/users/65717",
"pm_score": 1,
"selected": false,
"text": "<p>It's because your function <code>archive_action</code> is executed when the loop was already made. Tr... | 2016/06/08 | [
"https://wordpress.stackexchange.com/questions/229154",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94984/"
] | How can I add a Customizer widget to add social media icons with links to their social media profiles? To clear it up, I have created a few images with the inspect element.
**I want to have a section like this, with an *add widget* button:**
[](https://i.stack.imgur.com/emPVT.p... | Searching around and not being able to implement the action through `init` hook I've found this workaround which for sure isn't the best but does the job nicely.
```
echo "<script type='text/javascript'>
window.location=document.location.href;
</script>";
```
at the end of `$_POST` instructions.
If s... |
229,166 | <p>I am using a custom taxonomy series to keep track of posts that are in a series. I would like to find the posts that do not have a series. I have the following query:</p>
<pre><code>global $wpdb;
$pr = $wpdb->prefix;
$sql_no_series=
"Select
*
from
wp_term_taxonomy tt,... | [
{
"answer_id": 229170,
"author": "emily",
"author_id": 66454,
"author_profile": "https://wordpress.stackexchange.com/users/66454",
"pm_score": 1,
"selected": false,
"text": "<p>Something like this should work, where series is the taxonomy name and not a option within a taxonomy:</p>\n\n<... | 2016/06/08 | [
"https://wordpress.stackexchange.com/questions/229166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96456/"
] | I am using a custom taxonomy series to keep track of posts that are in a series. I would like to find the posts that do not have a series. I have the following query:
```
global $wpdb;
$pr = $wpdb->prefix;
$sql_no_series=
"Select
*
from
wp_term_taxonomy tt,
wp_ter... | Emily's answer is mostly correct, just that the operator shouldn't have an underscore in it:
```
$args = array(
'post_type' => 'my_post_type',
'tax_query' => array(
array(
'taxonomy' => 'series',
'operator' => 'NOT EXISTS',
),
),
);
$query = new WP_Query( $args );
`... |
229,181 | <p>I'm trying to learn how to use the Custom Field function. I have a series of posts with titles like "Adams County," "Lane County," etc. All are in the category "Washington" and are tagged with "county."</p>
<p>I want to display the following on each page:</p>
<p>"If you live in $MyCounty, tell us what you think."<... | [
{
"answer_id": 229201,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 1,
"selected": false,
"text": "<p>Quickest way is actually to make a standalone php file (wrap the code in <code><?php</code> CODE <code>?>... | 2016/06/08 | [
"https://wordpress.stackexchange.com/questions/229181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94575/"
] | I'm trying to learn how to use the Custom Field function. I have a series of posts with titles like "Adams County," "Lane County," etc. All are in the category "Washington" and are tagged with "county."
I want to display the following on each page:
"If you live in $MyCounty, tell us what you think."
$MyCounty would ... | I would not use custom fields or shortcodes for this functionality, I would look at filters. `the_content` filter and the `loop_end` action (*just make sure that your theme uses `while ( have_posts() )` in single post pages*) comes to immediate mind here. These are two options which requires no modification of any of y... |
229,182 | <p>I'm a software engineer with a WordPress site with hundreds of pages, and it's working very well. </p>
<p>There are certain cases, however, where I'd love to be able to code my own page with <em>no</em> interaction with / interference from the WordPress system (no themes, no styles, no javascript, etc) yet still ha... | [
{
"answer_id": 229200,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 0,
"selected": false,
"text": "<p>You could create a page with the slug you want, and add a custom field that specifies the HTML path to output ... | 2016/06/08 | [
"https://wordpress.stackexchange.com/questions/229182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51462/"
] | I'm a software engineer with a WordPress site with hundreds of pages, and it's working very well.
There are certain cases, however, where I'd love to be able to code my own page with *no* interaction with / interference from the WordPress system (no themes, no styles, no javascript, etc) yet still have it located on ... | If you're willing to create a child theme and put your PHP files in there, this approach is relatively clean. For each file, create a rewrite rule where you specify the path you want to use and the filename that should load. In the example below, `/custom-path/` loads `custom-file.php` from the root of your child theme... |
229,190 | <p>In the past my organisation has had some problems where a development copy of a site was cloned (through Installatron in cPanel) to a new hosting account, but the new (live) copy of the site had some absolute references to images or files on the development copy of the site.</p>
<p>This meant that when the developm... | [
{
"answer_id": 229200,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 0,
"selected": false,
"text": "<p>You could create a page with the slug you want, and add a custom field that specifies the HTML path to output ... | 2016/06/09 | [
"https://wordpress.stackexchange.com/questions/229190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76260/"
] | In the past my organisation has had some problems where a development copy of a site was cloned (through Installatron in cPanel) to a new hosting account, but the new (live) copy of the site had some absolute references to images or files on the development copy of the site.
This meant that when the development site w... | If you're willing to create a child theme and put your PHP files in there, this approach is relatively clean. For each file, create a rewrite rule where you specify the path you want to use and the filename that should load. In the example below, `/custom-path/` loads `custom-file.php` from the root of your child theme... |
229,209 | <p>I have been searching around the web for this but it doesn't seems there's any topic like this (or maybe I am searching in the wrong direction).</p>
<p>Currently I have a jQuery file which will retrieve 9 additional posts from the database and append to the current posts listing.</p>
<p><strong>File: load-more.js<... | [
{
"answer_id": 229200,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 0,
"selected": false,
"text": "<p>You could create a page with the slug you want, and add a custom field that specifies the HTML path to output ... | 2016/06/09 | [
"https://wordpress.stackexchange.com/questions/229209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96471/"
] | I have been searching around the web for this but it doesn't seems there's any topic like this (or maybe I am searching in the wrong direction).
Currently I have a jQuery file which will retrieve 9 additional posts from the database and append to the current posts listing.
**File: load-more.js**
```
var data = {
... | If you're willing to create a child theme and put your PHP files in there, this approach is relatively clean. For each file, create a rewrite rule where you specify the path you want to use and the filename that should load. In the example below, `/custom-path/` loads `custom-file.php` from the root of your child theme... |
229,222 | <p>I'm trying to access custom meta data from a custom post type called 'Videos'</p>
<p>The following code is on a template page called 'single-videos.php'</p>
<p>A custom field called 'Video URL', 'Video Width' and 'Video Height'</p>
<p>However when i run the script, these don't return the values for that particula... | [
{
"answer_id": 229240,
"author": "Aishan",
"author_id": 89530,
"author_profile": "https://wordpress.stackexchange.com/users/89530",
"pm_score": 0,
"selected": false,
"text": "<p>Were you showing all of your Custom Post Type \"Video\" post on a loop?</p>\n\n<p>Im not sure if your $video->... | 2016/06/09 | [
"https://wordpress.stackexchange.com/questions/229222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96261/"
] | I'm trying to access custom meta data from a custom post type called 'Videos'
The following code is on a template page called 'single-videos.php'
A custom field called 'Video URL', 'Video Width' and 'Video Height'
However when i run the script, these don't return the values for that particular post.
Any ideas where... | I don't know why you are using a custom template for displaying an individual Video post when there is a single file that is used for this purpose - `single-{post_type}`.
<https://codex.wordpress.org/Post_Type_Templates>
Using the single file, you will be able to get the post ID with `$post->ID` or `get_the_ID()`.
`... |
229,236 | <p>I have a custom post type where I can create pages in.("article.php")<br>
It automatically uses the template "single.php" when I create a page, although I want to change some things in it without effecting some other pages on the website.<br>
I tried making a single-article.php file, but it is still using the single... | [
{
"answer_id": 229238,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 3,
"selected": true,
"text": "<p><strong>If you want to change the single page</strong></p>\n<p><code>page-{page-slug}</code> is a good choic... | 2016/06/09 | [
"https://wordpress.stackexchange.com/questions/229236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96482/"
] | I have a custom post type where I can create pages in.("article.php")
It automatically uses the template "single.php" when I create a page, although I want to change some things in it without effecting some other pages on the website.
I tried making a single-article.php file, but it is still using the single.php ... | **If you want to change the single page**
`page-{page-slug}` is a good choice if you want the page template for specific page only and not multiple pages.
Check out his [custom page template for specific page](https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/#creating-a... |
229,250 | <p>I'am trying to make a wordpress website accessibility compliant but I have come across a problem with menu bar. It uses a modified them based on Twenty_Twelve.</p>
<p>I need to change the "ul" tag to "ol" which is required to make it compliant.
( I tried <a href="https://wordpress.stackexchange.com/questions/1725... | [
{
"answer_id": 229238,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 3,
"selected": true,
"text": "<p><strong>If you want to change the single page</strong></p>\n<p><code>page-{page-slug}</code> is a good choic... | 2016/06/09 | [
"https://wordpress.stackexchange.com/questions/229250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96492/"
] | I'am trying to make a wordpress website accessibility compliant but I have come across a problem with menu bar. It uses a modified them based on Twenty\_Twelve.
I need to change the "ul" tag to "ol" which is required to make it compliant.
( I tried [Edit HTML of Wordpress navigation bar](https://wordpress.stackexchan... | **If you want to change the single page**
`page-{page-slug}` is a good choice if you want the page template for specific page only and not multiple pages.
Check out his [custom page template for specific page](https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/#creating-a... |
229,256 | <p>When I write a quote in the text widget and displayed the text is wrapped as "My text...". I would like to remove the div and put simply "My text...". without using jquery.</p>
<p>For Example: Current output</p>
<pre><code><div class="container">
<div class=“textwidget”>
My text...
</di... | [
{
"answer_id": 229259,
"author": "Greg McMullen",
"author_id": 36028,
"author_profile": "https://wordpress.stackexchange.com/users/36028",
"pm_score": 3,
"selected": true,
"text": "<p>More than likely this is an issue with the <a href=\"https://codex.wordpress.org/Function_Reference/regi... | 2016/06/09 | [
"https://wordpress.stackexchange.com/questions/229256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96491/"
] | When I write a quote in the text widget and displayed the text is wrapped as "My text...". I would like to remove the div and put simply "My text...". without using jquery.
For Example: Current output
```
<div class="container">
<div class=“textwidget”>
My text...
</div>
</div>
```
Required output:
``... | More than likely this is an issue with the [`register_sidebar()`](https://codex.wordpress.org/Function_Reference/register_sidebars) call in `functions.php`.
Look for `before_widget` and `after_widget`. The code below is the default usage.
```
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' =>... |
229,310 | <p>I need to iframe a series of content on our site. I need to pass on the the user information via a URL - vendor request.</p>
<p>I have tons of shortcodes that display the username. It works fine. But when I append the src record it doesn't work.</p>
<pre><code><iframe src="https://test.com/video/112/[current... | [
{
"answer_id": 229325,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>Don't remember exactly when (4.3?) core had gone with a much more restrictive parsing of shortcodes due t... | 2016/06/09 | [
"https://wordpress.stackexchange.com/questions/229310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32393/"
] | I need to iframe a series of content on our site. I need to pass on the the user information via a URL - vendor request.
I have tons of shortcodes that display the username. It works fine. But when I append the src record it doesn't work.
```
<iframe src="https://test.com/video/112/[currentuser_username]" width="800"... | ```
<iframe src=https://test.com/video/112/[currentuser_username] width="800" height="450">
<p>Your browser does not support iframes.</p>
</iframe>
```
Simply removing the quotes around everything worked. All modern browsers add these back in - when that stops working (doubt anytime soon) we might have to create ... |
229,337 | <p>I very much like <a href="https://en.wikipedia.org/wiki/This_will_be_a_new_Site" rel="nofollow noreferrer">Wikipedia's feature</a> to create an article from a yet non-existing URL as shown below:</p>
<p><a href="https://i.stack.imgur.com/a4tJI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a4tJI... | [
{
"answer_id": 229386,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": true,
"text": "<p>Somehow the url must make clear that this is an editable link. So you need a filter on <code>the_content</code> t... | 2016/06/10 | [
"https://wordpress.stackexchange.com/questions/229337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75760/"
] | I very much like [Wikipedia's feature](https://en.wikipedia.org/wiki/This_will_be_a_new_Site) to create an article from a yet non-existing URL as shown below:
[](https://i.stack.imgur.com/a4tJI.png)
I imagine the workflow to be like this:
1. Open UR... | Somehow the url must make clear that this is an editable link. So you need a filter on `the_content` that checks if there are internal links that do not yet exist. Alternatively, if you let users determine which links are editable you need to check if the url's they give perhaps already exist. The filter should set a c... |
229,352 | <p>I need to build a website for a client where the can password protect certain pages and posts on the front end. So, a visitor is required to enter a password on these pages / posts.</p>
<p>Having searched and tried out a couple of plugins 'password protected' and 'smart passworded pages' without much success. </p>
... | [
{
"answer_id": 229357,
"author": "rémy",
"author_id": 92681,
"author_profile": "https://wordpress.stackexchange.com/users/92681",
"pm_score": -1,
"selected": false,
"text": "<p>You could create a template, which then should be choosen for protected sites. There you just copy the default ... | 2016/06/10 | [
"https://wordpress.stackexchange.com/questions/229352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96549/"
] | I need to build a website for a client where the can password protect certain pages and posts on the front end. So, a visitor is required to enter a password on these pages / posts.
Having searched and tried out a couple of plugins 'password protected' and 'smart passworded pages' without much success.
I was wonderi... | I've used the following to protect individual pages:
First add a field to the Publish Metabox:
```
add_action( 'post_submitbox_misc_actions', 'my_post_submitbox_misc_actions1' );
function my_post_submitbox_misc_actions1(){
echo '<div class="misc-pub-section my-options">
<input type="checkbox" id="fgpsn_prote... |
229,355 | <p><code>wp_title()</code> from theme's <code>header.php</code> shows "Page not found". Also the <code>body_class</code> displays the word "error404". </p>
<ul>
<li>the WP blog is installed on site.com/blog/</li>
<li>a post is rendered outside WP installation, more specific on wildcard-subdomain.site.com/articles/post... | [
{
"answer_id": 229388,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>To be able to show the title and have a proper body_class, wordpress has to parse first the url and find ... | 2016/06/10 | [
"https://wordpress.stackexchange.com/questions/229355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69275/"
] | `wp_title()` from theme's `header.php` shows "Page not found". Also the `body_class` displays the word "error404".
* the WP blog is installed on site.com/blog/
* a post is rendered outside WP installation, more specific on wildcard-subdomain.site.com/articles/post-slug
I added on page:
```
define('WP_USE_THEMES', f... | You could do an outside query instead.
```
<?php
define('WP_USE_THEMES', false);
global $wpdb;
require(ROOT_DIR.'/blog/wp-load.php');
query_posts('showposts=1');
get_header();
try{
$args = array('post_type' => array('post'), 'posts_per_page' => -1);
$qry = null;
$qry = new WP_Query($args);
if($qry->h... |
229,390 | <p>I have set-up my first VPS (Ubuntu). Apache 2 and php were pre-installed, I was able to install wp-cli, but it is kinda useless for me know. I am getting user permissions error. For example when I run </p>
<pre><code>wp core download
</code></pre>
<p>I am getting an error</p>
<pre><code>Error: /var/www/example.co... | [
{
"answer_id": 229395,
"author": "user3865184",
"author_id": 59612,
"author_profile": "https://wordpress.stackexchange.com/users/59612",
"pm_score": 1,
"selected": false,
"text": "<p>I think the error is very clear. The owner of <code>public_html</code> is <code>www-data</code>, you don'... | 2016/06/10 | [
"https://wordpress.stackexchange.com/questions/229390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67602/"
] | I have set-up my first VPS (Ubuntu). Apache 2 and php were pre-installed, I was able to install wp-cli, but it is kinda useless for me know. I am getting user permissions error. For example when I run
```
wp core download
```
I am getting an error
```
Error: /var/www/example.com/public_html/ is not writable by cur... | I think the error is very clear. The owner of `public_html` is `www-data`, you don't have any permisson to write to that folder.
You can use whatever user you want as long as that user have permission to read, write and execute your `DOCUMENT_ROOT` folder. But you shouldn't use `root` user.
So, to solve that error, t... |
229,394 | <p>My issue was the adminbar started to disappear for users who weren't the administrator. I have found a work-around ( below code ) that checks if they're logged in just before the closing <code></head></code> tag.</p>
<p>Has anyone come across a similar problem and found the root cause, or is there a better-pr... | [
{
"answer_id": 229397,
"author": "Dan Kinchen",
"author_id": 65580,
"author_profile": "https://wordpress.stackexchange.com/users/65580",
"pm_score": 0,
"selected": false,
"text": "<p>I have 2 choices for you. Both of which you place this code in your theme's function.php file.</p>\n\n<pr... | 2016/06/10 | [
"https://wordpress.stackexchange.com/questions/229394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96571/"
] | My issue was the adminbar started to disappear for users who weren't the administrator. I have found a work-around ( below code ) that checks if they're logged in just before the closing `</head>` tag.
Has anyone come across a similar problem and found the root cause, or is there a better-practice way of hiding the ad... | There's actually a [`show_admin_bar`](https://codex.wordpress.org/Function_Reference/show_admin_bar) hook where you can always return true or false. I haven't run across an issue where the admin bar is randomly disappearing though. Usually on my websites I like to turn it off for admins:
```
/**
* Remove Admin Bar Fo... |
229,432 | <p>Is it possible to load scripts through <code>wp_enqueue_script</code> based on a browser's width?</p>
<p>Thanks</p>
| [
{
"answer_id": 229435,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>No it isn't. Server can not know browser width. Not sure it is even a smart idea since the width of the b... | 2016/06/11 | [
"https://wordpress.stackexchange.com/questions/229432",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8049/"
] | Is it possible to load scripts through `wp_enqueue_script` based on a browser's width?
Thanks | Kinda just answering this to counter the "not-possible" answers...
Yes it is probably not the best thing to do, since we are still unsure what the OP is trying to achieve, but that does not make it not possible... complex and impractical perhaps, but still entirely possible.
First enqueue the script as you normally ... |
229,438 | <p>I am developing plugin right now, and I have one questions about <code>best practices</code> and conventions. </p>
<p><strong>What I need ?</strong> </p>
<p>My plugin is going to store some predefined object, list of objects (or just arrays/key-value pairs) and it will be possible to add new object and fill its... | [
{
"answer_id": 229446,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li>Yes</li>\n<li><p>this is actually the same as point 1, just without the helpers</p></li>\n<li><p>N... | 2016/06/11 | [
"https://wordpress.stackexchange.com/questions/229438",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93387/"
] | I am developing plugin right now, and I have one questions about `best practices` and conventions.
**What I need ?**
My plugin is going to store some predefined object, list of objects (or just arrays/key-value pairs) and it will be possible to add new object and fill its fields.
For example my object will have ... | It depends on how you are going to use the stored data.
If you want to run complex queries against the values, use a custom table with indexes optimized for those queries.
If you will always just fetch all the values for a given object, create a non-public custom post type, and store the data as post meta.
Do not ... |
229,480 | <p>I read that if you create a php file and save it in the /wp-content/mu-plugins/ directory, WordPress will auto-load it.</p>
<p>However, I haven't yet figured it out. I don't have a folder named mu-plugins; it's just wp-content/plugins. I created a file at wp-content/plugins/echo-values.php, put a simple echo value ... | [
{
"answer_id": 229482,
"author": "user6454281",
"author_id": 96610,
"author_profile": "https://wordpress.stackexchange.com/users/96610",
"pm_score": 2,
"selected": false,
"text": "<p>That is not how it works in WordPress. The <code>index.php</code> file is put in <code>plugins</code> dir... | 2016/06/11 | [
"https://wordpress.stackexchange.com/questions/229480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94575/"
] | I read that if you create a php file and save it in the /wp-content/mu-plugins/ directory, WordPress will auto-load it.
However, I haven't yet figured it out. I don't have a folder named mu-plugins; it's just wp-content/plugins. I created a file at wp-content/plugins/echo-values.php, put a simple echo value in it and ... | Yes, you can use a `/wp-content/mu-plugins` folder for
* single file
* autoloading
plugins. The only thing you will have to do is to use a plugin header comment in this file:
```
<?php /* Plugin Name: I am a MU-Plugin */
```
Then you will find a link on top of your `/wp-admin/plugins.php` page that says
>
> "M... |
229,530 | <p>domain.com/rents/miami-dade/</p>
<p>domain.com/companies/miami-dade/</p>
<p>Then for, say rents/miami-dade/ I would loop through some different areas within miami, showing a list of rents for each area. For example:</p>
<p>domain.com/rents/miami-dade/</p>
<p>would render something like this by looping through th... | [
{
"answer_id": 229541,
"author": "Prashant Gupta",
"author_id": 96640,
"author_profile": "https://wordpress.stackexchange.com/users/96640",
"pm_score": 1,
"selected": false,
"text": "<p>Ok, i have some basic ideas. \nYou can install a plugin called Redirection. And after that, you can ma... | 2016/06/12 | [
"https://wordpress.stackexchange.com/questions/229530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35549/"
] | domain.com/rents/miami-dade/
domain.com/companies/miami-dade/
Then for, say rents/miami-dade/ I would loop through some different areas within miami, showing a list of rents for each area. For example:
domain.com/rents/miami-dade/
would render something like this by looping through the areas in Miami:
North Miami ... | You can accomplish this with [`add_rewrite_rule()`](https://codex.wordpress.org/Rewrite_API/add_rewrite_rule).
I personally like to show this example in a class to make it copy/paste ready. You could throw this in a plugin or functions.php -- some place that loads this code before `query_vars`, `parse_request` and `in... |
229,556 | <p>Is it possible to remove "nextpage" tag inside posts text depending of utm_campaign ?</p>
<p>Depending of where my visitors are comming from, I want to remove the </p>
<pre><code><!--nextpage-->
</code></pre>
<p>of my post.</p>
<p>I am using this </p>
<pre><code>if($_GET['utm_campaign']== 'nonextpagecamp... | [
{
"answer_id": 229569,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 4,
"selected": true,
"text": "<p>You can use <code>the_post</code> hook to remove <code><!--nextpage--></code>. In this case:</p>\n\n<pre><c... | 2016/06/13 | [
"https://wordpress.stackexchange.com/questions/229556",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57405/"
] | Is it possible to remove "nextpage" tag inside posts text depending of utm\_campaign ?
Depending of where my visitors are comming from, I want to remove the
```
<!--nextpage-->
```
of my post.
I am using this
```
if($_GET['utm_campaign']== 'nonextpagecampaign') {
```
directly in my template in order to displ... | You can use `the_post` hook to remove `<!--nextpage-->`. In this case:
```
add_action( 'the_post', 'campaign_remove_nextpage', 99);
function campaign_remove_nextpage ( $post ) {
if ( ($_GET['utm_campaign']== 'nonextpagecampaign') && (false !== strpos( $post->post_content, '<!--nextpage-->' )) )
{
// ... |
229,575 | <p>I remove some metaboxes using</p>
<pre><code>remove_meta_box('commentsdiv','page','normal'); // Comments.
remove_meta_box( 'commentsdiv','post','normal' ); // Comments.
</code></pre>
<p>It doesn't seem to apply to CPTs.
So to remove a metabox from all CPTs, is there an alternative to repeating the above but with t... | [
{
"answer_id": 229579,
"author": "Jebble",
"author_id": 81939,
"author_profile": "https://wordpress.stackexchange.com/users/81939",
"pm_score": 0,
"selected": false,
"text": "<p>The standard meta boxes that are shown on Custom Post Types are determined by the support you've given to the ... | 2016/06/13 | [
"https://wordpress.stackexchange.com/questions/229575",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63350/"
] | I remove some metaboxes using
```
remove_meta_box('commentsdiv','page','normal'); // Comments.
remove_meta_box( 'commentsdiv','post','normal' ); // Comments.
```
It doesn't seem to apply to CPTs.
So to remove a metabox from all CPTs, is there an alternative to repeating the above but with the cpt name replacing page... | @Jeffrey's answer is correct is you are the one registering the post types, simply remove the support argument for `comments`.
But if you want to remove it from *all* custom post types (that may be registered by plugins too) you can do:
```
$cptslugs = get_post_types( array('public'=>false, '_builtin' => false) , 'na... |
229,594 | <p>I have seen some questions which look similar, but they all ended up with <a href="http://codex.wordpress.org/Create_A_Network" rel="noreferrer">multisite</a>. For maintainability, performance and security, I don't want to use multisite. So please bear with me.</p>
<p>This is what I'm thinking about:</p>
<pre><cod... | [
{
"answer_id": 229623,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 5,
"selected": true,
"text": "<p>As <a href=\"https://wordpress.stackexchange.com/users/736/tom-j-nowell\">@tom-j-nowell</a> said in comment to... | 2016/06/13 | [
"https://wordpress.stackexchange.com/questions/229594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92212/"
] | I have seen some questions which look similar, but they all ended up with [multisite](http://codex.wordpress.org/Create_A_Network). For maintainability, performance and security, I don't want to use multisite. So please bear with me.
This is what I'm thinking about:
```
.
|_____branch1 // for branch1.domain.com
| |_... | As [@tom-j-nowell](https://wordpress.stackexchange.com/users/736/tom-j-nowell) said in comment to OP, multisite can make this easier.
Performance and security are not really a problem for multisite (at least, not more than they are for regular installations), but I do agree that multisite can sometimes be a problem, b... |
229,596 | <p>The wordpress 'Help' and 'Screen Options' Buttons in the wordpress Admin Panels are not working when including bootstrap and specifically the bootstrap-css files.</p>
<p>It is caused because bootstraps css overides:</p>
<pre><code>.hidden {
display: none !important;
}
</code></pre>
<p>How can I make the buttons... | [
{
"answer_id": 229597,
"author": "sweisgerber.dev",
"author_id": 56540,
"author_profile": "https://wordpress.stackexchange.com/users/56540",
"pm_score": 2,
"selected": true,
"text": "<p>Check if you or a plugin include bootstrap and the bootstrap CSS / Theme files.</p>\n\n<p>Bootstraps <... | 2016/06/13 | [
"https://wordpress.stackexchange.com/questions/229596",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56540/"
] | The wordpress 'Help' and 'Screen Options' Buttons in the wordpress Admin Panels are not working when including bootstrap and specifically the bootstrap-css files.
It is caused because bootstraps css overides:
```
.hidden {
display: none !important;
}
```
How can I make the buttons working again?
It is related to... | Check if you or a plugin include bootstrap and the bootstrap CSS / Theme files.
Bootstraps `.hidden` class looks like:
```
.hidden {
display: none !important;
}
```
But overrides wordpress' definition of `.hidden`:
```
.hidden {
display: none;
}
```
The Top 'Help' & 'Screen Options' bars are displayed via in... |
229,598 | <p>I've created a new custom post type called MemberPost and want it to follow a slightly different template to my main index (which is where main news is kept). I've created a custom post type and inserted this into my <code>functions.php</code>.</p>
<pre><code>add_filter('excerpt_more', 'new_excerpt_more');
add_act... | [
{
"answer_id": 229601,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 2,
"selected": true,
"text": "<p>File should be <code>single-member_post.php</code> instead of <code>single-memberPost.php</code>.</p>\n\n<p>... | 2016/06/13 | [
"https://wordpress.stackexchange.com/questions/229598",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96680/"
] | I've created a new custom post type called MemberPost and want it to follow a slightly different template to my main index (which is where main news is kept). I've created a custom post type and inserted this into my `functions.php`.
```
add_filter('excerpt_more', 'new_excerpt_more');
add_action( 'init', 'register_cp... | File should be `single-member_post.php` instead of `single-memberPost.php`.
In `single-{posttype}` , `{post_type}` is the `$post_type` argument of the `register_post_type()` function.
Never use `flush_rewrite_rules();` in `init` use it only on theme/plugin deactivate or activate.
Since this is a theme you can use it... |
229,621 | <p>A search on this topic on this site throws up a lot of results claiming to have resolved this issue, but I am having a contrary experience after implementing these guidelines as outlined here:</p>
<ol>
<li><a href="https://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-custom-loops/120408#12... | [
{
"answer_id": 229601,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 2,
"selected": true,
"text": "<p>File should be <code>single-member_post.php</code> instead of <code>single-memberPost.php</code>.</p>\n\n<p>... | 2016/06/13 | [
"https://wordpress.stackexchange.com/questions/229621",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96667/"
] | A search on this topic on this site throws up a lot of results claiming to have resolved this issue, but I am having a contrary experience after implementing these guidelines as outlined here:
1. [How to fix pagination for custom loops?](https://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-cu... | File should be `single-member_post.php` instead of `single-memberPost.php`.
In `single-{posttype}` , `{post_type}` is the `$post_type` argument of the `register_post_type()` function.
Never use `flush_rewrite_rules();` in `init` use it only on theme/plugin deactivate or activate.
Since this is a theme you can use it... |
229,675 | <p>Animated gifs are getting more popular on the web (again) and currently there is no good tool for resizing animated gifs. </p>
<p>So I want to disable resizing/generation of image sizes for the gif mimetype and just save the original gif.</p>
<p>Someone that can help me out with this? Which filter to use will be a... | [
{
"answer_id": 229683,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>currently there is no good tool for resizing animated gifs</p>\n</blockquote>\n\n<p>Resizing of ... | 2016/06/14 | [
"https://wordpress.stackexchange.com/questions/229675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40819/"
] | Animated gifs are getting more popular on the web (again) and currently there is no good tool for resizing animated gifs.
So I want to disable resizing/generation of image sizes for the gif mimetype and just save the original gif.
Someone that can help me out with this? Which filter to use will be a good start. | image\_make\_intermediate\_size was not the hook I was looking for, but intermediate\_image\_sizes\_advanced.
Here is a working code:
```
function disable_upload_sizes( $sizes, $metadata ) {
// Get filetype data.
$filetype = wp_check_filetype($metadata['file']);
// Check if is gif.
if($filetype['... |
229,698 | <p>On my blog I have a large number of categories >500, so I need to have some kind of checklist which categories are already selected to continue selecting.</p>
<p>For example, if we have cat1, cat2, cat3...cat50, and I selected cat3, cat5, cat7 and cat44, and need to select more of them, I need to have checklist wha... | [
{
"answer_id": 229702,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>The easiest way would be to add a meta box and use <code>get_the_category_list</code> to show the categories tha... | 2016/06/14 | [
"https://wordpress.stackexchange.com/questions/229698",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31498/"
] | On my blog I have a large number of categories >500, so I need to have some kind of checklist which categories are already selected to continue selecting.
For example, if we have cat1, cat2, cat3...cat50, and I selected cat3, cat5, cat7 and cat44, and need to select more of them, I need to have checklist what is alrea... | Here's a script that you can enqueue into your admin panel. It will add a new tab to the category tabs called "Active". Whenever a checkbox is checked, it gets added to the "Active" tab list, you can also click links in the "Active" tab list to remove them ( uncheck them ).
[ to cache entire [$wp\_query](https://core.trac.wordpress.org/browser/tags/4.5/src/wp-includes/query.php) object with key is [$query\_vars\_hash](https://core.trac.wordpress.org/browser/tags/4.5/src/wp-includes/query.php#L1286).
This is how `$wp_quer... | At the moment, it is not possible.
When `'pre_get_posts'` runs, is too late to stop `WP_Query` to perform a query.
WordPress itself, when you try to query a taxonomy that does not exists, adds `AND (0 = 1)` to the `WHERE` clause of the SQL query, to ensure it returns no results very quickly...
There's a [trac ticket... |
229,747 | <p>I have code that wraps every 3 posts in a div (so that the posts will line up horizontally even if different heights). It closes the div after 3 posts, but the problem is the div is left open if there aren't any more posts left but it ended with 1 or 2 in that div row. How can I close the last div?</p>
<pre><code> ... | [
{
"answer_id": 229749,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p>Something like this should work:</p>\n\n<pre><code><?php\nif ( have_posts() ) { \n\n $i = 1;\n // Alwa... | 2016/06/14 | [
"https://wordpress.stackexchange.com/questions/229747",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69358/"
] | I have code that wraps every 3 posts in a div (so that the posts will line up horizontally even if different heights). It closes the div after 3 posts, but the problem is the div is left open if there aren't any more posts left but it ended with 1 or 2 in that div row. How can I close the last div?
```
<?php
if ( ... | This is purely PHP which is considered to be Off-topic but this is my take:
```
<?php if ( have_posts() ) : ?>
<?php
while ( have_posts() ) :
the_post();
$i = $wp_query->current_post;
echo ( 0 == $i % 3 ) ? '<div class="row">' : '';
?>
<div class="project">... |
229,755 | <p>I am working on a WP plugin, and I need to be able to call a URL (specifically an AJAX function) using a button click, but the page refreshes after clicking it, which I think is preventing the AJAX request from finishing.</p>
<p>When the button click is registered, JS is meant to grab the value of an input, combine... | [
{
"answer_id": 229758,
"author": "C C",
"author_id": 83299,
"author_profile": "https://wordpress.stackexchange.com/users/83299",
"pm_score": 0,
"selected": false,
"text": "<p>I can't comment on the validity of the AJAX call; it's a different style than I have used -- but inside the <code... | 2016/06/14 | [
"https://wordpress.stackexchange.com/questions/229755",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92901/"
] | I am working on a WP plugin, and I need to be able to call a URL (specifically an AJAX function) using a button click, but the page refreshes after clicking it, which I think is preventing the AJAX request from finishing.
When the button click is registered, JS is meant to grab the value of an input, combine it to for... | Please do not put this code into production
===========================================
OK. So there are many things wrong with the code that need fixing before we can even begin to answer your question.
1. Firstly we're using `$_REQUEST` without good reason -- `$_REQUEST` gives us access to all of the information se... |
229,761 | <p>i'm using code from the wordpress codex: (this is the generic version, my code is working though)</p>
<pre><code>$response = wp_remote_post( $url, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(... | [
{
"answer_id": 229758,
"author": "C C",
"author_id": 83299,
"author_profile": "https://wordpress.stackexchange.com/users/83299",
"pm_score": 0,
"selected": false,
"text": "<p>I can't comment on the validity of the AJAX call; it's a different style than I have used -- but inside the <code... | 2016/06/14 | [
"https://wordpress.stackexchange.com/questions/229761",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77767/"
] | i'm using code from the wordpress codex: (this is the generic version, my code is working though)
```
$response = wp_remote_post( $url, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => array( 'name' =... | Please do not put this code into production
===========================================
OK. So there are many things wrong with the code that need fixing before we can even begin to answer your question.
1. Firstly we're using `$_REQUEST` without good reason -- `$_REQUEST` gives us access to all of the information se... |
229,767 | <p>I'm trying to show WooCommerce Product Categories, Post Categories, Product Tags, Post Tags and Custom Taxonomy posts count in main navigation using wp_nav_menu.</p>
<p>My WP_NAV_MENU code</p>
<pre><code> <?php if( has_nav_menu( 'primary_menu' ) ) : ?>
<?php
... | [
{
"answer_id": 230512,
"author": "ngearing",
"author_id": 50184,
"author_profile": "https://wordpress.stackexchange.com/users/50184",
"pm_score": 2,
"selected": false,
"text": "<p>Alright so this isn't too difficult, first we will just check if the menu item is a taxonomy then get the co... | 2016/06/15 | [
"https://wordpress.stackexchange.com/questions/229767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84518/"
] | I'm trying to show WooCommerce Product Categories, Post Categories, Product Tags, Post Tags and Custom Taxonomy posts count in main navigation using wp\_nav\_menu.
My WP\_NAV\_MENU code
```
<?php if( has_nav_menu( 'primary_menu' ) ) : ?>
<?php
$primary_args ... | Alright so this isn't too difficult, first we will just check if the menu item is a taxonomy then get the count and display it!
```
function ggstyle_menu_item_count( $output, $item, $depth, $args ) {
// Check if the item is a Category or Custom Taxonomy
if( $item->type == 'taxonomy' ) {
$object = get_t... |
229,772 | <p>I don't want to style the default widget with only CSS. I want to display the default 'Categories' widget content with my own HTML structure. </p>
<p>Is there available any filter or hook to do that?</p>
| [
{
"answer_id": 229781,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 5,
"selected": true,
"text": "<p>To expand on Mark's answer, there's not much (generally) available in the way of filters in the default Wor... | 2016/06/15 | [
"https://wordpress.stackexchange.com/questions/229772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75264/"
] | I don't want to style the default widget with only CSS. I want to display the default 'Categories' widget content with my own HTML structure.
Is there available any filter or hook to do that? | To expand on Mark's answer, there's not much (generally) available in the way of filters in the default WordPress widgets (except for perhaps `widget_text`).
But adding your own custom widget is easy - put this in your `functions.php`:
```
require_once("my_widget.php");
add_action("widgets_init", "my_custom_widgets_i... |
229,841 | <p>For example, if I'm building a list in a plugin that loops over an array to produce a list <code>ul</code> or <code>ol</code>. I typically see code as follows. </p>
<pre><code>foreach($list as $item) {
$output .= '<li>' . $item['value'] . '</li>';
}
</code></pre>
<p>I guess I'm looking to see if ther... | [
{
"answer_id": 229848,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": true,
"text": "<p>There are specific functions like <a href=\"https://developer.wordpress.org/reference/functions/wp_list_cate... | 2016/06/15 | [
"https://wordpress.stackexchange.com/questions/229841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33401/"
] | For example, if I'm building a list in a plugin that loops over an array to produce a list `ul` or `ol`. I typically see code as follows.
```
foreach($list as $item) {
$output .= '<li>' . $item['value'] . '</li>';
}
```
I guess I'm looking to see if there is a comparable to such functions in the Drupal world such... | There are specific functions like [`wp_list_categories()`](https://developer.wordpress.org/reference/functions/wp_list_categories/) and [`wp_list_pages()`](https://developer.wordpress.org/reference/functions/wp_list_pages/) along with [some others](https://developer.wordpress.org/?s=wp_list&post_type%5B%5D=wp-parser-fu... |
229,867 | <p>I'm using this function right now in my theme to show each project's custom taxonomy. In this case, the custom taxonomy is <code>tipo_de_tarea</code>:</p>
<pre><code>echo get_the_term_list( $post->ID, 'tipo_de_tarea' );
</code></pre>
<p>I have various tipo_de_tareas. I would like the function to display a short... | [
{
"answer_id": 229872,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 1,
"selected": false,
"text": "<p>You could use <code>get_terms()</code> and loop through it - using the term description as the \"short name... | 2016/06/15 | [
"https://wordpress.stackexchange.com/questions/229867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96838/"
] | I'm using this function right now in my theme to show each project's custom taxonomy. In this case, the custom taxonomy is `tipo_de_tarea`:
```
echo get_the_term_list( $post->ID, 'tipo_de_tarea' );
```
I have various tipo\_de\_tareas. I would like the function to display a shorter name, instead of the complete name ... | You could use `get_terms()` and loop through it - using the term description as the "short name" and slug as the specific class ( or you could use an array of colors of your choice ). Let's look at a quick example:
```
<?php
$terms = wp_get_post_terms( $post_id, 'category' );
if( ! empty( $terms ) ) : ?>
... |
229,905 | <p>I enabled <a href="https://codex.wordpress.org/Function_Reference/add_theme_support#Custom_Logo"><code>custom-logo</code></a> for my theme and have it printed with <code><?php the_custom_logo(); ?></code> into the header. Is there any chance to simply add some more classes to this image directly? Per default i... | [
{
"answer_id": 229909,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 2,
"selected": false,
"text": "<p>I think I found one answer. But I really wonder if this is the right way? It feels a little bit dirty someho... | 2016/06/16 | [
"https://wordpress.stackexchange.com/questions/229905",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30597/"
] | I enabled [`custom-logo`](https://codex.wordpress.org/Function_Reference/add_theme_support#Custom_Logo) for my theme and have it printed with `<?php the_custom_logo(); ?>` into the header. Is there any chance to simply add some more classes to this image directly? Per default it only comes with `custom-logo`. | WordPress provide a filter hook to custom logo customization. The hook `get_custom_logo` is the filter. To change logo class, this code may help you.
```
add_filter( 'get_custom_logo', 'change_logo_class' );
function change_logo_class( $html ) {
$html = str_replace( 'custom-logo', 'your-custom-class', $html );
... |
229,921 | <p>Please help. Anyone knows of the proper way how to change the background color for a custom post type template only? Using chrome's inspect, I saw that my theme uses the ID of "#main" for all the page's background color so if I try changing it, all pages got affected. Just looking for a way on how only the CPT templ... | [
{
"answer_id": 229909,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 2,
"selected": false,
"text": "<p>I think I found one answer. But I really wonder if this is the right way? It feels a little bit dirty someho... | 2016/06/16 | [
"https://wordpress.stackexchange.com/questions/229921",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96830/"
] | Please help. Anyone knows of the proper way how to change the background color for a custom post type template only? Using chrome's inspect, I saw that my theme uses the ID of "#main" for all the page's background color so if I try changing it, all pages got affected. Just looking for a way on how only the CPT template... | WordPress provide a filter hook to custom logo customization. The hook `get_custom_logo` is the filter. To change logo class, this code may help you.
```
add_filter( 'get_custom_logo', 'change_logo_class' );
function change_logo_class( $html ) {
$html = str_replace( 'custom-logo', 'your-custom-class', $html );
... |
229,955 | <p>I have a custom post type for a simple schedule list and using the meta box plugin i have two meta boxes assigned to custom post type. 1 for an image and 1 for an array of date times .</p>
<p><a href="https://i.stack.imgur.com/OlDUy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OlDUy.png" alt=... | [
{
"answer_id": 229909,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 2,
"selected": false,
"text": "<p>I think I found one answer. But I really wonder if this is the right way? It feels a little bit dirty someho... | 2016/06/16 | [
"https://wordpress.stackexchange.com/questions/229955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96889/"
] | I have a custom post type for a simple schedule list and using the meta box plugin i have two meta boxes assigned to custom post type. 1 for an image and 1 for an array of date times .
[](https://i.stack.imgur.com/OlDUy.png)
In my functions.php file ... | WordPress provide a filter hook to custom logo customization. The hook `get_custom_logo` is the filter. To change logo class, this code may help you.
```
add_filter( 'get_custom_logo', 'change_logo_class' );
function change_logo_class( $html ) {
$html = str_replace( 'custom-logo', 'your-custom-class', $html );
... |
230,015 | <p>I need to use Bootstrap CSS for better UI in wp-admin but if I enqueue the <code>bootstrap.css</code>, it's affecting the admin default UI by changing background colors, etc.</p>
<p>How can I use <code>bootstrap.css</code> inside wp-admin? </p>
| [
{
"answer_id": 229909,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 2,
"selected": false,
"text": "<p>I think I found one answer. But I really wonder if this is the right way? It feels a little bit dirty someho... | 2016/06/17 | [
"https://wordpress.stackexchange.com/questions/230015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/90760/"
] | I need to use Bootstrap CSS for better UI in wp-admin but if I enqueue the `bootstrap.css`, it's affecting the admin default UI by changing background colors, etc.
How can I use `bootstrap.css` inside wp-admin? | WordPress provide a filter hook to custom logo customization. The hook `get_custom_logo` is the filter. To change logo class, this code may help you.
```
add_filter( 'get_custom_logo', 'change_logo_class' );
function change_logo_class( $html ) {
$html = str_replace( 'custom-logo', 'your-custom-class', $html );
... |
230,032 | <p>I've created a custom taxonomy:</p>
<pre><code>add_action( 'init', 'create_collection_taxonomies', 0 );
function create_collection_taxonomies() {
$labels = array(
'name' => _x( 'Collection Tags', 'taxonomy general name' ),
'singular_name' => _x( 'Collecti... | [
{
"answer_id": 230043,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 4,
"selected": true,
"text": "<p>Looking at the files that create the metabox, there isn't anything to really hook into that will allow us to... | 2016/06/17 | [
"https://wordpress.stackexchange.com/questions/230032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18984/"
] | I've created a custom taxonomy:
```
add_action( 'init', 'create_collection_taxonomies', 0 );
function create_collection_taxonomies() {
$labels = array(
'name' => _x( 'Collection Tags', 'taxonomy general name' ),
'singular_name' => _x( 'Collection Tag', 'taxonomy s... | Looking at the files that create the metabox, there isn't anything to really hook into that will allow us to add the description so we'll need to use jQuery. Since the script is extremely small, I've opted not to put it into an external file but instead use the [`admin_footer`](https://codex.wordpress.org/Plugin_API/Ac... |
230,085 | <p>The problem I am having is that the get_template_directory_uri is pointing to the parent theme like <code>site/wp-content/themes/twentythirteen/myGallery/gallery_functions_include.php</code></p>
<p>but I want it to point to my child theme which should be <code>site/wp-content/themes/child-twentythirteen/myGallery/g... | [
{
"answer_id": 230086,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 8,
"selected": true,
"text": "<p><code>get_template_directory_uri()</code> will always return the URI of the current parent theme.</p>\n\n<p... | 2016/06/18 | [
"https://wordpress.stackexchange.com/questions/230085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/88483/"
] | The problem I am having is that the get\_template\_directory\_uri is pointing to the parent theme like `site/wp-content/themes/twentythirteen/myGallery/gallery_functions_include.php`
but I want it to point to my child theme which should be `site/wp-content/themes/child-twentythirteen/myGallery/gallery_functions_includ... | `get_template_directory_uri()` will always return the URI of the current parent theme.
To get the child theme URI instead, you need to use `get_stylesheet_directory_uri()`.
You can find these [in the documentation](https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri), along with a list of othe... |
230,107 | <p>I have two translatable strings as follows in my 404.php file</p>
<pre><code>esc_html_e( 'I couldn't find the page you were looking for.', 'themename' );
esc_html_e( 'Try a search or one of the links below.', 'themename' );
</code></pre>
<p>At its present form, the first string does not get translated. Escaping th... | [
{
"answer_id": 230108,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>Anyone with a login can access the admin area, even if they're just a subscriber that can read posts and nothing... | 2016/06/18 | [
"https://wordpress.stackexchange.com/questions/230107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68715/"
] | I have two translatable strings as follows in my 404.php file
```
esc_html_e( 'I couldn't find the page you were looking for.', 'themename' );
esc_html_e( 'Try a search or one of the links below.', 'themename' );
```
At its present form, the first string does not get translated. Escaping the single quote with a back... | Anyone with a login can access the admin area, even if they're just a subscriber that can read posts and nothing more.
The crucial difference is not in the login, but in what parts of the admin one gets access to. A subscriber will only be able to see his personal profile, for instance. And admin gets access to everyt... |
230,129 | <p>I'm new to PHP, but I've noticed just about every PHP file has a security snippet, "Die if not accessed in the correct manner" script at the beginning; <strong>my question</strong>, does a child-theme <code>functions.php</code> need something like this as well to make it secure?</p>
<p><strong>PHP:</strong></p>
<p... | [
{
"answer_id": 230130,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 2,
"selected": false,
"text": "<p>Most of the times there is no need to check for <code>defined( 'ABSPATH' )</code> in the child theme.</p>\n... | 2016/06/18 | [
"https://wordpress.stackexchange.com/questions/230129",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93185/"
] | I'm new to PHP, but I've noticed just about every PHP file has a security snippet, "Die if not accessed in the correct manner" script at the beginning; **my question**, does a child-theme `functions.php` need something like this as well to make it secure?
**PHP:**
```
if ( ! defined( 'ABSPATH' ) ) {
die( 'Direct ... | Does it *need* it? Probably not (other than [this edge case](https://wordpress.stackexchange.com/a/63004/43098), props @bravokeyl). Should you add it? In my opinion, yes:
1. From a coding/architecture POV, you're declaring "this file needs WordPress".
2. Any direct hit to one of your theme's files (curious users, bots... |
230,150 | <p>I'm in Wordpress 4.5.2 on Windows 10 and I'm trying to register and enqueue my stylesheet in Wordpress, but it just isn't working. I'm having the same problem with jQuery.</p>
<p>I have this code in a plugin, and I am displaying a dashboard widget, which is working just fine:</p>
<pre><code><?php
/*
* ... | [
{
"answer_id": 230152,
"author": "Gregcta",
"author_id": 94533,
"author_profile": "https://wordpress.stackexchange.com/users/94533",
"pm_score": 3,
"selected": true,
"text": "<p>You can add stylesheet in back-office, but you need for that use the <code>admin_enqueue_scripts</code> action... | 2016/06/18 | [
"https://wordpress.stackexchange.com/questions/230150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67424/"
] | I'm in Wordpress 4.5.2 on Windows 10 and I'm trying to register and enqueue my stylesheet in Wordpress, but it just isn't working. I'm having the same problem with jQuery.
I have this code in a plugin, and I am displaying a dashboard widget, which is working just fine:
```
<?php
/*
* Plugin Name: TEST PLUG... | You can add stylesheet in back-office, but you need for that use the `admin_enqueue_scripts` action.
See Codex reference : <https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts> |
230,208 | <p>I would like show a list of tags assigned to the current post, but exclude one by tag id.</p>
<p>I tried excluding it from the array of objects returned from <code>wp_get_post_tags</code>, something like this:</p>
<pre><code>$tags = wp_get_post_tags($post->ID, array(
'exclude' => 13
)
);
</code></... | [
{
"answer_id": 230152,
"author": "Gregcta",
"author_id": 94533,
"author_profile": "https://wordpress.stackexchange.com/users/94533",
"pm_score": 3,
"selected": true,
"text": "<p>You can add stylesheet in back-office, but you need for that use the <code>admin_enqueue_scripts</code> action... | 2016/06/20 | [
"https://wordpress.stackexchange.com/questions/230208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96462/"
] | I would like show a list of tags assigned to the current post, but exclude one by tag id.
I tried excluding it from the array of objects returned from `wp_get_post_tags`, something like this:
```
$tags = wp_get_post_tags($post->ID, array(
'exclude' => 13
)
);
```
But it doesn't looks like the `wp_get_pos... | You can add stylesheet in back-office, but you need for that use the `admin_enqueue_scripts` action.
See Codex reference : <https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts> |
230,348 | <p>How to remove the:</p>
<pre><code> {site} / Proudly powered by WordPress
</code></pre>
<p>in bottom of generated pages using twentysixteen (2016) theme on version 4.5.2?</p>
<p>Would prefer if this change was not affected by later updates to the theme.</p>
<p>Note, that I could not make the previous answers wo... | [
{
"answer_id": 230152,
"author": "Gregcta",
"author_id": 94533,
"author_profile": "https://wordpress.stackexchange.com/users/94533",
"pm_score": 3,
"selected": true,
"text": "<p>You can add stylesheet in back-office, but you need for that use the <code>admin_enqueue_scripts</code> action... | 2016/06/21 | [
"https://wordpress.stackexchange.com/questions/230348",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97136/"
] | How to remove the:
```
{site} / Proudly powered by WordPress
```
in bottom of generated pages using twentysixteen (2016) theme on version 4.5.2?
Would prefer if this change was not affected by later updates to the theme.
Note, that I could not make the previous answers work, for example through modification of ... | You can add stylesheet in back-office, but you need for that use the `admin_enqueue_scripts` action.
See Codex reference : <https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts> |
230,394 | <p>I'm kind of new to WordPress development and I'm trying to make a plugin so I can show all the categories I have in a list.</p>
<p>The Idea is to customise the default view</p>
<p>Instead of the <a href="http://image.prntscr.com/image/a1f48a1cc67041e4b3e22753e5619f9a.png" rel="nofollow noreferrer">default list</a>... | [
{
"answer_id": 230468,
"author": "Howard E",
"author_id": 57589,
"author_profile": "https://wordpress.stackexchange.com/users/57589",
"pm_score": 1,
"selected": true,
"text": "<p>If you create your own shortcode based on the product category shortcode</p>\n\n<pre><code>function duck_prod... | 2016/06/21 | [
"https://wordpress.stackexchange.com/questions/230394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97165/"
] | I'm kind of new to WordPress development and I'm trying to make a plugin so I can show all the categories I have in a list.
The Idea is to customise the default view
Instead of the [default list](http://image.prntscr.com/image/a1f48a1cc67041e4b3e22753e5619f9a.png) I would like something like [this](http://image.prnts... | If you create your own shortcode based on the product category shortcode
```
function duck_product_categories( $atts ) {
global $woocommerce_loop;
$atts = shortcode_atts( array(
'number' => null,
'orderby' => 'name',
'order' => 'ASC',
'column... |
230,417 | <p>When adding a link in the WP visual post editor you have to click the settings after adding the link and then click the <strong>Open link in a new tab</strong> to have it add a link with a target in a new window/tab.</p>
<p>I am looking for a way to have this automatically checked by default. Is there a filter or ... | [
{
"answer_id": 230435,
"author": "BlueSuiter",
"author_id": 92665,
"author_profile": "https://wordpress.stackexchange.com/users/92665",
"pm_score": 3,
"selected": true,
"text": "<p>Add this function in your theme's functions.php</p>\n\n<pre><code>function my_enqueue($hook) {\n if ('po... | 2016/06/22 | [
"https://wordpress.stackexchange.com/questions/230417",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8668/"
] | When adding a link in the WP visual post editor you have to click the settings after adding the link and then click the **Open link in a new tab** to have it add a link with a target in a new window/tab.
I am looking for a way to have this automatically checked by default. Is there a filter or JavaScript code to do th... | Add this function in your theme's functions.php
```
function my_enqueue($hook) {
if ('post.php' != $hook ) {
return;
}
wp_enqueue_script('my_custom_script', get_template_directory_uri() . '/js/myscript.js');
}
add_action('admin_enqueue_scripts', 'my_enqueue');`
```
In myscript.js place this code... |
230,421 | <p>I originally posted this in the stackoverflow, but I believe it is better posted here as I am using wordpress and a wordpress function. I am trying to add the jquery cycle plugin (<a href="http://jquery.malsup.com/cycle/" rel="nofollow">http://jquery.malsup.com/cycle/</a>) to my wordpress site, so I enqueued it in ... | [
{
"answer_id": 230424,
"author": "LearntoExcel",
"author_id": 97108,
"author_profile": "https://wordpress.stackexchange.com/users/97108",
"pm_score": 2,
"selected": true,
"text": "<p>Problem was a simple misspelling.</p>\n\n<p>The add_action should be</p>\n\n<p>add_action ('wp_enqueue_sc... | 2016/06/22 | [
"https://wordpress.stackexchange.com/questions/230421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97108/"
] | I originally posted this in the stackoverflow, but I believe it is better posted here as I am using wordpress and a wordpress function. I am trying to add the jquery cycle plugin (<http://jquery.malsup.com/cycle/>) to my wordpress site, so I enqueued it in my functions.php, and then added a script right before the /bod... | Problem was a simple misspelling.
The add\_action should be
add\_action ('wp\_enqueue\_scripts', 'theme\_add\_cycle\_slide' );
I wrote 'script' |
230,426 | <p>OK so - we need a solid .htaccess rule to make the following happen:</p>
<p>Deny ALL from visiting the site (they are taken to 'down for maintenance' page, but ALLOW for me and our developer. </p>
<p>Yes, there is a WordPress Plugin but we had a terrible time with it.</p>
<p>Here's our propsed .htaccess rule</p>
... | [
{
"answer_id": 230424,
"author": "LearntoExcel",
"author_id": 97108,
"author_profile": "https://wordpress.stackexchange.com/users/97108",
"pm_score": 2,
"selected": true,
"text": "<p>Problem was a simple misspelling.</p>\n\n<p>The add_action should be</p>\n\n<p>add_action ('wp_enqueue_sc... | 2016/06/22 | [
"https://wordpress.stackexchange.com/questions/230426",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | OK so - we need a solid .htaccess rule to make the following happen:
Deny ALL from visiting the site (they are taken to 'down for maintenance' page, but ALLOW for me and our developer.
Yes, there is a WordPress Plugin but we had a terrible time with it.
Here's our propsed .htaccess rule
```
RewriteEngine On
Rewrit... | Problem was a simple misspelling.
The add\_action should be
add\_action ('wp\_enqueue\_scripts', 'theme\_add\_cycle\_slide' );
I wrote 'script' |
230,480 | <p>I've been wrestling with some code cobbled together for a function I found, first published circa 2009 and my inexperience with PHP has me at a loss.</p>
<p>The function is designed to count episodes in a podcast category, thus:</p>
<pre><code>function Get_Post_Number($postID){
$temp_query = $wp_query;
$postNumber... | [
{
"answer_id": 230456,
"author": "J. Davis",
"author_id": 97201,
"author_profile": "https://wordpress.stackexchange.com/users/97201",
"pm_score": -1,
"selected": false,
"text": "<p>Wordpress is generally fine as long as you change the siteurl and homeurl in the database.</p>\n"
},
{
... | 2016/06/22 | [
"https://wordpress.stackexchange.com/questions/230480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94803/"
] | I've been wrestling with some code cobbled together for a function I found, first published circa 2009 and my inexperience with PHP has me at a loss.
The function is designed to count episodes in a podcast category, thus:
```
function Get_Post_Number($postID){
$temp_query = $wp_query;
$postNumberQuery = new WP_Query(... | While this might be not the easiest task for a beginner, it is very well possible – with a little help from some plugins.
In a similar scenario I would usually install WordPress under a subdomain. When everything is looking ok to launch, I would recommend to first (always!) **make a backup** of everything. You can th... |
230,552 | <p>As we see in <a href="https://core.trac.wordpress.org/browser/tags/4.5/src/wp-includes/link-template.php#L2179" rel="nofollow">the source</a>, we can apply filters for <code>$attr</code>.</p>
<p>So I create something like this</p>
<pre><code>function asdff(){
return 'class="iamclass"';
}
add_filter('get_next_p... | [
{
"answer_id": 230456,
"author": "J. Davis",
"author_id": 97201,
"author_profile": "https://wordpress.stackexchange.com/users/97201",
"pm_score": -1,
"selected": false,
"text": "<p>Wordpress is generally fine as long as you change the siteurl and homeurl in the database.</p>\n"
},
{
... | 2016/06/23 | [
"https://wordpress.stackexchange.com/questions/230552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44538/"
] | As we see in [the source](https://core.trac.wordpress.org/browser/tags/4.5/src/wp-includes/link-template.php#L2179), we can apply filters for `$attr`.
So I create something like this
```
function asdff(){
return 'class="iamclass"';
}
add_filter('get_next_posts_link', 'asdff',10,2);
```
or
```
function asdff($a... | While this might be not the easiest task for a beginner, it is very well possible – with a little help from some plugins.
In a similar scenario I would usually install WordPress under a subdomain. When everything is looking ok to launch, I would recommend to first (always!) **make a backup** of everything. You can th... |
230,613 | <p>I have this code in my header.php and its working properly except showing li's without menu-item class, its showing them with page-item instead. this is when i dont have a menu created from admin and assigned it to a menu location.</p>
<p>So the menu is wordpress default menu which shows all the pages added. Is the... | [
{
"answer_id": 230641,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>The default fallback in <code>wp_nav_menu</code> for a menu that doesn't exist/isn't registered is <a href... | 2016/06/24 | [
"https://wordpress.stackexchange.com/questions/230613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97306/"
] | I have this code in my header.php and its working properly except showing li's without menu-item class, its showing them with page-item instead. this is when i dont have a menu created from admin and assigned it to a menu location.
So the menu is wordpress default menu which shows all the pages added. Is there a way t... | The default fallback in `wp_nav_menu` for a menu that doesn't exist/isn't registered is [`wp_page_menu`](https://developer.wordpress.org/reference/functions/wp_page_menu/), which unfortunately does not support the same arguments/implement the same level of "customisability" - you either need to create a custom fallback... |
230,686 | <p>I have a multisite wordpress with multiple localized sites (es_ES, de_DE, it_IT).
I want improve page speed by caching wordpress translation file.</p>
<p>My code works (inspired by <a href="http://blog.blackfire.io/improving-wordpress.html" rel="nofollow noreferrer">Tristan Darricau</a>)! and my page speed is impr... | [
{
"answer_id": 230685,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 1,
"selected": false,
"text": "<p>No, you cannot (easily) choose what tag ID is assigned. It's not random - it's the next ID available after... | 2016/06/25 | [
"https://wordpress.stackexchange.com/questions/230686",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92207/"
] | I have a multisite wordpress with multiple localized sites (es\_ES, de\_DE, it\_IT).
I want improve page speed by caching wordpress translation file.
My code works (inspired by [Tristan Darricau](http://blog.blackfire.io/improving-wordpress.html))! and my page speed is improved of 0.50 seconds.
Now, my question is: ... | No, you cannot (easily) choose what tag ID is assigned. It's not random - it's the next ID available after the last one that was created in the database.
If you *really* want to control tag IDs, you'll need to clear your database and start fresh, and create each tag in the order you want their IDs to be (and you won't... |
230,779 | <p>Recently i have install a wordpress multi-site for a client.<br>
After the initial launch client had change mind to transfer the site to a another domain, i have moved the WP multi-site successfully, i have no issue on front end, it's working fine i can access site 1 and site 2.</p>
<p>My issue is in back-end, when... | [
{
"answer_id": 230718,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 4,
"selected": true,
"text": "<p>Each of the files you have mentioned are theme files. When you upgrade WordPress itself, it will not touch ... | 2016/06/27 | [
"https://wordpress.stackexchange.com/questions/230779",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97402/"
] | Recently i have install a wordpress multi-site for a client.
After the initial launch client had change mind to transfer the site to a another domain, i have moved the WP multi-site successfully, i have no issue on front end, it's working fine i can access site 1 and site 2.
My issue is in back-end, when i access w... | Each of the files you have mentioned are theme files. When you upgrade WordPress itself, it will not touch any themes (or plugins) you have installed, whether or not you have modified them.
If this was a theme you created yourself, then you have no worries at all.
However, if this was a theme created by someone else,... |
230,836 | <p>In my site I'm using the Product Archive Customizer plugin for WooCommerce. Great plugin. However, there is an option to set the qty of products shown per page. The next piece of code is responsible for that:</p>
<pre><code>$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_products_per... | [
{
"answer_id": 230845,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know what hook Woocommerce uses to add that customizer code, but in your <code>functions.php</code> you'... | 2016/06/27 | [
"https://wordpress.stackexchange.com/questions/230836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64290/"
] | In my site I'm using the Product Archive Customizer plugin for WooCommerce. Great plugin. However, there is an option to set the qty of products shown per page. The next piece of code is responsible for that:
```
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_products_per_page', array(
... | I tried another solution and that did the trick. I found in the WooCommerce docs this little snippet:
`// Display 24 products per page. Goes in functions.php
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 );`.
It is overriding the settings in the customizer. I only have to change th... |
230,880 | <p>I have created a WordPress page that has this simple PHP code:</p>
<pre><code><?php
$result = array(
'State' => 'Done',
'ID' => 1
);
wp_send_json( $result );
?>
</code></pre>
<p>When submitting a form in another page using Ajax(JQuery) it calls this PHP page, then in th... | [
{
"answer_id": 230882,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>How can i return a PHP value from a WordPress page to a JQuery\n function?</p>\n</blockquot... | 2016/06/28 | [
"https://wordpress.stackexchange.com/questions/230880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97480/"
] | I have created a WordPress page that has this simple PHP code:
```
<?php
$result = array(
'State' => 'Done',
'ID' => 1
);
wp_send_json( $result );
?>
```
When submitting a form in another page using Ajax(JQuery) it calls this PHP page, then in the JQuery method i try to read the retu... | >
> How can i return a PHP value from a WordPress page to a JQuery
> function?
>
>
>
Use [`wp_localize_script`](https://developer.wordpress.org/reference/functions/wp_localize_script/) to create an object and pass it to the JavaScript. |
230,888 | <p>I've ran into this issue where WordPress requests my FTP login credentials.</p>
<p>So far I've tried:</p>
<ul>
<li>chown</li>
<li>change user</li>
<li>change file permissions</li>
<li>edited wp-config.php</li>
</ul>
<p>None of it seems to work. The server I'm hosting it on is a VPS. I don't have much info from it... | [
{
"answer_id": 230968,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": true,
"text": "<p>Guess it needs to be said first - it is a bad idea in general to just let anyone that succeeded to trick y... | 2016/06/28 | [
"https://wordpress.stackexchange.com/questions/230888",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97486/"
] | I've ran into this issue where WordPress requests my FTP login credentials.
So far I've tried:
* chown
* change user
* change file permissions
* edited wp-config.php
None of it seems to work. The server I'm hosting it on is a VPS. I don't have much info from it. I am able to connect to my FTP using FileZilla but Wor... | Guess it needs to be said first - it is a bad idea in general to just let anyone that succeeded to trick you into uploading his PHP onto your server to actually be able to write to your code directories. It is double problematic if you let him access to your root credentials and write to anywhere on your server.
That ... |
230,902 | <p>My html looks like this (simplified)</p>
<pre><code>$args = array(...);
$comments_query = new WP_Comment_Query;
$comments = $comments_query->query( $args );
foreach ($comments as $comment) {
<a class="respond-to-messages" href="#<?php echo $comment->comment_ID; ?>... | [
{
"answer_id": 230968,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": true,
"text": "<p>Guess it needs to be said first - it is a bad idea in general to just let anyone that succeeded to trick y... | 2016/06/28 | [
"https://wordpress.stackexchange.com/questions/230902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68619/"
] | My html looks like this (simplified)
```
$args = array(...);
$comments_query = new WP_Comment_Query;
$comments = $comments_query->query( $args );
foreach ($comments as $comment) {
<a class="respond-to-messages" href="#<?php echo $comment->comment_ID; ?>">Reply to message</a>
<div id="comment-<... | Guess it needs to be said first - it is a bad idea in general to just let anyone that succeeded to trick you into uploading his PHP onto your server to actually be able to write to your code directories. It is double problematic if you let him access to your root credentials and write to anywhere on your server.
That ... |
230,940 | <p>Contributors <a href="https://codex.wordpress.org/Roles_and_Capabilities#Contributor" rel="nofollow noreferrer">can create post drafts</a> but not publish. I'd like to add the same permission concept but to Pages. That is, can I allow a Contributor to create a page draft only to have an Editor/Admin to later approve... | [
{
"answer_id": 230942,
"author": "Rick",
"author_id": 33401,
"author_profile": "https://wordpress.stackexchange.com/users/33401",
"pm_score": -1,
"selected": false,
"text": "<p>A plugin to the rescue. It looks like <a href=\"https://wordpress.org/plugins/wpfront-user-role-editor/\" rel=\... | 2016/06/28 | [
"https://wordpress.stackexchange.com/questions/230940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33401/"
] | Contributors [can create post drafts](https://codex.wordpress.org/Roles_and_Capabilities#Contributor) but not publish. I'd like to add the same permission concept but to Pages. That is, can I allow a Contributor to create a page draft only to have an Editor/Admin to later approve or reject?
From this [question](https:... | >
> How would you go about this?
>
>
>
I see this is an old question and that you found a solution with an existing plugin. However, since this is a development StackExchange, it's probably better if there's an answer that explains how to accomplish the stated goals without the need for a third-party plugin.
### ... |
230,950 | <p>I'm migrating a site from my server to a client's Bluehost (ugh) account. I've tried using</p>
<ul>
<li>All In One WP Migrate</li>
<li>BackupBuddy</li>
<li>manual migration (copying files & exporting a db using WP Migrate DB)</li>
</ul>
<p>These are the stats on my server:</p>
<pre><code>Apache Version 2.2.2... | [
{
"answer_id": 230952,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 3,
"selected": true,
"text": "<p>You need to turn <code>WP_DEBUG</code> on in your <code>wp-config.php</code>:</p>\n\n<pre><code>define( 'WP... | 2016/06/28 | [
"https://wordpress.stackexchange.com/questions/230950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45248/"
] | I'm migrating a site from my server to a client's Bluehost (ugh) account. I've tried using
* All In One WP Migrate
* BackupBuddy
* manual migration (copying files & exporting a db using WP Migrate DB)
These are the stats on my server:
```
Apache Version 2.2.24
PHP Version 5.3.26
MySQL Version 5.6.28-76.1
```
An... | You need to turn `WP_DEBUG` on in your `wp-config.php`:
```
define( 'WP_DEBUG', true );
```
That'll help a lot with working out where that 500 error is coming from. Based on the PHP versions you've mentioned, I'm 99.999% sure that the error is due to a feature that isn't available in PHP 5.2.17. You're probably look... |
230,956 | <p><strong>WordPress setup:</strong> Installed WordPress using <a href="https://github.com/Varying-Vagrant-Vagrants/VVV" rel="nofollow">VVV</a>.</p>
<p><strong>PHPUnit setup:</strong>
I have setup the testing suite as mentioned in <a href="https://pippinsplugins.com/unit-tests-wordpress-plugins-setting-up-testing-sui... | [
{
"answer_id": 230978,
"author": "Mohit Kumar Arora",
"author_id": 97527,
"author_profile": "https://wordpress.stackexchange.com/users/97527",
"pm_score": 1,
"selected": false,
"text": "<p>There are many differences in css files of both websites.\nFor example, have a look at the div havi... | 2016/06/29 | [
"https://wordpress.stackexchange.com/questions/230956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83739/"
] | **WordPress setup:** Installed WordPress using [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV).
**PHPUnit setup:**
I have setup the testing suite as mentioned in [Pippin's blog](https://pippinsplugins.com/unit-tests-wordpress-plugins-setting-up-testing-suite/). And accessing PHPUnit after logging into the box ... | There are many differences in css files of both websites.
For example, have a look at the div having class **et-top-navigation** by inspecting it in browser.
You will find that in staging website, there is top padding and left padding applied while it is not in case of live website.
Similarly check for other css chan... |
230,960 | <p>Working on my first theme and thinking about adding some options that are specifically numbers like number of menu levels or number of posts to display on the homepage. Is it possible to check that the input in the customizer is just a number? And perhaps a certain limit like 5 for menu levels and 20 or something fo... | [
{
"answer_id": 230962,
"author": "jetyet47",
"author_id": 91783,
"author_profile": "https://wordpress.stackexchange.com/users/91783",
"pm_score": 1,
"selected": false,
"text": "<p>Think I figured it out. Type number definitely works not allowing text input. And it includes little arrow c... | 2016/06/29 | [
"https://wordpress.stackexchange.com/questions/230960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91783/"
] | Working on my first theme and thinking about adding some options that are specifically numbers like number of menu levels or number of posts to display on the homepage. Is it possible to check that the input in the customizer is just a number? And perhaps a certain limit like 5 for menu levels and 20 or something for p... | You are right. A couple of fixes/suggestions, though.
* You should use [`absint`](https://codex.wordpress.org/Function_Reference/absint) as a sanitization callback.
* Also, you don't have to explicitly use the WP\_Customize\_Control class. The number field can be created with the regular syntax you use for the text fi... |
230,991 | <p>I'm applying a filter to a custom fields plugin.</p>
<pre><code>add_filter('acf/load_value', word_swap);
</code></pre>
<p>My problem is this applies it to pages within the wp-admin also. I only want the filter applied to the actual WP site, and not the admin panel.</p>
<p>How can I prevent the filter being applie... | [
{
"answer_id": 230993,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>You need the <code>!is_admin()</code> check. This will return false on admin pages, failing your conditi... | 2016/06/29 | [
"https://wordpress.stackexchange.com/questions/230991",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29510/"
] | I'm applying a filter to a custom fields plugin.
```
add_filter('acf/load_value', word_swap);
```
My problem is this applies it to pages within the wp-admin also. I only want the filter applied to the actual WP site, and not the admin panel.
How can I prevent the filter being applied to the wp-admin pages?
I imagi... | You need the `!is_admin()` check. This will return false on admin pages, failing your condition. On front end pages, that condition will return true, executing your conditional statement
```
if ( !is_admin() ) {
// Do something only on frontend
}
``` |
231,003 | <p>How do I get a list of all users with role = 'Customers' including all the metadata per user, means wp_users + wp_usermeta.</p>
<p>Query blow does not generate the wanted results.</p>
<pre><code>$query = "SELECT * FROM wp_users INNER JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id ORDER BY ID DESC'); &qu... | [
{
"answer_id": 231057,
"author": "Syed Fakhar Abbas",
"author_id": 90591,
"author_profile": "https://wordpress.stackexchange.com/users/90591",
"pm_score": 6,
"selected": true,
"text": "<p>I think you should use wp-api functions which will do everything for you.</p>\n\n<ul>\n<li><a href=\... | 2016/06/29 | [
"https://wordpress.stackexchange.com/questions/231003",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78746/"
] | How do I get a list of all users with role = 'Customers' including all the metadata per user, means wp\_users + wp\_usermeta.
Query blow does not generate the wanted results.
```
$query = "SELECT * FROM wp_users INNER JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id ORDER BY ID DESC'); ";
$data = $wpdb->get_re... | I think you should use wp-api functions which will do everything for you.
* [get\_users()](https://developer.wordpress.org/reference/functions/get_users/) function will get all users data just define fields which u require.
* [get\_user\_meta(](https://developer.wordpress.org/reference/functions/get_user_meta/)) funct... |
231,008 | <p>In the <code>footer.php</code> I show all the authors of my blog with the following code: </p>
<pre><code>$args = array(
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC'
);
// Create the WP_User_Query object
$wp_user_query = new WP_User_Query( $args );
$wp_user_query->... | [
{
"answer_id": 231011,
"author": "Ismail",
"author_id": 70833,
"author_profile": "https://wordpress.stackexchange.com/users/70833",
"pm_score": 2,
"selected": false,
"text": "<p>Yes possible, just tell WordPress to use <code>RAND()</code> SQL sorting when passing <code>rand</code> in <a ... | 2016/06/29 | [
"https://wordpress.stackexchange.com/questions/231008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81609/"
] | In the `footer.php` I show all the authors of my blog with the following code:
```
$args = array(
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC'
);
// Create the WP_User_Query object
$wp_user_query = new WP_User_Query( $args );
$wp_user_query->query_orderby = str_replace( 'user_lo... | Yes possible, just tell WordPress to use `RAND()` SQL sorting when passing `rand` in [`orderby`](https://codex.wordpress.org/Class_Reference/WP_User_Query#Order_.26_Orderby_Parameters) parameter:
```
add_action( "pre_user_query", function( $query ) {
if( "rand" == $query->query_vars["orderby"] ) {
$query->... |
231,010 | <p>I'm trying to remove or hide the update nags for non-admin users. As an admin, I see:</p>
<p><a href="https://i.stack.imgur.com/29Kmx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/29Kmx.png" alt="enter image description here"></a></p>
<p>The popular answer I've seen to handle this says to use:</p>
<pr... | [
{
"answer_id": 231012,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 5,
"selected": true,
"text": "<p>In <code>wp-admin/includes/update.php</code> file</p>\n\n<pre><code>if ( current_user_can('update_core') )\n... | 2016/06/29 | [
"https://wordpress.stackexchange.com/questions/231010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26666/"
] | I'm trying to remove or hide the update nags for non-admin users. As an admin, I see:
[](https://i.stack.imgur.com/29Kmx.png)
The popular answer I've seen to handle this says to use:
```
function hide_update_nag() {
if ( !current_user_can('updat... | In `wp-admin/includes/update.php` file
```
if ( current_user_can('update_core') )
$msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
else
$msg = __('An automated WordPress update has failed to comp... |
231,040 | <p>Default WordPress galleries img tags close like <code><img></code> which is invalid XHTML. The lazyload XT plugin that I'm using targets valid XHTML img tags which means ending should be:</p>
<pre><code><img src="http://www.acaciafotografia.com/wp-content/themes/jamdxstarter/img/tri.jpg"/>
</code></pre>... | [
{
"answer_id": 231045,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 1,
"selected": false,
"text": "<p>As <a href=\"https://stackoverflow.com/a/23410472/1982136\">linked to</a> from the comments on your questi... | 2016/06/29 | [
"https://wordpress.stackexchange.com/questions/231040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67879/"
] | Default WordPress galleries img tags close like `<img>` which is invalid XHTML. The lazyload XT plugin that I'm using targets valid XHTML img tags which means ending should be:
```
<img src="http://www.acaciafotografia.com/wp-content/themes/jamdxstarter/img/tri.jpg"/>
```
*instead of*
```
<img src="http://www.acaci... | As [linked to](https://stackoverflow.com/a/23410472/1982136) from the comments on your question, the [post\_gallery filter](https://developer.wordpress.org/reference/hooks/post_gallery/) should help you here.
Unlike a lot of other hooks though, you can't filter the output that comes through from WordPress; you can onl... |
231,054 | <p>As you see this pagination. there is no "pre" button or text. because there is no previous posts. ( <a href="http://prntscr.com/bmuui2" rel="nofollow">http://prntscr.com/bmuui2</a> )</p>
<p>However I want to show the buttons (previous / next ) even if there is no (previous / next ) posts.</p>
<p>Because of design ... | [
{
"answer_id": 231045,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 1,
"selected": false,
"text": "<p>As <a href=\"https://stackoverflow.com/a/23410472/1982136\">linked to</a> from the comments on your questi... | 2016/06/30 | [
"https://wordpress.stackexchange.com/questions/231054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34463/"
] | As you see this pagination. there is no "pre" button or text. because there is no previous posts. ( <http://prntscr.com/bmuui2> )
However I want to show the buttons (previous / next ) even if there is no (previous / next ) posts.
Because of design balance.
I want to make to show like this all the time. ( <http://pr... | As [linked to](https://stackoverflow.com/a/23410472/1982136) from the comments on your question, the [post\_gallery filter](https://developer.wordpress.org/reference/hooks/post_gallery/) should help you here.
Unlike a lot of other hooks though, you can't filter the output that comes through from WordPress; you can onl... |
231,087 | <p>I want to make a permalink to my most recent blog post. I would use this link as a navbar link. The reason I'm not putting code straight into the navbar is because I am using a widget which will not let me get into the code, and my coding knowledge is next to none. Could someone ELI5 how to do this and where to inse... | [
{
"answer_id": 231045,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 1,
"selected": false,
"text": "<p>As <a href=\"https://stackoverflow.com/a/23410472/1982136\">linked to</a> from the comments on your questi... | 2016/06/30 | [
"https://wordpress.stackexchange.com/questions/231087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97595/"
] | I want to make a permalink to my most recent blog post. I would use this link as a navbar link. The reason I'm not putting code straight into the navbar is because I am using a widget which will not let me get into the code, and my coding knowledge is next to none. Could someone ELI5 how to do this and where to insert ... | As [linked to](https://stackoverflow.com/a/23410472/1982136) from the comments on your question, the [post\_gallery filter](https://developer.wordpress.org/reference/hooks/post_gallery/) should help you here.
Unlike a lot of other hooks though, you can't filter the output that comes through from WordPress; you can onl... |
231,096 | <p>Using this code to get some data into a PHP array:</p>
<pre><code>$currentProducts = array();
$currentProducts = $wpdb->get_results("SELECT id, feedid, size, price FROM products WHERE shopid = $shopid");
</code></pre>
<p>No problems getting the data into a normal PHP array.</p>
<p>How do I get the data into an... | [
{
"answer_id": 231101,
"author": "dg4220",
"author_id": 91201,
"author_profile": "https://wordpress.stackexchange.com/users/91201",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure why you need to do that but, all you need is a loop:</p>\n\n<pre><code>foreach ( $currentProducts as ... | 2016/06/30 | [
"https://wordpress.stackexchange.com/questions/231096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97605/"
] | Using this code to get some data into a PHP array:
```
$currentProducts = array();
$currentProducts = $wpdb->get_results("SELECT id, feedid, size, price FROM products WHERE shopid = $shopid");
```
No problems getting the data into a normal PHP array.
How do I get the data into an array where the feedid is key, so I... | Found the solution:
```
$currentProducts = $wpdb->get_results("SELECT feedid, id, size, price FROM products WHERE shopid = $shopid", OBJECT_K);
```
The OBJECT\_K parameter makes an associative array with feedid as key: <https://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results> |