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 |
|---|---|---|---|---|---|---|
59,235 | <p>Setting up a multisite on a blog which root url is dev.domain.com, using subdomains. So, for example, a subsites address : site1.dev.domain.com</p>
<p>Everything works fine as long as i stay on the main site (dev.domain.com)
When i try to access any of the other sites, I get a 404 error.</p>
<p>Here is my .htacces... | [
{
"answer_id": 59264,
"author": "Damien",
"author_id": 17132,
"author_profile": "https://wordpress.stackexchange.com/users/17132",
"pm_score": 0,
"selected": false,
"text": "<p>Can you go back to wp-config.php and add this line </p>\n\n<pre><code>define('WP_ALLOW_MULTISITE', true); //ch... | 2012/07/21 | [
"https://wordpress.stackexchange.com/questions/59235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82/"
] | Setting up a multisite on a blog which root url is dev.domain.com, using subdomains. So, for example, a subsites address : site1.dev.domain.com
Everything works fine as long as i stay on the main site (dev.domain.com)
When i try to access any of the other sites, I get a 404 error.
Here is my .htaccess sitting in the ... | You must also register the wildcard domain \*.dev.domain.com (The asterisk in as the sub-domain will usually allow you to create any sub domain you want and it will work) and point it to your main site. You can normally do this through you host's Control Panel. I didn't do this when I started with WPMU and this is what... |
59,238 | <p>I have a few categories with the same name [some of them are sub-categories]. And I want to get an array of ID's for certain cattegory name.
I tried this: </p>
<pre><code> $term = get_term_by('name', $cat_name, 'category');
</code></pre>
<p>but it seems that <code>get_term_by()</code> returns only the first term ... | [
{
"answer_id": 59242,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 5,
"selected": true,
"text": "<p>Use <a href=\"https://developer.wordpress.org/reference/functions/get_terms/\" rel=\"nofollow noreferrer\"><... | 2012/07/21 | [
"https://wordpress.stackexchange.com/questions/59238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16331/"
] | I have a few categories with the same name [some of them are sub-categories]. And I want to get an array of ID's for certain cattegory name.
I tried this:
```
$term = get_term_by('name', $cat_name, 'category');
```
but it seems that `get_term_by()` returns only the first term that match the query. | Use [`get_terms()`](https://developer.wordpress.org/reference/functions/get_terms/), which uses `WP_Term_Query` under the hood. For a full list of all the available parameters check out the documentation for [`WP_Term_Query::__construct`](https://developer.wordpress.org/reference/classes/wp_term_query/__construct/)
``... |
59,239 | <p>When making an AJAX request is works when my data is a URL style string.</p>
<pre><code>var options = {
type: 'post',
data: 'action=my_action'
};
</code></pre>
<p>The function will get called and return some fake data just fine.</p>
<p>If I try to make the same call but use JSON, it doesn't work. I've tri... | [
{
"answer_id": 59240,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": true,
"text": "<p>Firstly, <code>stringify</code> won't build a URL query - it <em>serializes</em> it into JSON object notatio... | 2012/07/21 | [
"https://wordpress.stackexchange.com/questions/59239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18396/"
] | When making an AJAX request is works when my data is a URL style string.
```
var options = {
type: 'post',
data: 'action=my_action'
};
```
The function will get called and return some fake data just fine.
If I try to make the same call but use JSON, it doesn't work. I've tried several different ways of doin... | Firstly, `stringify` won't build a URL query - it *serializes* it into JSON object notation.
And secondly, you don't even *need* to build the URL query - if you're using jQuery to make the AJAX call, just pass the JSON object as it is - [`jQuery.param()`](http://api.jquery.com/jQuery.param/) will internally handle it ... |
59,271 | <p>I have this url to call the taxonomy.php by pressing the button with the code beneath to show filtered posts:</p>
<pre><code>http://myurl/?meta_key=post_views_count&orderby=meta_value&order=ASC
</code></pre>
<p>This is the JS I am using: </p>
<pre><code> $(document).ready(function(){
$.ajaxSetup({cache... | [
{
"answer_id": 59286,
"author": "xsonic",
"author_id": 18247,
"author_profile": "https://wordpress.stackexchange.com/users/18247",
"pm_score": 3,
"selected": true,
"text": "<p>Try this code in your <code>complete</code> callback of the <code>load</code> function:</p>\n\n<pre><code>$(\".p... | 2012/07/22 | [
"https://wordpress.stackexchange.com/questions/59271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17376/"
] | I have this url to call the taxonomy.php by pressing the button with the code beneath to show filtered posts:
```
http://myurl/?meta_key=post_views_count&orderby=meta_value&order=ASC
```
This is the JS I am using:
```
$(document).ready(function(){
$.ajaxSetup({cache:false});
$("#hot a").click(function(){
... | Try this code in your `complete` callback of the `load` function:
```
$(".postbox_wrapper").load(
jQuery(this).attr("href") + " .postbox_wrapper",
function(response, status, xhr) { // complete callback
// create a empty div
var div = document.createElement('div');
// fill div with resp... |
59,278 | <p>I am trying to create posts in hindi language. These characters <code>UÉeÉMÑüqÉÉU</code> after saving/publishing are interpreted as <code>U�e�M��q��U</code>. Though, the special characters are stored with no change in the mysql database. The <code>�</code> symbol is only during retrieving.
I'm stuck here. The post e... | [
{
"answer_id": 59286,
"author": "xsonic",
"author_id": 18247,
"author_profile": "https://wordpress.stackexchange.com/users/18247",
"pm_score": 3,
"selected": true,
"text": "<p>Try this code in your <code>complete</code> callback of the <code>load</code> function:</p>\n\n<pre><code>$(\".p... | 2012/07/22 | [
"https://wordpress.stackexchange.com/questions/59278",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18421/"
] | I am trying to create posts in hindi language. These characters `UÉeÉMÑüqÉÉU` after saving/publishing are interpreted as `U�e�M��q��U`. Though, the special characters are stored with no change in the mysql database. The `�` symbol is only during retrieving.
I'm stuck here. The post editor is modified to intake multiple... | Try this code in your `complete` callback of the `load` function:
```
$(".postbox_wrapper").load(
jQuery(this).attr("href") + " .postbox_wrapper",
function(response, status, xhr) { // complete callback
// create a empty div
var div = document.createElement('div');
// fill div with resp... |
59,289 | <p>Is there any reason to use admin-ajax.php for ajax requests versus a custom page template?</p>
<p>I didn't know about admin-ajax.php until recently, so what I had been doing is creating a custom page template like this:</p>
<pre><code><?php
/**
* Template Name: API
*/
if ( isset( $_GET['ajax_request'] ) ) {
... | [
{
"answer_id": 59292,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>First, the obvious drawback to the first method is that it depends on your specific page, template, and permalink st... | 2012/07/22 | [
"https://wordpress.stackexchange.com/questions/59289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9058/"
] | Is there any reason to use admin-ajax.php for ajax requests versus a custom page template?
I didn't know about admin-ajax.php until recently, so what I had been doing is creating a custom page template like this:
```
<?php
/**
* Template Name: API
*/
if ( isset( $_GET['ajax_request'] ) ) {
// do stuff
}
```
And ... | First, the obvious drawback to the first method is that it depends on your specific page, template, and permalink structure to all work correctly. Using `admin-ajax.php` will work correctly in any context, theme or plugin, where proper WordPress best practices are followed.
The less obvious drawback to the first metho... |
59,299 | <p>Installing Wordpress SEO (an a few others but not all plugins) gives the following console error:</p>
<pre>GET http://craigmdennis.com/content/plugins/nfs/c08/h04/mnt/152547/domains/craigmdennis.com/html/content/plugins/wordpress-seo/js/wp-seo-admin-global.js?ver=1.2.5 404 (Not Found)
</pre>
<p>For some reason it ... | [
{
"answer_id": 59292,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>First, the obvious drawback to the first method is that it depends on your specific page, template, and permalink st... | 2012/07/22 | [
"https://wordpress.stackexchange.com/questions/59299",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3766/"
] | Installing Wordpress SEO (an a few others but not all plugins) gives the following console error:
```
GET http://craigmdennis.com/content/plugins/nfs/c08/h04/mnt/152547/domains/craigmdennis.com/html/content/plugins/wordpress-seo/js/wp-seo-admin-global.js?ver=1.2.5 404 (Not Found)
```
For some reason it is listing th... | First, the obvious drawback to the first method is that it depends on your specific page, template, and permalink structure to all work correctly. Using `admin-ajax.php` will work correctly in any context, theme or plugin, where proper WordPress best practices are followed.
The less obvious drawback to the first metho... |
59,309 | <p>Apparently a lot of people complain that they only see random letters and characters:</p>
<p><img src="https://i.stack.imgur.com/sBWPt.png" alt="enter image description here"></p>
<p>My biggest problem is that I can't reproduce the problem on ANY of my devices!
Not on my Windows XP laptop, not on my Windows 7 lapt... | [
{
"answer_id": 59312,
"author": "Androliyah",
"author_id": 17636,
"author_profile": "https://wordpress.stackexchange.com/users/17636",
"pm_score": 2,
"selected": false,
"text": "<p>Always specify the encoding used for an HTML or XML page. If you don't, characters in your content may be i... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59309",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6903/"
] | Apparently a lot of people complain that they only see random letters and characters:

My biggest problem is that I can't reproduce the problem on ANY of my devices!
Not on my Windows XP laptop, not on my Windows 7 laptop, not on my Android phone or ... | Let’s start with the output we got before the fix:

What happened here? My **guess:** a collision between the [plugin W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/) and your web server [LiteSpeed](http://www.litespeedtech.com/do... |
59,314 | <p>I have made a custom post type and need to be able to create posts and assign them to authors. It is easy to do this with posts as you can go to the bulk edit screen and immediately change the author. However, when I try to do this with my custom post type the author box is not there. How do I add the functionality ... | [
{
"answer_id": 59318,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 2,
"selected": false,
"text": "<p>Go to Screen Options in the top right corner and check the box that says Author. It will then display the A... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59314",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8288/"
] | I have made a custom post type and need to be able to create posts and assign them to authors. It is easy to do this with posts as you can go to the bulk edit screen and immediately change the author. However, when I try to do this with my custom post type the author box is not there. How do I add the functionality to ... | I found out that the edit author attribute is not added by default in for custom post types. To add the author attribute the following code is required:
```
function allowAuthorEditing()
{
add_post_type_support( 'mytype', 'author' );
}
add_action('init','allowAuthorEditing');
``` |
59,315 | <p>Pretty much all of the content on the site is going to be dynamically generated (php + db backend)</p>
<p>What is the preferred "wordpress way" of passing data to a php template (set up as a template in a wordpress theme)</p>
<p>So the template would be something like</p>
<pre><code><?php
generate_content_bas... | [
{
"answer_id": 59318,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 2,
"selected": false,
"text": "<p>Go to Screen Options in the top right corner and check the box that says Author. It will then display the A... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18432/"
] | Pretty much all of the content on the site is going to be dynamically generated (php + db backend)
What is the preferred "wordpress way" of passing data to a php template (set up as a template in a wordpress theme)
So the template would be something like
```
<?php
generate_content_based_on_this_variable(page);
?>
... | I found out that the edit author attribute is not added by default in for custom post types. To add the author attribute the following code is required:
```
function allowAuthorEditing()
{
add_post_type_support( 'mytype', 'author' );
}
add_action('init','allowAuthorEditing');
``` |
59,326 | <p>We need to add two snippets of code, one right below the opening body tag, and the other right before the closing body tag. What is the best way to do this? I checked out the wp_enqueue_script, but it appears the content would be in the head section.</p>
| [
{
"answer_id": 59334,
"author": "Aras",
"author_id": 10828,
"author_profile": "https://wordpress.stackexchange.com/users/10828",
"pm_score": 1,
"selected": false,
"text": "<p>You were on the right track. <code>wp_enqueue_script</code> takes a parameter called in_footer which defines whet... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59326",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17545/"
] | We need to add two snippets of code, one right below the opening body tag, and the other right before the closing body tag. What is the best way to do this? I checked out the wp\_enqueue\_script, but it appears the content would be in the head section. | Did you even open `header.php` and take a peek? You'll see `genesis_before()` called right after the opening `<body>` tag - follow the white rabbit and you get:
```
function genesis_before() { do_action('genesis_before'); }
```
And likewise for the footer. So...
```
add_action( 'genesis_before', 'im_a_lazy_copy_pas... |
59,331 | <p>I have a post with image gallery, it has 10 images. Can I get the direct link to the images in the post, so that I can display first 5 images on the homepage? </p>
| [
{
"answer_id": 59338,
"author": "Damien",
"author_id": 17132,
"author_profile": "https://wordpress.stackexchange.com/users/17132",
"pm_score": 0,
"selected": false,
"text": "<p>If you are using <a href=\"http://wordpress.org/extend/plugins/nextgen-gallery/\" rel=\"nofollow\">Next Gen Gal... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17303/"
] | I have a post with image gallery, it has 10 images. Can I get the direct link to the images in the post, so that I can display first 5 images on the homepage? | You could use this loop for fetching the images from current post.
```
<?php
$images = get_posts(array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'posts_per_page' => 5,
'post_mime_type' => 'image'
));
if( $image ) {
foreach($images as $image) :
echo wp_get_attachment_link... |
59,354 | <p>This code works for page 1 </p>
<pre><code><?php
$paged1 = (get_query_var('paged')) ? get_query_var('paged') : 1;
$recent1 = get_transient( 'recent1' );
if ( false === $recent1) {
$recent1 = new WP_Query ('cat=3&posts_per_page=5'.'&paged='.$page... | [
{
"answer_id": 59360,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>\"This code works\" - but it doesn't!</p>\n\n<p>If you're gonna cache paginated posts, you'll need to store ... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18025/"
] | This code works for page 1
```
<?php
$paged1 = (get_query_var('paged')) ? get_query_var('paged') : 1;
$recent1 = get_transient( 'recent1' );
if ( false === $recent1) {
$recent1 = new WP_Query ('cat=3&posts_per_page=5'.'&paged='.$paged1);
set_transient('r... | "This code works" - but it doesn't!
If you're gonna cache paginated posts, you'll need to store them chunked:
```
if ( ! $my_paged = absint( get_query_var( 'paged' ) ) )
$my_paged = 1;
if ( ! $my_query = get_transient( "recent_$paged" ) ) {
$my_query = new WP_Query( "cat=3&posts_per_page=5&paged=$my_paged" )... |
59,377 | <p>I know all the <a href="http://ottopress.com/2010/dont-include-wp-load-please/" rel="nofollow">downsides</a> of trying to include wp-load.php, but bear with me :)</p>
<p>I'm trying to create my own admin-ajax-like functionality, in a way that I can control whether or not I load the default WordPress environment, wh... | [
{
"answer_id": 59388,
"author": "Tomas Buteler",
"author_id": 5552,
"author_profile": "https://wordpress.stackexchange.com/users/5552",
"pm_score": 1,
"selected": true,
"text": "<p>Well, it turns out it was a problem of variable scope. I discovered that <code>$wpdb</code> was loading fin... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5552/"
] | I know all the [downsides](http://ottopress.com/2010/dont-include-wp-load-please/) of trying to include wp-load.php, but bear with me :)
I'm trying to create my own admin-ajax-like functionality, in a way that I can control whether or not I load the default WordPress environment, whether I load it with the `SHORTINIT`... | Well, it turns out it was a problem of variable scope. I discovered that `$wpdb` was loading fine, but was inaccessible outside of the function that generated it, so it kind of led me to the solution: the `includes()` I mention in the question are done inside a function, with local (not global) scope. I'm sure, then, t... |
59,397 | <p>I have a custom post type and need to display it in a certain way. I would like other posts to display as normal. When I tried to use the following code to accomplish this, I get a 500 Internal Server Error.</p>
<pre><code>global $post;
//do this only for custom type
if (!(get_post_type()=='customt'))
{
$... | [
{
"answer_id": 59388,
"author": "Tomas Buteler",
"author_id": 5552,
"author_profile": "https://wordpress.stackexchange.com/users/5552",
"pm_score": 1,
"selected": true,
"text": "<p>Well, it turns out it was a problem of variable scope. I discovered that <code>$wpdb</code> was loading fin... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8288/"
] | I have a custom post type and need to display it in a certain way. I would like other posts to display as normal. When I tried to use the following code to accomplish this, I get a 500 Internal Server Error.
```
global $post;
//do this only for custom type
if (!(get_post_type()=='customt'))
{
$rawContent = $p... | Well, it turns out it was a problem of variable scope. I discovered that `$wpdb` was loading fine, but was inaccessible outside of the function that generated it, so it kind of led me to the solution: the `includes()` I mention in the question are done inside a function, with local (not global) scope. I'm sure, then, t... |
59,398 | <p>I have <strong>portfolio-post-type.php</strong> which contains this:</p>
<pre><code><?php
add_action( 'init', 'create_portfolio_post_type' );
function create_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => _x( 'Portfolio',... | [
{
"answer_id": 59388,
"author": "Tomas Buteler",
"author_id": 5552,
"author_profile": "https://wordpress.stackexchange.com/users/5552",
"pm_score": 1,
"selected": true,
"text": "<p>Well, it turns out it was a problem of variable scope. I discovered that <code>$wpdb</code> was loading fin... | 2012/07/23 | [
"https://wordpress.stackexchange.com/questions/59398",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12572/"
] | I have **portfolio-post-type.php** which contains this:
```
<?php
add_action( 'init', 'create_portfolio_post_type' );
function create_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => _x( 'Portfolio', 'post type general name', 'flowthem... | Well, it turns out it was a problem of variable scope. I discovered that `$wpdb` was loading fine, but was inaccessible outside of the function that generated it, so it kind of led me to the solution: the `includes()` I mention in the question are done inside a function, with local (not global) scope. I'm sure, then, t... |
59,426 | <p>Will wordpress run cron if I have scheduled emails to send? Seems like if no visit (request) is made to the site, scheduled tasks won't run and therefore emails won't be sent eg. hourly. </p>
<p>According to current situation, if there is no visit to the site for few hours ( and than visit is made) than all schedul... | [
{
"answer_id": 59427,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<h2>Overall</h2>\n\n<p>The <a href=\"http://codex.wordpress.org/Function_Reference/wp_schedule_event\" rel=\"nofollow\... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59426",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18465/"
] | Will wordpress run cron if I have scheduled emails to send? Seems like if no visit (request) is made to the site, scheduled tasks won't run and therefore emails won't be sent eg. hourly.
According to current situation, if there is no visit to the site for few hours ( and than visit is made) than all scheduled emails ... | You cannot rely on wp-cron for consistent results so you have to look to the server level. Most enterprise-level Wordpress installations need some sort of consistent automation. This is how I automate WordPress in this type of situation.
You will need to add a crontab to the server itself. If you're running Linux, you... |
59,435 | <p>I want to display the user names by the reference of user id.</p>
<p>Is there any function like get_user_displaynme($userid)?
(and one more Is there any shortcode to get group names?)</p>
<p>Thanks in Advance</p>
| [
{
"answer_id": 59456,
"author": "vmassuchetto",
"author_id": 7385,
"author_profile": "https://wordpress.stackexchange.com/users/7385",
"pm_score": 3,
"selected": true,
"text": "<p>You can use the very same <code>get_userdata</code> function of WordPress to code a specific function. Stick... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59435",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17613/"
] | I want to display the user names by the reference of user id.
Is there any function like get\_user\_displaynme($userid)?
(and one more Is there any shortcode to get group names?)
Thanks in Advance | You can use the very same `get_userdata` function of WordPress to code a specific function. Stick this in your `functions.php`:
```
function get_display_name($user_id) {
if (!$user = get_userdata($user_id))
return false;
return $user->data->display_name;
}
```
So you can do something like:
```
$disp... |
59,442 | <p>I'm using a plugin called <a href="http://wordpress.org/extend/plugins/simple-local-avatars">Simple Local Avatars</a> which lets me upload author images which are stored on my server locally (no Gravatar). The plugin works fine and <code>get_avatar</code> returns the local avatar.</p>
<p>However, I need to use that... | [
{
"answer_id": 59445,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": false,
"text": "<p>You can use the filter <code>get_avatar</code> for get all data to the avatar, also the url inside the markup. I t... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14411/"
] | I'm using a plugin called [Simple Local Avatars](http://wordpress.org/extend/plugins/simple-local-avatars) which lets me upload author images which are stored on my server locally (no Gravatar). The plugin works fine and `get_avatar` returns the local avatar.
However, I need to use that avatar in different ways and di... | Good news for WordPress versions 4.2+
-------------------------------------
Since version 4.2 the handy `get_avatar_url()` function, introduced as a *feature request* in ticket [#21195](https://core.trac.wordpress.org/ticket/21195) few years ago, [now ships with the core](https://github.com/WordPress/WordPress/blob/4.... |
59,446 | <p>I know qTranslate has the option to hide untranslated content, but that doesn't seem to work. I.e: I have a website with three languages: Dutch, French and English. There is one particular page that has some subpages that are only available in Dutch. I want them to show up on the Dutch website, but hide them complet... | [
{
"answer_id": 59475,
"author": "Matthias",
"author_id": 18470,
"author_profile": "https://wordpress.stackexchange.com/users/18470",
"pm_score": 1,
"selected": true,
"text": "<p>Little hack in my submenu code:</p>\n\n<pre><code>function hierarchical_submenu($post) {\n $top_post = $pos... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59446",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18470/"
] | I know qTranslate has the option to hide untranslated content, but that doesn't seem to work. I.e: I have a website with three languages: Dutch, French and English. There is one particular page that has some subpages that are only available in Dutch. I want them to show up on the Dutch website, but hide them completely... | Little hack in my submenu code:
```
function hierarchical_submenu($post) {
$top_post = $post;
// If the post has ancestors, get its ultimate parent and make that the top post
if ($post->post_parent && $post->ancestors) {
$top_post = get_post(end($post->ancestors));
}
// Always start travers... |
59,449 | <p>When going through your own plugin details and checking the active version downloads. It's helpful to see which version that webmasters prefer, but I see no details on the subject on WordPress (and on here, yet). I recently had an unexpected change in stats, and I can't find anything as to what the time frame is. Wh... | [
{
"answer_id": 59475,
"author": "Matthias",
"author_id": 18470,
"author_profile": "https://wordpress.stackexchange.com/users/18470",
"pm_score": 1,
"selected": true,
"text": "<p>Little hack in my submenu code:</p>\n\n<pre><code>function hierarchical_submenu($post) {\n $top_post = $pos... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59449",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16045/"
] | When going through your own plugin details and checking the active version downloads. It's helpful to see which version that webmasters prefer, but I see no details on the subject on WordPress (and on here, yet). I recently had an unexpected change in stats, and I can't find anything as to what the time frame is. What ... | Little hack in my submenu code:
```
function hierarchical_submenu($post) {
$top_post = $post;
// If the post has ancestors, get its ultimate parent and make that the top post
if ($post->post_parent && $post->ancestors) {
$top_post = get_post(end($post->ancestors));
}
// Always start travers... |
59,476 | <p>I'm trying to get category ID of the current archive displayed.</p>
<p>I tried:</p>
<pre><code>// category (can be a parent category)
$current_cat_ID = get_query_var('cat');
//
print_r ($current_cat_ID);
</code></pre>
<p>It doesn't print anything...</p>
| [
{
"answer_id": 59483,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 7,
"selected": true,
"text": "<p>you can use <a href=\"http://codex.wordpress.org/Function_Reference/get_queried_object\"><code>get_queried_object()<... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm trying to get category ID of the current archive displayed.
I tried:
```
// category (can be a parent category)
$current_cat_ID = get_query_var('cat');
//
print_r ($current_cat_ID);
```
It doesn't print anything... | you can use [`get_queried_object()`](http://codex.wordpress.org/Function_Reference/get_queried_object)
```
$category = get_queried_object();
echo $category->term_id;
``` |
59,485 | <p>Is there some documentation somewhere that explains what is the life cycle of the plugins?</p>
<p>I'm starting a new plugin with OOP style, and I just found out that my main class is being instanciated <strong>a lot</strong> (thanks to Xdebug and Netbeans).<br>
I wonder why, and it annoys me because I'm instanciati... | [
{
"answer_id": 92139,
"author": "Arevico",
"author_id": 11487,
"author_profile": "https://wordpress.stackexchange.com/users/11487",
"pm_score": 0,
"selected": false,
"text": "<p>What might happen is that you pass a copy of you class to a filter or action. For example, if you want to dire... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18474/"
] | Is there some documentation somewhere that explains what is the life cycle of the plugins?
I'm starting a new plugin with OOP style, and I just found out that my main class is being instanciated **a lot** (thanks to Xdebug and Netbeans).
I wonder why, and it annoys me because I'm instanciating a Dropbox-API object,... | >
> I'm starting a new plugin with OOP style
>
>
>
What does 'OOP style' means for you? Wrapping all your functions with a class statement? Then you doing it wrong. You missuse the class as namespace.
>
> and I just found out that my main class is being instanciated a lot
>
>
>
Huh?
```
class Foo
{
publi... |
59,486 | <p>this code is designed to select posts with selected meta value in wordpress query</p>
<pre><code><?php $values = $wpdb->get_results("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'wpcf-scr'",ARRAY_A);?>
<select name="wpcf-scr">
<option value="">default</option>
<... | [
{
"answer_id": 92139,
"author": "Arevico",
"author_id": 11487,
"author_profile": "https://wordpress.stackexchange.com/users/11487",
"pm_score": 0,
"selected": false,
"text": "<p>What might happen is that you pass a copy of you class to a filter or action. For example, if you want to dire... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59486",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16505/"
] | this code is designed to select posts with selected meta value in wordpress query
```
<?php $values = $wpdb->get_results("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'wpcf-scr'",ARRAY_A);?>
<select name="wpcf-scr">
<option value="">default</option>
<?php foreach ($values as $value):?>
<?php if($v... | >
> I'm starting a new plugin with OOP style
>
>
>
What does 'OOP style' means for you? Wrapping all your functions with a class statement? Then you doing it wrong. You missuse the class as namespace.
>
> and I just found out that my main class is being instanciated a lot
>
>
>
Huh?
```
class Foo
{
publi... |
59,489 | <p><a href="http://www.101greatgoals.com/picture-gallery/" rel="nofollow">I have this page where I am showing all post's attachments.</a></p>
<p>This is the code:</p>
<pre><code><?php
$args = array(
'post_type' => 'attachment',
'post_status' => 'published',
'posts_per_page' =>25,
'post_par... | [
{
"answer_id": 59600,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$posts = get_posts( array( 'post_type' => 'post', 'posts_per_page' => -1 ) );\n\n foreach ( $pos... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17707/"
] | [I have this page where I am showing all post's attachments.](http://www.101greatgoals.com/picture-gallery/)
This is the code:
```
<?php
$args = array(
'post_type' => 'attachment',
'post_status' => 'published',
'posts_per_page' =>25,
'post_parent' => null, // Post-> ID;
'numberposts' => null,
);
... | ```
$posts = get_posts( array( 'post_type' => 'post', 'posts_per_page' => -1 ) );
foreach ( $posts as $post ) {
$attachments = get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_per_pag... |
59,490 | <p>I am trying to figure out how to use jQuery <code>$.ajax()</code> for a project. I setup this test using what I learned from <a href="http://wp.tutsplus.com/articles/getting-started-with-ajax-wordpress-pagination/" rel="nofollow">TutsPlus.com</a>. Everything seems to be working correctly except I am getting a <code>... | [
{
"answer_id": 59491,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>1st) Add another dependency: <code>array( 'json2', 'jquery' );</code>.</p>\n\n<p>2nd) Dig into <a href=\"/questions... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59490",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14190/"
] | I am trying to figure out how to use jQuery `$.ajax()` for a project. I setup this test using what I learned from [TutsPlus.com](http://wp.tutsplus.com/articles/getting-started-with-ajax-wordpress-pagination/). Everything seems to be working correctly except I am getting a `-1` returned. So I get an alert with `Success... | 1st) Add another dependency: `array( 'json2', 'jquery' );`.
2nd) Dig into [wp-localize-script](/questions/tagged/wp-localize-script "show questions tagged 'wp-localize-script'") and read about [`wp-localize-script()`](http://codex.wordpress.org/Function_Reference/wp_localize_script) in Codex. It allows you to send dat... |
59,492 | <p><strong>I am able to add a post featured image to the RSS feed like so:</strong></p>
<pre><code>function insertThumbnailRSS($content) {
global $post;
if(has_post_thumbnail($post->ID)){
$content = ''.get_the_post_thumbnail($post->ID, 'thumbnail', array('alt' => get_the_title(), 'title' =>... | [
{
"answer_id": 60189,
"author": "codekipple",
"author_id": 14557,
"author_profile": "https://wordpress.stackexchange.com/users/14557",
"pm_score": 5,
"selected": true,
"text": "<p>You could do it by adding an action to the hook 'rss2_item' like so:</p>\n\n<pre><code>add_action('rss2_item... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9579/"
] | **I am able to add a post featured image to the RSS feed like so:**
```
function insertThumbnailRSS($content) {
global $post;
if(has_post_thumbnail($post->ID)){
$content = ''.get_the_post_thumbnail($post->ID, 'thumbnail', array('alt' => get_the_title(), 'title' => get_the_title(), 'style' => 'float:rig... | You could do it by adding an action to the hook 'rss2\_item' like so:
```
add_action('rss2_item', function(){
global $post;
$output = '';
$thumbnail_ID = get_post_thumbnail_id( $post->ID );
$thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'thumbnail');
$output .= '<post-thumbnail>';
$output .= '<... |
59,507 | <p>When I create a custom field and associate it to a custom page template, it doesn't show in the post editor screen until I click save (draft / publish). </p>
<p>Ideally, the custom field should show when I select the page template from the dropdown, without having to save anything. Can anyone suggest how I would ac... | [
{
"answer_id": 60189,
"author": "codekipple",
"author_id": 14557,
"author_profile": "https://wordpress.stackexchange.com/users/14557",
"pm_score": 5,
"selected": true,
"text": "<p>You could do it by adding an action to the hook 'rss2_item' like so:</p>\n\n<pre><code>add_action('rss2_item... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18487/"
] | When I create a custom field and associate it to a custom page template, it doesn't show in the post editor screen until I click save (draft / publish).
Ideally, the custom field should show when I select the page template from the dropdown, without having to save anything. Can anyone suggest how I would achieve this... | You could do it by adding an action to the hook 'rss2\_item' like so:
```
add_action('rss2_item', function(){
global $post;
$output = '';
$thumbnail_ID = get_post_thumbnail_id( $post->ID );
$thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'thumbnail');
$output .= '<post-thumbnail>';
$output .= '<... |
59,508 | <p>How can i get "post id" in post edit area for add_filter in functions.php?</p>
<p>I want to change file name automatically during upload. so i need to obtain post id.</p>
<p>the code is as follows:</p>
<pre><code>add_filter( 'wp_handle_upload_prefilter', 'custom_upload_name' );
function custom_upload_name($fil... | [
{
"answer_id": 59509,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 0,
"selected": false,
"text": "<p>Did you tried using global $post object?</p>\n\n<pre><code>add_filter( 'wp_handle_upload_prefilter', 'custom_uploa... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59508",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18488/"
] | How can i get "post id" in post edit area for add\_filter in functions.php?
I want to change file name automatically during upload. so i need to obtain post id.
the code is as follows:
```
add_filter( 'wp_handle_upload_prefilter', 'custom_upload_name' );
function custom_upload_name($file)
{
list($name, $... | Try using $\_POST['post\_id'] in the upload area as file.php does not include the global $post object. |
59,514 | <p><a href="http://css-tricks.com/video-screencasts/" rel="nofollow">http://css-tricks.com/video-screencasts/</a></p>
<p>Try to look at this famous site which also powered by wordpress. The content in the loop is different from the single post. It use "dl" element in loop, but not main content in the single post. It s... | [
{
"answer_id": 59515,
"author": "lupor",
"author_id": 18491,
"author_profile": "https://wordpress.stackexchange.com/users/18491",
"pm_score": 2,
"selected": true,
"text": "<p>you can add additional information to your posts through using post meta:</p>\n\n<p><a href=\"http://wp.tutsplus.... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59514",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18490/"
] | <http://css-tricks.com/video-screencasts/>
Try to look at this famous site which also powered by wordpress. The content in the loop is different from the single post. It use "dl" element in loop, but not main content in the single post. It something like it has a another brief summary of a post that will only display ... | you can add additional information to your posts through using post meta:
<http://wp.tutsplus.com/tutorials/plugins/how-to-create-custom-wordpress-writemeta-boxes/>
If you want to check if Wordpress is going to display just a single post/single page or more, you could use something like this before your loop:
```
$s... |
59,531 | <p>For a custom post type, I'm pulling in a list of another custom post types that I need to select for saving ...</p>
<pre><code><input type="checkbox" name="32"> My CPT <br>
<input type="checkbox" name="41"> My CPT 2 <br>
<input type="checkbox" name="42"> My CPT 3 <br>
<input t... | [
{
"answer_id": 59534,
"author": "Cristian",
"author_id": 2264,
"author_profile": "https://wordpress.stackexchange.com/users/2264",
"pm_score": 3,
"selected": true,
"text": "<p>You will need to save them as an array and currently your HTML is not in the correct format to do this.</p>\n\n<... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9295/"
] | For a custom post type, I'm pulling in a list of another custom post types that I need to select for saving ...
```
<input type="checkbox" name="32"> My CPT <br>
<input type="checkbox" name="41"> My CPT 2 <br>
<input type="checkbox" name="42"> My CPT 3 <br>
<input type="checkbox" name="43"> My CPT 4
```
It's easy en... | You will need to save them as an array and currently your HTML is not in the correct format to do this.
```
<label for="my-cpt-32">
<input type="checkbox" name="cpt_ids[]" value="32" id="my-cpt-32" />
My CPT #32
</label>
<label for="my-cpt-41">
<input type="checkbox" name="cpt_ids[]" value="41" id="my-cpt-... |
59,536 | <p>I uploaded to a WordPress site (3.3.1) a plugin that works perfectly in my other sites (3.3.1 and 3.4), but when try to activate it I get Fatal Error. When I go to check the plugin's main file content to do some changes and identify the error I detect that at the end of my code appears some random code from my file ... | [
{
"answer_id": 60082,
"author": "jackson5",
"author_id": 18684,
"author_profile": "https://wordpress.stackexchange.com/users/18684",
"pm_score": 1,
"selected": false,
"text": "<p>looks like a UTF-8 vs ASCII issue, try resaving the file as UTF-8 and uploading via FTP.</p>\n"
},
{
... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12669/"
] | I uploaded to a WordPress site (3.3.1) a plugin that works perfectly in my other sites (3.3.1 and 3.4), but when try to activate it I get Fatal Error. When I go to check the plugin's main file content to do some changes and identify the error I detect that at the end of my code appears some random code from my file rep... | Check if you have a class or function with many `echo`'s, that are called on the functions `register_activation_hook` or `register_deactivation_hook`.
Also - this functions must use static functions.
Also, is it possible that you have a `var_dump()` inside your source?
It is important that you not have an output (lik... |
59,539 | <p>I am using this as my starter template: <a href="http://html5reset.org/" rel="nofollow">www.html5reset.org/</a></p>
<p>It's pretty nice, but I believe something is wrong with jQuery in there.</p>
<p>In the <code>functions.php</code> it says:</p>
<pre><code>// Load jQuery
if ( !function_exists(core_mods) ) {
... | [
{
"answer_id": 59540,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 3,
"selected": false,
"text": "<p>There's a typo in <code>wp_register_script()</code> where \"http:\" is missing in the URL. Fix that and you'll at... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12580/"
] | I am using this as my starter template: [www.html5reset.org/](http://html5reset.org/)
It's pretty nice, but I believe something is wrong with jQuery in there.
In the `functions.php` it says:
```
// Load jQuery
if ( !function_exists(core_mods) ) {
function core_mods() {
if ( !is_admin() ) {
... | just to help a bit further ... WordPress runs jQuery in 'safe' mode
which means in WordPress you need to write code like this
`jQuery(document).ready(function() {`
and not like this
`$(document).ready(function() {`
But what the HTML5BP has done is added this funky bit of code (probably kindly to help Developers... |
59,541 | <p>I have been beating my head against this for a couple of hours now and can't seem to figure it out. I am trying to enqueue a script into my page with the following code in my functions.php.</p>
<pre><code>function my_slider_scripts() {
$scriptsrc = get_stylesheet_directory_uri().'/js/jquery.nivo.slider.pack.js';
wp... | [
{
"answer_id": 59543,
"author": "nvwd",
"author_id": 18496,
"author_profile": "https://wordpress.stackexchange.com/users/18496",
"pm_score": 2,
"selected": false,
"text": "<p>try <code>add_action('wp_enqueue_scripts', 'my_slider_scripts')</code></p>\n\n<p>the hook doesn't have a dash. It... | 2012/07/24 | [
"https://wordpress.stackexchange.com/questions/59541",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18501/"
] | I have been beating my head against this for a couple of hours now and can't seem to figure it out. I am trying to enqueue a script into my page with the following code in my functions.php.
```
function my_slider_scripts() {
$scriptsrc = get_stylesheet_directory_uri().'/js/jquery.nivo.slider.pack.js';
wp_register_scri... | try `add_action('wp_enqueue_scripts', 'my_slider_scripts')`
the hook doesn't have a dash. It's an underscore. |
59,574 | <p>In my plugin I have a custom post type with a slug of 'ready-to-wear' and I have a custom taxonomy called 'seasons' associated with it.</p>
<p>The odd thing is that this url with query works:</p>
<p><code>http://dev.catwalkyourself.com/ready-to-wear/?seasons=autumn-winter-2012-2013-en</code></p>
<p>but the same o... | [
{
"answer_id": 60899,
"author": "Amit Erandole",
"author_id": 3361,
"author_profile": "https://wordpress.stackexchange.com/users/3361",
"pm_score": 3,
"selected": true,
"text": "<p>I solved this issue by making sure that the calls to register my taxonomies were placed before the calls to... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59574",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3361/"
] | In my plugin I have a custom post type with a slug of 'ready-to-wear' and I have a custom taxonomy called 'seasons' associated with it.
The odd thing is that this url with query works:
`http://dev.catwalkyourself.com/ready-to-wear/?seasons=autumn-winter-2012-2013-en`
but the same one with custom permalink doesn't:
... | I solved this issue by making sure that the calls to register my taxonomies were placed before the calls to registering my custom post types. Weird but it works! |
59,575 | <p>I've only ever used wordpress as a self-hosted blogging platform - until now. I have a requirement to use it for a very basic CMS which will consist of ~ 10 pages, most of which will be static content, updated periodically. I'm going to need to ability to upload documents, embed images, edit copy using the text edit... | [
{
"answer_id": 59576,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>If I understood correctly, you want to have different layouts for different pages. You can achieve this either by ... | 2010/08/03 | [
"https://wordpress.stackexchange.com/questions/59575",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119/"
] | I've only ever used wordpress as a self-hosted blogging platform - until now. I have a requirement to use it for a very basic CMS which will consist of ~ 10 pages, most of which will be static content, updated periodically. I'm going to need to ability to upload documents, embed images, edit copy using the text editor ... | As tnorthcutt mentioned, you may want to use [custom post types](http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes-using-custom-post-types/). However, you should also take a look at [custom fields](http://codex.wordpress.org/Custom_Fields), which will allow you to specify bits of dynamic custo... |
59,581 | <p>I met some trouble. I tried to get user display_name in a custom mysql query foreach, but it failed. I have tried three method. <code>new WP_User</code>, <code>get_user_by</code> and <code>get_userdata</code>. but they only can get back the result <code>$user->display_name</code> which is ID=1 in table <code>wp_u... | [
{
"answer_id": 59750,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 3,
"selected": true,
"text": "<p>You should use all of the goodness of the wpdb object.</p>\n\n<pre><code>#Create a new WPDB object for your ... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59581",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5988/"
] | I met some trouble. I tried to get user display\_name in a custom mysql query foreach, but it failed. I have tried three method. `new WP_User`, `get_user_by` and `get_userdata`. but they only can get back the result `$user->display_name` which is ID=1 in table `wp_users`(admin). failed get any `$user->display_name` whi... | You should use all of the goodness of the wpdb object.
```
#Create a new WPDB object for your custom DB
$foo_db = new wpdb('username','password','database','localhost');
$query = ('SELECT * FROM custom_table');
#Use the get_results method - You can return OBJECT(default), OBJECT_K, ARRAY_A, ARRAY_N
$results = $foo_db... |
59,585 | <p>This is my example code placed in functions.php:</p>
<pre><code>function my_init_method() {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core', false, array('jquery'), false, false);
wp_enqueue_script('jquery-ui-widget', false, array('jquery'), false, false);
wp_enqueue_script('jquery-u... | [
{
"answer_id": 59595,
"author": "valscion",
"author_id": 14095,
"author_profile": "https://wordpress.stackexchange.com/users/14095",
"pm_score": 0,
"selected": false,
"text": "<p>As others have pointed out, you need to hook into <code>wp_enqueue_scripts</code>. You also need to enqueue t... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | This is my example code placed in functions.php:
```
function my_init_method() {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core', false, array('jquery'), false, false);
wp_enqueue_script('jquery-ui-widget', false, array('jquery'), false, false);
wp_enqueue_script('jquery-ui-mouse', fals... | All of these scripts are already registered to print in the footer. See `wp-includes/script-loader.php` for details. When you try to register the scripts again WordPress doesn’t change that.
The workaround would be to register a new script for `wp_head` with those scripts as dependencies (the third parameter of `wp_en... |
59,589 | <p>I have recently started to learn WordPress and after learning how to use it at basic level I immediately started to learn how to develop templates since this is what interested me from the start when I started to learn it.</p>
<p>I am reading <a href="http://rads.stackoverflow.com/amzn/click/1849514100" rel="nofoll... | [
{
"answer_id": 59591,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>You have to make sure WordPress finds the directory where your theme is. There is a useful function doing all the work ... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59589",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14752/"
] | I have recently started to learn WordPress and after learning how to use it at basic level I immediately started to learn how to develop templates since this is what interested me from the start when I started to learn it.
I am reading [WordPress 3 Complete](http://rads.stackoverflow.com/amzn/click/1849514100) and at ... | You have to make sure WordPress finds the directory where your theme is. There is a useful function doing all the work for you: [`bloginfo()`](http://codex.wordpress.org/Function_Reference/bloginfo).
```
<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
``` |
59,593 | <p>I want to check if post meta key exists or not, out side of the loop. Is there any WordPress function to check if post meta key exist or not in WordPress database. I have to check this outside the loop. Any help will be highly appreciated.</p>
| [
{
"answer_id": 59598,
"author": "Davs Howard",
"author_id": 16569,
"author_profile": "https://wordpress.stackexchange.com/users/16569",
"pm_score": 2,
"selected": false,
"text": "<p>You could use get_post_custom(POST ID GOES HERE) which will return a multidimensional array with all custo... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16965/"
] | I want to check if post meta key exists or not, out side of the loop. Is there any WordPress function to check if post meta key exist or not in WordPress database. I have to check this outside the loop. Any help will be highly appreciated. | In case anyone else stumbles across this old question like I just did, it looks like the best way to handle this is using `metadata_exists()`
see <https://developer.wordpress.org/reference/functions/metadata_exists/>
Here's what the syntax would be for post meta:
```
metadata_exists('post', $post_id, 'meta_key_to_ch... |
59,605 | <p>I have a custom post type called <code>transaction</code>, and on the post type's edit/publish screen I have removed the post title field. The post title is now being generated by the function below, which labels each post <code>Transaction</code> followed by a unique string, thanks to the <code>uniqid</code> PHP fu... | [
{
"answer_id": 59618,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried using <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data\" re... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59605",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I have a custom post type called `transaction`, and on the post type's edit/publish screen I have removed the post title field. The post title is now being generated by the function below, which labels each post `Transaction` followed by a unique string, thanks to the `uniqid` PHP function.
I'm running this function ... | ```
function transaction_title( $title )
{
if ( 'transaction' == get_current_screen()->post_type && '' == $title )
{
return 'Transaction '.uniqid();
}
// else return the normal title
else
{
return $title;
}
}
add_filter( 'title_save_pre', 'transaction_title' );
``` |
59,611 | <p>I wrote a custom AJAX function in which I have assigned a post type to be a child of another post type. In one function I am looping through those child posts, and I want to update the database to reflect the post_parent(the post which the child posts belong to). </p>
<p>Problem is, I cannot grab that post's ID fro... | [
{
"answer_id": 59616,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p>The ajax hook won't pass back a <code>$post</code> object to your callback - how on earth would it know to ... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18520/"
] | I wrote a custom AJAX function in which I have assigned a post type to be a child of another post type. In one function I am looping through those child posts, and I want to update the database to reflect the post\_parent(the post which the child posts belong to).
Problem is, I cannot grab that post's ID from anywher... | Its an old question however would like to answer for other people
Within ajax function hooked to wp\_ajax do this.
```
$url = wp_get_referer();
$post_id = url_to_postid( $url );
``` |
59,615 | <p>I am trying to create a modular plugin that includes action hooks for developers to add content before and after the main shortcode content. I'm having some trouble because anything I do in the function called by the action hook is always echoed out at the top of the shortcode instead of inside the shortcode where i... | [
{
"answer_id": 59619,
"author": "KalenGi",
"author_id": 657,
"author_profile": "https://wordpress.stackexchange.com/users/657",
"pm_score": 4,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>function example_shortcode( $atts ) {\n\n $shortcode_output = \"<p>Some shortc... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/799/"
] | I am trying to create a modular plugin that includes action hooks for developers to add content before and after the main shortcode content. I'm having some trouble because anything I do in the function called by the action hook is always echoed out at the top of the shortcode instead of inside the shortcode where it b... | Try this:
```
function example_shortcode( $atts ) {
$shortcode_output = "<p>Some shortcode content.</p>";
$shortcode_output .= "<p>More shortcode content.</p>";
ob_start();
do_action('below_shortcode');
$below_shortcode = ob_get_contents();
ob_end_clean();
$shortcode_output .= $b... |
59,617 | <p>How can I modify my query in order to exclude certain posts by slug?
Is it possible?</p>
<pre><code>query_posts(array('category_name' => 'Mycat', 'posts_per_page' => -1));
</code></pre>
<p>Ty</p>
| [
{
"answer_id": 59620,
"author": "Dalton Rooney",
"author_id": 799,
"author_profile": "https://wordpress.stackexchange.com/users/799",
"pm_score": 3,
"selected": true,
"text": "<p>You can get the post ID from the slug with the <a href=\"http://codex.wordpress.org/Function_Reference/url_to... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2979/"
] | How can I modify my query in order to exclude certain posts by slug?
Is it possible?
```
query_posts(array('category_name' => 'Mycat', 'posts_per_page' => -1));
```
Ty | You can get the post ID from the slug with the [`url_to_postid()`](http://codex.wordpress.org/Function_Reference/url_to_postid) function:
```
$ID = url_to_postid(slug);
```
then just exclude the ID from your query:
```
query_posts(array('category_name' => 'Mycat', 'posts_per_page' => -1, 'post__not_in' => $ID ));
... |
59,622 | <p>I have a blog which has three top level categories. Each top level category has a list of sub categories. I am displaying only certain top level category posts in certain sections of the website. </p>
<p>When viewing the post I want to display something like:
Posted under Cards, Races, Lifestyle</p>
<p>These thre... | [
{
"answer_id": 59620,
"author": "Dalton Rooney",
"author_id": 799,
"author_profile": "https://wordpress.stackexchange.com/users/799",
"pm_score": 3,
"selected": true,
"text": "<p>You can get the post ID from the slug with the <a href=\"http://codex.wordpress.org/Function_Reference/url_to... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18524/"
] | I have a blog which has three top level categories. Each top level category has a list of sub categories. I am displaying only certain top level category posts in certain sections of the website.
When viewing the post I want to display something like:
Posted under Cards, Races, Lifestyle
These three categories woul... | You can get the post ID from the slug with the [`url_to_postid()`](http://codex.wordpress.org/Function_Reference/url_to_postid) function:
```
$ID = url_to_postid(slug);
```
then just exclude the ID from your query:
```
query_posts(array('category_name' => 'Mycat', 'posts_per_page' => -1, 'post__not_in' => $ID ));
... |
59,649 | <p>I have a hook into the WordPress Add New User process via an <code>add_action('user_register', 'doMyFunction');</code> hook.</p>
<p>What results is that I am (Step 1) adding a new user through WordPress and then (Step 2) having to add the same user to BuddyPress in order to get the user fully activated in WP/BP wit... | [
{
"answer_id": 59659,
"author": "KalenGi",
"author_id": 657,
"author_profile": "https://wordpress.stackexchange.com/users/657",
"pm_score": 2,
"selected": false,
"text": "<p>In order to get the user id when a user is registered, hook into <code>bp_core_signup_user</code>:</p>\n\n<pre><co... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17532/"
] | I have a hook into the WordPress Add New User process via an `add_action('user_register', 'doMyFunction');` hook.
What results is that I am (Step 1) adding a new user through WordPress and then (Step 2) having to add the same user to BuddyPress in order to get the user fully activated in WP/BP with the proper role.
I... | In order to get the user id when a user is registered, hook into `bp_core_signup_user`:
```
add_action('bp_core_signup_user', 'doMyFunction', 10, 5);
function doMyFunction($user_id, $user_login, $user_password, $user_email, $usermeta){
//do stuff
}
```
It supplies the user id as the first parameter. |
59,652 | <p>I'd like to prevent the "Featured" category from appearing for certain user roles. To be specific, I want only the admins and editors to be able to see and thus select or unselect that category. Everybody else can see the whole tree but the Featured cat. </p>
<p>Which hooks and WP API do I need to tap into in writi... | [
{
"answer_id": 59705,
"author": "Joshua Abenazer",
"author_id": 10251,
"author_profile": "https://wordpress.stackexchange.com/users/10251",
"pm_score": 0,
"selected": false,
"text": "<p>You could check out this plugin. It does exactly the same thing -> <a href=\"http://wordpress.org/exte... | 2012/07/25 | [
"https://wordpress.stackexchange.com/questions/59652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | I'd like to prevent the "Featured" category from appearing for certain user roles. To be specific, I want only the admins and editors to be able to see and thus select or unselect that category. Everybody else can see the whole tree but the Featured cat.
Which hooks and WP API do I need to tap into in writing the nec... | Based on the [first Answer](https://wordpress.stackexchange.com/posts/761/revisions) from Mike Schinkel. For testing purposes in a default installation, the category is "Uncategorized".
```
add_filter( 'list_terms_exclusions', 'wpse_59652_list_terms_exclusions', 10, 2 );
function wpse_59652_list_terms_exclusions( $ex... |
59,730 | <p>I am currently using <a href="http://wptheming.com" rel="nofollow">Options Framework Theme</a> for making WordPress options panel. I created a checkbox in admin panel by this code in <code>options.php</code> </p>
<pre><code>$options[] = array(
'name' => __('Input Checkbox Name', 'options_framework_theme'),
'desc... | [
{
"answer_id": 59752,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>'true' should be '1':</p>\n\n<pre><code>$options[] = array(\n 'name' => __('Input Checkbox Name', 'options_fr... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59730",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14495/"
] | I am currently using [Options Framework Theme](http://wptheming.com) for making WordPress options panel. I created a checkbox in admin panel by this code in `options.php`
```
$options[] = array(
'name' => __('Input Checkbox Name', 'options_framework_theme'),
'desc' => __('Check to display.'),
'id' => 'example_checkbo... | 'true' should be '1':
```
$options[] = array(
'name' => __('Input Checkbox Name', 'options_framework_theme'),
'desc' => __('Check to display.'),
'id' => 'example_checkbox_2',
'std' => '1',
'type' => 'checkbox'
);
```
and:
```
<?php if ( 1 == of_get_option('example_checkbox2') ) { ?>
<p>c... |
59,735 | <p>I would like to remove the [...] from the RSS feed widget.</p>
<p>I have tried adding the following to functions:</p>
<pre><code>function replace_ellipsis($text) {
$return = str_replace('[...]', '-', $text);
return $return;
}
add_filter('get_the_excerpt', 'replace_ellipsis');
</code></pre>
<p>However, this does... | [
{
"answer_id": 238800,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>The body of the <a href=\"https://github.com/WordPress/WordPress/blob/master/wp-includes/widgets/class-wp-widget... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59735",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18577/"
] | I would like to remove the [...] from the RSS feed widget.
I have tried adding the following to functions:
```
function replace_ellipsis($text) {
$return = str_replace('[...]', '-', $text);
return $return;
}
add_filter('get_the_excerpt', 'replace_ellipsis');
```
However, this does not affect the widget.
Any help... | The body of the [default RSS widget](https://github.com/WordPress/WordPress/blob/master/wp-includes/widgets/class-wp-widget-rss.php) is generated by the function [`wp_widget_rss_output`](https://developer.wordpress.org/reference/functions/wp_widget_rss_output/). As you can see in the source, the `[...]` is hardwired in... |
59,751 | <p>Ok, so I want to embed youtube videos but also remove the annoying annotations. The following code works great from to embed the video</p>
<pre><code>[embed width="599" height="360"]youtube.com/watch?v=mNf0v2WkV0U [/embed]
</code></pre>
<p>But whatever I seem to do, I cannot add the following parameter:</p>
<bloc... | [
{
"answer_id": 238800,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>The body of the <a href=\"https://github.com/WordPress/WordPress/blob/master/wp-includes/widgets/class-wp-widget... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17965/"
] | Ok, so I want to embed youtube videos but also remove the annoying annotations. The following code works great from to embed the video
```
[embed width="599" height="360"]youtube.com/watch?v=mNf0v2WkV0U [/embed]
```
But whatever I seem to do, I cannot add the following parameter:
>
>
> ```
> iv_load_policy=3
>
>... | The body of the [default RSS widget](https://github.com/WordPress/WordPress/blob/master/wp-includes/widgets/class-wp-widget-rss.php) is generated by the function [`wp_widget_rss_output`](https://developer.wordpress.org/reference/functions/wp_widget_rss_output/). As you can see in the source, the `[...]` is hardwired in... |
59,760 | <p>I want to create a user account on my multi-site installation of Wordpress with a username less than 4 characters. But since Wordpress has a limit of usernames at least being 4 characters, this error message is shown:</p>
<blockquote>
<p>Username must be at least 4 characters.</p>
</blockquote>
<p>I found a solu... | [
{
"answer_id": 59771,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You can filter <code>'wpmu_validate_user_signup'</code> and check if the error code matches the 4 character warning. Th... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10572/"
] | I want to create a user account on my multi-site installation of Wordpress with a username less than 4 characters. But since Wordpress has a limit of usernames at least being 4 characters, this error message is shown:
>
> Username must be at least 4 characters.
>
>
>
I found a solution involving a mu-plugins fold... | You can filter `'wpmu_validate_user_signup'` and check if the error code matches the 4 character warning. Then just unset the error code.
Sample plugin:
```
<?php # -*- coding: utf-8 -*-
/* Plugin Name: Allow short user names for multi site. */
add_filter( 'wpmu_validate_user_signup', 'wpse_59760_short_user_names' )... |
59,763 | <p>I am using WordPress 3.4.1 on Ubuntu 12.04 using Apache and PHP 5.3.X</p>
<p>When I login to the dashboard and add a new post. Then try uploading an image to set as a featured image, I get a red box with a message "HTTP Error".</p>
<p>I have read about people saying to not use the flash uploader and just use the b... | [
{
"answer_id": 59777,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 6,
"selected": true,
"text": "<p>After troubleshooting with @Wyck in chat, we have narrowed to the underlying issue.</p>\n\n<p>The issue w... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59763",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9579/"
] | I am using WordPress 3.4.1 on Ubuntu 12.04 using Apache and PHP 5.3.X
When I login to the dashboard and add a new post. Then try uploading an image to set as a featured image, I get a red box with a message "HTTP Error".
I have read about people saying to not use the flash uploader and just use the browser uploader, ... | After troubleshooting with @Wyck in chat, we have narrowed to the underlying issue.
The issue was related to my **server configuration** not having the proper amount of memory allocated to Apache/PHP.
If anyone has this same problem, please try verifying that you have enough (64 MB+) server memory allocated to Apache... |
59,767 | <p>I've found several similar question but none of them explains why the below is giving me nothing with ASC order. It works with DESC.</p>
<p>Basically it's a query that should list posts where the custom field values are equal or greater to the current date, then arrange it in reversed order, so the first post shoul... | [
{
"answer_id": 59776,
"author": "elbatron",
"author_id": 6768,
"author_profile": "https://wordpress.stackexchange.com/users/6768",
"pm_score": 4,
"selected": true,
"text": "<p>With some more googling:</p>\n\n<pre><code><?php\n$today = date(\"Y/m/j\");\nquery_posts(array(\n'post_type' ... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6768/"
] | I've found several similar question but none of them explains why the below is giving me nothing with ASC order. It works with DESC.
Basically it's a query that should list posts where the custom field values are equal or greater to the current date, then arrange it in reversed order, so the first post should be a pos... | With some more googling:
```
<?php
$today = date("Y/m/j");
query_posts(array(
'post_type' => 'custompost',
'posts_per_page' => 4,
'meta_key' => 'mydate',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'mydate',
'meta-value' => $value,
'v... |
59,772 | <p>When I enter content in posts/pages' WYSIWYG editor, I do not get <code><p></code> when ending paragraphs, just <code>&nbsp</code>s. If I manually place <code><p></p></code> in the HTML mode, they are stripped as soon as I switch to 'visual' mode.
This is repeated in several sites (I thought i... | [
{
"answer_id": 59780,
"author": "Androliyah",
"author_id": 17636,
"author_profile": "https://wordpress.stackexchange.com/users/17636",
"pm_score": 1,
"selected": false,
"text": "<p>You can try the CKEditor</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/ckeditor-for-wordpress/\" ... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12762/"
] | When I enter content in posts/pages' WYSIWYG editor, I do not get `<p>` when ending paragraphs, just ` `s. If I manually place `<p></p>` in the HTML mode, they are stripped as soon as I switch to 'visual' mode.
This is repeated in several sites (I thought it was the theme but it isn't).
I have read dozens of topic... | I have done extended research and found the answer - I am now using a hook on 'tiny\_mce\_before\_init'.
Based on [other answers](https://wordpress.stackexchange.com/a/15666/12762) (special thanks to answer #2 [@Chip Bennett](https://wordpress.stackexchange.com/users/3966/chip-bennett)), I have used the following code... |
59,779 | <p>On one of my templates I have an action hook 'do_xyz'</p>
<p>I want to attach a custom sidebar to the action hook do_xyz</p>
<p>Here is what I am trying in my theme functions.php file, does not work:</p>
<pre><code>add_action('do_xyz', 'get_sidebar('secondary')' );
</code></pre>
<p>What is the proper way of doin... | [
{
"answer_id": 59789,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": true,
"text": "<h2>Explanation</h2>\n\n<p>There's the global array <code>$wp_filters</code>. This array stores some sub arrays. One fo... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59779",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18595/"
] | On one of my templates I have an action hook 'do\_xyz'
I want to attach a custom sidebar to the action hook do\_xyz
Here is what I am trying in my theme functions.php file, does not work:
```
add_action('do_xyz', 'get_sidebar('secondary')' );
```
What is the proper way of doing this?
I know my hooks are setup rig... | Explanation
-----------
There's the global array `$wp_filters`. This array stores some sub arrays. One for each `priority`. Each sub array then contains an array for each callback added. And the keys for those sub-sub arrays are the attached functions.
### Example
If you do the following, somewhere in your code (pre... |
59,786 | <p>Trying this in my functions file. There is actually a lot more to this function than I am showing, but this is the important part that is messed up.</p>
<p><pre><code>
function xyz_loop() {
$defaults = array (
'before' => 'article id="post-' .get_the_ID(). '"' .post_class('clearfix'). 'role="mai... | [
{
"answer_id": 59789,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": true,
"text": "<h2>Explanation</h2>\n\n<p>There's the global array <code>$wp_filters</code>. This array stores some sub arrays. One fo... | 2012/07/26 | [
"https://wordpress.stackexchange.com/questions/59786",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18595/"
] | Trying this in my functions file. There is actually a lot more to this function than I am showing, but this is the important part that is messed up.
```
function xyz_loop() {
$defaults = array (
'before' => 'article id="post-' .get_the_ID(). '"' .post_class('clearfix'). 'role="main">',
... | Explanation
-----------
There's the global array `$wp_filters`. This array stores some sub arrays. One for each `priority`. Each sub array then contains an array for each callback added. And the keys for those sub-sub arrays are the attached functions.
### Example
If you do the following, somewhere in your code (pre... |
59,827 | <p>I have build a plugin where I can output special php pages on a page using shortcode.</p>
<p>The plugin directory consists of the following php pages.</p>
<pre><code>product_info.php
index.php
account.php
login.php
checkout.php
core.php
</code></pre>
<p>The shortcode function which is on <code>core.php</code> is ... | [
{
"answer_id": 59829,
"author": "vmassuchetto",
"author_id": 7385,
"author_profile": "https://wordpress.stackexchange.com/users/7385",
"pm_score": 2,
"selected": false,
"text": "<p>In your case would be something like:</p>\n\n<pre><code>add_action('rewrite_rules_array', 'rewrite_rules');... | 2012/07/27 | [
"https://wordpress.stackexchange.com/questions/59827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7749/"
] | I have build a plugin where I can output special php pages on a page using shortcode.
The plugin directory consists of the following php pages.
```
product_info.php
index.php
account.php
login.php
checkout.php
core.php
```
The shortcode function which is on `core.php` is as follows,
```
function output_store(){
if... | In your case would be something like:
```
add_action('rewrite_rules_array', 'rewrite_rules');
function rewrite_rules($rules) {
$new_rules = array(
'product/([0-9]+)/?$' => 'index.php?product=$matches[1]'
);
return $rules + $new_rules;
}
add_action('query_vars', 'add_query_vars');
function add_quer... |
59,828 | <p>We can get multiple posts manually in a page, but that's generated in a template, AFTER the default query returned something else (page/post, etc)</p>
<p>How do you query multiple posts in a public query, which share no taxonomy or anything else?</p>
<p>e.g. by ID:</p>
<pre><code>http://example.com/?p=23,18,2,199... | [
{
"answer_id": 59830,
"author": "vmassuchetto",
"author_id": 7385,
"author_profile": "https://wordpress.stackexchange.com/users/7385",
"pm_score": 3,
"selected": false,
"text": "<p>Maybe you're looking for the <code>post__in</code> parameter in <code>WP_Query</code>.</p>\n\n<pre><code>$q... | 2012/07/27 | [
"https://wordpress.stackexchange.com/questions/59828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17358/"
] | We can get multiple posts manually in a page, but that's generated in a template, AFTER the default query returned something else (page/post, etc)
How do you query multiple posts in a public query, which share no taxonomy or anything else?
e.g. by ID:
```
http://example.com/?p=23,18,2,199,6,8
```
I got it working ... | Maybe you're looking for the `post__in` parameter in `WP_Query`.
```
$query = new WP_Query(array(
'post__in' => array(23,18,2,199,6,8)
);
```
And then:
```
while ( $query->have_posts() ) {
$query->the_post();
/* post loop */
}
```
Take a look at the [docs](http://codex.wordpress.org/Class_Reference/WP... |
59,871 | <p>I would like to remove some items from the quick edit screen on a custom post type.</p>
<p>I would like to remove "slug", "date" and "password", as they will never not be used by end users.</p>
<p><a href="https://i.stack.imgur.com/XQUc5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XQUc5.png" alt="qui... | [
{
"answer_id": 59961,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 4,
"selected": true,
"text": "<p>There's no hooks to modify the Quick Edit, it has to be done with CSS and/or jQuery.</p>\n\n<p>The plugin <a ... | 2012/07/27 | [
"https://wordpress.stackexchange.com/questions/59871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10629/"
] | I would like to remove some items from the quick edit screen on a custom post type.
I would like to remove "slug", "date" and "password", as they will never not be used by end users.
[](https://i.stack.imgur.com/XQUc5.png)
I'm open to any suggestions! | There's no hooks to modify the Quick Edit, it has to be done with CSS and/or jQuery.
The plugin [Adminimize](http://wordpress.org/extend/plugins/adminimize/) is **very good** to hide administrative elements, CPTs included.
But in the Quick Edit box, for lack of CSS classes or ID's to target, it is not possible to hi... |
59,892 | <p>I want to have a link in the wordpress menu pointing to the latest post of a specific category.</p>
<p>Because I am not able put a dynamic URL in the wordpress menu, my approach was to put a page with a custom page template in the menu.</p>
<p>This page template should behave like the themes <code>single.php</code... | [
{
"answer_id": 59918,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You can filter <code>wp_nav_menu_objects</code> and add a new item. Here is a simple plugin doing that:</p>\n\n<pre><co... | 2012/07/27 | [
"https://wordpress.stackexchange.com/questions/59892",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14085/"
] | I want to have a link in the wordpress menu pointing to the latest post of a specific category.
Because I am not able put a dynamic URL in the wordpress menu, my approach was to put a page with a custom page template in the menu.
This page template should behave like the themes `single.php` but showing that last post... | You can filter `wp_nav_menu_objects` and add a new item. Here is a simple plugin doing that:
```
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Latest Post In Menu
* Description: Append a link to the latest post to all nav menus called with the argument <code>'add_latest_post' => TRUE</code>.
* Plugin URI: http:... |
59,902 | <p>How can I completely remove the custom fields and the collapse button in the Edit Post/Edit Page custom screen, but without removing the capability to add custom fields with a PHP function?</p>
| [
{
"answer_id": 59906,
"author": "nvwd",
"author_id": 18496,
"author_profile": "https://wordpress.stackexchange.com/users/18496",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/remove_meta_box\" rel=\"noreferrer\">http://codex.wordpres... | 2012/07/27 | [
"https://wordpress.stackexchange.com/questions/59902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/492/"
] | How can I completely remove the custom fields and the collapse button in the Edit Post/Edit Page custom screen, but without removing the capability to add custom fields with a PHP function? | <http://codex.wordpress.org/Function_Reference/remove_meta_box>
```
function remove_custom_meta_form() {
remove_meta_box( 'postcustom', 'post', 'normal' );
remove_meta_box( 'postcustom', 'page', 'normal' );
}
add_action( 'admin_menu' , 'remove_custom_meta_form' );
```
HTH |
59,934 | <p>Here is the website <a href="http://ariadneswonderland.gr/" rel="nofollow">http://ariadneswonderland.gr/</a> that all this concerns.</p>
<p>On the homepage I'm using a Drop shadow box plugin
under the gallery to show a series of images of featured posts, as of right now, as i'm still building the website all you se... | [
{
"answer_id": 59936,
"author": "pcarvalho",
"author_id": 18559,
"author_profile": "https://wordpress.stackexchange.com/users/18559",
"pm_score": 0,
"selected": false,
"text": "<p>i suggest you use that code in the .php file itself. if its a page with a unique template, change that templ... | 2012/07/27 | [
"https://wordpress.stackexchange.com/questions/59934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18639/"
] | Here is the website <http://ariadneswonderland.gr/> that all this concerns.
On the homepage I'm using a Drop shadow box plugin
under the gallery to show a series of images of featured posts, as of right now, as i'm still building the website all you see is the White box under the gallery and a emoticon inside it..
*... | ```
<?php /* Set the name of the category and the number os posts to be displayed */?>
<?php $first_query = new WP_Query('category_name=name&posts_per_page=7'); ?>
<?php /* Show the posts */ ?>
<?php while ($first_query->have_posts()) : $first_query->the_post(); ?>
<?php /* Make the hiperlink to the post */ ?>
... |
59,951 | <p>I wanted to create a plugin to batch manage posts' custom field data. I know I can add post meta by add a meta box in post edit screen and use <strong>add_action('save_post','function_to_update_meta')</strong> to trigger add meta functions.</p>
<p>But I don't know how to trigger the <strong>add_post_meta</strong> f... | [
{
"answer_id": 59968,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 2,
"selected": true,
"text": "<p>You will need to use an <a href=\"http://codex.wordpress.org/AJAX_in_Plugins\" rel=\"nofollow\">Ajax function</a>. ... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18428/"
] | I wanted to create a plugin to batch manage posts' custom field data. I know I can add post meta by add a meta box in post edit screen and use **add\_action('save\_post','function\_to\_update\_meta')** to trigger add meta functions.
But I don't know how to trigger the **add\_post\_meta** function in a admin menu page ... | You will need to use an [Ajax function](http://codex.wordpress.org/AJAX_in_Plugins). Which requires javascript to send the form data to your php Ajax function which you can use to run update\_post\_meta();
Example:
Form Html:
```
<form>
<input id="meta" type ="text" name="2344" value="<?php echo esc_html( get_post_m... |
59,953 | <p>Im starting to delve deeper into Wordpress custom fields and wanting to replicate this page in Wordpress:
<a href="http://www.clubsact.com.au/corporate/index.php" rel="nofollow">http://www.clubsact.com.au/corporate/index.php</a></p>
<p>So my site is not tightly structured to a parent/child relationship, I have crea... | [
{
"answer_id": 59967,
"author": "pcarvalho",
"author_id": 18559,
"author_profile": "https://wordpress.stackexchange.com/users/18559",
"pm_score": 2,
"selected": false,
"text": "<p>my suggesting is going for a different way by using get_pages()</p>\n\n<p>for example</p>\n\n<pre><code>$arg... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17884/"
] | Im starting to delve deeper into Wordpress custom fields and wanting to replicate this page in Wordpress:
<http://www.clubsact.com.au/corporate/index.php>
So my site is not tightly structured to a parent/child relationship, I have created a custom field 'Partner\_Level' and based on the partner level entered by the au... | my suggesting is going for a different way by using get\_pages()
for example
```
$args = array(
'meta_key ' => 'Partner_Level',
'meta_value' => 'Gold' );
$pageslist = get_pages( $args );
```
$pageslist should have all your posts in the "gold" level. |
59,979 | <p>When I'm using <code>is_single();</code> in my <code><head></code> section to add some style to website navigation it executes correctly on blog posts but it also executes on single "portfolio" post type posts (so single-portfolio.php and single.php). </p>
<p>How do I make it execute only on single.php?</p>
| [
{
"answer_id": 59980,
"author": "Simon",
"author_id": 9458,
"author_profile": "https://wordpress.stackexchange.com/users/9458",
"pm_score": 3,
"selected": false,
"text": "<p>You could try something like (http://codex.wordpress.org/Function_Reference/get_post_type) :</p>\n\n<p>to check if... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59979",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | When I'm using `is_single();` in my `<head>` section to add some style to website navigation it executes correctly on blog posts but it also executes on single "portfolio" post type posts (so single-portfolio.php and single.php).
How do I make it execute only on single.php? | You can use the following instead,
```
if (is_singular('post')) {
//your code here...
}
```
Where by `is_singular` is the WordPress API conditional function for testing for the existence of a post type. You can also pass an array of post types if you wish.
<http://codex.wordpress.org/Function_Reference/is_sin... |
59,995 | <p>I've got the following loop in index.php file:</p>
<pre><code>$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = 30;
$do_not_show_stickies = 1;
$args=array(
'post_type' => array ('portfolio'),
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $post_... | [
{
"answer_id": 59980,
"author": "Simon",
"author_id": 9458,
"author_profile": "https://wordpress.stackexchange.com/users/9458",
"pm_score": 3,
"selected": false,
"text": "<p>You could try something like (http://codex.wordpress.org/Function_Reference/get_post_type) :</p>\n\n<p>to check if... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59995",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | I've got the following loop in index.php file:
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = 30;
$do_not_show_stickies = 1;
$args=array(
'post_type' => array ('portfolio'),
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $post_per_page,
'ignore_stic... | You can use the following instead,
```
if (is_singular('post')) {
//your code here...
}
```
Where by `is_singular` is the WordPress API conditional function for testing for the existence of a post type. You can also pass an array of post types if you wish.
<http://codex.wordpress.org/Function_Reference/is_sin... |
60,013 | <p>I have the following code in attempt to check for an image before an echo. The reason for doing so is if there is no image it won't echo anything and there won't be a missing image link put in a post that has no image. However this code does not work and when no image exists a missing image icon is added. Is there a... | [
{
"answer_id": 60003,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 4,
"selected": true,
"text": "<p>Create a custom Page Template, leave out the get_header(), get_footer(), and get_sidebar() calls in it, and put in y... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/60013",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7653/"
] | I have the following code in attempt to check for an image before an echo. The reason for doing so is if there is no image it won't echo anything and there won't be a missing image link put in a post that has no image. However this code does not work and when no image exists a missing image icon is added. Is there anot... | Create a custom Page Template, leave out the get\_header(), get\_footer(), and get\_sidebar() calls in it, and put in your own html header/footer code in the Page template instead.
<http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates> |
60,030 | <p>Hi I have this code for custom post types</p>
<pre><code>add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() )
$query->set( 'post_type', array( 'post', 'page', 'album', 'movie', 'quote', 'attachment' ) );
return $query;
}
</code></pre>
<p>i added it to my funct... | [
{
"answer_id": 60032,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like you're overwriting the nav menu query. By adding the <code>! is_admin()</code> and <code>$quer... | 2012/07/29 | [
"https://wordpress.stackexchange.com/questions/60030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13556/"
] | Hi I have this code for custom post types
```
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() )
$query->set( 'post_type', array( 'post', 'page', 'album', 'movie', 'quote', 'attachment' ) );
return $query;
}
```
i added it to my functions.php file, it works but i... | Found a solution, and it does more than what i asked. This solution shows the custom post types that you want to appear on the homepage and the second half shows it in the archives and search results :)
```
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() && false =... |
60,052 | <p>Imagine the following situation:</p>
<pre><code>//header.php contains:
<header id="header">logo and navigation</header>
//my-template.php contains:
<?php get_header(); ?>
<style type="text/css">#header { display: none; }</style>
<div class="main-container-of-my-template"&... | [
{
"answer_id": 60062,
"author": "Mario Peshev",
"author_id": 11506,
"author_profile": "https://wordpress.stackexchange.com/users/11506",
"pm_score": 1,
"selected": false,
"text": "<p>Option one is to use the same is_page_template and use wp_enqueue_style which would add some stylesheet o... | 2012/07/29 | [
"https://wordpress.stackexchange.com/questions/60052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | Imagine the following situation:
```
//header.php contains:
<header id="header">logo and navigation</header>
//my-template.php contains:
<?php get_header(); ?>
<style type="text/css">#header { display: none; }</style>
<div class="main-container-of-my-template"></div>
<?php get_footer(); ?>
```
This will d... | What about putting styles before the function `get_header();`
```
<style type="text/css">#header { display: none; }</style>
<?php get_header();?>
<div class="main-container-of-my-template"></div>
<?php get_footer(); ?>
```
However this is not recommended as it loads the styles even before the `<html>` not within the... |
60,056 | <p>Building my first theme from scratch in Wordpress 3.4.1, I know Wordpress already has the latest version of the JQuery via Google. I have read about issue's if the script is not called properly, so want to try and keep everything as close to the recommended coding as possibly. I want to make sure the script is loa... | [
{
"answer_id": 60059,
"author": "W van Dam",
"author_id": 17918,
"author_profile": "https://wordpress.stackexchange.com/users/17918",
"pm_score": 3,
"selected": true,
"text": "<p>You're on the right track, but missing one piece:</p>\n\n<pre><code>add_action('wp_enqueue_scripts', 'my_scri... | 2012/07/29 | [
"https://wordpress.stackexchange.com/questions/60056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18677/"
] | Building my first theme from scratch in Wordpress 3.4.1, I know Wordpress already has the latest version of the JQuery via Google. I have read about issue's if the script is not called properly, so want to try and keep everything as close to the recommended coding as possibly. I want to make sure the script is loaded w... | You're on the right track, but missing one piece:
```
add_action('wp_enqueue_scripts', 'my_scripts_method');
```
add\_action allows you to run code at specific times during page loads / specific events. The above action tells WP to run your function when it is adding the scripts to the html head element. Your functi... |
60,084 | <p>So, I've got an entirely custom theme which has a number of custom post-types.</p>
<p>I've also got a custom taxonomy which I can visit on the front end with URLs such as:</p>
<pre><code>www.mysite.local/custom-tax/custom-term
</code></pre>
<p>Which runs a query giving me results of posts that match the term 'cus... | [
{
"answer_id": 60110,
"author": "Rachel Baker",
"author_id": 8054,
"author_profile": "https://wordpress.stackexchange.com/users/8054",
"pm_score": 1,
"selected": false,
"text": "<p>Your Custom Post Type is using the single.php and (most likely) archive.php templates.</p>\n\n<p><a href=\"... | 2012/07/29 | [
"https://wordpress.stackexchange.com/questions/60084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18936/"
] | So, I've got an entirely custom theme which has a number of custom post-types.
I've also got a custom taxonomy which I can visit on the front end with URLs such as:
```
www.mysite.local/custom-tax/custom-term
```
Which runs a query giving me results of posts that match the term 'custom-term' in the tax 'custom-tax'... | Your Custom Post Type is using the single.php and (most likely) archive.php templates.
[A single CPT post looks for templates in this order](http://codex.wordpress.org/Template_Hierarchy#Single_Post_display):
* single-{post\_type}.php - If the post type were product, WordPress would look for single-product.php
* sin... |
60,092 | <p>I have tried many different things to get <code>add_editor_style()</code> to load into the source code on my site without any luck. I would like to use <code>editor-style.css</code> to customize CSS properties for my WordPress WYSIWYG. However, I am unable to get it working. Even when I look in Chrome Inspector's Re... | [
{
"answer_id": 82202,
"author": "Abhinav Sood",
"author_id": 26219,
"author_profile": "https://wordpress.stackexchange.com/users/26219",
"pm_score": -1,
"selected": false,
"text": "<p><strong>Correct Answer</strong>: Put <code>add_editor_style('editor-style.css');</code> in a function ho... | 2012/07/29 | [
"https://wordpress.stackexchange.com/questions/60092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17193/"
] | I have tried many different things to get `add_editor_style()` to load into the source code on my site without any luck. I would like to use `editor-style.css` to customize CSS properties for my WordPress WYSIWYG. However, I am unable to get it working. Even when I look in Chrome Inspector's Resources tab and scroll do... | You shouldn't call `add_editor_style()` directly in your `functions.php` file. Instead, you should wait until the plugins and themes have been loaded:
```
add_action( 'after_setup_theme', 'add_editor_style' );
```
If you already have a function hooked to `after_setup_theme`, you can call `add_editor_style()` inside ... |
60,142 | <p>Im hoping someone maybe able to point out my mistake. I have a function in functions.php with a simple meta_query.</p>
<p>If I use this query.</p>
<pre><code>$args = array(
'meta_query' => array(
array(
'meta_key' => 'Partner_Level',
'meta_value' => 'Gold',
'post_type' => 'page',
'post_st... | [
{
"answer_id": 60156,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 0,
"selected": false,
"text": "<p>When you do <code>meta_query</code> there is no keys called <code>meta_key</code> or <code>meta_value</code> try u... | 2012/07/30 | [
"https://wordpress.stackexchange.com/questions/60142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17884/"
] | Im hoping someone maybe able to point out my mistake. I have a function in functions.php with a simple meta\_query.
If I use this query.
```
$args = array(
'meta_query' => array(
array(
'meta_key' => 'Partner_Level',
'meta_value' => 'Gold',
'post_type' => 'page',
'post_status' => 'publish'
)));
$pages ... | I have pulled up stumps on this approach and gone back to my original function. It goes through the posts, looks for the Partner Level passed to it, and then retrieves a list of pages. I then display a styled list with the posts thumbnail as the clickable link. Will need to tweak for reach desired accessibility level, ... |
60,144 | <p>I want to use the Jetpack Carousel for all my posts without editing all of them. Is there a way to show pictures in the carousel even if they're not in a gallery?</p>
| [
{
"answer_id": 60156,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 0,
"selected": false,
"text": "<p>When you do <code>meta_query</code> there is no keys called <code>meta_key</code> or <code>meta_value</code> try u... | 2012/07/30 | [
"https://wordpress.stackexchange.com/questions/60144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10427/"
] | I want to use the Jetpack Carousel for all my posts without editing all of them. Is there a way to show pictures in the carousel even if they're not in a gallery? | I have pulled up stumps on this approach and gone back to my original function. It goes through the posts, looks for the Partner Level passed to it, and then retrieves a list of pages. I then display a styled list with the posts thumbnail as the clickable link. Will need to tweak for reach desired accessibility level, ... |
60,184 | <p>Is there an easy way to add another 'read more' link? I'm using the standard 'continue reading' link for some posts but I also want to use a different text like 'more info' for other posts. Can I do this using <code>the_excerpt</code>?</p>
<p>Later update:
This are the two standard twentyelven functions that are u... | [
{
"answer_id": 60198,
"author": "MechEngineer",
"author_id": 5648,
"author_profile": "https://wordpress.stackexchange.com/users/5648",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_more\" rel=\"nofol... | 2012/07/30 | [
"https://wordpress.stackexchange.com/questions/60184",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13214/"
] | Is there an easy way to add another 'read more' link? I'm using the standard 'continue reading' link for some posts but I also want to use a different text like 'more info' for other posts. Can I do this using `the_excerpt`?
Later update:
This are the two standard twentyelven functions that are used for the 'read mor... | How about using condition to change the readmore links.
Here is an sample code which returns a different read more text based upon the category of post. You should read the [official codex page](http://codex.wordpress.org/Conditional_Tags) to know more about other conditional tags you can use in wordpress.
**Usage** ... |
60,195 | <p>I am in need of a function that automatically generates and returns salts for Wordpress wp-config.php (Don't link me to their API, I'm looking for offline solution).</p>
<p>Does Wordpress core has this function defined somewhere?
If it doesn't, can these salts be generated randomly or are there any specific rules ... | [
{
"answer_id": 60248,
"author": "Pothi Kalimuthu",
"author_id": 9584,
"author_profile": "https://wordpress.stackexchange.com/users/9584",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>Does Wordpress core has this function defined somewhere?</p>\n</blockquote>\n\n<p>While I... | 2012/07/30 | [
"https://wordpress.stackexchange.com/questions/60195",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11288/"
] | I am in need of a function that automatically generates and returns salts for Wordpress wp-config.php (Don't link me to their API, I'm looking for offline solution).
Does Wordpress core has this function defined somewhere?
If it doesn't, can these salts be generated randomly or are there any specific rules for creati... | >
> Does Wordpress core has this function defined somewhere?
>
>
>
While I haven't used it, you are probably looking for [wp\_salt](http://codex.wordpress.org/Function_Reference/wp_salt) or `wp_generate_password`. `wp_salt` is located in `wp-includes/pluggable.php`.
>
> can these salts be generated randomly
>
>... |
60,200 | <p>I have a custom content type of <code>tab_content</code> with a relationship to a <code>page</code>.</p>
<p>In my current script I have the <em>id</em> of a <code>page</code> and I want to do a query that will list all the children of type <code>tab_content</code> that have the relationship of a <code>page</code> w... | [
{
"answer_id": 60215,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": -1,
"selected": false,
"text": "<p>The only way to do what you want with WP_Query is to use two queries:</p>\n\n<ol>\n<li>Get the list of IDs of <c... | 2012/07/30 | [
"https://wordpress.stackexchange.com/questions/60200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13170/"
] | I have a custom content type of `tab_content` with a relationship to a `page`.
In my current script I have the *id* of a `page` and I want to do a query that will list all the children of type `tab_content` that have the relationship of a `page` with the specified id.
All I have so far is:
```
new WP_Query(array('po... | You can try using the `post_parent` paramter or WP\_Query ex:
```
new WP_Query(array(
'post_type' => 'tab_content',
'post_parent' => 80
));
``` |
60,208 | <p>I used the the following script (only with get_permalink....) to display posts from a post type where the post author has an extra meta field on his user page:</p>
<pre><code><?php // get users from user page
$blogusers = get_users();
foreach ($blogusers as $user) {
if(get_field('races','user_' .... | [
{
"answer_id": 60242,
"author": "W van Dam",
"author_id": 17918,
"author_profile": "https://wordpress.stackexchange.com/users/17918",
"pm_score": 2,
"selected": false,
"text": "<p>Edit: Re-reading your question I noticed I may have mixed some things up, but the point remains that you sho... | 2012/07/30 | [
"https://wordpress.stackexchange.com/questions/60208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6768/"
] | I used the the following script (only with get\_permalink....) to display posts from a post type where the post author has an extra meta field on his user page:
```
<?php // get users from user page
$blogusers = get_users();
foreach ($blogusers as $user) {
if(get_field('races','user_' . $user->ID)) {
... | Thanks for the ideas. Finally I came up with a quick solution that seems to give the right numbers in the format I need.
I'm sure there is a cleaner method to get results from a query like this, but I haven't seen anything similar so far.
```
<?php // get users from user page
$blogusers = get_users();
$i = 0;
foreach ... |
60,222 | <p>I followed the steps to create a lightbox gallery. The gallery is created, but does not open with the lightbox. It just opens as a post. Does anybody know the step I've missed?</p>
<p>Here is the site in progress. (I also must mention that pretty much nothing in this theme I bought seems to work)</p>
<p><a href="h... | [
{
"answer_id": 60242,
"author": "W van Dam",
"author_id": 17918,
"author_profile": "https://wordpress.stackexchange.com/users/17918",
"pm_score": 2,
"selected": false,
"text": "<p>Edit: Re-reading your question I noticed I may have mixed some things up, but the point remains that you sho... | 2012/07/30 | [
"https://wordpress.stackexchange.com/questions/60222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18724/"
] | I followed the steps to create a lightbox gallery. The gallery is created, but does not open with the lightbox. It just opens as a post. Does anybody know the step I've missed?
Here is the site in progress. (I also must mention that pretty much nothing in this theme I bought seems to work)
<http://www.gregtaylordesig... | Thanks for the ideas. Finally I came up with a quick solution that seems to give the right numbers in the format I need.
I'm sure there is a cleaner method to get results from a query like this, but I haven't seen anything similar so far.
```
<?php // get users from user page
$blogusers = get_users();
$i = 0;
foreach ... |
60,244 | <p>Does Wordpress have something similar to Drupal's <a href="http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_set_message/7">drupal_set_message</a> function? I want to notify the user of something and was hoping there was a built in API call to do this.</p>
| [
{
"answer_id": 60249,
"author": "Joseph Leedy",
"author_id": 8554,
"author_profile": "https://wordpress.stackexchange.com/users/8554",
"pm_score": 3,
"selected": true,
"text": "<p>Here's an idea: use the <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/save_post\" rel=\"n... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15468/"
] | Does Wordpress have something similar to Drupal's [drupal\_set\_message](http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_set_message/7) function? I want to notify the user of something and was hoping there was a built in API call to do this. | Here's an idea: use the [`save_post`](http://codex.wordpress.org/Plugin_API/Action_Reference/save_post) hook to set a session containing the message you want to show the user and then redirect to the home page. In the home page template, check for the presence of that session and show the message to the user.
Somethin... |
60,245 | <p>I am using this code directly from the <a href="http://codex.wordpress.org/Function_Reference/get_children">codex</a>. </p>
<pre><code>function echo_first_image ($postID)
{
$args = array(
'numberposts' => 1,
'order'=> 'ASC',
'post_mime_type' => 'image',
'post_parent' ... | [
{
"answer_id": 60246,
"author": "pcarvalho",
"author_id": 18559,
"author_profile": "https://wordpress.stackexchange.com/users/18559",
"pm_score": 2,
"selected": false,
"text": "<p>the code seems perfectly safe. like you said, you don't have any image <strong>attached</strong> to the post... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60245",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6169/"
] | I am using this code directly from the [codex](http://codex.wordpress.org/Function_Reference/get_children).
```
function echo_first_image ($postID)
{
$args = array(
'numberposts' => 1,
'order'=> 'ASC',
'post_mime_type' => 'image',
'post_parent' => $postID,
'post_status' => n... | If you want **display an image that is inserted into your content** (a hotlinked image, for example), you must use a function like this [(source)](http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it):
add in **functions.php**:
```
function catch_that_image() {
global $post, $posts;
$f... |
60,266 | <p>i'm query multiple taxonomies and have no problem with it but pagination is not working how to solve it, i try alot of suggestion but no success
here is my code</p>
<pre><code> if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
... | [
{
"answer_id": 60258,
"author": "Ian Dunn",
"author_id": 3898,
"author_profile": "https://wordpress.stackexchange.com/users/3898",
"pm_score": 1,
"selected": false,
"text": "<p>Try adding <code>global $post;</code> to the function, so that the <code>$post</code> variable will be availabl... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17639/"
] | i'm query multiple taxonomies and have no problem with it but pagination is not working how to solve it, i try alot of suggestion but no success
here is my code
```
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
$paged = get... | The following solution worked
`$query2= mysql_query("SELECT * FROM wp_posts WHERE ID='$post->ID' AND post_parent=302");
$numrows2 = mysql_num_rows($query2);
if($numrows2 != 0) {
// query goes here
}` |
60,272 | <p>Is there a conditional tag that will allow me to display certain content only if the user is NOT a subscriber?</p>
| [
{
"answer_id": 60280,
"author": "gArn",
"author_id": 10629,
"author_profile": "https://wordpress.stackexchange.com/users/10629",
"pm_score": -1,
"selected": false,
"text": "<p>Is this what you mean?</p>\n\n<pre><code>global $userdata;\nget_currentuserinfo();\nif ( $userdata->user_leve... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60272",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16309/"
] | Is there a conditional tag that will allow me to display certain content only if the user is NOT a subscriber? | ```
<?php
$current_user = wp_get_current_user();
if ( ! user_can( $current_user, "subscriber" ) ) // Check user object has not got subscriber role
echo 'User is a not Subscriber';
else
echo 'User is a Subscriber';
?>
``` |
60,279 | <p>I wrote my own function to list all taxonomy terms of a certain taxonomy …</p>
<pre><code>function wr_list_taxonomy($taxonomy, $orderby, $hierarchical) {
$show_count = 0;
$pad_counts = 0;
$title = '';
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderb... | [
{
"answer_id": 60287,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 2,
"selected": true,
"text": "<p>Yes off course. You just need to get the term id and put it on the args. Check <a href=\"http://codex.wordpress.org... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I wrote my own function to list all taxonomy terms of a certain taxonomy …
```
function wr_list_taxonomy($taxonomy, $orderby, $hierarchical) {
$show_count = 0;
$pad_counts = 0;
$title = '';
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count... | Yes off course. You just need to get the term id and put it on the args. Check [`wp_list_categories()`](http://codex.wordpress.org/Template_Tags/wp_list_categories#Parameters)
```
function wr_list_taxonomy($taxonomy, $orderby, $hierarchical, $cat_id) {
$show_count = 0;
$pad_counts = 0;
$title = ... |
60,292 | <p>Can anyone please help me to with the wp_query.</p>
<p>I am making a template file/loop to create and archive page of the current page children pages.</p>
<p>This query needs to be automatic as I am using in on few pages.</p>
<p>This is my query below, but it just returns my posts instead of child pages.</p>
<pr... | [
{
"answer_id": 60295,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 8,
"selected": true,
"text": "<p>You have to change <code>child_of</code> to <code>post_parent</code> and also add <code>post_type =&... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60292",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | Can anyone please help me to with the wp\_query.
I am making a template file/loop to create and archive page of the current page children pages.
This query needs to be automatic as I am using in on few pages.
This is my query below, but it just returns my posts instead of child pages.
```
<?php
$parent = new WP_Qu... | You have to change `child_of` to `post_parent` and also add `post_type => 'page'`:
WordPress codex Wp\_query [Post & Page Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters)
```
<?php
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' ... |
60,297 | <pre><code><?php
$current_term = $wp_query->queried_object->name;
$current_term_id = $wp_query->queried_object->ID;
?>
<hgroup class="section-heading wrapper">
<h1><?php echo $current_term; ?></h1>
<h3><?php echo category_description( $current_term_id... | [
{
"answer_id": 60299,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 4,
"selected": true,
"text": "<p>I faced the exact same problem for days and then found this!\nUse the function <code>$wp_query->get_q... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | ```
<?php
$current_term = $wp_query->queried_object->name;
$current_term_id = $wp_query->queried_object->ID;
?>
<hgroup class="section-heading wrapper">
<h1><?php echo $current_term; ?></h1>
<h3><?php echo category_description( $current_term_id ); ?></h3>
</hgroup>
```
This works fine but the `$curr... | I faced the exact same problem for days and then found this!
Use the function `$wp_query->get_queried_object_id()`. Check [this](http://codex.wordpress.org/Class_Reference/WP_Query) for more details. |
60,304 | <p>I have the following setup: the front-page is setup as 'static' and it uses a theme page template. On this template / front-page, I need to get the page title, URL and excerpt of the About page. </p>
<p>I found this code that does exactly what I need, but I'm wandering if there's a different approach to this, one t... | [
{
"answer_id": 60305,
"author": "pcarvalho",
"author_id": 18559,
"author_profile": "https://wordpress.stackexchange.com/users/18559",
"pm_score": 4,
"selected": true,
"text": "<p>the codex has exacly what you need: <a href=\"http://codex.wordpress.org/Function_Reference/get_page_by_title... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13214/"
] | I have the following setup: the front-page is setup as 'static' and it uses a theme page template. On this template / front-page, I need to get the page title, URL and excerpt of the About page.
I found this code that does exactly what I need, but I'm wandering if there's a different approach to this, one that would ... | the codex has exacly what you need: [`get_page_by_title()`](http://codex.wordpress.org/Function_Reference/get_page_by_title)
Example
-------
```
$page = get_page_by_title( 'About' );
$the_excerpt = $page->post_excerpt;
```
or
```
$page = get_page_by_path( 'parent-page/sub-page' );
``` |
60,306 | <p>Hi i was wondering if there is a way that i can display the custom post type title.</p>
<p>For example:</p>
<p>I have a custom post type entitled "Pretty Little Liars" and it also shows on the homepage, but how do i get the POST TYPE title, not the title of the post to show up like a category. </p>
<p>For example... | [
{
"answer_id": 60312,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": true,
"text": "<p>You can write a general template tag for this task.</p>\n\n<pre><code>function wpse60306_get_post_type( $echo = true... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13556/"
] | Hi i was wondering if there is a way that i can display the custom post type title.
For example:
I have a custom post type entitled "Pretty Little Liars" and it also shows on the homepage, but how do i get the POST TYPE title, not the title of the post to show up like a category.
For example:
Plublished in: Pretty... | You can write a general template tag for this task.
```
function wpse60306_get_post_type( $echo = true )
{
static $post_types, $labels = '';
// Get all post type *names*, that are shown in the admin menu
empty( $post_types ) AND $post_types = get_post_types(
array(
'show_in_menu' => ... |
60,307 | <p>My blog page is not my homepage. How can I add a title to the top of the page? i.e. "My Blog". Right now there is no title on the page. The title of the first post is at the top. (Sorry it's on my local machine or I'd provide a link and I'm too new to post an image.)</p>
<p>Things I've tried: </p>
<ul>
<li>Creatin... | [
{
"answer_id": 60319,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 2,
"selected": false,
"text": "<p>the accepted answer in the <a href=\"https://wordpress.stackexchange.com/questions/48006/i-put-my-blog-on-a-subp... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60307",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18744/"
] | My blog page is not my homepage. How can I add a title to the top of the page? i.e. "My Blog". Right now there is no title on the page. The title of the first post is at the top. (Sorry it's on my local machine or I'd provide a link and I'm too new to post an image.)
Things I've tried:
* Creating a "blog" template p... | the accepted answer in the [similar question on stackexchange](https://wordpress.stackexchange.com/questions/48006/i-put-my-blog-on-a-subpage-how-do-i-get-page-title) should work;
try to add this to a suitable location in index.php of your theme:
```
<?php if( is_home() && get_option( 'page_for_posts' ) ) echo get_th... |
60,309 | <p>How it is possible to <strong>disable plugin update check and notification</strong> for an custom <strong>specific plugin</strong> in WP <strong>Multisite</strong>.</p>
<p>I think it is also important, the plugin is usable as single activation in each blog of network and also as network wide active plugin. The chec... | [
{
"answer_id": 60311,
"author": "Varun Sridharan",
"author_id": 18746,
"author_profile": "https://wordpress.stackexchange.com/users/18746",
"pm_score": 1,
"selected": false,
"text": "<p>use the below code in your functions.php</p>\n\n<pre><code>function jm_update_notice()\n{\nremove_acti... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60309",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/170/"
] | How it is possible to **disable plugin update check and notification** for an custom **specific plugin** in WP **Multisite**.
I think it is also important, the plugin is usable as single activation in each blog of network and also as network wide active plugin. The check is different on an activation on single blog in... | I have found a solution for me. Create a plugin, active in network - network wide. This is important on a mu install. If the check only in a plugin, there is active in a blog of a mu install, then was the check only active in this blog and the update check and notice was active in the network.
Define the plugins, ther... |
60,313 | <p>I'm using a template, which uses Custom Post Type 'movies'. When I try to change the page I got 404 Not Found :(</p>
<p>This is my index.php</p>
<pre><code><div id="content">
<?php
$temp = $wp_query;
$page = get_query_var('page');
$page = (!empty($page) ? $page : 1);
$wp_query= null;
$wp_query = new WP_Qu... | [
{
"answer_id": 60320,
"author": "nvwd",
"author_id": 18496,
"author_profile": "https://wordpress.stackexchange.com/users/18496",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried using double quotes around the query string with the variable?</p>\n\n<p>Change:</p>\n\n<pre><code... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18745/"
] | I'm using a template, which uses Custom Post Type 'movies'. When I try to change the page I got 404 Not Found :(
This is my index.php
```
<div id="content">
<?php
$temp = $wp_query;
$page = get_query_var('page');
$page = (!empty($page) ? $page : 1);
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('post_... | **Couple of small corrections:**
`$wp_query` is a global variable so you need to declear it as a global and i believe the query var is `paged` not `page`. so,
change
```
$temp = $wp_query;
$page = get_query_var('page');
```
to
```
global $wp_query;
$temp = $wp_query;
$page = get_query_var('paged');
```
Check if... |
60,318 | <p>I have this manually created page:</p>
<pre class="lang-php prettyprint-override"><code>$user_login = sanitize_text_field( $_GET['user_login'] );
if ( username_exists( $user_login ) || email_exists($user_login) ) { ?>
<!--Everything has been validated, proceed ....-->
<!DOCTYPE HTML>
<html lang=... | [
{
"answer_id": 60694,
"author": "nvartolomei",
"author_id": 18848,
"author_profile": "https://wordpress.stackexchange.com/users/18848",
"pm_score": 6,
"selected": true,
"text": "<p>So if you want to send the reset password link and you have access to the code base, you can use the follow... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16113/"
] | I have this manually created page:
```php
$user_login = sanitize_text_field( $_GET['user_login'] );
if ( username_exists( $user_login ) || email_exists($user_login) ) { ?>
<!--Everything has been validated, proceed ....-->
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
... | So if you want to send the reset password link and you have access to the code base, you can use the following snippet and you can modify it further. Actually this code is a slightly modified version of `wp-login.php`
```
/**
* Handles sending password retrieval email to user.
*
* @uses $wpdb WordPress Database obj... |
60,322 | <p>I'm trying to insert the slugs of custom taxonomies as classes in the opening body tag on certain WordPress pages. What I have so far is causing errors.</p>
<p>I found a bit of help with the examples <a href="https://codex.wordpress.org/Function_Reference/get_the_terms#A_Basic_Example" rel="nofollow">here</a> and <... | [
{
"answer_id": 60323,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": true,
"text": "<p>What is the job of <code>$section_name</code>? Also you must get an return; you if statement kill the default retur... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18706/"
] | I'm trying to insert the slugs of custom taxonomies as classes in the opening body tag on certain WordPress pages. What I have so far is causing errors.
I found a bit of help with the examples [here](https://codex.wordpress.org/Function_Reference/get_the_terms#A_Basic_Example) and [here](https://codex.wordpress.org/Fu... | What is the job of `$section_name`? Also you must get an return; you if statement kill the default return. It is important, if your if statement fails.
maybe this works, but not tested, write from scratch.
```
add_filter( 'body_class', 'section_id_class' );
// add classes to body based on custom taxonomy ('sections')... |
60,327 | <h2>Question</h2>
<p>I want to display total number of Authors and total number of subscribers on the blog but exclude the admin in this way: </p>
<p><em><strong>56</em></strong> Authors so far</p>
<p><em><strong>15</em></strong> Subscribers so far</p>
<h2>Code that is close to what I need :)</h2>
<p>I have this c... | [
{
"answer_id": 60332,
"author": "Joshua Abenazer",
"author_id": 10251,
"author_profile": "https://wordpress.stackexchange.com/users/10251",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/count_users\" rel=\"nofollow\"><code>count_use... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5499/"
] | Question
--------
I want to display total number of Authors and total number of subscribers on the blog but exclude the admin in this way:
***56*** Authors so far
***15*** Subscribers so far
Code that is close to what I need :)
------------------------------------
I have this code and it displays the total number... | [`count_users()`](http://codex.wordpress.org/Function_Reference/count_users) should give you an array of all the required user counts.
You can use it like this.
```
$user_counts = count_users();
$authors = $user_counts['avail_roles']['author']; //Get the author count
$subscribers = $user_counts['avail_roles']['su... |
60,347 | <p>I am trying to devlope a plugin that will search and return my users so I can edit some other metatdata that belongs to them. I have been using the plug-in listed on the <a href="http://wordpress.org/extend/plugins/custom-list-table-example/" rel="nofollow">Codex</a> as my starting point.</p>
<p>I have my table app... | [
{
"answer_id": 84536,
"author": "Stephen M. Harris",
"author_id": 11957,
"author_profile": "https://wordpress.stackexchange.com/users/11957",
"pm_score": 1,
"selected": false,
"text": "<p>As Brian noted, your form sends the data via POST, and you are fetching via GET. Change for method ... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15091/"
] | I am trying to devlope a plugin that will search and return my users so I can edit some other metatdata that belongs to them. I have been using the plug-in listed on the [Codex](http://wordpress.org/extend/plugins/custom-list-table-example/) as my starting point.
I have my table appearing with the the users from a WP\... | Brian is correct. By changing the form to use get instead of post and then using $\_REQUEST to fetch it should work, and is for me.
```
// Fetch, prepare, sort, and filter our data.
if( isset( $_REQUEST ["s"] ) ){
// Form that displays the table and also contains the search_box()
<form id="table-class-filter" method=... |
60,379 | <p>When I put -- into a post it is automatically converted to the – <code>&ndash;</code> character in the output by wordpress.</p>
<p>How can I get normal <code>'--'</code> double dashes in my content.</p>
| [
{
"answer_id": 60395,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": false,
"text": "<p>In your <code>functions.php</code>:</p>\n\n<pre><code>remove_filter( 'the_content', 'wptexturize' );\n</cod... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18773/"
] | When I put -- into a post it is automatically converted to the – `–` character in the output by wordpress.
How can I get normal `'--'` double dashes in my content. | In your `functions.php`:
```
remove_filter( 'the_content', 'wptexturize' );
```
And the same for `the_excerpt` or `the_title` (if required). |
60,383 | <p>I'm creating a new Page Template.</p>
<p>I want to change margins, fonts, font sizes, and things like that.</p>
<p>I don't know if I've done things right. Is the following process that I've followed sound?:</p>
<ol>
<li><p>I created a new file 'salespagetemplate.php' and placed this in the active theme (twentyele... | [
{
"answer_id": 60385,
"author": "Ken",
"author_id": 15091,
"author_profile": "https://wordpress.stackexchange.com/users/15091",
"pm_score": -1,
"selected": false,
"text": "<p>Child theme is the way to go.</p>\n\n<p><a href=\"http://codex.wordpress.org/Child_Themes\" rel=\"nofollow\">http... | 2012/07/31 | [
"https://wordpress.stackexchange.com/questions/60383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7692/"
] | I'm creating a new Page Template.
I want to change margins, fonts, font sizes, and things like that.
I don't know if I've done things right. Is the following process that I've followed sound?:
1. I created a new file 'salespagetemplate.php' and placed this in the active theme (twentyeleven-child).
2. In the file 'sa... | A page template defines the full rendered content displayed: header, footer, content - everything. So, at the very least, you'll need to call `get_header()` and `get_footer()`, or manually add the header and footer code to the template.
Also, I would recommend using a *callback* to enqueue your custom stylesheet. You ... |
60,404 | <p>Im using a theme which has my thumbnais set to 150x150px. But after installing plugin (just too check it out) I noticed it displays them correctly, but the default thumbnails are zoomed in. Can anybody give me a clue on where I should be looking? This is the css for the thumbs:</p>
<pre><code>#content .featured_box... | [
{
"answer_id": 60465,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>I'm pretty sure it's because CSS is forcing a dimension on all images, and the ones that appear \"zoomed\" ... | 2012/08/01 | [
"https://wordpress.stackexchange.com/questions/60404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17965/"
] | Im using a theme which has my thumbnais set to 150x150px. But after installing plugin (just too check it out) I noticed it displays them correctly, but the default thumbnails are zoomed in. Can anybody give me a clue on where I should be looking? This is the css for the thumbs:
```
#content .featured_box { width: 150p... | Isn't it because you're using `$crop` as `true`, as the 4th parameter for the `add_image_size()` function?
This will crop the image and does not actually resize the image. |
60,420 | <p>Registration Form Fields: (Front-end Registration)</p>
<pre><code>Username,
Email (password will generate to email).
</code></pre>
<p>Edit Profile: (Front-end Edit Profile)</p>
<pre><code>Firstname,
Lastname,
Username,
Email,
Phone,
Address,
Zip / postal code,
Website,
State(Drop down-Dynamic),
Country(Drop down... | [
{
"answer_id": 60421,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 2,
"selected": false,
"text": "<p>This answer is copied from <a href=\"http://justintadlock.com/archives/2009/09/10/adding-and-using-cust... | 2012/08/01 | [
"https://wordpress.stackexchange.com/questions/60420",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18794/"
] | Registration Form Fields: (Front-end Registration)
```
Username,
Email (password will generate to email).
```
Edit Profile: (Front-end Edit Profile)
```
Firstname,
Lastname,
Username,
Email,
Phone,
Address,
Zip / postal code,
Website,
State(Drop down-Dynamic),
Country(Drop down),
Newsletter (Check box),
Change pa... | This answer is copied from [the best post](http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields) over this topic! I could've just given you the links, but that would get me a comment from the mod to post sample code ;)
For adding the fields:
```
add_action( 'show_user_profile', 'my... |
60,436 | <p>i've been trying to get the attachment URL on single.php, so far this code gets the DIRECT LINK to the image;</p>
<pre><code><?php
if ( $attachments = get_children( array(
'post_type' => 'attachment',
'post_mime_type'=>'image',
'numberposts' => 1,
'post_status' => null,
'post_parent' => $post->... | [
{
"answer_id": 60437,
"author": "Geert",
"author_id": 4936,
"author_profile": "https://wordpress.stackexchange.com/users/4936",
"pm_score": 2,
"selected": false,
"text": "<p>You’re looking for: <a href=\"http://codex.wordpress.org/Function_Reference/get_attachment_link\" rel=\"nofollow\"... | 2012/08/01 | [
"https://wordpress.stackexchange.com/questions/60436",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18800/"
] | i've been trying to get the attachment URL on single.php, so far this code gets the DIRECT LINK to the image;
```
<?php
if ( $attachments = get_children( array(
'post_type' => 'attachment',
'post_mime_type'=>'image',
'numberposts' => 1,
'post_status' => null,
'post_parent' => $post->ID
)));
foreach ($attachments as $... | The `the_attachment_link` returns an HTML link, so use this code:
```
if ( $attachments = get_children( array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => 1,
'post_status' => null,
'post_parent' => $post->ID
) ) );
foreach ( $attachments as $attachment )... |