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 |
|---|---|---|---|---|---|---|
145,008 | <p>I'm trying to output a list of dates that are held in a meta key called event_dates without duplicates. I've also tried a <code>wp_query</code> with a <code>meta_compare</code> but I'm not able to make that work either. Any help would be greatly appreciated. Thanks!</p>
<pre><code><?php
$args1 = array(
... | [
{
"answer_id": 145009,
"author": "felipelavinz",
"author_id": 16714,
"author_profile": "https://wordpress.stackexchange.com/users/16714",
"pm_score": 1,
"selected": false,
"text": "<p>Ok, you can do this using direct queries with $wpdb or just with WordPress.</p>\n\n<p>Generally speaking... | 2014/05/20 | [
"https://wordpress.stackexchange.com/questions/145008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51857/"
] | I'm trying to output a list of dates that are held in a meta key called event\_dates without duplicates. I've also tried a `wp_query` with a `meta_compare` but I'm not able to make that work either. Any help would be greatly appreciated. Thanks!
```
<?php
$args1 = array(
'post_type'=>'cw_events',
... | The answer by felipelavinz assumes that there is an array of dates stored in the post\_meta of each post, but the way I read your question and sample code it seemed as though you have one date specified per post? If this is true (one date per post)
then the following would suit you better
```
<?php
// this is the cor... |
145,015 | <p>There are some styles in my parent theme that I would simply remove from the stylesheet if I was not using a child theme. Obviously, I do not want to remove them from the parent css, but is there a way to effectively "remove" the styles using my child theme?</p>
| [
{
"answer_id": 145019,
"author": "totels",
"author_id": 23446,
"author_profile": "https://wordpress.stackexchange.com/users/23446",
"pm_score": 0,
"selected": false,
"text": "<p>Effectively, yes. Unless I am misunderstanding your question, this is just basic CSS specificity. I assume you... | 2014/05/20 | [
"https://wordpress.stackexchange.com/questions/145015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51932/"
] | There are some styles in my parent theme that I would simply remove from the stylesheet if I was not using a child theme. Obviously, I do not want to remove them from the parent css, but is there a way to effectively "remove" the styles using my child theme? | The only way to "remove" styles from the parent theme is to override them in your child theme's css.
For example if you have the following declaration in your parent theme:
```
.someclass{
width: 200px;
float: left;
}
```
You can override the width and float by declaring the following in your child theme:
... |
145,018 | <p>I'm creating my own Wordpress theme, and I'm trying to make it compatible with Woocommerce. I understand pretty much everything about theming woocommerce, including copying the template files and changing them, also I'm confortable with some of the Woocommerce hooks as well.</p>
<p>Now Woocommerce uses an archive-p... | [
{
"answer_id": 145076,
"author": "aj-adl",
"author_id": 51825,
"author_profile": "https://wordpress.stackexchange.com/users/51825",
"pm_score": 3,
"selected": true,
"text": "<p>Woocommerce does hijack the main query on the shop page / product queries, so it's possible that you're used to... | 2014/05/20 | [
"https://wordpress.stackexchange.com/questions/145018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43834/"
] | I'm creating my own Wordpress theme, and I'm trying to make it compatible with Woocommerce. I understand pretty much everything about theming woocommerce, including copying the template files and changing them, also I'm confortable with some of the Woocommerce hooks as well.
Now Woocommerce uses an archive-product.php... | Woocommerce does hijack the main query on the shop page / product queries, so it's possible that you're used to referencing your custom fields within the loop or in some other context where the global $post is the page you are on, but in this case the contents of $post will be Woocommerce products and not the page.
I... |
145,023 | <p>Been trying to use the pagination functions in wordpress with this code</p>
<pre><code><?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_status' => 'pending', 'posts_per_page' => 3, 'paged'=>$paged);
$recent_posts = new WP_Query( $args );
?>
<?php while (... | [
{
"answer_id": 145076,
"author": "aj-adl",
"author_id": 51825,
"author_profile": "https://wordpress.stackexchange.com/users/51825",
"pm_score": 3,
"selected": true,
"text": "<p>Woocommerce does hijack the main query on the shop page / product queries, so it's possible that you're used to... | 2014/05/20 | [
"https://wordpress.stackexchange.com/questions/145023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51887/"
] | Been trying to use the pagination functions in wordpress with this code
```
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_status' => 'pending', 'posts_per_page' => 3, 'paged'=>$paged);
$recent_posts = new WP_Query( $args );
?>
<?php while ( $recent_posts->have_posts()) {
... | Woocommerce does hijack the main query on the shop page / product queries, so it's possible that you're used to referencing your custom fields within the loop or in some other context where the global $post is the page you are on, but in this case the contents of $post will be Woocommerce products and not the page.
I... |
145,026 | <p>This seems like a very unusual behavior: Usually, when activating a plugin, a path to the plugin's main file (or bootstrap) is stored in the database under <code>options.active_plugins</code>.
However, something in the following code is causing Wordpress to store the object itself, rather than a path to it, in the d... | [
{
"answer_id": 145027,
"author": "Yoav Kadosh",
"author_id": 25959,
"author_profile": "https://wordpress.stackexchange.com/users/25959",
"pm_score": -1,
"selected": false,
"text": "<p>It turns out that using a variable named <code>$plugin</code> as a part of the plugin's bootstrap proces... | 2014/05/20 | [
"https://wordpress.stackexchange.com/questions/145026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25959/"
] | This seems like a very unusual behavior: Usually, when activating a plugin, a path to the plugin's main file (or bootstrap) is stored in the database under `options.active_plugins`.
However, something in the following code is causing Wordpress to store the object itself, rather than a path to it, in the database.
Here... | You should just not add code outside of actions (callbacks attached to hooks and filters). Else your variables might conflict with global variables. The default/first action for a plugin bootstrap would be (depending on the type of plugin): `plugins_loaded` or `muplugins_loaded`.
Attach hooks from there on to `wp_load... |
145,062 | <p>I want to add_filter for the_content in functions.php of my theme.
I have added code which just display echo but it seams that my filter is not applied.</p>
<pre><code>function add_mod_hatom_data($content) {
// $t = get_the_modified_time('F jS, Y');
//$author = get_the_author();
// $title = get_the_title()... | [
{
"answer_id": 145068,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 1,
"selected": false,
"text": "<p>That is because the variable '$content' is empty. The way you are using this filter is correct. Instead of... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50720/"
] | I want to add\_filter for the\_content in functions.php of my theme.
I have added code which just display echo but it seams that my filter is not applied.
```
function add_mod_hatom_data($content) {
// $t = get_the_modified_time('F jS, Y');
//$author = get_the_author();
// $title = get_the_title();
//if(is... | This part of the single post template is called the loop:
```
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
```
Within the loop you need to call in the content:
```
<?php the_content(); ?>
```
Replace your single post template with this and see if it works now:
```
<?php get_header(); ?>
... |
145,090 | <pre><code>if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $wp_query;
if ( $wp_query->max_num_pages <= 1 )
return;
?>
<nav class="woocommerce-pagination">
<?php
echo paginate_links( apply_filters( 'woocommerce_pagination_args', array(
'base' ... | [
{
"answer_id": 145093,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>A simple <code>str_replace</code> would do the trick:</p>\n\n<pre><code>$links = paginate_links( $argument... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51965/"
] | ```
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $wp_query;
if ( $wp_query->max_num_pages <= 1 )
return;
?>
<nav class="woocommerce-pagination">
<?php
echo paginate_links( apply_filters( 'woocommerce_pagination_args', array(
'base' => str_replace( 9999999... | A simple `str_replace` would do the trick:
```
$links = paginate_links( $arguments );
$links = str_replace( 'href="', 'rel="nofollow" href="', $links );
echo $links;
``` |
145,092 | <p>I created a theme and use Themes Customizer. Is there any way I can give anonymous users access to the themes customizer without the ability to save it? </p>
<p>It will be very convenient in terms of user experience if users are able to know what kind of theme customization we offer and how they can change it.</p>
... | [
{
"answer_id": 145093,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>A simple <code>str_replace</code> would do the trick:</p>\n\n<pre><code>$links = paginate_links( $argument... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17521/"
] | I created a theme and use Themes Customizer. Is there any way I can give anonymous users access to the themes customizer without the ability to save it?
It will be very convenient in terms of user experience if users are able to know what kind of theme customization we offer and how they can change it.
Thank you | A simple `str_replace` would do the trick:
```
$links = paginate_links( $arguments );
$links = str_replace( 'href="', 'rel="nofollow" href="', $links );
echo $links;
``` |
145,094 | <p>I would like to override some mark-up and css (like <code><div class="soma_container"><ul class=""></ul></div></code>)styling on a chosen custom menu widget. How would I do that? Should be hooked as the main navigation in <code>functions.php</code> or if there is good tutorial on this would b... | [
{
"answer_id": 145097,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 0,
"selected": false,
"text": "<p>Without extending the default widget and creating your own custom widget from it, I am not sure if you can... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23759/"
] | I would like to override some mark-up and css (like `<div class="soma_container"><ul class=""></ul></div>`)styling on a chosen custom menu widget. How would I do that? Should be hooked as the main navigation in `functions.php` or if there is good tutorial on this would be really appreciated
I think a some of the thing... | Ok, here we go. I extended the default Navigation widget for you. Add this to your themes functions file. After you have done this, go to widgets in your dashboard and you will see a widget called 'Matt Royal Custom Menu' now. Use this one.
In the below code, the div class has been added as you have specified and you ... |
145,115 | <p>I'd like to debug some WordPress functionality, but to do so I need to know where to find the php file that is executing on a given page. How can I set up something that will tell me what php files (or functions, objects) are being called to generate a given page? I'm using a ridiculous amount of plugins, and I have... | [
{
"answer_id": 145123,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure there is a generic answer to this question but my advice would be to:</p>\n\n<ol>\n<li><a href... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26588/"
] | I'd like to debug some WordPress functionality, but to do so I need to know where to find the php file that is executing on a given page. How can I set up something that will tell me what php files (or functions, objects) are being called to generate a given page? I'm using a ridiculous amount of plugins, and I have a ... | There's a [native PHP function `get_included_files()`](http://us1.php.net/manual/en/function.get-included-files.php) for that.
Simply attach it to an action on the hook from where you want to know it. The first one is `muplugins_loaded` and the last accessible on is `shutdown`.
```
add_action( 'muplugins_loaded', fun... |
145,125 | <p>I'm trying to get my news page to display content from one category only (number 3) but I cant seem to get it to work. Instead of just displaying posts from category 3 it displays posts from all category's.</p>
<p>Here is my code:</p>
<pre><code><?php get_header(); ?>
<div class="content news... | [
{
"answer_id": 145126,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters\" rel=\"noreferrer\">The ar... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51632/"
] | I'm trying to get my news page to display content from one category only (number 3) but I cant seem to get it to work. Instead of just displaying posts from category 3 it displays posts from all category's.
Here is my code:
```
<?php get_header(); ?>
<div class="content news_page">
... | [The argument isn't `category`, it is `cat`.](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters) Your query fails because you are using an argument that doesn't exist.
```
$args = array(
'post_type' => 'post' ,
'orderby' => 'date' ,
'order' => 'DESC' ,
'posts_per_page' => 6,
'cat' ... |
145,131 | <p>I couldn't add selected data to a div using ajax. Here is my code:</p>
<pre><code><?php
function master_ajaxurl() {
$myOpt = $_POST['option'];
bringDetails($myOpt);
}
function bringDetails($opt)
{
global $wpdb;
$sql ="SELECT * from mst_urun_liste WHERE kod l... | [
{
"answer_id": 145150,
"author": "Hybrid Web Dev",
"author_id": 36506,
"author_profile": "https://wordpress.stackexchange.com/users/36506",
"pm_score": 0,
"selected": false,
"text": "<p>A look at the script itself, it appears you have everything hooked correctly.</p>\n\n<p>Looking at you... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145131",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34632/"
] | I couldn't add selected data to a div using ajax. Here is my code:
```
<?php
function master_ajaxurl() {
$myOpt = $_POST['option'];
bringDetails($myOpt);
}
function bringDetails($opt)
{
global $wpdb;
$sql ="SELECT * from mst_urun_liste WHERE kod like '$opt'";
... | ```
$.post(ajaxurl,{
action:'master_ajaxurl',
option: $(this).find("option:selected").val(), // use option also here
},
function(data){
//adds the echoed response to our container
// alert(data);
$("#details").html(data);
}
);
```
Mo... |
145,141 | <p>In header.php, I like to attribute a version number to the stylesheet so that the browser gets forced to refresh it. But when working with a child theme, its stylesheet is not explicitely called, rather WordPress automatically seeks it. So how or where to attribute a version number to the child theme's stylesheet?</... | [
{
"answer_id": 145145,
"author": "selfagency",
"author_id": 45819,
"author_profile": "https://wordpress.stackexchange.com/users/45819",
"pm_score": 0,
"selected": false,
"text": "<p>I believe that if you use the Wordpress theme editor to edit your child theme's stylesheet that it automat... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | In header.php, I like to attribute a version number to the stylesheet so that the browser gets forced to refresh it. But when working with a child theme, its stylesheet is not explicitely called, rather WordPress automatically seeks it. So how or where to attribute a version number to the child theme's stylesheet? | You can update the version in the child themes style sheet itself...
```
/*
Theme Name: Twenty Fourteen Child
Theme URI: http://example.com/twenty-fourteen-child/
Description: Twenty Fourteen Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentyfourteen
Version: 1.1... |
145,148 | <p>I want to create a list of posts from a Custom Post Type and add some filters the user can click to filter the list.</p>
<p>I added filters for all the categories by using the get_terms() function. Now I want to add filters by year, so I need a way to retrieve a list of all the years in which at least one post has ... | [
{
"answer_id": 145149,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 2,
"selected": false,
"text": "<p>You could use a WP function and a shortcode this way :</p>\n\n<pre><code>add_shortcode( 'archives', '_get_archiv... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145148",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48313/"
] | I want to create a list of posts from a Custom Post Type and add some filters the user can click to filter the list.
I added filters for all the categories by using the get\_terms() function. Now I want to add filters by year, so I need a way to retrieve a list of all the years in which at least one post has been publ... | Your question is pretty old, but I just wanted to add a real solution to your question. Here's a function that will return an array of years you have posts published in. You can put this function in functions.php or in a plugin or whatever you want.
```
function get_posts_years_array() {
global $wpdb;
$result ... |
145,155 | <p>I have developed a wordpress plugin and I need to delete the options I am creating when uninstalling. What I did is I created a file called uninstall.php and included the following code:</p>
<pre><code><?php
function WCM_Setup_Demo_on_uninstall()
{
//if uninstall not called from WordPress exit
if ( !defined( 'W... | [
{
"answer_id": 145149,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 2,
"selected": false,
"text": "<p>You could use a WP function and a shortcode this way :</p>\n\n<pre><code>add_shortcode( 'archives', '_get_archiv... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51885/"
] | I have developed a wordpress plugin and I need to delete the options I am creating when uninstalling. What I did is I created a file called uninstall.php and included the following code:
```
<?php
function WCM_Setup_Demo_on_uninstall()
{
//if uninstall not called from WordPress exit
if ( !defined( 'WP_UNINSTALL_PLUGI... | Your question is pretty old, but I just wanted to add a real solution to your question. Here's a function that will return an array of years you have posts published in. You can put this function in functions.php or in a plugin or whatever you want.
```
function get_posts_years_array() {
global $wpdb;
$result ... |
145,158 | <p>Is it possible to export WordPress from command line?</p>
<p>I don't mean use <code>mysqldump</code> to export the database, but create the xml file used to easily import to another WordPress installation.</p>
| [
{
"answer_id": 145161,
"author": "Adam H",
"author_id": 38234,
"author_profile": "https://wordpress.stackexchange.com/users/38234",
"pm_score": 4,
"selected": true,
"text": "<p>Check out <a href=\"http://wp-cli.org/\" rel=\"noreferrer\">http://wp-cli.org/</a>. It's fantastic and I've use... | 2014/05/21 | [
"https://wordpress.stackexchange.com/questions/145158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47317/"
] | Is it possible to export WordPress from command line?
I don't mean use `mysqldump` to export the database, but create the xml file used to easily import to another WordPress installation. | Check out <http://wp-cli.org/>. It's fantastic and I've used the export capability multiple times.
More information on wp-cli.
>
> WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
>
>
>
You wi... |
145,194 | <p>Is there a way to extract the url from <a href="http://codex.wordpress.org/Function_Reference/next_image_link" rel="nofollow">next_image_link</a>?</p>
<p>I want the image on the attachment page to link to the next image, but i didn't manage to figure out how to do it.</p>
| [
{
"answer_id": 145161,
"author": "Adam H",
"author_id": 38234,
"author_profile": "https://wordpress.stackexchange.com/users/38234",
"pm_score": 4,
"selected": true,
"text": "<p>Check out <a href=\"http://wp-cli.org/\" rel=\"noreferrer\">http://wp-cli.org/</a>. It's fantastic and I've use... | 2014/05/22 | [
"https://wordpress.stackexchange.com/questions/145194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47701/"
] | Is there a way to extract the url from [next\_image\_link](http://codex.wordpress.org/Function_Reference/next_image_link)?
I want the image on the attachment page to link to the next image, but i didn't manage to figure out how to do it. | Check out <http://wp-cli.org/>. It's fantastic and I've used the export capability multiple times.
More information on wp-cli.
>
> WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
>
>
>
You wi... |
145,215 | <p>I want to list all sites in the multi site network in alphabetical order? Right now, the code lists by registered date</p>
<pre><code><?php
// Query for getting blogs
$blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '... | [
{
"answer_id": 145161,
"author": "Adam H",
"author_id": 38234,
"author_profile": "https://wordpress.stackexchange.com/users/38234",
"pm_score": 4,
"selected": true,
"text": "<p>Check out <a href=\"http://wp-cli.org/\" rel=\"noreferrer\">http://wp-cli.org/</a>. It's fantastic and I've use... | 2014/05/22 | [
"https://wordpress.stackexchange.com/questions/145215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17971/"
] | I want to list all sites in the multi site network in alphabetical order? Right now, the code lists by registered date
```
<?php
// Query for getting blogs
$blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND ... | Check out <http://wp-cli.org/>. It's fantastic and I've used the export capability multiple times.
More information on wp-cli.
>
> WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
>
>
>
You wi... |
145,234 | <p>I am trying to find a solution for getting next pages for category or tag page in WordPress, tried with <code>next_posts_link</code> and <code>previous_posts_link</code> in these pages, but it's not working.</p>
<p>Same functions are working on post listing page for me</p>
<p>Below is my code</p>
<pre><code><d... | [
{
"answer_id": 145240,
"author": "user48752",
"author_id": 48752,
"author_profile": "https://wordpress.stackexchange.com/users/48752",
"pm_score": -1,
"selected": false,
"text": "<p>Try using <code>get_next_posts_link();</code> right after or outside your while loop. So you'd use it some... | 2014/05/22 | [
"https://wordpress.stackexchange.com/questions/145234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52031/"
] | I am trying to find a solution for getting next pages for category or tag page in WordPress, tried with `next_posts_link` and `previous_posts_link` in these pages, but it's not working.
Same functions are working on post listing page for me
Below is my code
```
<div class="wrapper inner_content_wrap">
<?p... | Two problems I can see off hand here
Firstly, you should move your query to outside your `if` conditional statement.
Secondly, when using `WP_Query`, the `$max_pages` parameter should be used when using [`next_posts_link( $label , $max_pages );`](http://codex.wordpress.org/Function_Reference/next_posts_link)
So, yo... |
145,250 | <p>Just a quick question to see if anyone has done this before, is there a function that I can use to add a custom message to the "Wordpress XX is available"</p>
<p><img src="https://i.stack.imgur.com/EwGgg.png" alt="Update Notice Image"></p>
<p>Recently, I've had clients updating their own site and making a right me... | [
{
"answer_id": 145240,
"author": "user48752",
"author_id": 48752,
"author_profile": "https://wordpress.stackexchange.com/users/48752",
"pm_score": -1,
"selected": false,
"text": "<p>Try using <code>get_next_posts_link();</code> right after or outside your while loop. So you'd use it some... | 2014/05/22 | [
"https://wordpress.stackexchange.com/questions/145250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27504/"
] | Just a quick question to see if anyone has done this before, is there a function that I can use to add a custom message to the "Wordpress XX is available"

Recently, I've had clients updating their own site and making a right mess of things, especially with t... | Two problems I can see off hand here
Firstly, you should move your query to outside your `if` conditional statement.
Secondly, when using `WP_Query`, the `$max_pages` parameter should be used when using [`next_posts_link( $label , $max_pages );`](http://codex.wordpress.org/Function_Reference/next_posts_link)
So, yo... |
145,256 | <p>I can't seem to figure this out! I set up my site (<a href="https://goinspire.com/secure-payment/" rel="nofollow">https://goinspire.com/secure-payment/</a>) to be https, but instead of the lock symbol I see a warning symbol. According to <a href="http://www.whynopadlock.com/" rel="nofollow">http://www.whynopadlock.c... | [
{
"answer_id": 145261,
"author": "Jonathan Lafleur",
"author_id": 10501,
"author_profile": "https://wordpress.stackexchange.com/users/10501",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you have a cache issue, from my end everything work fine, I have the padlock, and when I look ... | 2014/05/22 | [
"https://wordpress.stackexchange.com/questions/145256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36515/"
] | I can't seem to figure this out! I set up my site (<https://goinspire.com/secure-payment/>) to be https, but instead of the lock symbol I see a warning symbol. According to <http://www.whynopadlock.com/> the issue is a certain url in the header ( <http://malsup.github.io/jquery.cycle2.js>). I changed header.php to have... | Maybe you have a cache issue, from my end everything work fine, I have the padlock, and when I look to the source, it show https. Good luck ! |
145,276 | <p>Does anyone know how to structure a WP template in the loop by:</p>
<p>Publishing the page content on top, immediate followed by certain category posts underneath the page content?</p>
<p>Seems like it should be straight forward. I have not been able to locate any help on it.</p>
<p>Thank you.</p>
<p><strong>Her... | [
{
"answer_id": 145278,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>This <em>is</em> very straightforward, at least from development point of view.</p>\n\n<ol>\n<li>You need to create... | 2014/05/22 | [
"https://wordpress.stackexchange.com/questions/145276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Does anyone know how to structure a WP template in the loop by:
Publishing the page content on top, immediate followed by certain category posts underneath the page content?
Seems like it should be straight forward. I have not been able to locate any help on it.
Thank you.
**Here's what I pulled together so far:**
... | This *is* very straightforward, at least from development point of view.
1. You need to create [Page Template](http://codex.wordpress.org/Page_Templates) for the page.
2. Main [Loop](http://codex.wordpress.org/The_Loop) will take care of page itself.
3. Follow it by adding secondary loop with arguments for set of post... |
145,283 | <p>I need to create a system where the user first selects the state, then select the city and then see the information of the stores in that city.</p>
<p>For this, I created a cpt called store with 2 meta boxes: state and city.</p>
<p>For the first drop-down list, I'm using a wp_query with the following args:</p>
<p... | [
{
"answer_id": 145284,
"author": "Pim",
"author_id": 50432,
"author_profile": "https://wordpress.stackexchange.com/users/50432",
"pm_score": 2,
"selected": false,
"text": "<p>I haven't tried it myself, but that sounds like something for the <code>posts_distinct</code> or <code>posts_grou... | 2014/05/22 | [
"https://wordpress.stackexchange.com/questions/145283",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38553/"
] | I need to create a system where the user first selects the state, then select the city and then see the information of the stores in that city.
For this, I created a cpt called store with 2 meta boxes: state and city.
For the first drop-down list, I'm using a wp\_query with the following args:
```
$args = array(
... | I haven't tried it myself, but that sounds like something for the `posts_distinct` or `posts_groupby` filters:
```
function search_distinct() {
return "DISTINCT";
}
add_filter('posts_distinct', 'search_distinct');
``` |
145,289 | <p>I upgraded my Wordpress from 3.8.1 to 3.9.1. I am using the magic-fields-2 plugin for custom data, I have created a custom post type and a custom template for displaying single posts of that type. Everything worked fine before the update. After updating, all posts of this type use index.php in my theme directory.</p... | [
{
"answer_id": 145772,
"author": "user2569737",
"author_id": 50429,
"author_profile": "https://wordpress.stackexchange.com/users/50429",
"pm_score": 2,
"selected": false,
"text": "<p>Since I don't have your theme I can't find what causing this problem, but this should definitely solve yo... | 2014/05/22 | [
"https://wordpress.stackexchange.com/questions/145289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27316/"
] | I upgraded my Wordpress from 3.8.1 to 3.9.1. I am using the magic-fields-2 plugin for custom data, I have created a custom post type and a custom template for displaying single posts of that type. Everything worked fine before the update. After updating, all posts of this type use index.php in my theme directory.
I ha... | Since I don't have your theme I can't find what causing this problem, but this should definitely solve your problem for now
Create `content-{post_type}.php` file and add your custom-post.
in the index.php add the below code above `<?php get_template_part( 'templates/content', 'format'); ?>`
```
<?php if(!in_array(ge... |
145,325 | <p>I am trying to highlight the newest post in a separate layout and rest of them in a masonry index. There are 5 posts per page and I am getting the newest 5 posts on previous posts pages as well. </p>
<p>I had all posts in a single loop under masonry index. I tried making the first element of masonry index a differe... | [
{
"answer_id": 145772,
"author": "user2569737",
"author_id": 50429,
"author_profile": "https://wordpress.stackexchange.com/users/50429",
"pm_score": 2,
"selected": false,
"text": "<p>Since I don't have your theme I can't find what causing this problem, but this should definitely solve yo... | 2014/05/23 | [
"https://wordpress.stackexchange.com/questions/145325",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52060/"
] | I am trying to highlight the newest post in a separate layout and rest of them in a masonry index. There are 5 posts per page and I am getting the newest 5 posts on previous posts pages as well.
I had all posts in a single loop under masonry index. I tried making the first element of masonry index a different width v... | Since I don't have your theme I can't find what causing this problem, but this should definitely solve your problem for now
Create `content-{post_type}.php` file and add your custom-post.
in the index.php add the below code above `<?php get_template_part( 'templates/content', 'format'); ?>`
```
<?php if(!in_array(ge... |
145,345 | <p>I'm looking for a way to modify the search query if the performed query returned no results.</p>
<p>Let's say I'm looking for "Opening times", so I go to this URL:</p>
<pre><code>http://mysite.com?s=Opening+times
</code></pre>
<p>Now, in my <code>search.php</code> I want to check if that query gave no results, an... | [
{
"answer_id": 145347,
"author": "MortalViews",
"author_id": 38194,
"author_profile": "https://wordpress.stackexchange.com/users/38194",
"pm_score": 3,
"selected": true,
"text": "<p>You should create a custom query inside if. </p>\n\n<pre><code>if ( $total_results == 0 ) {\n // Create... | 2014/05/23 | [
"https://wordpress.stackexchange.com/questions/145345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48313/"
] | I'm looking for a way to modify the search query if the performed query returned no results.
Let's say I'm looking for "Opening times", so I go to this URL:
```
http://mysite.com?s=Opening+times
```
Now, in my `search.php` I want to check if that query gave no results, and in that case, I want to perform a new quer... | You should create a custom query inside if.
```
if ( $total_results == 0 ) {
// Create a new query with the terms 'Find Us'
$query = new Wp_query('s=Find Us');
if ($query->have_posts()):
while ($query->have_posts()):$query->the_post();
//whatever you want to do with the result
... |
145,357 | <pre><code>add_action('wp_footer','slider_option');
function slider_option() {
$option ="<script>script function data
</script>";
echo $option;
}
</code></pre>
<p>I want to print or you can say insert data in <code>$option</code> variable to footer menu </p>
<p>Any suggest... | [
{
"answer_id": 145364,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 3,
"selected": true,
"text": "<p>Do you have to use a variable for you script? </p>\n\n<p>I have done this in the past and has worked...</p>... | 2014/05/23 | [
"https://wordpress.stackexchange.com/questions/145357",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52030/"
] | ```
add_action('wp_footer','slider_option');
function slider_option() {
$option ="<script>script function data
</script>";
echo $option;
}
```
I want to print or you can say insert data in `$option` variable to footer menu
Any suggestions? | Do you have to use a variable for you script?
I have done this in the past and has worked...
```
// add script to the footer and break out of PHP
function slider_option(){ ?>
<script>script function data</script>
<?php } ?>
add_action('wp_footer','slider_option');
```
If this does not work make sure you have th... |
145,375 | <p>I am trying to display a single "featured post" in the archive.php template using a custom query. This featured post should be the <strong>most recent post</strong> in that category or tag. I'm using pagination for the rest of the archive page (also a custom query so that pagination is retained), and this <strong>sa... | [
{
"answer_id": 145364,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 3,
"selected": true,
"text": "<p>Do you have to use a variable for you script? </p>\n\n<p>I have done this in the past and has worked...</p>... | 2014/05/23 | [
"https://wordpress.stackexchange.com/questions/145375",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24573/"
] | I am trying to display a single "featured post" in the archive.php template using a custom query. This featured post should be the **most recent post** in that category or tag. I'm using pagination for the rest of the archive page (also a custom query so that pagination is retained), and this **same post** should appea... | Do you have to use a variable for you script?
I have done this in the past and has worked...
```
// add script to the footer and break out of PHP
function slider_option(){ ?>
<script>script function data</script>
<?php } ?>
add_action('wp_footer','slider_option');
```
If this does not work make sure you have th... |
145,377 | <p>In a recently personal theme project for publishing travel posts, I desired a slider-style image gallery rather than the standard column/list-style one WordPress uses out of the box.</p>
<p>I like the look-and-feel of the <a href="http://getbootstrap.com/javascript/#carousel" rel="nofollow">Bootstrap Carousel</a>, ... | [
{
"answer_id": 145378,
"author": "Stephen S.",
"author_id": 5019,
"author_profile": "https://wordpress.stackexchange.com/users/5019",
"pm_score": 2,
"selected": true,
"text": "<p>On a separate thread, I found out that it was indeed possible to <a href=\"https://wordpress.stackexchange.co... | 2014/05/23 | [
"https://wordpress.stackexchange.com/questions/145377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5019/"
] | In a recently personal theme project for publishing travel posts, I desired a slider-style image gallery rather than the standard column/list-style one WordPress uses out of the box.
I like the look-and-feel of the [Bootstrap Carousel](http://getbootstrap.com/javascript/#carousel), so my challenge was this:
Is it pos... | On a separate thread, I found out that it was indeed possible to [customize the output of the Gallery Shortcode](https://wordpress.stackexchange.com/questions/4343/how-to-customise-the-output-of-the-wp-image-gallery-shortcode-from-a-plugin) using some code in the `functions.php`.
The code below would be a fairly stand... |
145,406 | <p>I would like to disable the 'Visual' tab so that the 'Text' tab is always used.</p>
<p>Is there a clean way to do this besides just doing something like .wp-switch-editor { display:none!important; }</p>
<p><img src="https://i.stack.imgur.com/wYuG0.jpg" alt="enter image description here"></p>
| [
{
"answer_id": 145417,
"author": "Webloper",
"author_id": 29035,
"author_profile": "https://wordpress.stackexchange.com/users/29035",
"pm_score": 1,
"selected": false,
"text": "<p>You can use this style/script to remove the visual tab. It works for me.</p>\n\n<pre><code>add_filter( 'admi... | 2014/05/24 | [
"https://wordpress.stackexchange.com/questions/145406",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45362/"
] | I would like to disable the 'Visual' tab so that the 'Text' tab is always used.
Is there a clean way to do this besides just doing something like .wp-switch-editor { display:none!important; }
 | I can think of three way you can do this
1. Log in to the Admin Control Panel and go to:
Users -> All Users
Find your username and click on Edit.
Check "Disable the visual editor when writing"
2. Add this code in the themes function.php file
```
add_filter( 'user_can_richedit' , '__return_false', 50 );
```
3. Ins... |
145,409 | <p>I have a function that allows me to display ALL users on my site, but I was wondering if there was a way to display Admins and Contributors in a separate loop? </p>
<p>My current function: </p>
<pre><code>function contributors() {
global $wpdb;
$authors = $wpdb->get_results("SELECT ID, user_nicename from ... | [
{
"answer_id": 145411,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 2,
"selected": true,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/get_users\" rel=\"nofollow\">get_users</a> funct... | 2014/05/24 | [
"https://wordpress.stackexchange.com/questions/145409",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52048/"
] | I have a function that allows me to display ALL users on my site, but I was wondering if there was a way to display Admins and Contributors in a separate loop?
My current function:
```
function contributors() {
global $wpdb;
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY dis... | Use [get\_users](http://codex.wordpress.org/Function_Reference/get_users) function it allows you to query user by role.
For contributors,
```
$contributors = get_users('role=contributors');
foreach($contributors as $contributors){
// do something with contributors
}
```
For Admins,
```
$admins = get_users('rol... |
145,420 | <p>I am trying to understand some basic concepts of WordPress.</p>
<p>Let's say I am a coder and I made a template for my client. I am at the point when some basic layout of the page is complete and now I want to fill in some text. I will use Wordpress Pages for this so my client can edit the texts whenever he wants. ... | [
{
"answer_id": 145425,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 0,
"selected": false,
"text": "<p>This has been a frustration for me before, so you are not alone :-) Fortunately the automatic formatting i... | 2014/05/24 | [
"https://wordpress.stackexchange.com/questions/145420",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52107/"
] | I am trying to understand some basic concepts of WordPress.
Let's say I am a coder and I made a template for my client. I am at the point when some basic layout of the page is complete and now I want to fill in some text. I will use Wordpress Pages for this so my client can edit the texts whenever he wants.
Now I wa... | You can add this code to your function.php file of your theme
```
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
```
or you can use [this](http://wordpress.org/plugins/toggle-wpautop/) plugin for easier control |
145,422 | <p>I want to redeclare a function that I inherited from the parent theme.</p>
<p>When I do it in functions.php, I get a fatal error that redeclaration is not possible.</p>
<p>I did a workaround: creating a modified function name and copying all the template files, index.php etc. into the child theme's directory and r... | [
{
"answer_id": 145423,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Redeclaring a function in a child theme only works when the parent themes' function is wrapped in a </p>... | 2014/05/24 | [
"https://wordpress.stackexchange.com/questions/145422",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28354/"
] | I want to redeclare a function that I inherited from the parent theme.
When I do it in functions.php, I get a fatal error that redeclaration is not possible.
I did a workaround: creating a modified function name and copying all the template files, index.php etc. into the child theme's directory and rewriting the func... | Redeclaring a function in a child theme only works when the parent themes' function is wrapped in a
```
if( !function_exists( 'function_name' )):
```
condition. Then you can simply just copy the complete function to the child theme and do whatever modifications you need to do.
If the parent themes' functions aren... |
145,427 | <p>I have created a custom post type in my wordpress theme dedicated to creating slides for a slider displayed on the homepage, It has a title, slide text and slide url and also featured image.</p>
<p>I'm now trying to get this info from the meta boxes within the custom post type and turn it into a slider that shows a... | [
{
"answer_id": 145430,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 0,
"selected": false,
"text": "<p>It doesn't look like you are correctly referencing your field name in the get_post_meta(); function. I wou... | 2014/05/24 | [
"https://wordpress.stackexchange.com/questions/145427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32864/"
] | I have created a custom post type in my wordpress theme dedicated to creating slides for a slider displayed on the homepage, It has a title, slide text and slide url and also featured image.
I'm now trying to get this info from the meta boxes within the custom post type and turn it into a slider that shows as many sli... | You are using [`the_post_thumbnail()`](http://codex.wordpress.org/Function_Reference/the_post_thumbnail#Usage) which will echo the actual thumbnail. You should use [`get_the_post_thumbnail()`](http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail) if you want the value to be returned, not echoed.
So, c... |
145,432 | <p>I recently spotted the <a href="http://i.hanni.me/2014/05/24/1181/" rel="nofollow noreferrer">code for a <code>wp-lunch.php</code> file</a> intended for a WordPress template, what would this look like if following the proper WordPress coding standards?</p>
<p><img src="https://i.stack.imgur.com/Y6e0Q.jpg" alt="wp-l... | [
{
"answer_id": 145434,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<pre><code><!-- file shouldn't be named wp-lunch.php as it's not part of WP core -->\n\n<?php if ( current_us... | 2014/05/24 | [
"https://wordpress.stackexchange.com/questions/145432",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/736/"
] | I recently spotted the [code for a `wp-lunch.php` file](http://i.hanni.me/2014/05/24/1181/) intended for a WordPress template, what would this look like if following the proper WordPress coding standards?

```
<?php if ( current_user_can('has_sandwich') ): ?>
<... | What happen if the user don't have capability to eat sandwich? WSOF?
If I'd want to follow average default themes templates, I'd go for
```
// eat-sandwich.php (as @Rarst said avoid wp-lunch.php as it's not part of WP core)
get_header( 'sandwich' );
if ( current_user_can( 'eat_sandwich' ) ) {
get_template_part( ... |
145,445 | <p>I need to build a news site with 16 user roles.</p>
<p>How can I add more user roles?</p>
<p>By default I see 4 roles:</p>
<ul>
<li>contributor</li>
<li>author</li>
<li>editor</li>
<li>administrator</li>
</ul>
| [
{
"answer_id": 145446,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>What you want is <a href=\"http://codex.wordpress.org/Function_Reference/add_role\" rel=\"nofollow\"><code>ad... | 2014/05/24 | [
"https://wordpress.stackexchange.com/questions/145445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51531/"
] | I need to build a news site with 16 user roles.
How can I add more user roles?
By default I see 4 roles:
* contributor
* author
* editor
* administrator | What you want is [`add_role()`](http://codex.wordpress.org/Function_Reference/add_role)
The [Codex provides sample code](http://codex.wordpress.org/Function_Reference/add_role#Example):
```
$result = add_role(
'basic_contributor',
__( 'Basic Contributor' ),
array(
'read' => true, // true ... |
145,449 | <p>I've been working at this for weeks without success. I've figured out problem after problem with the code, but none of the corrections seem to fix my core problem. The form doesn't insert anything into the database and I don't know why. In this particular example, submit results in going to the following URL: (myurl... | [
{
"answer_id": 145776,
"author": "user1497158",
"author_id": 52119,
"author_profile": "https://wordpress.stackexchange.com/users/52119",
"pm_score": 1,
"selected": false,
"text": "<p>I never did figure out how to do this with serialize or formData, but I figured out two other ways to do ... | 2014/05/24 | [
"https://wordpress.stackexchange.com/questions/145449",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52119/"
] | I've been working at this for weeks without success. I've figured out problem after problem with the code, but none of the corrections seem to fix my core problem. The form doesn't insert anything into the database and I don't know why. In this particular example, submit results in going to the following URL: (myurl)/?... | I never did figure out how to do this with serialize or formData, but I figured out two other ways to do it. The easiest is to just skip this step altogether and in the action and js url list the url to a php file like you might do if you weren't in wordpress. I then added this line to the top of it and it worked. requ... |
145,487 | <p>I'm using the following code in functions.php to add a TinyMCE box on custom field textareas inside the Editor:</p>
<pre><code>add_action('admin_print_footer_scripts','FT_TinymceCustom',99);
function FT_TinymceCustom()
{
?>
<script type="text/javascript">
jQuery(function($)
{
var i=1;
... | [
{
"answer_id": 145491,
"author": "user28216",
"author_id": 28216,
"author_profile": "https://wordpress.stackexchange.com/users/28216",
"pm_score": 0,
"selected": false,
"text": "<p>Found the answer here:\n<a href=\"https://stackoverflow.com/questions/5956174/tinymce-editors-in-meta-boxes... | 2014/05/25 | [
"https://wordpress.stackexchange.com/questions/145487",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28216/"
] | I'm using the following code in functions.php to add a TinyMCE box on custom field textareas inside the Editor:
```
add_action('admin_print_footer_scripts','FT_TinymceCustom',99);
function FT_TinymceCustom()
{
?>
<script type="text/javascript">
jQuery(function($)
{
var i=1;
$('.customEditor tex... | Since that SO link is to my question, I will re-post it and expand on it here.
TinyMCE does NOT save "p" tags in the editor, instead linebreaks and the like are converted into p tags by WordPress functions (such as `wpautop()`. So the solution was a combination of altering my textbox to look like:
```
<textarea clas... |
145,497 | <p>How I can assign a different css class to each post of the 10 posts of each blog page?</p>
<p>Like this :</p>
<pre><code><li class="first-post">..
<li class="second-post">..
.
.
.
<li class="tenth-post">
--
Second page
--
<li class="first-post">..
<li class="second-post">..
..
</code>... | [
{
"answer_id": 145500,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use the function <code>post_class()</code> in your template:</p>\n\n<pre><code><div <?php post_class(); ?>&g... | 2014/05/25 | [
"https://wordpress.stackexchange.com/questions/145497",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52144/"
] | How I can assign a different css class to each post of the 10 posts of each blog page?
Like this :
```
<li class="first-post">..
<li class="second-post">..
.
.
.
<li class="tenth-post">
--
Second page
--
<li class="first-post">..
<li class="second-post">..
..
```
So on !
Thank You a lot for the help. | Use the function `post_class()` in your template:
```
<div <?php post_class(); ?>>
// your post content
</div>
```
Then add a counter to the post classes per filter on `post_class`:
```php
// functions.php
add_filter( 'post_class', function( Array $classes ) {
static $number = 1;
$classes[] = 'post-number... |
145,531 | <p>I'm new to Wordpress plugin development and I'm trying to create a list of checkboxes (from a WP Query) to associate as custom fields for a specific post type. Nothing wrong with the display function, but when I'm trying to save I get the error </p>
<blockquote>
<p>Invalid argument supplied for foreach().</p>
</b... | [
{
"answer_id": 145500,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use the function <code>post_class()</code> in your template:</p>\n\n<pre><code><div <?php post_class(); ?>&g... | 2014/05/25 | [
"https://wordpress.stackexchange.com/questions/145531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52153/"
] | I'm new to Wordpress plugin development and I'm trying to create a list of checkboxes (from a WP Query) to associate as custom fields for a specific post type. Nothing wrong with the display function, but when I'm trying to save I get the error
>
> Invalid argument supplied for foreach().
>
>
>
How can I check w... | Use the function `post_class()` in your template:
```
<div <?php post_class(); ?>>
// your post content
</div>
```
Then add a counter to the post classes per filter on `post_class`:
```php
// functions.php
add_filter( 'post_class', function( Array $classes ) {
static $number = 1;
$classes[] = 'post-number... |
145,536 | <p>I am using the follow function to create a custom default avatar for users who comment and do not have a gravatar setup.</p>
<pre><code> if(!function_exists('custom_avatar')){
function custom_avatar($avatar_defaults){
$new_default_icon = get_bloginfo('template_directory') . '/images/VR-default-avatar.pn... | [
{
"answer_id": 145500,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use the function <code>post_class()</code> in your template:</p>\n\n<pre><code><div <?php post_class(); ?>&g... | 2014/05/25 | [
"https://wordpress.stackexchange.com/questions/145536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41346/"
] | I am using the follow function to create a custom default avatar for users who comment and do not have a gravatar setup.
```
if(!function_exists('custom_avatar')){
function custom_avatar($avatar_defaults){
$new_default_icon = get_bloginfo('template_directory') . '/images/VR-default-avatar.png';
$a... | Use the function `post_class()` in your template:
```
<div <?php post_class(); ?>>
// your post content
</div>
```
Then add a counter to the post classes per filter on `post_class`:
```php
// functions.php
add_filter( 'post_class', function( Array $classes ) {
static $number = 1;
$classes[] = 'post-number... |
145,539 | <p>I am trying to find a solution for 2 months now but unfortunately I came up with no results. I have a subscription based website which streams music. What customers basically buy is a "panel" where they are listening to music <strong><em>without the need to refresh</em></strong> the page. What I need is to disallow ... | [
{
"answer_id": 145500,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use the function <code>post_class()</code> in your template:</p>\n\n<pre><code><div <?php post_class(); ?>&g... | 2014/05/25 | [
"https://wordpress.stackexchange.com/questions/145539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31047/"
] | I am trying to find a solution for 2 months now but unfortunately I came up with no results. I have a subscription based website which streams music. What customers basically buy is a "panel" where they are listening to music ***without the need to refresh*** the page. What I need is to disallow their account being log... | Use the function `post_class()` in your template:
```
<div <?php post_class(); ?>>
// your post content
</div>
```
Then add a counter to the post classes per filter on `post_class`:
```php
// functions.php
add_filter( 'post_class', function( Array $classes ) {
static $number = 1;
$classes[] = 'post-number... |
145,569 | <p>When developing themes and plugins it is sometimes neccesary to add some functionality to some hook using conditional statements. </p>
<p>Example:</p>
<pre><code>function my_custom_function() {
if( is_home()) {
<---what should the function do--->
}
}
add_action( 'some_hook', 'my_custom_funct... | [
{
"answer_id": 145571,
"author": "Berend",
"author_id": 20044,
"author_profile": "https://wordpress.stackexchange.com/users/20044",
"pm_score": 0,
"selected": false,
"text": "<p>I'd say personal preference.</p>\n\n<p>Additionally it is cleaner to take the function call outside the if-sta... | 2014/05/26 | [
"https://wordpress.stackexchange.com/questions/145569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31545/"
] | When developing themes and plugins it is sometimes neccesary to add some functionality to some hook using conditional statements.
Example:
```
function my_custom_function() {
if( is_home()) {
<---what should the function do--->
}
}
add_action( 'some_hook', 'my_custom_function' );
```
To my underst... | [WordPress coding standards for PHP](http://make.wordpress.org/core/handbook/coding-standards/php/) does not state anything about this, and there is no other standard, so it's up to developers to choose one way or another.
I have to say that the 2 methods have different approaches; while the first contains conditional... |
145,587 | <p>I am trying to exclude a specific post ID from displaying. I've included the post ID as a <code>post__not_in</code> but being given an error I am unsure of, any obvious changes needed here?</p>
<pre><code> <?php
// Create a variable to hold our custom Loop results
... | [
{
"answer_id": 145584,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 3,
"selected": true,
"text": "<p>Release Date:</p>\n\n<blockquote>\n <p>WordPress 4.0 is planned for <strike>August 27</strike>September 3, 2... | 2014/05/26 | [
"https://wordpress.stackexchange.com/questions/145587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52096/"
] | I am trying to exclude a specific post ID from displaying. I've included the post ID as a `post__not_in` but being given an error I am unsure of, any obvious changes needed here?
```
<?php
// Create a variable to hold our custom Loop results
$frontpageposts =... | Release Date:
>
> WordPress 4.0 is planned for August 27September 3, 2014
>
>
> [Source](http://wordpress.org/about/roadmap/)
>
>
>
WordPress 4.0 Release:
>
> [...] For those unaware, for WordPress, version 4.0 sounds like a
> “big” version number but it’s just another major release for us, like
> 3.9 and 4... |
145,606 | <p>I've created a custom post with categories like books, foods, and make some sub-categories like in foods cat, pizza, fastfood. But when I display them in my side bar, it's showing same as sub category. Just like:</p>
<blockquote>
<p>.books</p>
<p>.foods</p>
<p>.pizza</p>
<p>.fastfood</p>
</blockquote>
<p>I want them... | [
{
"answer_id": 145584,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 3,
"selected": true,
"text": "<p>Release Date:</p>\n\n<blockquote>\n <p>WordPress 4.0 is planned for <strike>August 27</strike>September 3, 2... | 2014/05/26 | [
"https://wordpress.stackexchange.com/questions/145606",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52182/"
] | I've created a custom post with categories like books, foods, and make some sub-categories like in foods cat, pizza, fastfood. But when I display them in my side bar, it's showing same as sub category. Just like:
>
> .books
>
>
> .foods
>
>
> .pizza
>
>
> .fastfood
>
>
>
I want them to display like this:
>... | Release Date:
>
> WordPress 4.0 is planned for August 27September 3, 2014
>
>
> [Source](http://wordpress.org/about/roadmap/)
>
>
>
WordPress 4.0 Release:
>
> [...] For those unaware, for WordPress, version 4.0 sounds like a
> “big” version number but it’s just another major release for us, like
> 3.9 and 4... |
145,615 | <p>I'm doing a plugin to add likes to posts</p>
<p>I want to create a table on a page in the plugin to show each post and the number of likes</p>
<pre><code>function my_plugin_options() {
echo '<p>Table of Likes</p>';
echo '</div>';
echo '<table>';
echo '<tr>';
echo '&l... | [
{
"answer_id": 145618,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Once your run <code>$like_loop->the_post()</code> the global <code>$post</code> variable is set to the cu... | 2014/05/26 | [
"https://wordpress.stackexchange.com/questions/145615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51590/"
] | I'm doing a plugin to add likes to posts
I want to create a table on a page in the plugin to show each post and the number of likes
```
function my_plugin_options() {
echo '<p>Table of Likes</p>';
echo '</div>';
echo '<table>';
echo '<tr>';
echo '<td>Post</td>';
echo '<td>Number of likes</td>';
... | Once your run `$like_loop->the_post()` the global `$post` variable is set to the current post in the Loop, so what you want is:
```
$likes = get_post_meta( $post->ID, "_like_amount", true);
```
Or...
```
$likes = get_post_meta( get_the_ID(), "_like_amount", true);
```
... which is a bit more robust in some circ... |
145,641 | <p>I am developing a WordPress Theme and I've got stuck in a point. What I want to do is to add a box at the right of page editor so the admin of the site can add multiple images on the fly in this concrete page. I've found that WooCommerce has this box enabled at the product creation editor. Do anybody know how can I ... | [
{
"answer_id": 145618,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Once your run <code>$like_loop->the_post()</code> the global <code>$post</code> variable is set to the cu... | 2014/05/26 | [
"https://wordpress.stackexchange.com/questions/145641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52198/"
] | I am developing a WordPress Theme and I've got stuck in a point. What I want to do is to add a box at the right of page editor so the admin of the site can add multiple images on the fly in this concrete page. I've found that WooCommerce has this box enabled at the product creation editor. Do anybody know how can I cre... | Once your run `$like_loop->the_post()` the global `$post` variable is set to the current post in the Loop, so what you want is:
```
$likes = get_post_meta( $post->ID, "_like_amount", true);
```
Or...
```
$likes = get_post_meta( get_the_ID(), "_like_amount", true);
```
... which is a bit more robust in some circ... |
145,657 | <p>I've been searching around for a few hours now and can't figure out how to do this. Seems really simple. I've seen lots of redundant examples on how to redirect to a single post when a search result returns only one post, but what if I set up a custom WP_query to only show posts by a custom field/metabox value and i... | [
{
"answer_id": 178944,
"author": "EliasNS",
"author_id": 40743,
"author_profile": "https://wordpress.stackexchange.com/users/40743",
"pm_score": 0,
"selected": false,
"text": "<p>I think you only have to change <code>'0'</code>, that is a string, by simply <code>0</code>, that is a integ... | 2014/05/26 | [
"https://wordpress.stackexchange.com/questions/145657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52207/"
] | I've been searching around for a few hours now and can't figure out how to do this. Seems really simple. I've seen lots of redundant examples on how to redirect to a single post when a search result returns only one post, but what if I set up a custom WP\_query to only show posts by a custom field/metabox value and if ... | You can do this by checking the number of results returned by your query. Try this.
```
<?php
$rawfiltertag = get_post_meta( $post->ID, '_cmb_client_name', true );
$filtertag = sanitize_title( $rawfiltertag );
// wp_query arguments
$args = array (
'post_type' => 'post',
'meta_query' =... |
145,664 | <p>I want to unregister a custom tinymce plugin in one of my child themes. The custom tinymce plugin uses basically:</p>
<p><a href="http://codex.wordpress.org/Plugin_API/Filter_Reference/mce_external_plugins" rel="nofollow">http://codex.wordpress.org/Plugin_API/Filter_Reference/mce_external_plugins</a></p>
<p>excerp... | [
{
"answer_id": 178944,
"author": "EliasNS",
"author_id": 40743,
"author_profile": "https://wordpress.stackexchange.com/users/40743",
"pm_score": 0,
"selected": false,
"text": "<p>I think you only have to change <code>'0'</code>, that is a string, by simply <code>0</code>, that is a integ... | 2014/05/27 | [
"https://wordpress.stackexchange.com/questions/145664",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35677/"
] | I want to unregister a custom tinymce plugin in one of my child themes. The custom tinymce plugin uses basically:
<http://codex.wordpress.org/Plugin_API/Filter_Reference/mce_external_plugins>
excerpt:
```
add_filter( "mce_external_plugins", "foo_add_buttons" );
add_filter( 'mce_buttons', 'foo_register_buttons' );
`... | You can do this by checking the number of results returned by your query. Try this.
```
<?php
$rawfiltertag = get_post_meta( $post->ID, '_cmb_client_name', true );
$filtertag = sanitize_title( $rawfiltertag );
// wp_query arguments
$args = array (
'post_type' => 'post',
'meta_query' =... |
145,670 | <p>I'm using Wordpress 3.9.1 and I get the</p>
<blockquote>
<p>Fatal error: Call to undefined function get_current_screen()</p>
</blockquote>
<p>if I put the following in my funcitons.php or in any file of my theme:</p>
<pre><code>$screen = get_current_screen();
echo $screen;
</code></pre>
<p>Initially when I got... | [
{
"answer_id": 145672,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_current_screen\" rel=\"nofollow\"><code>get_curr... | 2014/05/27 | [
"https://wordpress.stackexchange.com/questions/145670",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43834/"
] | I'm using Wordpress 3.9.1 and I get the
>
> Fatal error: Call to undefined function get\_current\_screen()
>
>
>
if I put the following in my funcitons.php or in any file of my theme:
```
$screen = get_current_screen();
echo $screen;
```
Initially when I got the error, I was working on a theme that I'm creatin... | [`get_current_screen()`](http://codex.wordpress.org/Function_Reference/get_current_screen) is a backend function and it returns data about the current *backend* administration page. It makes no sense to use this in theme code. The only way it would work (I think but haven't tested) in `functions.php` would be if it wer... |
145,698 | <p>How to remove the letter P from the default wordpress editor? Previously i have removed that P but now the entire code changed from the <code>class-wp-editor.php</code> file. </p>
<blockquote>
<p><img src="https://i.stack.imgur.com/HXh4s.png" alt="WordPress 3.9.1 WP_Editor"></p>
</blockquote>
| [
{
"answer_id": 145702,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>That's a mere indication of the HTML tag of the place where your cursor is. The \"p\" here stands for a \"paragra... | 2014/05/27 | [
"https://wordpress.stackexchange.com/questions/145698",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32819/"
] | How to remove the letter P from the default wordpress editor? Previously i have removed that P but now the entire code changed from the `class-wp-editor.php` file.
>
> 
>
>
> | This ended up working for me, uses the tinyMCE init filter to remove the 'statusbar' entirely.
```
/** Edit TinyMCE **/
function myformatTinyMCE($in) {
$in['statusbar'] = false;
return $in;
}
add_filter('tiny_mce_before_init', 'myformatTinyMCE' );
```
Even with CSS, I couldn't find a way to definitely remo... |
145,701 | <p>My website (at <a href="http://japanaddicts.org" rel="nofollow noreferrer">http://japanaddicts.org</a>) breaks down in a rudimentary pro-HTML form when I try to activate the child theme.</p>
<p>My parent theme is Codilight. Just explain to me why is this happening. I am not looking for Codilight-specific premium su... | [
{
"answer_id": 145703,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 0,
"selected": false,
"text": "<p>If you examine your pages source code CAREFULLY, check the URL’s of your stylesheets and scripts. Click on... | 2014/05/27 | [
"https://wordpress.stackexchange.com/questions/145701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | My website (at <http://japanaddicts.org>) breaks down in a rudimentary pro-HTML form when I try to activate the child theme.
My parent theme is Codilight. Just explain to me why is this happening. I am not looking for Codilight-specific premium support, but a reason that any knowledgeable person will know.
I have pre... | Enable [WP\_debug](http://codex.wordpress.org/WP_DEBUG) by editing your wp-config.php in your WordPress root files
Look for:
```
define('WP_DEBUG', false);
```
Change to:
```
define('WP_DEBUG', true);
```
Post any error messages in your top post, this will help us identify where the issue could be. |
145,711 | <p>I am currently building a custom Wordpress theme for my rugby team. I just noticed something and I can't work out whether this has been happening for a while and I have only just noticed it or it is a new thing. </p>
<p>It would appear that any page address without a slash at the end of the address renders a white ... | [
{
"answer_id": 145703,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 0,
"selected": false,
"text": "<p>If you examine your pages source code CAREFULLY, check the URL’s of your stylesheets and scripts. Click on... | 2014/05/27 | [
"https://wordpress.stackexchange.com/questions/145711",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44235/"
] | I am currently building a custom Wordpress theme for my rugby team. I just noticed something and I can't work out whether this has been happening for a while and I have only just noticed it or it is a new thing.
It would appear that any page address without a slash at the end of the address renders a white screen of ... | Enable [WP\_debug](http://codex.wordpress.org/WP_DEBUG) by editing your wp-config.php in your WordPress root files
Look for:
```
define('WP_DEBUG', false);
```
Change to:
```
define('WP_DEBUG', true);
```
Post any error messages in your top post, this will help us identify where the issue could be. |
145,730 | <p>Let's say that I have an entry titled <strong>Crime & Punishment</strong></p>
<p>I tried to count the number of characters of my entry titles using the following line:</p>
<pre><code>echo strlen( get_the_title() );
</code></pre>
<p>I expected the code would give me 18 characters for <strong>Crime & Punish... | [
{
"answer_id": 145733,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code><?php echo strip_tags(strlen(get_the_title())); ?>\n</code></pre>\n"
},... | 2014/05/27 | [
"https://wordpress.stackexchange.com/questions/145730",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43723/"
] | Let's say that I have an entry titled **Crime & Punishment**
I tried to count the number of characters of my entry titles using the following line:
```
echo strlen( get_the_title() );
```
I expected the code would give me 18 characters for **Crime & Punishment**, but the result turned out to be 23 characters.
The ... | There are actually two problems:
1. The `&` is encoded as `&`, so you have to use [`html_entity_decode()`](http://www.php.net/manual/en/function.html-entity-decode.php) first.
2. Multi-byte characters need more than one byte, and `strlen()` will fail with them. [Don’t use strlen()](http://wpengineer.com/2410/dont... |
145,762 | <p>I'm not sure how many people have experience with Digital Ocean but they're like the new kid on the block for SSD cloud hosting.</p>
<p>Anyways there entire model is to basically be a hosting solution for develops (much like AWS).</p>
<p>I have created a droplet, accessed it via SFTP, and pointed my nameservers in... | [
{
"answer_id": 145733,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code><?php echo strip_tags(strlen(get_the_title())); ?>\n</code></pre>\n"
},... | 2014/05/28 | [
"https://wordpress.stackexchange.com/questions/145762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35567/"
] | I'm not sure how many people have experience with Digital Ocean but they're like the new kid on the block for SSD cloud hosting.
Anyways there entire model is to basically be a hosting solution for develops (much like AWS).
I have created a droplet, accessed it via SFTP, and pointed my nameservers in their direction.... | There are actually two problems:
1. The `&` is encoded as `&`, so you have to use [`html_entity_decode()`](http://www.php.net/manual/en/function.html-entity-decode.php) first.
2. Multi-byte characters need more than one byte, and `strlen()` will fail with them. [Don’t use strlen()](http://wpengineer.com/2410/dont... |
145,764 | <p>so I've got a bunch of custom page templates that are scripts that are meant to be run by cron to update various things on my wordpress site, there are not meant to be viewed by regular site users. </p>
<p>Note: I'm using "regular" cron jobs, not "wp-cron" jobs.</p>
<p>Q: Is there a way to block average joe from v... | [
{
"answer_id": 145733,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code><?php echo strip_tags(strlen(get_the_title())); ?>\n</code></pre>\n"
},... | 2014/05/28 | [
"https://wordpress.stackexchange.com/questions/145764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47366/"
] | so I've got a bunch of custom page templates that are scripts that are meant to be run by cron to update various things on my wordpress site, there are not meant to be viewed by regular site users.
Note: I'm using "regular" cron jobs, not "wp-cron" jobs.
Q: Is there a way to block average joe from visting these page... | There are actually two problems:
1. The `&` is encoded as `&`, so you have to use [`html_entity_decode()`](http://www.php.net/manual/en/function.html-entity-decode.php) first.
2. Multi-byte characters need more than one byte, and `strlen()` will fail with them. [Don’t use strlen()](http://wpengineer.com/2410/dont... |
145,771 | <p>Why people say this is a bad approach to add conditional comments to wp_head? For example:</p>
<pre><code>function add_ie_html5_shim () {
echo '<!--[if lt IE 9]>';
echo '<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>';
echo '<![endif]-->';
}
if ($GLOB... | [
{
"answer_id": 145733,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code><?php echo strip_tags(strlen(get_the_title())); ?>\n</code></pre>\n"
},... | 2014/05/28 | [
"https://wordpress.stackexchange.com/questions/145771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50429/"
] | Why people say this is a bad approach to add conditional comments to wp\_head? For example:
```
function add_ie_html5_shim () {
echo '<!--[if lt IE 9]>';
echo '<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>';
echo '<![endif]-->';
}
if ($GLOBALS['is_IE']) {
add_action('wp_he... | There are actually two problems:
1. The `&` is encoded as `&`, so you have to use [`html_entity_decode()`](http://www.php.net/manual/en/function.html-entity-decode.php) first.
2. Multi-byte characters need more than one byte, and `strlen()` will fail with them. [Don’t use strlen()](http://wpengineer.com/2410/dont... |
145,799 | <p>I am using the following code in content.php to repeat an ad insertion. Ads are inserted in the middle of every 2nd row in a grid of thumbnails. There are 3 thumbnails per row.</p>
<pre><code><?php else : ?>
<?php global $wp_query; ?>
<?php if (($wp_query->current_post + 1) % 5 == 0 ): ?>
... | [
{
"answer_id": 145733,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code><?php echo strip_tags(strlen(get_the_title())); ?>\n</code></pre>\n"
},... | 2014/05/28 | [
"https://wordpress.stackexchange.com/questions/145799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52276/"
] | I am using the following code in content.php to repeat an ad insertion. Ads are inserted in the middle of every 2nd row in a grid of thumbnails. There are 3 thumbnails per row.
```
<?php else : ?>
<?php global $wp_query; ?>
<?php if (($wp_query->current_post + 1) % 5 == 0 ): ?>
<div class="box">
<adsense code>... | There are actually two problems:
1. The `&` is encoded as `&`, so you have to use [`html_entity_decode()`](http://www.php.net/manual/en/function.html-entity-decode.php) first.
2. Multi-byte characters need more than one byte, and `strlen()` will fail with them. [Don’t use strlen()](http://wpengineer.com/2410/dont... |
145,805 | <p>I'm using the Default Post Type <code>post</code> for various purposes. To sort them I'm using different categories. And I'm designing different category layout using the slug preference, like: <code>category-book.php</code>, <code>category-notice.php</code> etc., and everything was just fine.</p>
<p>But just a mom... | [
{
"answer_id": 145812,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>The category archive branch of template hierarchy only operates on actual category queried.</p>\n\n<p>If you take a... | 2014/05/28 | [
"https://wordpress.stackexchange.com/questions/145805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | I'm using the Default Post Type `post` for various purposes. To sort them I'm using different categories. And I'm designing different category layout using the slug preference, like: `category-book.php`, `category-notice.php` etc., and everything was just fine.
But just a moment ago found that, any subcategory of the ... | Thanks to @Rarst for guiding me to the right direction. Using his direction I googled again and again and found a blog article of WerdsWords with an excellent bit of code snippet filtered to `category_template` as Rarst suggested me, and the good news is: it worked for my cause:
```
function new_subcategory_hierarchy(... |
145,811 | <p>This is really driving me up the wall now.</p>
<p>Randomly, all my menu items for all menus are just being deleted on their own. Not the menus themselves but all items within them.</p>
<p>This is a custom theme we built upon the Bones boilerplate. We've built plenty of sites on Bones though and we're not experienc... | [
{
"answer_id": 145812,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>The category archive branch of template hierarchy only operates on actual category queried.</p>\n\n<p>If you take a... | 2014/05/28 | [
"https://wordpress.stackexchange.com/questions/145811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29524/"
] | This is really driving me up the wall now.
Randomly, all my menu items for all menus are just being deleted on their own. Not the menus themselves but all items within them.
This is a custom theme we built upon the Bones boilerplate. We've built plenty of sites on Bones though and we're not experiencing the problem w... | Thanks to @Rarst for guiding me to the right direction. Using his direction I googled again and again and found a blog article of WerdsWords with an excellent bit of code snippet filtered to `category_template` as Rarst suggested me, and the good news is: it worked for my cause:
```
function new_subcategory_hierarchy(... |
145,871 | <p>I would like to be able to get the URL of the page that I am crawling when the callback function is called. I tried <code>$_SERVER['HTTP REFERER']</code> but it gives me the URL of the page that the script is being called from, not the URL of the page being crawled.</p>
<p>How can I solve this</p>
| [
{
"answer_id": 145873,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>You need the protocol, the host name and the (root relative) request URL. Then stick them together:</p>\n\n<pre><code... | 2014/05/29 | [
"https://wordpress.stackexchange.com/questions/145871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47366/"
] | I would like to be able to get the URL of the page that I am crawling when the callback function is called. I tried `$_SERVER['HTTP REFERER']` but it gives me the URL of the page that the script is being called from, not the URL of the page being crawled.
How can I solve this | You need the protocol, the host name and the (root relative) request URL. Then stick them together:
```
$scheme = 'http' . ( is_ssl() ? '' : 's' ) . '://';
$url = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
``` |
145,892 | <p>In my wordpress project I have seen several times the use of <code>do_action()</code> function. </p>
<p>I don't know the working of this function, nor why we call it or where we use it?</p>
<p>Can someone please explain this to me?</p>
| [
{
"answer_id": 145873,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>You need the protocol, the host name and the (root relative) request URL. Then stick them together:</p>\n\n<pre><code... | 2014/05/29 | [
"https://wordpress.stackexchange.com/questions/145892",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52328/"
] | In my wordpress project I have seen several times the use of `do_action()` function.
I don't know the working of this function, nor why we call it or where we use it?
Can someone please explain this to me? | You need the protocol, the host name and the (root relative) request URL. Then stick them together:
```
$scheme = 'http' . ( is_ssl() ? '' : 's' ) . '://';
$url = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
``` |
145,915 | <p>I have problem.</p>
<pre><code><?php query_posts('category_name=events&posts_per_page=2&offset=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<div>
<?php $children = get_categories('child_of=3');
foreach ($children as $child) {
$child = get_category($child);
echo $child->... | [
{
"answer_id": 145916,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>First of all, you <strong>should not</strong> be using <a href=\"http://codex.wordpress.org/Function_Re... | 2014/05/29 | [
"https://wordpress.stackexchange.com/questions/145915",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have problem.
```
<?php query_posts('category_name=events&posts_per_page=2&offset=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<div>
<?php $children = get_categories('child_of=3');
foreach ($children as $child) {
$child = get_category($child);
echo $child->cat_name;
}; ?>
</div>
<?php endif; ?>
<?php ... | I have a suspicion that you've fallen into a misunderstanding a lot of new users fall into, but rarely realise.
I suspect you have done this:

This is bad, and suggests a lack of understanding about how... |
145,937 | <p>I have some PHP variables that each represent some user settings set via a theme options interface such as:</p>
<ul>
<li>theme colors</li>
<li>typography</li>
<li>etc.</li>
</ul>
<p>All these variables are in a file called <code>dynamic-style.php</code>:</p>
<pre><code><?php
<style type="text/css">
body ... | [
{
"answer_id": 145916,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>First of all, you <strong>should not</strong> be using <a href=\"http://codex.wordpress.org/Function_Re... | 2014/05/29 | [
"https://wordpress.stackexchange.com/questions/145937",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33903/"
] | I have some PHP variables that each represent some user settings set via a theme options interface such as:
* theme colors
* typography
* etc.
All these variables are in a file called `dynamic-style.php`:
```
<?php
<style type="text/css">
body {
color: <?php echo $text_color; ?>;
}
</style>
?>
```
Is there a w... | I have a suspicion that you've fallen into a misunderstanding a lot of new users fall into, but rarely realise.
I suspect you have done this:

This is bad, and suggests a lack of understanding about how... |
145,970 | <p>Following a recent upgrade to WP and MySQL one site that has a custom built plugin throws a Fatal error:</p>
<blockquote>
<p>Fatal error: Cannot re-assign auto-global variable _REQUEST in
/home/mysitexyz/public_html/wp-content/plugins/employment_application/employment_application.php
on line 549</p>
</blockqu... | [
{
"answer_id": 145916,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>First of all, you <strong>should not</strong> be using <a href=\"http://codex.wordpress.org/Function_Re... | 2014/05/29 | [
"https://wordpress.stackexchange.com/questions/145970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48611/"
] | Following a recent upgrade to WP and MySQL one site that has a custom built plugin throws a Fatal error:
>
> Fatal error: Cannot re-assign auto-global variable \_REQUEST in
> /home/mysitexyz/public\_html/wp-content/plugins/employment\_application/employment\_application.php
> on line 549
>
>
>
Here is the offen... | I have a suspicion that you've fallen into a misunderstanding a lot of new users fall into, but rarely realise.
I suspect you have done this:

This is bad, and suggests a lack of understanding about how... |
145,979 | <p>I'm trying to add a shortcode within the text of the_content(). It is possible to add it to the beginning or the end however I cannot figure out how I would get it to show after say 200 characters.</p>
<p>Here's the shortcode that I need added:</p>
<p>[related-posts]</p>
<p>I've tried <a href="https://wordpress.s... | [
{
"answer_id": 145997,
"author": "varadha",
"author_id": 52324,
"author_profile": "https://wordpress.stackexchange.com/users/52324",
"pm_score": 0,
"selected": false,
"text": "<p>yes you can, </p>\n\n<pre>\n $kvcodes_con = the_content();\n $kvcodes_first_param = substr($kvcodes_con, 0, 2... | 2014/05/29 | [
"https://wordpress.stackexchange.com/questions/145979",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52374/"
] | I'm trying to add a shortcode within the text of the\_content(). It is possible to add it to the beginning or the end however I cannot figure out how I would get it to show after say 200 characters.
Here's the shortcode that I need added:
[related-posts]
I've tried [this](https://wordpress.stackexchange.com/question... | Here's what I've used after finding something on the web (wpbeginner).
It finds the fourth p tag closing and adds it after that. Originally it was to add ad banners in the middle of post content dynamically.
```
add_filter( 'the_content', 'prefix_insert_post_related' );
function prefix_insert_post_related( $content )... |
146,018 | <p>How can I display a term's name & description for a custom taxonomy within The Loop (single post page template)? </p>
<p>Currently I can show its name like this: </p>
<pre><code>the_terms( $post->ID , 'director', 'director: ');
</code></pre>
<p>but can't get the description</p>
<p><strong>EDIT</strong><... | [
{
"answer_id": 146020,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Have a look at <a href=\"http://codex.wordpress.org/Function_Reference/get_term\" rel=\"nofollow norefer... | 2014/05/30 | [
"https://wordpress.stackexchange.com/questions/146018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52225/"
] | How can I display a term's name & description for a custom taxonomy within The Loop (single post page template)?
Currently I can show its name like this:
```
the_terms( $post->ID , 'director', 'director: ');
```
but can't get the description
**EDIT**
I dont want to use extra php coding like:
```
$directors ... | Have a look at [`get term()`](http://codex.wordpress.org/Function_Reference/get_term). This return the name and description for a term.
Here is the axamples given in the codex
>
> Gives you term name: e.g. Term Name Example
>
>
> $name = $term->name;
>
>
> Gives you term description: e.g. This is my new cool cus... |
146,036 | <p>I have a wordpress article with 50 000 words.
After a debug I realised that the CPU is 100% when I read the post / open the category page.
I have a quad core server with 8gb ram (the ram level is below 1%), so the problem is the CPU.</p>
<p>I opened putty and entered the command: top</p>
<p>This is the first line:... | [
{
"answer_id": 146060,
"author": "ahmetlutfu",
"author_id": 25086,
"author_profile": "https://wordpress.stackexchange.com/users/25086",
"pm_score": -1,
"selected": false,
"text": "<ul>\n<li>upgrade your php to php 5.5.</li>\n<li>switch apache to nginx.</li>\n<li>enable opcache.</li>\n<li... | 2014/05/30 | [
"https://wordpress.stackexchange.com/questions/146036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21370/"
] | I have a wordpress article with 50 000 words.
After a debug I realised that the CPU is 100% when I read the post / open the category page.
I have a quad core server with 8gb ram (the ram level is below 1%), so the problem is the CPU.
I opened putty and entered the command: top
This is the first line:
```
20961 zzz ... | Check the number of post revisions for that one 50K word article. While in Edit Page, go to Screen Options and be sure "Revisions" is ticked.
If you have more than one revision, WP is querying the database for that one large post and all revisions, and that will account for some - possibly all - of the CPU spike. The ... |
146,051 | <p>I created a page for my posts, and a home.php for the structure.</p>
<p>I would like to show the page's name on the top of the posts, but the result is always the latest post.</p>
<p>My code:</p>
<pre><code><?php get_header(); ?>
<section id="primary-content" class="col-md-9">
<?php the_title()... | [
{
"answer_id": 146054,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 2,
"selected": true,
"text": "<p>The call for the page title is outside the loop so you need to use this function instead:</p>\n\n<pre><code... | 2014/05/30 | [
"https://wordpress.stackexchange.com/questions/146051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38284/"
] | I created a page for my posts, and a home.php for the structure.
I would like to show the page's name on the top of the posts, but the result is always the latest post.
My code:
```
<?php get_header(); ?>
<section id="primary-content" class="col-md-9">
<?php the_title(); ?>
<?php if ( have_posts() ) : while ... | The call for the page title is outside the loop so you need to use this function instead:
```
<?php echo get_the_title(); ?>
```
Here is the updated code:
```
<?php get_header(); ?>
<section id="primary-content" class="col-md-9">
<?php echo get_the_title(); ?>
<?php if ( have_posts() ) : while ( have_po... |
146,067 | <p>I am trying pass a WP function to a user function, where I can pass a new func argument <code>$key</code> for each <code>post_meta</code> type here: </p>
<p>functions.php</p>
<pre><code> function my_post_meta($key){
$meta = get_post_meta($post->ID, $key, true);
if ($meta) {
echo $meta . '&l... | [
{
"answer_id": 146054,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 2,
"selected": true,
"text": "<p>The call for the page title is outside the loop so you need to use this function instead:</p>\n\n<pre><code... | 2014/05/30 | [
"https://wordpress.stackexchange.com/questions/146067",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43893/"
] | I am trying pass a WP function to a user function, where I can pass a new func argument `$key` for each `post_meta` type here:
functions.php
```
function my_post_meta($key){
$meta = get_post_meta($post->ID, $key, true);
if ($meta) {
echo $meta . '<br />';
}
}
```
page-tem... | The call for the page title is outside the loop so you need to use this function instead:
```
<?php echo get_the_title(); ?>
```
Here is the updated code:
```
<?php get_header(); ?>
<section id="primary-content" class="col-md-9">
<?php echo get_the_title(); ?>
<?php if ( have_posts() ) : while ( have_po... |
146,070 | <p>My question here is to display all the single detail page of future scheduled posts.
It is returning 404 page. How can this be done in wordpress?</p>
<p>What I have used so far is </p>
<pre><code>$args = array(
'posts_per_page' => 10,
'category__in' => $category->term_id,
... | [
{
"answer_id": 146133,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>A much cleaner solution is to just set the post status via <code>pre_get_posts</code>. By default, the ... | 2014/05/30 | [
"https://wordpress.stackexchange.com/questions/146070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52417/"
] | My question here is to display all the single detail page of future scheduled posts.
It is returning 404 page. How can this be done in wordpress?
What I have used so far is
```
$args = array(
'posts_per_page' => 10,
'category__in' => $category->term_id,
'orderby' ... | After some research this worked for me:
```
add_filter('the_posts', 'show_future_posts');
function show_future_posts($posts)
{
global $wp_query, $wpdb;
if(is_single() && $wp_query->post_count == 0)
{
$posts = $wpdb->get_results($wp_query->request);
}
return $posts;
}
```
Hopefully it will wor... |
146,094 | <p>I am using Vagrant to build up a little Wordpress development VM. When I select permalinks (postname) then the page from an article doesn't load. However, when I select the standard link (i.e page id) all is working good.
I've used the service PuPHPet to build the VM.</p>
<p>My settings can be found <a href="http:/... | [
{
"answer_id": 147179,
"author": "Nazeem",
"author_id": 40920,
"author_profile": "https://wordpress.stackexchange.com/users/40920",
"pm_score": 2,
"selected": true,
"text": "<p>I solved the problem myself.</p>\n\n<p>In the default apache configuration, under <code>/etc/apache2/sites-enab... | 2014/05/30 | [
"https://wordpress.stackexchange.com/questions/146094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40920/"
] | I am using Vagrant to build up a little Wordpress development VM. When I select permalinks (postname) then the page from an article doesn't load. However, when I select the standard link (i.e page id) all is working good.
I've used the service PuPHPet to build the VM.
My settings can be found [here](http://pastebin.co... | I solved the problem myself.
In the default apache configuration, under `/etc/apache2/sites-enabled`, where mine is called `15-default.conf`
This was declared under the document root:
```
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow... |
146,103 | <p>What is the best way to duplicate an entire Wordpress site, including database, themes, plugins and all associated settings to another URL for development purposes, and then redeploying it back to the main site?</p>
<p>The site in question is a large Wordpress install — Wordpress 3.5 to be specific — with thousands... | [
{
"answer_id": 147179,
"author": "Nazeem",
"author_id": 40920,
"author_profile": "https://wordpress.stackexchange.com/users/40920",
"pm_score": 2,
"selected": true,
"text": "<p>I solved the problem myself.</p>\n\n<p>In the default apache configuration, under <code>/etc/apache2/sites-enab... | 2014/05/30 | [
"https://wordpress.stackexchange.com/questions/146103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52431/"
] | What is the best way to duplicate an entire Wordpress site, including database, themes, plugins and all associated settings to another URL for development purposes, and then redeploying it back to the main site?
The site in question is a large Wordpress install — Wordpress 3.5 to be specific — with thousands of posts ... | I solved the problem myself.
In the default apache configuration, under `/etc/apache2/sites-enabled`, where mine is called `15-default.conf`
This was declared under the document root:
```
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow... |
146,118 | <p>Is there any possibility to get featured post title and image using the <a href="https://wordpress.org/plugins/json-api/" rel="nofollow">JSON API</a>.</p>
<p>I tried using this:</p>
<pre><code>example.com/?json=the_post_thumbnails&count=3
</code></pre>
<p>But instead of recent posts, I get featured posts.</p>... | [
{
"answer_id": 199897,
"author": "jim.duck",
"author_id": 78337,
"author_profile": "https://wordpress.stackexchange.com/users/78337",
"pm_score": -1,
"selected": false,
"text": "<p>Tty this one </p>\n\n<p></p>\n\n<p></p>\n\n<pre><code>jQuery.getJSON('/latest-post-as-json/', function(data... | 2014/05/30 | [
"https://wordpress.stackexchange.com/questions/146118",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52438/"
] | Is there any possibility to get featured post title and image using the [JSON API](https://wordpress.org/plugins/json-api/).
I tried using this:
```
example.com/?json=the_post_thumbnails&count=3
```
But instead of recent posts, I get featured posts. | I made a shortcut to my image by adding it directly to the API response.
---
```
//Add in functions.php, this hook is for my 'regions' post type
add_action( 'rest_api_init', 'create_api_posts_meta_field' );
function create_api_posts_meta_field() {
register_rest_field( 'regions', 'group', array(
'get_call... |
146,121 | <p>I have been trying to add 2 tabs on user profile. “posts”,”gallery”</p>
<p>posts : my posted posts. it will display a custom-post-type “user-post”</p>
<p>gallery : my pictures .. or any thing.. it will display a custom-post-type “user-images”</p>
<pre><code>// Set up Cutsom BP navigation
function my_setup_nav() ... | [
{
"answer_id": 147174,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 2,
"selected": true,
"text": "<p>Unless you're willing to create new components, it'll be easier and faster to inject content into members/sing... | 2014/05/31 | [
"https://wordpress.stackexchange.com/questions/146121",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34463/"
] | I have been trying to add 2 tabs on user profile. “posts”,”gallery”
posts : my posted posts. it will display a custom-post-type “user-post”
gallery : my pictures .. or any thing.. it will display a custom-post-type “user-images”
```
// Set up Cutsom BP navigation
function my_setup_nav() {
global $bp;
bp_core_n... | Unless you're willing to create new components, it'll be easier and faster to inject content into members/single/plugins
```
function jv_user_posts() {
add_action( 'bp_template_content', 'jv_user_posts_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
fun... |
146,159 | <p>I am using the code below for showing featured image in single post content.It's working fine.But when I call the_excerpt(); in any template it showing featured image with post content.I want it show featured image only single post.Please help!</p>
<pre><code>add_filter( 'the_content', 'put_thumbnail_in_posting' );... | [
{
"answer_id": 146168,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>Use an <code>is_single()</code> condition to ensure the thumbnail isn't added on archive pages. You should... | 2014/05/31 | [
"https://wordpress.stackexchange.com/questions/146159",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45128/"
] | I am using the code below for showing featured image in single post content.It's working fine.But when I call the\_excerpt(); in any template it showing featured image with post content.I want it show featured image only single post.Please help!
```
add_filter( 'the_content', 'put_thumbnail_in_posting' );
function pu... | Use an `is_single()` condition to ensure the thumbnail isn't added on archive pages. You should also be using `get_the_post_thumbnail` and prepending it to `$content`, rather than just echo'ing it out:
```
function put_thumbnail_in_posting( $content ) {
if ( is_single() && has_post_thumbnail() && get_post_type() ... |
147,173 | <p>Ok, so my code is meant to be pulled from the function using the jquery code below, but it isn't pulling the code and I can't see why not.</p>
<p>My pages code</p>
<pre><code><script>
var click_to_choose_user = function(){
jQuery.ajax({
type: "POST",
url: ajaxurl,
data: "action=twitchuser",
su... | [
{
"answer_id": 147177,
"author": "Marcos Rodrigues",
"author_id": 41354,
"author_profile": "https://wordpress.stackexchange.com/users/41354",
"pm_score": 3,
"selected": true,
"text": "<h1>1) Is your function working?</h1>\n\n<p>First do a <code>console.log( \"it's working\" );</code> ins... | 2014/05/31 | [
"https://wordpress.stackexchange.com/questions/147173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51887/"
] | Ok, so my code is meant to be pulled from the function using the jquery code below, but it isn't pulling the code and I can't see why not.
My pages code
```
<script>
var click_to_choose_user = function(){
jQuery.ajax({
type: "POST",
url: ajaxurl,
data: "action=twitchuser",
success: function(msg){
jQ... | 1) Is your function working?
============================
First do a `console.log( "it's working" );` inside your function and check it on your browser's console.
If it's not showing when you click, you must refactor your function.
2) Have you defined ajaxurl?
============================
>
> Unlike on the admin si... |
147,211 | <p>My website is fully API based and builds pages/posts from API data.
I was thinking to create something like PHP magic function __call to call specific function when requested URL would return 404, but do it before it happens, so I could send API request and create the page on the fly and return the previously missin... | [
{
"answer_id": 147219,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>If you want to add this logic <em>after</em> WP churns through the query and concludes it's 404, but <em>before</em... | 2014/06/01 | [
"https://wordpress.stackexchange.com/questions/147211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45130/"
] | My website is fully API based and builds pages/posts from API data.
I was thinking to create something like PHP magic function \_\_call to call specific function when requested URL would return 404, but do it before it happens, so I could send API request and create the page on the fly and return the previously missing... | Simply use template\_redirect filter to perform check on request you get in wordpress.
```
add_filter('template_redirect', 'my_404_override' );
function my_404_override() {
global $wp_query;
if (!$wp_query->post) { // Check if any post is found. If not its 404.
status_header( 200 );
... |
147,238 | <p>I want to include several scripts and styles from a remote CDN... in this case bootstrap and similer files but i want to provide a safety net in the form of a callback in the case the CDN is down for some reason...</p>
<p>I would add some code but i really dont know how to approace this at all... </p>
<p><strong>... | [
{
"answer_id": 147259,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 2,
"selected": false,
"text": "<p>You could try something like this to test the CDN version first and then load conditionally based on if it... | 2014/06/02 | [
"https://wordpress.stackexchange.com/questions/147238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7990/"
] | I want to include several scripts and styles from a remote CDN... in this case bootstrap and similer files but i want to provide a safety net in the form of a callback in the case the CDN is down for some reason...
I would add some code but i really dont know how to approace this at all...
**Here is an example of a ... | The accepted answer is completely wrong. I suspect a gross misunderstanding of the OP'S question, since anyone with even a little experience with programming will never recommend something like "cache your own copy of the script, and perform get\_url calls every 20 minutes".
@Paul G. says there is no point in loading ... |
147,247 | <p>the condition is: </p>
<p>there's a wordpress site
that has 8 categories, and each category has sub-category, and each subcategory has several posts (and still will be updating/counting) :</p>
<ul>
<li>Category A - 8 subcat </li>
<li>Category B - 5 subcat</li>
<li>Category C - 4 subcat</li>
<li>Category D - 3 su... | [
{
"answer_id": 147249,
"author": "Andrew",
"author_id": 50767,
"author_profile": "https://wordpress.stackexchange.com/users/50767",
"pm_score": 0,
"selected": false,
"text": "<p>From what I understand you would like to add a class based on the current category to the <code><body></... | 2014/06/02 | [
"https://wordpress.stackexchange.com/questions/147247",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52514/"
] | the condition is:
there's a wordpress site
that has 8 categories, and each category has sub-category, and each subcategory has several posts (and still will be updating/counting) :
* Category A - 8 subcat
* Category B - 5 subcat
* Category C - 4 subcat
* Category D - 3 subcat
* Category E - 2 subcat
* Category F - 1... | Category archive pages can be styled using the body class as per your example - WordPress does this out of the box. But for single pages, you need to add this to `functions.php`:
```
function add_category_name($classes = '') {
if(is_single()) {
$category = get_the_category();
$classes[] = 'category-'.$... |
147,251 | <p>I want to get WordPress database name. I have also try to get database name from $wpdb but failed. When print the $wpdb it give an object array but i don't know how to get database name from object array.</p>
| [
{
"answer_id": 147252,
"author": "тнє Sufi",
"author_id": 28744,
"author_profile": "https://wordpress.stackexchange.com/users/28744",
"pm_score": 4,
"selected": true,
"text": "<p>To get the db name using <code>$wpdb</code>:</p>\n\n<pre><code>global $wpdb;\necho $wpdb->dbname;\n</code>... | 2014/06/02 | [
"https://wordpress.stackexchange.com/questions/147251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52516/"
] | I want to get WordPress database name. I have also try to get database name from $wpdb but failed. When print the $wpdb it give an object array but i don't know how to get database name from object array. | To get the db name using `$wpdb`:
```
global $wpdb;
echo $wpdb->dbname;
```
It will return database name as a string. |
147,317 | <p>Need help displaying my custom meta boxes on a template file.</p>
<p>Following a <a href="http://wpshed.com/create-custom-meta-box-easy-way/" rel="nofollow">tutorial</a></p>
<p>Here's the code from my functions.php:</p>
<pre><code>function get_custom_field( $value ) {
global $post;
$custom_field = get_post_meta(... | [
{
"answer_id": 147320,
"author": "тнє Sufi",
"author_id": 28744,
"author_profile": "https://wordpress.stackexchange.com/users/28744",
"pm_score": -1,
"selected": false,
"text": "<p>use <code>get_post_meta( get_the_ID(), 'textfield', true )</code> inside the loop</p>\n"
},
{
"answ... | 2014/06/02 | [
"https://wordpress.stackexchange.com/questions/147317",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52548/"
] | Need help displaying my custom meta boxes on a template file.
Following a [tutorial](http://wpshed.com/create-custom-meta-box-easy-way/)
Here's the code from my functions.php:
```
function get_custom_field( $value ) {
global $post;
$custom_field = get_post_meta( $post->ID, $value, true );
if ( !empty( $custom_field... | use `get_post_meta( get_the_ID(), 'textfield', true )` inside the loop |
147,318 | <p>I just migrated some content from another CMS [SPIP] into WordPress and I am seeing weird characters like ' Unité dans la diversité ', this is supposed to come in french but its not . Please let me know what can be done to convert this content into Unicode.</p>
<p>Praveen</p>
| [
{
"answer_id": 147335,
"author": "Pressaholic",
"author_id": 52556,
"author_profile": "https://wordpress.stackexchange.com/users/52556",
"pm_score": 1,
"selected": false,
"text": "<p>Try to change encoding rule to utf8 in your databse. This can easily be done with phpMyAdmin for example.... | 2014/06/02 | [
"https://wordpress.stackexchange.com/questions/147318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26393/"
] | I just migrated some content from another CMS [SPIP] into WordPress and I am seeing weird characters like ' Unité dans la diversité ', this is supposed to come in french but its not . Please let me know what can be done to convert this content into Unicode.
Praveen | I ran the Following bash script for the conversion from non unicode to utf-8
```
#!/bin/bash -e
DB_HOST="localhost"
DB_USER="username"
DB_PASSWORD="paassword"
DB_NAME="dbname"
mysqldump -h "$DB_HOST" -u "$DB_USER" - p"$DB_PASSWORD" --opt --quote-names -- skip-set-charset --default-character-set=latin1 "$DB_NAME" > /... |
147,366 | <p>I'm fairly stumped on this. </p>
<p>Without getting too query-heavy, I was wondering what path one might take to produce a menu that links to a category of posts, and displays in parenthesis how many new posts there are.</p>
<p>Example:</p>
<p><strong>News (5 new)<br>
Articles (8 new)</strong> </p>
<p>...and so ... | [
{
"answer_id": 149527,
"author": "Matt Dietsche",
"author_id": 11273,
"author_profile": "https://wordpress.stackexchange.com/users/11273",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress' get_categories() function returns an array of category objects, each of which has a \"count\... | 2014/06/03 | [
"https://wordpress.stackexchange.com/questions/147366",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29565/"
] | I'm fairly stumped on this.
Without getting too query-heavy, I was wondering what path one might take to produce a menu that links to a category of posts, and displays in parenthesis how many new posts there are.
Example:
**News (5 new)
Articles (8 new)**
...and so forth.
What is the most efficient way to ach... | WordPress' get\_categories() function returns an array of category objects, each of which has a "count" property for the number of posts in that category. So something like this would get you a list of links to category pages:
```
$categories = get_categories();
$markup = '<ul>';
foreach( $categories as $category ) {... |
147,377 | <p>Once again struggling with htaccess. I've successfully redirected the home page to my holding page with the following rule but it's not applying to child pages for some reason (mydomain.com/child-page). </p>
<pre><code># MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUE... | [
{
"answer_id": 149527,
"author": "Matt Dietsche",
"author_id": 11273,
"author_profile": "https://wordpress.stackexchange.com/users/11273",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress' get_categories() function returns an array of category objects, each of which has a \"count\... | 2014/06/03 | [
"https://wordpress.stackexchange.com/questions/147377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45504/"
] | Once again struggling with htaccess. I've successfully redirected the home page to my holding page with the following rule but it's not applying to child pages for some reason (mydomain.com/child-page).
```
# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !/holding [N... | WordPress' get\_categories() function returns an array of category objects, each of which has a "count" property for the number of posts in that category. So something like this would get you a list of links to category pages:
```
$categories = get_categories();
$markup = '<ul>';
foreach( $categories as $category ) {... |
147,401 | <p>For development purpose I need to constantly fill and unfill a Wordpress instance with dummy content. Deleting everything in two steps is quite annoying, so I'm wondering if there's a way to cut the long way around to trash when deleting posts. Please help.</p>
| [
{
"answer_id": 147403,
"author": "NETCreator Hosting - WebDesign",
"author_id": 35040,
"author_profile": "https://wordpress.stackexchange.com/users/35040",
"pm_score": 2,
"selected": false,
"text": "<p>You can set a time interval for automatically empty trash:</p>\n\n<p>In your wp-config... | 2014/06/03 | [
"https://wordpress.stackexchange.com/questions/147401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30597/"
] | For development purpose I need to constantly fill and unfill a Wordpress instance with dummy content. Deleting everything in two steps is quite annoying, so I'm wondering if there's a way to cut the long way around to trash when deleting posts. Please help. | Considering this site is WordPress Development, I'm assuming you would like to know how to (force) delete posts programmatically.
```
wp_delete_post(257, true); // `true` indicated you would like to force delete (skip trash)
```
[More on `wp_delete_post()` function](http://codex.wordpress.org/Function_Reference/wp_d... |
147,407 | <p>Is it possible to order posts retrieved via <code>WP_Query</code> according to a meta value of the corresponding <strong>post author</strong>?</p>
<p>Use case: I have premium subscribers and basic subscribers. I want the posts of the premium subscribers to appear before the posts of the basic subscribers in a searc... | [
{
"answer_id": 147408,
"author": "Matt",
"author_id": 52536,
"author_profile": "https://wordpress.stackexchange.com/users/52536",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand correctly, this is what you're looking for:</p>\n\n<p>You will need to specify for each post, it... | 2014/06/03 | [
"https://wordpress.stackexchange.com/questions/147407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48847/"
] | Is it possible to order posts retrieved via `WP_Query` according to a meta value of the corresponding **post author**?
Use case: I have premium subscribers and basic subscribers. I want the posts of the premium subscribers to appear before the posts of the basic subscribers in a search result page.
One way to solve t... | This should give you an idea and I believe this should help you forward.
This query first uses [`WP_User_Query`](http://codex.wordpress.org/Class_Reference/WP_User_Query) to fetch all users that are authors registered as premium subscribers and basic subscribers. These users are ordered by `meta_value` so that premium... |
147,413 | <p>I am testing WP-Deploy, but can't get it work. I follow the steps in the docs but for some reason when I execute </p>
<pre><code>$ bundle exec cap staging wp:setup:local
INFO [b4d7f211] Running /usr/bin/env wp core install --url='http://localhost/blog' --title='TITLE' --admin_user='YYYY' --admin_password='YYYY' --... | [
{
"answer_id": 147408,
"author": "Matt",
"author_id": 52536,
"author_profile": "https://wordpress.stackexchange.com/users/52536",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand correctly, this is what you're looking for:</p>\n\n<p>You will need to specify for each post, it... | 2014/06/03 | [
"https://wordpress.stackexchange.com/questions/147413",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52580/"
] | I am testing WP-Deploy, but can't get it work. I follow the steps in the docs but for some reason when I execute
```
$ bundle exec cap staging wp:setup:local
INFO [b4d7f211] Running /usr/bin/env wp core install --url='http://localhost/blog' --title='TITLE' --admin_user='YYYY' --admin_password='YYYY' --admin_email='Y... | This should give you an idea and I believe this should help you forward.
This query first uses [`WP_User_Query`](http://codex.wordpress.org/Class_Reference/WP_User_Query) to fetch all users that are authors registered as premium subscribers and basic subscribers. These users are ordered by `meta_value` so that premium... |
147,420 | <p>I'm very new to WordPress, but I'm currently doing work on a site built on the platform. I'm making my way through, but I've run into a bit of a problem. </p>
<p>I'm trying to add content from the text editor of the site's blog <code>page</code>, which uses the standard index.php template. However, when I use <code... | [
{
"answer_id": 147408,
"author": "Matt",
"author_id": 52536,
"author_profile": "https://wordpress.stackexchange.com/users/52536",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand correctly, this is what you're looking for:</p>\n\n<p>You will need to specify for each post, it... | 2014/06/03 | [
"https://wordpress.stackexchange.com/questions/147420",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52609/"
] | I'm very new to WordPress, but I'm currently doing work on a site built on the platform. I'm making my way through, but I've run into a bit of a problem.
I'm trying to add content from the text editor of the site's blog `page`, which uses the standard index.php template. However, when I use `<?php the_content(); ?>` ... | This should give you an idea and I believe this should help you forward.
This query first uses [`WP_User_Query`](http://codex.wordpress.org/Class_Reference/WP_User_Query) to fetch all users that are authors registered as premium subscribers and basic subscribers. These users are ordered by `meta_value` so that premium... |
147,441 | <p>I want to make Ajax requests without JQuery, and without including <code>wp_load.php</code>. I want to use a vanilla <code>XmlHttpRequest</code> object that I write myself.</p>
<p>Any links, hints, done-it-befores, etc? </p>
| [
{
"answer_id": 149291,
"author": "akamaozu",
"author_id": 13176,
"author_profile": "https://wordpress.stackexchange.com/users/13176",
"pm_score": 1,
"selected": false,
"text": "<p>If all you need to do is grab data about a post/ posts, I'll seriously recommend using the JSON API plugin (... | 2014/06/03 | [
"https://wordpress.stackexchange.com/questions/147441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52625/"
] | I want to make Ajax requests without JQuery, and without including `wp_load.php`. I want to use a vanilla `XmlHttpRequest` object that I write myself.
Any links, hints, done-it-befores, etc? | Coming back to this on a new application. I just solved this using Angular, and a similar approach could be used with vanilla JS.
First, give Javascript access to the `admin-ajax.php` URL, something like:
```
echo "<script type='text/javascript'>var ajaxurl = '".admin_url('admin-ajax.php')."'</script>";
```
Next, i... |
147,484 | <p>I have a CPT for "Band Members", and I want to list all of them at the top of a template, above all the posts (which will just be featured images) - a sort-of Navigation for all members. I can't think of how to do this... is there two loops? Any help would be appreciated!</p>
<pre><code><div id="main">
<?p... | [
{
"answer_id": 147485,
"author": "IntensiveWordpress",
"author_id": 52652,
"author_profile": "https://wordpress.stackexchange.com/users/52652",
"pm_score": 0,
"selected": false,
"text": "<p>to save you from having to use wp_reset_query ... </p>\n\n<pre><code> $args = array(\n ... | 2014/06/04 | [
"https://wordpress.stackexchange.com/questions/147484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47344/"
] | I have a CPT for "Band Members", and I want to list all of them at the top of a template, above all the posts (which will just be featured images) - a sort-of Navigation for all members. I can't think of how to do this... is there two loops? Any help would be appreciated!
```
<div id="main">
<?php
$args=array(
'pos... | You are on the right track here, but it is a bit bumpy
Firstly, `caller_get_posts` is depreciated, that has been replaced with `ignore_sticky_posts`
Secondly, you should use `wp_reset_postdata` not `wp_reset_query`. The latter is used in conjuction with `query_posts` which should never be used.
Thirdly, your call t... |
147,505 | <p>I'm having a weird problem I have written the code as below:</p>
<pre><code>add_action('save_post', 'save_post_func');
function save_post_func(){
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed($url);
if (!is_wp_error($rss)) {
//ini_set('xdebug.max_nesting_level', 1000); <--... | [
{
"answer_id": 147500,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>The short answer is no. If you have a look at terms, taxonomies and categories, all of them is stores in... | 2014/06/04 | [
"https://wordpress.stackexchange.com/questions/147505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37040/"
] | I'm having a weird problem I have written the code as below:
```
add_action('save_post', 'save_post_func');
function save_post_func(){
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed($url);
if (!is_wp_error($rss)) {
//ini_set('xdebug.max_nesting_level', 1000); <-- Doesn't work
... | The short answer is no. If you have a look at terms, taxonomies and categories, all of them is stores in the database in the `wp_terms` table.
Every one of these are assigned a numerical value that is unique to that term/category/taxonomy. This don't just apply to "objects" added to `wp_terms`, but to anything added t... |
147,529 | <p>I have a page-contact.php for my contact form in my template. I wanted to add jquery validation and some fancy ajax action to my form. This is already a working code in a simple PHP page, but getting it work in wordpress fails.</p>
<p>My contact form:</p>
<pre><code><form id="contact_form" method="POST" action=... | [
{
"answer_id": 147530,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 2,
"selected": true,
"text": "<p>WordPress is running Jquery in noconflict mode. <a href=\"http://codex.wordpress.org/Function_Reference/wp_... | 2014/06/04 | [
"https://wordpress.stackexchange.com/questions/147529",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47810/"
] | I have a page-contact.php for my contact form in my template. I wanted to add jquery validation and some fancy ajax action to my form. This is already a working code in a simple PHP page, but getting it work in wordpress fails.
My contact form:
```
<form id="contact_form" method="POST" action="" enctype="application/... | WordPress is running Jquery in noconflict mode. [(WordPress Codex Reference)](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers)
or read this brief article I posted some time ago. [View it here](http://mattroyal.co.za/2013/07/working-with-jquery-in-wordpress/).
You need to rep... |
147,601 | <p>Is is possible to combine a tax_query with a date_query in the most recent Wordpress?</p>
<p>Here's my attempt to do so:</p>
<pre><code>$args = array(
'post_type' => 'job',
'tax_query' => array(
array(
'taxonomy' => 'location',
'terms' => 'dallas',
'field' => 'slu... | [
{
"answer_id": 147530,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 2,
"selected": true,
"text": "<p>WordPress is running Jquery in noconflict mode. <a href=\"http://codex.wordpress.org/Function_Reference/wp_... | 2014/06/04 | [
"https://wordpress.stackexchange.com/questions/147601",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8802/"
] | Is is possible to combine a tax\_query with a date\_query in the most recent Wordpress?
Here's my attempt to do so:
```
$args = array(
'post_type' => 'job',
'tax_query' => array(
array(
'taxonomy' => 'location',
'terms' => 'dallas',
'field' => 'slug',
)
),
'date_query' =... | WordPress is running Jquery in noconflict mode. [(WordPress Codex Reference)](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers)
or read this brief article I posted some time ago. [View it here](http://mattroyal.co.za/2013/07/working-with-jquery-in-wordpress/).
You need to rep... |
147,602 | <p>I'm trying to figure out how to remove wordpress widgets added by plugins. I know there are a couple of plugins that do this, like <a href="https://wordpress.org/plugins/wp-remove-widgets/" rel="nofollow">https://wordpress.org/plugins/wp-remove-widgets/</a> and <a href="https://wordpress.org/plugins/post-lists-view-... | [
{
"answer_id": 147609,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 2,
"selected": false,
"text": "<p><em>Without being able to see the code used by WPEngine to do this, this is partly guess work.</em> </p>... | 2014/06/04 | [
"https://wordpress.stackexchange.com/questions/147602",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38123/"
] | I'm trying to figure out how to remove wordpress widgets added by plugins. I know there are a couple of plugins that do this, like <https://wordpress.org/plugins/wp-remove-widgets/> and <https://wordpress.org/plugins/post-lists-view-custom/>, however I'd rather not use a seperate plugin for something that seems like su... | Thanks Stephen for helping me wrap my head around this today. Even though it's something so small, I absolutely hate when develpers bloat plugins with crap you don't want. I was very frustrated after WPengine, telling me it can't be removed and that if I really want to remove it than I need to find the function in the ... |
147,621 | <p>I've recently started integrating Foundation 5.2.3 into Wordpress 3.9, and I am having issues with getting jquery to initialize via wp_enqueue. The styles load just fine, though.</p>
<p>A working example of what I am trying to achieve can be found <a href="http://www.elevancement.com/novus-theme/" rel="nofollow nor... | [
{
"answer_id": 147624,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 0,
"selected": false,
"text": "<p>There are a couple of problems here, and some other things that I would do diffirently.</p>\n<p>Lets st... | 2014/06/05 | [
"https://wordpress.stackexchange.com/questions/147621",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52719/"
] | I've recently started integrating Foundation 5.2.3 into Wordpress 3.9, and I am having issues with getting jquery to initialize via wp\_enqueue. The styles load just fine, though.
A working example of what I am trying to achieve can be found [here](http://www.elevancement.com/novus-theme/) (styles & scripts in header.... | **EDIT:** I'm coming back to correct this post, having successfully wp\_enqueue'd Foundation 5.3 for Sites to Wordpress 3.9. This code below is for **anyone** who has struggled to *WP\_ENQUEUE* Foundation. The code below works perfectly.
**UPDATES:** I will continue to update this post with the newest version of Word... |
147,631 | <p>I have a custom post type called "RESOURCES" which I used to create a directory of resources on my website. This CPT has the taxonomy called "PRICES". There are three terms </p>
<ul>
<li>free</li>
<li>free trial</li>
<li>premium</li>
</ul>
<p>So, when someone's viewing my directory and they see in the sidebar "PRI... | [
{
"answer_id": 147703,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 0,
"selected": false,
"text": "<p>You can try using WP_Query like this to get all the posts in that taxonomy and count them.</p>\n\n<pre><co... | 2014/06/05 | [
"https://wordpress.stackexchange.com/questions/147631",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52723/"
] | I have a custom post type called "RESOURCES" which I used to create a directory of resources on my website. This CPT has the taxonomy called "PRICES". There are three terms
* free
* free trial
* premium
So, when someone's viewing my directory and they see in the sidebar "PRICES" with those options underneath, they c... | You can use `WP_Query` [Methods and Properties](http://codex.wordpress.org/Class_Reference/WP_Query#Methods_and_Properties) to accomplish this. `$wp_query->found_posts` will return the amount of posts within the term while `$wp_query->queried_object->name` will return the name of the term currently displayed.
You can ... |
147,646 | <p>Say I have 3 sites, abc.com, def.com and xyz.com. And all the 3 sites have different wordpress installation and different databases. Now What I want to show all the latest articles of all three sites in sidebar of main site say abc.com. Secondly in story page I want that related articles should come from all the thr... | [
{
"answer_id": 147647,
"author": "fran p.",
"author_id": 52725,
"author_profile": "https://wordpress.stackexchange.com/users/52725",
"pm_score": -1,
"selected": false,
"text": "<p>You can try with the rss/atom importer, just add a rss widget in your main site abc.com sidebar with the fee... | 2014/06/05 | [
"https://wordpress.stackexchange.com/questions/147646",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52729/"
] | Say I have 3 sites, abc.com, def.com and xyz.com. And all the 3 sites have different wordpress installation and different databases. Now What I want to show all the latest articles of all three sites in sidebar of main site say abc.com. Secondly in story page I want that related articles should come from all the three ... | @franp. is correct, but in case you want to go a code route here's how you get an RSS Feed of a website. You can duplicate this as you see fit, or combine multiple into an array etc.
**Let's get our RSS Feed from ABC.com**
```
$rss = fetch_feed('http://abc.com/feed'); // Or where ever that websites feeds are locate... |
147,675 | <p>The soundcloud short code does not seem to be working. I've tried over several days and it just shows up as raw code. Is this a glitch, has support officially been discontinued, is there some workaround?</p>
<pre><code>[soundcloud url="https://api.soundcloud.com/tracks/151458437" params="color=ff5500&auto_play=... | [
{
"answer_id": 147677,
"author": "H3r0k0",
"author_id": 51425,
"author_profile": "https://wordpress.stackexchange.com/users/51425",
"pm_score": 0,
"selected": false,
"text": "<p>add this to your functions.php</p>\n\n<pre><code>// Add SoundCloud oEmbed\nfunction add_oembed_soundcloud(){\n... | 2014/06/05 | [
"https://wordpress.stackexchange.com/questions/147675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45834/"
] | The soundcloud short code does not seem to be working. I've tried over several days and it just shows up as raw code. Is this a glitch, has support officially been discontinued, is there some workaround?
```
[soundcloud url="https://api.soundcloud.com/tracks/151458437" params="color=ff5500&auto_play=false&hide_related... | If you are on WordPress 3.5 or higher just putting the URL on **a separate line** should work:
<https://soundcloud.com/radhanath-swami/offer-the-best-you-have>
You do not need to use the embed code, WordPress handles the embedding via oEmbed itself.
Also [have a look at the Codex](http://codex.wordpress.org/Embeds).... |
147,699 | <p>Ok guys... I'm sure this is going to be a really easy answer. I'm a complete noob at this. </p>
<p>I have a custom field that is supposed to return a link. For some reason, it just redirects me back to my site homepage. I'm really new to Wordpress so I'm not sure what's going on but I've scoured Google and this is ... | [
{
"answer_id": 147701,
"author": "APAD1",
"author_id": 38829,
"author_profile": "https://wordpress.stackexchange.com/users/38829",
"pm_score": 2,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code><?php echo get_post_meta($post->ID, 'ramco-videos-link', true); ?>\n</code... | 2014/06/05 | [
"https://wordpress.stackexchange.com/questions/147699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52749/"
] | Ok guys... I'm sure this is going to be a really easy answer. I'm a complete noob at this.
I have a custom field that is supposed to return a link. For some reason, it just redirects me back to my site homepage. I'm really new to Wordpress so I'm not sure what's going on but I've scoured Google and this is what I've ... | Try this:
```
<?php echo get_post_meta($post->ID, 'ramco-videos-link', true); ?>
```
Make sure you have the closing PHP tag in there. |