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 |
|---|---|---|---|---|---|---|
125,200 | <p>I am having a little trouble trying to figure out how I can accomplish this: I have a container with two colums in it, a right and a left column. Each column will have 3 posts with a short excerpt stacked in it. Ideally I would like to add one into the right and one into the left until it reaches 3 rows of posts(alt... | [
{
"answer_id": 125201,
"author": "Jake",
"author_id": 11966,
"author_profile": "https://wordpress.stackexchange.com/users/11966",
"pm_score": 3,
"selected": true,
"text": "<p>The key, I think, to what you are doing is to use \"offset\"</p>\n\n<pre><code><div class=\"col4 inner-left\"&... | 2013/12/03 | [
"https://wordpress.stackexchange.com/questions/125200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | I am having a little trouble trying to figure out how I can accomplish this: I have a container with two colums in it, a right and a left column. Each column will have 3 posts with a short excerpt stacked in it. Ideally I would like to add one into the right and one into the left until it reaches 3 rows of posts(althou... | The key, I think, to what you are doing is to use "offset"
```
<div class="col4 inner-left">
<ul class="popular-list">
<?php
query_posts('order=DESC&posts_per_page=3&post_type=pop');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<a href="<?php th... |
125,208 | <p>if I have more than one posts that publish in the same day, <code>the_date()</code> function does not print publish date.</p>
<p>How can I fix it?</p>
<p>thanks</p>
<p>I solve this by: "<code>the_time(get_option('date_format'));</code>" </p>
| [
{
"answer_id": 125201,
"author": "Jake",
"author_id": 11966,
"author_profile": "https://wordpress.stackexchange.com/users/11966",
"pm_score": 3,
"selected": true,
"text": "<p>The key, I think, to what you are doing is to use \"offset\"</p>\n\n<pre><code><div class=\"col4 inner-left\"&... | 2013/12/03 | [
"https://wordpress.stackexchange.com/questions/125208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31075/"
] | if I have more than one posts that publish in the same day, `the_date()` function does not print publish date.
How can I fix it?
thanks
I solve this by: "`the_time(get_option('date_format'));`" | The key, I think, to what you are doing is to use "offset"
```
<div class="col4 inner-left">
<ul class="popular-list">
<?php
query_posts('order=DESC&posts_per_page=3&post_type=pop');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<a href="<?php th... |
125,250 | <p>I cannot access either wp-admin, or wp-login.php on a wordpress site. I'm <strong>not</strong> getting a 404, or a redirect, it simply says cannot connect in firefox.</p>
<p>I have tried everything relevant on this <a href="http://codex.wordpress.org/Login_Trouble" rel="nofollow">guide</a> and also this <a href="h... | [
{
"answer_id": 125201,
"author": "Jake",
"author_id": 11966,
"author_profile": "https://wordpress.stackexchange.com/users/11966",
"pm_score": 3,
"selected": true,
"text": "<p>The key, I think, to what you are doing is to use \"offset\"</p>\n\n<pre><code><div class=\"col4 inner-left\"&... | 2013/12/03 | [
"https://wordpress.stackexchange.com/questions/125250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33751/"
] | I cannot access either wp-admin, or wp-login.php on a wordpress site. I'm **not** getting a 404, or a redirect, it simply says cannot connect in firefox.
I have tried everything relevant on this [guide](http://codex.wordpress.org/Login_Trouble) and also this [guide](http://www.hongkiat.com/blog/common-wordpress-errors... | The key, I think, to what you are doing is to use "offset"
```
<div class="col4 inner-left">
<ul class="popular-list">
<?php
query_posts('order=DESC&posts_per_page=3&post_type=pop');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<a href="<?php th... |
125,281 | <p>I'm trying add "Tuppersex" text before categories but it's impossible! Everyone can help me please?</p>
<p>Now, final code is this:</p>
<pre><code><ul id="cat-col-1" class="cat_col">
<li class="cat-item cat-item-815">
<a title="" href="http://www.domain.com/1/">1</a>
</li>
</code></pr... | [
{
"answer_id": 125201,
"author": "Jake",
"author_id": 11966,
"author_profile": "https://wordpress.stackexchange.com/users/11966",
"pm_score": 3,
"selected": true,
"text": "<p>The key, I think, to what you are doing is to use \"offset\"</p>\n\n<pre><code><div class=\"col4 inner-left\"&... | 2013/12/03 | [
"https://wordpress.stackexchange.com/questions/125281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41267/"
] | I'm trying add "Tuppersex" text before categories but it's impossible! Everyone can help me please?
Now, final code is this:
```
<ul id="cat-col-1" class="cat_col">
<li class="cat-item cat-item-815">
<a title="" href="http://www.domain.com/1/">1</a>
</li>
```
But i want show:
```
<ul id="cat-col-1" class="cat_col"... | The key, I think, to what you are doing is to use "offset"
```
<div class="col4 inner-left">
<ul class="popular-list">
<?php
query_posts('order=DESC&posts_per_page=3&post_type=pop');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<a href="<?php th... |
125,284 | <p>I have some custom forms in my template pages. I'm using a form "action" to link to a formtoemail.php file. Everything works if I leave formtoemail.php as is, but I would like to call in my theme elements to style the page dynamically. </p>
<p>I have tried the following, but unfortunately get an error "Call to unde... | [
{
"answer_id": 125201,
"author": "Jake",
"author_id": 11966,
"author_profile": "https://wordpress.stackexchange.com/users/11966",
"pm_score": 3,
"selected": true,
"text": "<p>The key, I think, to what you are doing is to use \"offset\"</p>\n\n<pre><code><div class=\"col4 inner-left\"&... | 2013/12/03 | [
"https://wordpress.stackexchange.com/questions/125284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37657/"
] | I have some custom forms in my template pages. I'm using a form "action" to link to a formtoemail.php file. Everything works if I leave formtoemail.php as is, but I would like to call in my theme elements to style the page dynamically.
I have tried the following, but unfortunately get an error "Call to undefined func... | The key, I think, to what you are doing is to use "offset"
```
<div class="col4 inner-left">
<ul class="popular-list">
<?php
query_posts('order=DESC&posts_per_page=3&post_type=pop');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<a href="<?php th... |
125,289 | <p>Im trying to get the category ID from <code>wp_dropdown_categories();</code>and then pass the ID into a loop to have it output posts titles from that particular category.</p>
<p>I currently have this:</p>
<pre><code> <form action="<?php bloginfo('url'); ?>" method="get">
<?php wp_dropdown_... | [
{
"answer_id": 125291,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>You're on the right track with using a <code>form</code>, the only thing you're missing, you have t... | 2013/12/03 | [
"https://wordpress.stackexchange.com/questions/125289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16613/"
] | Im trying to get the category ID from `wp_dropdown_categories();`and then pass the ID into a loop to have it output posts titles from that particular category.
I currently have this:
```
<form action="<?php bloginfo('url'); ?>" method="get">
<?php wp_dropdown_categories(); ?>
</form>
<div class... | You're on the right track with using a `form`, the only thing you're missing, you have to submit what you have selected. For example like this:
```
<form method="GET" action="">
<div>
<?php
$select = wp_dropdown_categories('show_option_none=Select category&orderby=name&echo=0');
$se... |
125,306 | <p>I have tried every way I know about, and have read about, to move the jquery library to the footer including the following and every possible variation of the following:</p>
<pre><code>function add_scripts() {
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://ajax.googleapis.com/... | [
{
"answer_id": 135593,
"author": "David",
"author_id": 48017,
"author_profile": "https://wordpress.stackexchange.com/users/48017",
"pm_score": -1,
"selected": false,
"text": "<p>I did this in my <code>functions.php</code> file and it worked. Of course, you need <code>wp_footer()</code> j... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43462/"
] | I have tried every way I know about, and have read about, to move the jquery library to the footer including the following and every possible variation of the following:
```
function add_scripts() {
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jque... | Use the 5th parameter when using the [wp\_enqueue\_script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) function:
Normally, scripts are placed in `<head>` of the HTML document. If this parameter is true, the script is placed before the end tag. This requires the theme to have the wp\_footer() templ... |
125,308 | <p>I know I am missing something simple. I am trying to use html to log to footer to learn wp. In theme functions.php:</p>
<pre><code>function myLog() {
echo 'test';
}
</code></pre>
<p>In theme footer within the .siteInfo div:</p>
<pre><code><?php add_action( 'wpmu_new_blog', 'myLog' );?>
</code></pre>... | [
{
"answer_id": 125318,
"author": "saifur",
"author_id": 31689,
"author_profile": "https://wordpress.stackexchange.com/users/31689",
"pm_score": 0,
"selected": false,
"text": "<p>Write <code>myLog()</code> in theme footer within the <code>.siteInfo</code> div. It will work.</p>\n"
},
... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125308",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43465/"
] | I know I am missing something simple. I am trying to use html to log to footer to learn wp. In theme functions.php:
```
function myLog() {
echo 'test';
}
```
In theme footer within the .siteInfo div:
```
<?php add_action( 'wpmu_new_blog', 'myLog' );?>
```
when a new user creates a new site myLog should ou... | If you want something to display in the footer, you first need to hook it into the footer to display it. So that would look like this:
```
function myLog() {
echo 'test';
}
add_action('wp_footer','myLog');
```
However, this is not at all connected to the data you want, which is when a new user creates a new site... |
125,315 | <p>I am relatively new to Wordpress, but I'm sure there's a way to do what I'd like to do. </p>
<p>I have a container in my template, and on the home page I'd like to specify slightly different padding to this element. </p>
<p>My current CSS is as follows:</p>
<pre><code>#main_content .container {
position: relative... | [
{
"answer_id": 125317,
"author": "saifur",
"author_id": 31689,
"author_profile": "https://wordpress.stackexchange.com/users/31689",
"pm_score": 1,
"selected": false,
"text": "<p>Check the class of body tag, there is a class named home for home page. I hope the following css will help you... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38138/"
] | I am relatively new to Wordpress, but I'm sure there's a way to do what I'd like to do.
I have a container in my template, and on the home page I'd like to specify slightly different padding to this element.
My current CSS is as follows:
```
#main_content .container {
position: relative;
padding: 120px 0;
}
```
... | WordPress [`body_class($class)`](http://codex.wordpress.org/Function_Reference/body_class) is a nice dynamic way to load styles, js for specific body contents. If your theme doesn't support body class add them very simply:
* Open the `header.php` (or the template that contains the `<body>` tag)
* Edit the `<body>` tag... |
125,328 | <p>The nested shortcodes won't parse correctly:</p>
<pre><code>[row]
[col size="6"]...[/col]
[col size="6"]
[row]
[col size="6"]...[/col]
[col size="6"]...[/col]
[/row]
[/col]
[/row]
</code></pre>
<p>From the <a href="http://codex.wordpress.org/Shortcode_API#Nested_... | [
{
"answer_id": 125329,
"author": "Unix",
"author_id": 37313,
"author_profile": "https://wordpress.stackexchange.com/users/37313",
"pm_score": 2,
"selected": false,
"text": "<p>There's a solution for that, actually. The shortcode you are using has the variable $content, whithout the filte... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125328",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38318/"
] | The nested shortcodes won't parse correctly:
```
[row]
[col size="6"]...[/col]
[col size="6"]
[row]
[col size="6"]...[/col]
[col size="6"]...[/col]
[/row]
[/col]
[/row]
```
From the [WordPress documentation](http://codex.wordpress.org/Shortcode_API#Nested_Shortcode... | There's a solution for that, actually. The shortcode you are using has the variable $content, whithout the filter [do\_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode), like this:
```
do_shortcode($content)
```
Open the file where there are the shortcodes and change $content for do\_shortcode($... |
125,349 | <p>I can find everywhere infos on how to get the terms for a specific a post, but I only need the taxonomies names. I mean:</p>
<p>tax: Taxonomy1
terms: term1, term2, etc</p>
<p>tax: Taxonomy2
terms: term1, term2, term3, etc</p>
<p>My post is setted as Taxonomy1.term1, Taxonomy2.term3 OK.</p>
<p>What I want is to k... | [
{
"answer_id": 125355,
"author": "mxml.bernard",
"author_id": 43489,
"author_profile": "https://wordpress.stackexchange.com/users/43489",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$t = get_post_type($post);\n$taxonomies = get_object_taxonomies($t);\n</code></pre>\n\n<p>$taxon... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125349",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | I can find everywhere infos on how to get the terms for a specific a post, but I only need the taxonomies names. I mean:
tax: Taxonomy1
terms: term1, term2, etc
tax: Taxonomy2
terms: term1, term2, term3, etc
My post is setted as Taxonomy1.term1, Taxonomy2.term3 OK.
What I want is to know that my post is on Taxonomy... | I've just found an undocumented function (in wp-includes/taxonomy.php). It's a shortcut that uses get\_object\_taxonomies(): get\_post\_taxonomies($post\_id). It returns the taxonomy names.
Anyway, I've just coded another symple function:
```
function get_taxonomies_info($id){
global $wpdb;
return $wpdb->get_... |
125,362 | <p>I have a theme and I want to show vistors how shortcode format is in <code><pre></code> tag. But when I add shortcode in <code><pre></code>, it shows what shortcode does. I just want to show shortcode format in plain text. How to do that?</p>
| [
{
"answer_id": 125369,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p><strong>A)</strong> If you want to show the <em>shortcode syntax</em> you can try to write it with <em>double ... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42631/"
] | I have a theme and I want to show vistors how shortcode format is in `<pre>` tag. But when I add shortcode in `<pre>`, it shows what shortcode does. I just want to show shortcode format in plain text. How to do that? | **A)** If you want to show the *shortcode syntax* you can try to write it with *double brackets* in the editor:
```
<pre>[[shortcode foo="bar"]]</pre>
```
It will then display as
```
<pre>[shortcode foo="bar"]</pre>
```
on your frontend and it will not activate the shortcode callback.
**B)** Or if you want some ... |
125,380 | <p>I can't seem to find a simple reliable way to do this - perhaps?:</p>
<pre><code>// delete row ##
global $wpdb;
$delete = $wpdb->query(
$wpdb->prepare(
"DELETE * FROM `wp_table_name`"
)
);
// return ##
$return = __('Table Emptied.');
if ( $wpdb->last_error ) {
$return = $wpdb->la... | [
{
"answer_id": 125385,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 4,
"selected": true,
"text": "<p>Thanks @s_ha_dum - Truncate does the job nicely:</p>\n\n<pre><code>// delete row ##\nglobal $wpdb;\n$delete = $... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125380",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7968/"
] | I can't seem to find a simple reliable way to do this - perhaps?:
```
// delete row ##
global $wpdb;
$delete = $wpdb->query(
$wpdb->prepare(
"DELETE * FROM `wp_table_name`"
)
);
// return ##
$return = __('Table Emptied.');
if ( $wpdb->last_error ) {
$return = $wpdb->last_error;
}
```
But this... | Thanks @s\_ha\_dum - Truncate does the job nicely:
```
// delete row ##
global $wpdb;
$delete = $wpdb->query("TRUNCATE TABLE `wp_table_name`");
``` |
125,387 | <p>How do I remove the date from the google search results of my posts? </p>
<p>Is this related to WordPress or is it theme-specific?</p>
| [
{
"answer_id": 125397,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 3,
"selected": true,
"text": "<p>Paste this code in <code>functions.php</code></p>\n\n<pre><code>add_filter( 'wpseo_show_date_in_snippet... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | How do I remove the date from the google search results of my posts?
Is this related to WordPress or is it theme-specific? | Paste this code in `functions.php`
```
add_filter( 'wpseo_show_date_in_snippet_preview', false); //Returning false on this will prevent the date from showing up in the snippet preview.
```
Note:
[WordPress SEO api](http://yoast.com/wordpress/seo/api/) |
125,407 | <p>I am trying to set up my blog so that there are different colors for 2 different categories, however, if there is a post that is tagged with neither of these 2 categories I want it to default to green.</p>
<p>Here is my code:</p>
<pre><code> <?php if ( in_category( 'News' )) : ?>
<div class="green"... | [
{
"answer_id": 125408,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": true,
"text": "<p>You should familiarize yourself with PHP, but if you want a default color ( assuming the code below already ... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38829/"
] | I am trying to set up my blog so that there are different colors for 2 different categories, however, if there is a post that is tagged with neither of these 2 categories I want it to default to green.
Here is my code:
```
<?php if ( in_category( 'News' )) : ?>
<div class="green">
<?php elseif ( in_catego... | You should familiarize yourself with PHP, but if you want a default color ( assuming the code below already works ) you could do:
```
<?php if ( in_category( 'News' )) : ?>
<div class="green">
<?php elseif ( in_category('Blog')) : ?>
<div class="orange">
<?php else : ?>
<div class="pink">
<?php endif; ?>
... |
125,412 | <p>On my clients website</p>
<p><a href="http://pacificwomen.org/events/" rel="nofollow">http://pacificwomen.org/events/</a></p>
<p>we are getting the error on the Console and the loader is spinning but doesn't load the page. I' am already attempted many times but still it doesn't work at all. This error mostly happe... | [
{
"answer_id": 125415,
"author": "socki03",
"author_id": 43511,
"author_profile": "https://wordpress.stackexchange.com/users/43511",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like it's not loading jQuery at all, and actually it's commented out. So, none of your (All In One Even... | 2013/12/04 | [
"https://wordpress.stackexchange.com/questions/125412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34221/"
] | On my clients website
<http://pacificwomen.org/events/>
we are getting the error on the Console and the loader is spinning but doesn't load the page. I' am already attempted many times but still it doesn't work at all. This error mostly happens when jQuery is not loading on page. But I' am already loading jQuery, Wel... | Looks like it's not loading jQuery at all, and actually it's commented out. So, none of your (All In One Event Calendar's) subsequent jQuery is firing.
Take a look at [WP Tuts' article on how to enqueue scripts](http://wp.tutsplus.com/tutorials/the-ins-and-outs-of-the-enqueue-script-for-wordpress-themes-and-plugins/).... |
125,443 | <p>The documentation says:</p>
<blockquote>
<p>Checks the list of defined functions, both built-in (internal) and user-defined, for function_name. ( <strong>SOURCE:</strong> <a href="http://php.net/manual/en/function.function-exists.php" rel="nofollow">http://php.net/manual/en/function.function-exists.php</a>)</p>
<... | [
{
"answer_id": 125447,
"author": "sun",
"author_id": 35819,
"author_profile": "https://wordpress.stackexchange.com/users/35819",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Yes</strong> the php function <strong><a href=\"http://php.net/manual/en/function.function-exists.php\" r... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125443",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41479/"
] | The documentation says:
>
> Checks the list of defined functions, both built-in (internal) and user-defined, for function\_name. ( **SOURCE:** <http://php.net/manual/en/function.function-exists.php>)
>
>
>
Does the function merely scan the single php document using function\_exists, looking for any functions that... | `function_exists('f')` will check if a function `f` was declared before the call to function\_exists. Therefor the direct answer to your question is - in the functions section of the interpreter memory.
The result of `function_exists` do not only depend on the file in which the function is declared and the file in whi... |
125,446 | <pre><code>add_action( $hook, $function_to_add, $priority, $accepted_args );
</code></pre>
<p>I am unenable to understand what the code is used for?
What are the inbuilt parameters and functions are mostly used in add_action?</p>
| [
{
"answer_id": 125454,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>From <a href=\"http://codex.wordpress.org/Function_Reference/add_action\" rel=\"nofollow\">Codex</a>:... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125446",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43445/"
] | ```
add_action( $hook, $function_to_add, $priority, $accepted_args );
```
I am unenable to understand what the code is used for?
What are the inbuilt parameters and functions are mostly used in add\_action? | From [Codex](http://codex.wordpress.org/Function_Reference/add_action):
>
> **Usage**
>
>
>
> ```
> add_action( $hook, $function_to_add, $priority, $accepted_args );
>
> ```
>
> **Parameters**
>
>
> `$hook`
>
>
> (string) (required) The name of the action to which $function\_to\_add is hooked. (See Plugin AP... |
125,469 | <p>I am using wp site where registered users have authors roles.</p>
<p>I want authors to have permissions to <strong>edit their own comments</strong>. Now only admin user have capability to edit comments and even editors do not have this capability.</p>
<p>I tried plugins like Role Scoper or Members but they don't h... | [
{
"answer_id": 126240,
"author": "cytofu",
"author_id": 43825,
"author_profile": "https://wordpress.stackexchange.com/users/43825",
"pm_score": 1,
"selected": false,
"text": "<p>The role needs \"edit_post\" capability to edit comments (the reason beeing that comments are posts for wordpr... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16650/"
] | I am using wp site where registered users have authors roles.
I want authors to have permissions to **edit their own comments**. Now only admin user have capability to edit comments and even editors do not have this capability.
I tried plugins like Role Scoper or Members but they don't have this capabilities | The role needs "edit\_post" capability to edit comments (the reason beeing that comments are posts for wordpress)
--> do your authors have "edit\_post" capability?
this enables the role to edit posts also, which might not be desired.
Wordpress capabilites are weird.
There exists a meta capability 'edit\_comment'... |
125,471 | <p>I am new to Wordpress so I don't really know how the rewrite rules should look like. My problem is that I have a custom template in my theme called portfolio-inner.php</p>
<p>My rule looks something like that <code>['portfolio/php/wordpress'] => 'portfolio-inner/?galid=3'</code>.</p>
<p>The problem is that all ... | [
{
"answer_id": 125531,
"author": "Seamus Leahy",
"author_id": 33106,
"author_profile": "https://wordpress.stackexchange.com/users/33106",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>index.php</code> you see is not the template file. It is pointed to <code>index.php</code> fil... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17148/"
] | I am new to Wordpress so I don't really know how the rewrite rules should look like. My problem is that I have a custom template in my theme called portfolio-inner.php
My rule looks something like that `['portfolio/php/wordpress'] => 'portfolio-inner/?galid=3'`.
The problem is that all the examples show an `index.php... | The `index.php` you see is not the template file. It is pointed to `index.php` file you see in the root of your WordPress installation.
**How does the pretty URL translate into a template file**
1. When a person goes to a URL on your site, the `.htaccess` redirects all requests, that don't match an actual file, to `i... |
125,475 | <p>Now what I need to find a solution of is this issue:</p>
<p>I have 8 authors, and a bunch of posts. All authors have there own adsense (or other affiliate), we wish to show the adds belongings to the authors on there OWN posts.</p>
<p>So the author collects payment (if any) from there own posts, and only from ther... | [
{
"answer_id": 125531,
"author": "Seamus Leahy",
"author_id": 33106,
"author_profile": "https://wordpress.stackexchange.com/users/33106",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>index.php</code> you see is not the template file. It is pointed to <code>index.php</code> fil... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43544/"
] | Now what I need to find a solution of is this issue:
I have 8 authors, and a bunch of posts. All authors have there own adsense (or other affiliate), we wish to show the adds belongings to the authors on there OWN posts.
So the author collects payment (if any) from there own posts, and only from there own posts.
Is ... | The `index.php` you see is not the template file. It is pointed to `index.php` file you see in the root of your WordPress installation.
**How does the pretty URL translate into a template file**
1. When a person goes to a URL on your site, the `.htaccess` redirects all requests, that don't match an actual file, to `i... |
125,480 | <p>Possibly duplicate of many Question, the reason I am posting here none of them helps, here is the log which appear on Wp-login.php page.</p>
<pre><code>Notice: automatic_feed_links is deprecated since version 3.0! Use add_theme_support( 'automatic-feed-links' ) instead. in /home/truckgua/public_html/test2/wp-includ... | [
{
"answer_id": 125485,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n <p>Now Here is what I have already did to make it work:</p>\n \n <ol>\n <li>Disabling... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27526/"
] | Possibly duplicate of many Question, the reason I am posting here none of them helps, here is the log which appear on Wp-login.php page.
```
Notice: automatic_feed_links is deprecated since version 3.0! Use add_theme_support( 'automatic-feed-links' ) instead. in /home/truckgua/public_html/test2/wp-includes/functions.p... | >
> Now Here is what I have already did to make it work:
>
>
> 1. Disabling plugin from FTP
>
>
>
Which plugin?
>
> 1. Switching theme by renaming the selected theme folder
> 2. Checking for Space after and before,
>
>
>
After and before what?
>
> 1. Replacing WP files with fresh download
>
>
>
You s... |
125,488 | <p>In Wordpress Multisite,a site admin (not a super admin) doesn't have the option “Add the user without sending them a confirmation email” when adding a new user.
Is there a way to bypass the confirmation email or to add this option also for site admin ?
Many thanks</p>
| [
{
"answer_id": 125528,
"author": "Seamus Leahy",
"author_id": 33106,
"author_profile": "https://wordpress.stackexchange.com/users/33106",
"pm_score": 2,
"selected": false,
"text": "<p>You will not be able to enable the checkbox for non-super-admins as the code for it shows:</p>\n\n<pre><... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43547/"
] | In Wordpress Multisite,a site admin (not a super admin) doesn't have the option “Add the user without sending them a confirmation email” when adding a new user.
Is there a way to bypass the confirmation email or to add this option also for site admin ?
Many thanks | You will not be able to enable the checkbox for non-super-admins as the code for it shows:
```
<?php if ( is_multisite() && is_super_admin() ) { ?>
<tr>
<th scope="row"><label for="noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th>
<td><label for="noconfirmation"><input type="checkbox" name="n... |
125,490 | <p>I have set up a custom post type and taxonomy. The post type is called Local Services and the hierarchical taxonomy is called Regions. The Regions have child categories called Areas. I have set up a custom page to display my results. So far I have managed to display the latest 10 posts. But what I NEED to do is ... | [
{
"answer_id": 125948,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p>Like I said in the comment, this can be solved by using two dropdowns. Additionally I already hinte... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125490",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37971/"
] | I have set up a custom post type and taxonomy. The post type is called Local Services and the hierarchical taxonomy is called Regions. The Regions have child categories called Areas. I have set up a custom page to display my results. So far I have managed to display the latest 10 posts. But what I NEED to do is display... | Like I said in the comment, this can be solved by using two dropdowns. Additionally I already hinted you to an [answer](https://wordpress.stackexchange.com/a/125291/22534) of mine doing this for a simple, one level, non conditional category selection. Category dropdowns can easily constructed with wordpress by making u... |
125,494 | <p>I'm trying to figure out how I can check if a custom attribute is set in woocommerce on a product. As It generates an error if that particular attribute isn't set.</p>
<p>Here is my code that pulls in the attribute.</p>
<pre><code><?php
$terms = get_the_terms( $post->ID, 'pa_size');
if ( iss... | [
{
"answer_id": 125495,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": true,
"text": "<p>Simply check this by using:</p>\n\n<pre><code>if ( $terms && ! is_wp_error( $terms ) ) {\n ... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125494",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34257/"
] | I'm trying to figure out how I can check if a custom attribute is set in woocommerce on a product. As It generates an error if that particular attribute isn't set.
Here is my code that pulls in the attribute.
```
<?php
$terms = get_the_terms( $post->ID, 'pa_size');
if ( isset ($terms)) // checking if... | Simply check this by using:
```
if ( $terms && ! is_wp_error( $terms ) ) {
//your code
}
```
Take a look at the codex page for [`get_the_terms()`](http://codex.wordpress.org/Function_Reference/get_the_terms) for a deeper insight, especially the »Returns« and »Examples« section. |
125,498 | <p>I want to get post url from the back end edit post page,
the edit post url is : www.ddd.com/wp-admin/post.php?post=1&action=edit
the real post is: www.ddd.com/wp/?p=1</p>
<p>since the user can edit permalink, i need some wordpress parametrs so it will be constant.</p>
<p>Looking for this answer:</p>
<pre><co... | [
{
"answer_id": 125520,
"author": "stianlik",
"author_id": 39102,
"author_profile": "https://wordpress.stackexchange.com/users/39102",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the 'current_screen' hook and <code>get_permalink()</code>:</p>\n\n<pre><code>add_action( 'curre... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41168/"
] | I want to get post url from the back end edit post page,
the edit post url is : www.ddd.com/wp-admin/post.php?post=1&action=edit
the real post is: www.ddd.com/wp/?p=1
since the user can edit permalink, i need some wordpress parametrs so it will be constant.
Looking for this answer:
```
global $post;
get_permalink... | You can get the `ID` of the post you're editing like this:
```
//currently edited post id
$cep_id = $_GET['post'];
//permalink
get_permalink( $cep_id );
```
This is and can only work if your editing an existing/saved post. It won't and can't work on »Add New«-Pages, because the post you're going to add isn't saved ... |
125,535 | <p>I am writing a plugin and I'm currently implementing my admin menu using the wordpress <a href="http://codex.wordpress.org/Settings_API" rel="nofollow">settins API</a>. As always with API's, it facilitates programming to a certain degree, but it seems like I have an issue:</p>
<p>I need to wrap custom html around t... | [
{
"answer_id": 125745,
"author": "Jason D. Moss",
"author_id": 28062,
"author_profile": "https://wordpress.stackexchange.com/users/28062",
"pm_score": 3,
"selected": true,
"text": "<p>I've just run across this same issue myself on a project I am currently working on.</p>\n\n<p>Basically,... | 2013/12/05 | [
"https://wordpress.stackexchange.com/questions/125535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26286/"
] | I am writing a plugin and I'm currently implementing my admin menu using the wordpress [settins API](http://codex.wordpress.org/Settings_API). As always with API's, it facilitates programming to a certain degree, but it seems like I have an issue:
I need to wrap custom html around those sections. For example I want to... | I've just run across this same issue myself on a project I am currently working on.
Basically, what I did was break my settings into groups so they can then be displayed as a separate section(s):
```
<?php
class MyPluginSettings
{
/**
* Constructor.
*
* @return void
* @access public
*/
... |
125,559 | <p>I am making a template page name new_template.php,here i want to add a feature image source.
how to add featured image source on this blank page. and when i add featured image then the description content is not displaying.
thanks</p>
| [
{
"answer_id": 125745,
"author": "Jason D. Moss",
"author_id": 28062,
"author_profile": "https://wordpress.stackexchange.com/users/28062",
"pm_score": 3,
"selected": true,
"text": "<p>I've just run across this same issue myself on a project I am currently working on.</p>\n\n<p>Basically,... | 2013/12/06 | [
"https://wordpress.stackexchange.com/questions/125559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43574/"
] | I am making a template page name new\_template.php,here i want to add a feature image source.
how to add featured image source on this blank page. and when i add featured image then the description content is not displaying.
thanks | I've just run across this same issue myself on a project I am currently working on.
Basically, what I did was break my settings into groups so they can then be displayed as a separate section(s):
```
<?php
class MyPluginSettings
{
/**
* Constructor.
*
* @return void
* @access public
*/
... |
125,577 | <p>I would like to query out only posts that have comments. So posts with comment_count = 0 won't show but anything above that will.</p>
<p>This is what i query but it still picks out posts that doesen't have comments. Is there another way?</p>
<pre><code>query_posts(array('comment_count' > 0, 'post_type' => 'l... | [
{
"answer_id": 125580,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": 1,
"selected": false,
"text": "<p>By using the query below(not tested) you will be able to get all the ids of posts that have comments.</p>\n\n<pre... | 2013/12/06 | [
"https://wordpress.stackexchange.com/questions/125577",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11348/"
] | I would like to query out only posts that have comments. So posts with comment\_count = 0 won't show but anything above that will.
This is what i query but it still picks out posts that doesen't have comments. Is there another way?
```
query_posts(array('comment_count' > 0, 'post_type' => 'letters', 'showposts' => 10... | I ran into this same problem recently and developed a good solution that maintains paging (which some of the answers here do not) and also allows for only targeting certain comment types and comment approved statuses.
```
function has_comments_join( $join, &$wp_query ) {
global $wpdb;
if ($comment_term = $wp_q... |
125,616 | <p>Here is my rewrite rule code:</p>
<pre><code>add_rewrite_rule('tides/([^/]+)/([^/]*)', 'index.php?page_id=4348&location=$matches[1]&month=$matches[2]', 'top');
add_rewrite_tag('%location%', '([^&]+)');
add_rewrite_tag('%month%', '([^&]*)');
</code></pre>
<p>This works great for the following URL:</... | [
{
"answer_id": 125618,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>Your second example URL doesn't match the pattern you defined in your rewrite rule. You need to add another rule t... | 2013/12/06 | [
"https://wordpress.stackexchange.com/questions/125616",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43593/"
] | Here is my rewrite rule code:
```
add_rewrite_rule('tides/([^/]+)/([^/]*)', 'index.php?page_id=4348&location=$matches[1]&month=$matches[2]', 'top');
add_rewrite_tag('%location%', '([^&]+)');
add_rewrite_tag('%month%', '([^&]*)');
```
This works great for the following URL:
```
/tides/mylocation/mymonth/
```
but 4... | Your regular expression is requiring the last slash be present which it will not be by default. So the path `tides/mylocation/` is shortened to `tides/mylocation` and then tested. Instead, wrap the last part in an optional group using the `?` and update the match number.
```
add_rewrite_rule('tides/([^/]+)(/([^/]+))?'... |
125,622 | <p>I was given a theme called Orion available from themeforest. I had experienced troubles installing it via GUI (style.css was missing), therefore I did that operation manually by copying Update directory up the directory tree.</p>
<p>Now the theme appears somehow empty/broken. I was wondering whether this specific t... | [
{
"answer_id": 125618,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>Your second example URL doesn't match the pattern you defined in your rewrite rule. You need to add another rule t... | 2013/12/06 | [
"https://wordpress.stackexchange.com/questions/125622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43594/"
] | I was given a theme called Orion available from themeforest. I had experienced troubles installing it via GUI (style.css was missing), therefore I did that operation manually by copying Update directory up the directory tree.
Now the theme appears somehow empty/broken. I was wondering whether this specific theme is me... | Your regular expression is requiring the last slash be present which it will not be by default. So the path `tides/mylocation/` is shortened to `tides/mylocation` and then tested. Instead, wrap the last part in an optional group using the `?` and update the match number.
```
add_rewrite_rule('tides/([^/]+)(/([^/]+))?'... |
125,634 | <p>How do I use update_option to give me a new option name each time a form is submitted? The code I'm using now overwrites the database value. Instead I need to have a new address saved each time.</p>
<p>The code:</p>
<pre><code> // assign addrss to var
$address = esc_html( $_P... | [
{
"answer_id": 125635,
"author": "user564285",
"author_id": 18958,
"author_profile": "https://wordpress.stackexchange.com/users/18958",
"pm_score": -1,
"selected": false,
"text": "<p>submit data as array, and add to array before submit</p>\n\n<pre><code>$all_data = get_option('all_data',... | 2013/12/06 | [
"https://wordpress.stackexchange.com/questions/125634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43564/"
] | How do I use update\_option to give me a new option name each time a form is submitted? The code I'm using now overwrites the database value. Instead I need to have a new address saved each time.
The code:
```
// assign addrss to var
$address = esc_html( $_POST['address'] );
... | To update a new option name each time you need something unique to be used as option name so may be using 'time' in the option name
```
$now = new DateTime();
$mytime = $now->format('Y-m-d H:i:s'); // MySQL datetime format
// $now->getTimestamp(); // Unix Timestamp
$option['prefix-'.$mytime] = 'your valu... |
125,651 | <p>I have a custom theme where I've tried to integrate the Infinite Scroll option within JetPack. Per <a href="http://jetpack.me/support/infinite-scroll/" rel="nofollow">this article</a>, I've added the following code to functions.php (in addition to activating the module) - </p>
<pre><code><?php
add_theme_sup... | [
{
"answer_id": 126026,
"author": "Sarah",
"author_id": 39063,
"author_profile": "https://wordpress.stackexchange.com/users/39063",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried adding <code>'type' => 'click'</code> under <code>'footer' => 'page',</code> to see if the... | 2013/12/07 | [
"https://wordpress.stackexchange.com/questions/125651",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | I have a custom theme where I've tried to integrate the Infinite Scroll option within JetPack. Per [this article](http://jetpack.me/support/infinite-scroll/), I've added the following code to functions.php (in addition to activating the module) -
```
<?php
add_theme_support( 'infinite-scroll', array(
... | Have you tried adding `'type' => 'click'` under `'footer' => 'page',` to see if the Jetpack works with click rather than the default scroll?
It is also worth going to Settings -> Reading in the admin panel... does it say "To infinity and beyond....We've disabled this option for you since you have footer widgets in App... |
125,669 | <p>I am developing a plugin in which i am required to allow front end users to upload media, which I am able to do. But I don't want to let them sneak into media library which comes as tab with uploader screen.</p>
<p>I tried the following</p>
<pre><code>function remove_medialibrary_tab($tabs) {
if ( !current_use... | [
{
"answer_id": 125690,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p><strike>The function <code>media_upload_tabs()</code> is not deprecated. It is called only by <code>the_media_uplo... | 2013/12/07 | [
"https://wordpress.stackexchange.com/questions/125669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36972/"
] | I am developing a plugin in which i am required to allow front end users to upload media, which I am able to do. But I don't want to let them sneak into media library which comes as tab with uploader screen.
I tried the following
```
function remove_medialibrary_tab($tabs) {
if ( !current_user_can( 'administrator... | **This function will not show media library tab in upload screen**
```
function remove_medialibrary_tab($strings) {
if ( !current_user_can( 'administrator' ) ) {
unset($strings["mediaLibraryTitle"]);
return $strings;
}
else
{
return $strings;
}... |
125,672 | <p>I'm tring to use <code>str_replace</code> within a wordpress function but its not working.</p>
<p>My code:</p>
<pre><code>function fields($content) {
if(is_feed()) {
$post_id = get_the_ID();
$url = str_replace('http://', '', '' . get_post_meta($post_id, 'book-author', true) . '');
$output = '<... | [
{
"answer_id": 125690,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p><strike>The function <code>media_upload_tabs()</code> is not deprecated. It is called only by <code>the_media_uplo... | 2013/12/07 | [
"https://wordpress.stackexchange.com/questions/125672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23841/"
] | I'm tring to use `str_replace` within a wordpress function but its not working.
My code:
```
function fields($content) {
if(is_feed()) {
$post_id = get_the_ID();
$url = str_replace('http://', '', '' . get_post_meta($post_id, 'book-author', true) . '');
$output = '<div>';
$output .= '' .url. '';... | **This function will not show media library tab in upload screen**
```
function remove_medialibrary_tab($strings) {
if ( !current_user_can( 'administrator' ) ) {
unset($strings["mediaLibraryTitle"]);
return $strings;
}
else
{
return $strings;
}... |
125,680 | <p>I'm using a custom form field on a Custom Taxonomy to hold various data. All working well except in one particular case where I'm trying to save an iframe embed code (from Bandcamp) which is to be echoed in a template later. Wordpress is inserting \ before any " in the output.</p>
<p>I've tried using <code>htmlspec... | [
{
"answer_id": 125690,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p><strike>The function <code>media_upload_tabs()</code> is not deprecated. It is called only by <code>the_media_uplo... | 2013/12/07 | [
"https://wordpress.stackexchange.com/questions/125680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43615/"
] | I'm using a custom form field on a Custom Taxonomy to hold various data. All working well except in one particular case where I'm trying to save an iframe embed code (from Bandcamp) which is to be echoed in a template later. Wordpress is inserting \ before any " in the output.
I've tried using `htmlspecialchars` on my... | **This function will not show media library tab in upload screen**
```
function remove_medialibrary_tab($strings) {
if ( !current_user_can( 'administrator' ) ) {
unset($strings["mediaLibraryTitle"]);
return $strings;
}
else
{
return $strings;
}... |
125,681 | <p>I want to find out gender of commenter and based on that, assign a display picture of commenter who don't have any picture, based on their gender, i.e if a male commenter has no picture, it should assign it a male avatar. I have. I am unable to find ways to query gender.How can i make something like that? And where ... | [
{
"answer_id": 125706,
"author": "henrywright",
"author_id": 22599,
"author_profile": "https://wordpress.stackexchange.com/users/22599",
"pm_score": 0,
"selected": false,
"text": "<p>Install BuddyPress, then create xProfile fields such as name, location, <strong>gender</strong> and so on... | 2013/12/07 | [
"https://wordpress.stackexchange.com/questions/125681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33028/"
] | I want to find out gender of commenter and based on that, assign a display picture of commenter who don't have any picture, based on their gender, i.e if a male commenter has no picture, it should assign it a male avatar. I have. I am unable to find ways to query gender.How can i make something like that? And where sho... | As per the comments above, you can't have this functionality directly. So we need to add this functionality as per the steps given below.
1. Add the gender field in the comment form.
2. Save the gender as meta data of that comment.
3. Change the get avatar functionality of the comment to pass the default url as per ge... |
125,684 | <p>When pulling numeric data ( a number ) which has been saved to post_meta when editing a page - for example:</p>
<pre><code>$number = get_post_meta( $post->ID, 'number', true );
</code></pre>
<p>And then using that value with get_posts in a meta_query - for example:</p>
<pre><code>$args = array (
'posts_pe... | [
{
"answer_id": 125687,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>The key and value in the <a href=\"https://codex.wordpress.org/Database_Description#Table%3a_wp_postmeta\" re... | 2013/12/07 | [
"https://wordpress.stackexchange.com/questions/125684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7968/"
] | When pulling numeric data ( a number ) which has been saved to post\_meta when editing a page - for example:
```
$number = get_post_meta( $post->ID, 'number', true );
```
And then using that value with get\_posts in a meta\_query - for example:
```
$args = array (
'posts_per_page' => 4, // limit ##
'pos... | The key and value in the [postmeta table](https://codex.wordpress.org/Database_Description#Table%3a_wp_postmeta) are technically always strings. even if you were to cast your `string` to an `int` it would be cast to a `string` by the query. Try:
```
$args = array (
'post_type' => 'post',
'meta_query' ... |
125,692 | <p>I use this after I checked if the user is admin</p>
<pre><code> if ( isset($_GET['action']) && $_GET['action'] === 'edit' )
</code></pre>
<p>is there better way?</p>
| [
{
"answer_id": 125694,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 6,
"selected": true,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_current_screen\" rel=\"noref... | 2013/12/07 | [
"https://wordpress.stackexchange.com/questions/125692",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41168/"
] | I use this after I checked if the user is admin
```
if ( isset($_GET['action']) && $_GET['action'] === 'edit' )
```
is there better way? | You can use [`get_current_screen`](http://codex.wordpress.org/Function_Reference/get_current_screen) to determine this.
```
$screen = get_current_screen();
if ( $screen->parent_base == 'edit' ) {
echo 'edit screen';
}
```
I don't know if I exactly would say this is always better, it depends on what's needed, but... |
125,719 | <p>This should b really easy but I can't find reference - easy points for someone!</p>
<p>I have an option in my <code>wp_options</code> table, and need to set it via <code>update_option()</code>. I just can't find the correct syntax for doing something similar to the following where I update the key <code>object_key... | [
{
"answer_id": 125721,
"author": "Brian",
"author_id": 2527,
"author_profile": "https://wordpress.stackexchange.com/users/2527",
"pm_score": 1,
"selected": false,
"text": "<p>Sorry for being dense, you need to grab the object, overwrite the key you want to set and then save the updated o... | 2013/12/08 | [
"https://wordpress.stackexchange.com/questions/125719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2527/"
] | This should b really easy but I can't find reference - easy points for someone!
I have an option in my `wp_options` table, and need to set it via `update_option()`. I just can't find the correct syntax for doing something similar to the following where I update the key `object_key` in the option `my_plugin_settings` w... | Sorry for being dense, you need to grab the object, overwrite the key you want to set and then save the updated object as the new option:
```
$my_plugin_settings = get_option('my_plugin_settings');
$my_plugin_settings->object_key = 'new_value';
update_option('my_plugin_settings', $my_plugin_settings);
``` |
125,729 | <p>My page ID is: <code>30601</code>.</p>
<p>I want to get the page's title with ID.</p>
| [
{
"answer_id": 125730,
"author": "metodiew",
"author_id": 29360,
"author_profile": "https://wordpress.stackexchange.com/users/29360",
"pm_score": 6,
"selected": true,
"text": "<p>Try with this:</p>\n\n<pre><code><?php echo get_the_title( $ID ); ?>\n</code></pre>\n"
},
{
"an... | 2013/12/08 | [
"https://wordpress.stackexchange.com/questions/125729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43406/"
] | My page ID is: `30601`.
I want to get the page's title with ID. | Try with this:
```
<?php echo get_the_title( $ID ); ?>
``` |
125,733 | <p>For a particular project, I'm currently using only wp's admin and core functions/sugars, so no themes. Still, I'm forced to choose a theme.</p>
<p>I would like a couple of things:</p>
<ol>
<li><p>move theme's functions.php (that currently contains only custom code by me) in /wp-contents, outside the themes and mak... | [
{
"answer_id": 125730,
"author": "metodiew",
"author_id": 29360,
"author_profile": "https://wordpress.stackexchange.com/users/29360",
"pm_score": 6,
"selected": true,
"text": "<p>Try with this:</p>\n\n<pre><code><?php echo get_the_title( $ID ); ?>\n</code></pre>\n"
},
{
"an... | 2013/12/08 | [
"https://wordpress.stackexchange.com/questions/125733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | For a particular project, I'm currently using only wp's admin and core functions/sugars, so no themes. Still, I'm forced to choose a theme.
I would like a couple of things:
1. move theme's functions.php (that currently contains only custom code by me) in /wp-contents, outside the themes and make WP still load it
2. f... | Try with this:
```
<?php echo get_the_title( $ID ); ?>
``` |
125,740 | <p>We have a sidebar consisting of some text.</p>
<p>The client/owner will want to change the sidebar text occasionally. Out of the box he'll have to do this by navigating:</p>
<p>-> Admin menu<br>
-> Appearance<br>
-> Widgets<br>
-> look past the "Available Widgets" (all of which are irrelevant to him) to <strong>Pr... | [
{
"answer_id": 125730,
"author": "metodiew",
"author_id": 29360,
"author_profile": "https://wordpress.stackexchange.com/users/29360",
"pm_score": 6,
"selected": true,
"text": "<p>Try with this:</p>\n\n<pre><code><?php echo get_the_title( $ID ); ?>\n</code></pre>\n"
},
{
"an... | 2013/12/08 | [
"https://wordpress.stackexchange.com/questions/125740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/875/"
] | We have a sidebar consisting of some text.
The client/owner will want to change the sidebar text occasionally. Out of the box he'll have to do this by navigating:
-> Admin menu
-> Appearance
-> Widgets
-> look past the "Available Widgets" (all of which are irrelevant to him) to **Primary Sidebar** on the rig... | Try with this:
```
<?php echo get_the_title( $ID ); ?>
``` |
125,741 | <p>I have a custom post type:products
to have my post from my custom post type i have changeed these codes </p>
<pre><code><?php
$post_count = 1;
?>
<?php if (have_posts()) : while ( have_posts() ) : the_post() ?>
</code></pre>
<p>to</p>
<pre><code>?php
$post_count = 1; $args = array( ... | [
{
"answer_id": 125744,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>you can try wordpress query like</p>\n\n<pre><code>$args = array(\n 'post_type' => 'any'\n);\n$quer... | 2013/12/08 | [
"https://wordpress.stackexchange.com/questions/125741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43163/"
] | I have a custom post type:products
to have my post from my custom post type i have changeed these codes
```
<?php
$post_count = 1;
?>
<?php if (have_posts()) : while ( have_posts() ) : the_post() ?>
```
to
```
?php
$post_count = 1; $args = array( 'post_type' => 'products' ); $pro... | ```
function namespace_add_custom_types( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'post_type1', 'post_type2'
));
return $query;
}
}
add_filter( 'pre_get_posts', 'namespace_add_custom_types' );
`... |
125,754 | <p><strong>Members Loop Query</strong> </p>
<p><code><?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?></code></p>
<p><strong>Question: How can this function be integrated into the members loop so that Female members are served a directory of males and male members are served a directory of fe... | [
{
"answer_id": 125765,
"author": "henrywright",
"author_id": 22599,
"author_profile": "https://wordpress.stackexchange.com/users/22599",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the 'include' parameter to pass a string of comma separated user IDs\n<a href=\"http://codex.... | 2013/12/08 | [
"https://wordpress.stackexchange.com/questions/125754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17636/"
] | **Members Loop Query**
`<?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>`
**Question: How can this function be integrated into the members loop so that Female members are served a directory of males and male members are served a directory of females?\*\***
```
<?php
class BP_Custom_User... | Here is the solution that we discussed on
<http://buddypress.org/support/topic/filter-members-list-based-on-profile-field/>
It is based on <http://codex.buddypress.org/developer/bp_user_query/#code-examples>
```
class BP_Custom_User_Ids {
private $custom_ids = array();
public function __construct() {
... |
125,781 | <p>I'm grabbing URLs of my Gallery images:</p>
<pre><code>$gallery = get_post_gallery_images( $post );
foreach($gallery as $thumbnail) {
echo $thumbnail_slideshow;
}
</code></pre>
<p>The problem is all I'm getting are thumbnails:</p>
<pre><code>image1-150x150.jpg
image2-150x150.jpg
image3-150x150.jpg
</code><... | [
{
"answer_id": 125765,
"author": "henrywright",
"author_id": 22599,
"author_profile": "https://wordpress.stackexchange.com/users/22599",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the 'include' parameter to pass a string of comma separated user IDs\n<a href=\"http://codex.... | 2013/12/08 | [
"https://wordpress.stackexchange.com/questions/125781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I'm grabbing URLs of my Gallery images:
```
$gallery = get_post_gallery_images( $post );
foreach($gallery as $thumbnail) {
echo $thumbnail_slideshow;
}
```
The problem is all I'm getting are thumbnails:
```
image1-150x150.jpg
image2-150x150.jpg
image3-150x150.jpg
```
And I want to get:
```
image1-600x100.... | Here is the solution that we discussed on
<http://buddypress.org/support/topic/filter-members-list-based-on-profile-field/>
It is based on <http://codex.buddypress.org/developer/bp_user_query/#code-examples>
```
class BP_Custom_User_Ids {
private $custom_ids = array();
public function __construct() {
... |
125,784 | <p>I want to upload my custom image sizes in custom folders. The folder should have the name of the selected width. For example:</p>
<p>If I add these custom sizes...</p>
<pre><code>add_image_size('custom-1', 300, 9999);
add_image_size('custom-2', 400, 9999);
</code></pre>
<p>It would be nice the uploaded images are... | [
{
"answer_id": 126242,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>I've looked at these parts of WordPress code and I'm afraid I don't have any good news.</p>\n\n<p>The... | 2013/12/08 | [
"https://wordpress.stackexchange.com/questions/125784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21207/"
] | I want to upload my custom image sizes in custom folders. The folder should have the name of the selected width. For example:
If I add these custom sizes...
```
add_image_size('custom-1', 300, 9999);
add_image_size('custom-2', 400, 9999);
```
It would be nice the uploaded images are uploaded like this:
```
http://... | Philipp, anything is possible if you set your mind to it. You can solve your issue by extending the WordPress image editor class.
*Note I'm using WordPress 3.7 - I haven't checked any of the below code in earlier versions and in the latest 3.8 release.*
Image Editor basics
-------------------
WordPress has two built... |
125,800 | <p>anyone know how to custom box that contain "<code>Publish,save draft,and preview button</code>" ?
i'll hide all button except Publish button.
and same as "<code>change permalink</code>" also "<code>view,delete,edit</code>" link inside post how to hide the permalink and view link ?</p>
<p>here the illustration what ... | [
{
"answer_id": 125813,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 5,
"selected": true,
"text": "<p>You can accomplish the above using hooks. Use the code below in your active theme's <strong><code>funct... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43610/"
] | anyone know how to custom box that contain "`Publish,save draft,and preview button`" ?
i'll hide all button except Publish button.
and same as "`change permalink`" also "`view,delete,edit`" link inside post how to hide the permalink and view link ?
here the illustration what i talking about.
>
> Customizing Publish ... | You can accomplish the above using hooks. Use the code below in your active theme's **`functions.php`** file to get this work
>
> delete permalink under wordpress post title
>
>
>
```
add_filter( 'get_sample_permalink_html', 'wpse_125800_sample_permalink' );
function wpse_125800_sample_permalink( $return ) {
... |
125,805 | <p>Can anyone tell me how to auto fill/add same image title in title, caption, alt text and description while uploading any image in my WordPress Posts.</p>
<p><img src="https://i.stack.imgur.com/fdkIb.jpg" alt="desired screenshot"></p>
| [
{
"answer_id": 212388,
"author": "Webloper",
"author_id": 29035,
"author_profile": "https://wordpress.stackexchange.com/users/29035",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>You can hook into the 'add_attachment' action from wp-includes/post.php Line:3332. <strong>(... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43655/"
] | Can anyone tell me how to auto fill/add same image title in title, caption, alt text and description while uploading any image in my WordPress Posts.
 | >
> You can hook into the 'add\_attachment' action from wp-includes/post.php Line:3332. **(Version 4.4)**
> It passes in the post\_id and from there you can get the file name and then update the post meta with anything you need to.
>
>
>
[Reference taken from](https://wordpress.stackexchange.com/a/32839/29035)
... |
125,817 | <p>I'm trying to build a search query in PHP in WordPress and I need to get all posts by a specific author in a specific category including drafts.</p>
<p>For example, is it possible to do something like, "status=draft and author=12 and category=7"?</p>
<p>Also, I haven't been able to find the page that shows how to ... | [
{
"answer_id": 212388,
"author": "Webloper",
"author_id": 29035,
"author_profile": "https://wordpress.stackexchange.com/users/29035",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>You can hook into the 'add_attachment' action from wp-includes/post.php Line:3332. <strong>(... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125817",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29247/"
] | I'm trying to build a search query in PHP in WordPress and I need to get all posts by a specific author in a specific category including drafts.
For example, is it possible to do something like, "status=draft and author=12 and category=7"?
Also, I haven't been able to find the page that shows how to build WordPress q... | >
> You can hook into the 'add\_attachment' action from wp-includes/post.php Line:3332. **(Version 4.4)**
> It passes in the post\_id and from there you can get the file name and then update the post meta with anything you need to.
>
>
>
[Reference taken from](https://wordpress.stackexchange.com/a/32839/29035)
... |
125,819 | <p>I'm looking for a way to check if an image has properly created a custom thumbnail size that has been hard cropped. </p>
<pre><code>add_image_size( 'homepage-thumb', 1676, 828, true );
$size = "homepage-thumb";
echo wp_get_attachment_image( $attachment_id, $size );
</code></pre>
<p>This works well if the uploade... | [
{
"answer_id": 125823,
"author": "Nizam Kazi",
"author_id": 29101,
"author_profile": "https://wordpress.stackexchange.com/users/29101",
"pm_score": 0,
"selected": false,
"text": "<p>I guess you can do that using CSS, use Inspect Element facility of browser to confirm. Let me know if you ... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125819",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28824/"
] | I'm looking for a way to check if an image has properly created a custom thumbnail size that has been hard cropped.
```
add_image_size( 'homepage-thumb', 1676, 828, true );
$size = "homepage-thumb";
echo wp_get_attachment_image( $attachment_id, $size );
```
This works well if the uploaded image is large enough bu... | ```
$image_attributes = wp_get_attachment_image_src( $attachment_id, $size );
```
Returns an array containing:
```
[0] => url
[1] => width
[2] => height
[3] => boolean: true if $url is a re-sized image, false if it is the original.
```
Even though you pass the $size as parameter, while returning; it returns the... |
125,842 | <p>This is somewhat of a continued problem from another question that I had asked. Here is the original post.
<a href="https://wordpress.stackexchange.com/questions/124533/pre-get-post-filter-returns-results-when-there-should-not-be/124695#124695">pre_get_post filter returns results when there should not be</a></p>
<p... | [
{
"answer_id": 125823,
"author": "Nizam Kazi",
"author_id": 29101,
"author_profile": "https://wordpress.stackexchange.com/users/29101",
"pm_score": 0,
"selected": false,
"text": "<p>I guess you can do that using CSS, use Inspect Element facility of browser to confirm. Let me know if you ... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125842",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38434/"
] | This is somewhat of a continued problem from another question that I had asked. Here is the original post.
[pre\_get\_post filter returns results when there should not be](https://wordpress.stackexchange.com/questions/124533/pre-get-post-filter-returns-results-when-there-should-not-be/124695#124695)
Since then I added... | ```
$image_attributes = wp_get_attachment_image_src( $attachment_id, $size );
```
Returns an array containing:
```
[0] => url
[1] => width
[2] => height
[3] => boolean: true if $url is a re-sized image, false if it is the original.
```
Even though you pass the $size as parameter, while returning; it returns the... |
125,862 | <p>I have a welcome paragraph on me front page. I did this using sticky post. But the welcome to my website sticky post also shows in my category? Is there a way to have it show on the front page only?</p>
| [
{
"answer_id": 125863,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You will want to instruct the query to ignore sticky posts on category archives.</p>\n\n<pre><code>function ... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125862",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43684/"
] | I have a welcome paragraph on me front page. I did this using sticky post. But the welcome to my website sticky post also shows in my category? Is there a way to have it show on the front page only? | You will want to instruct the query to ignore sticky posts on category archives.
```
function no_sticky_cats_wpse_125862($qry) {
if ($qry->is_main_query() && $qry->is_category()) {
$qry->set('ignore_sticky_posts',true);
}
}
add_action('pre_get_posts','no_sticky_cats_wpse_125862');
``` |
125,873 | <p>I have a plugin that adds custom admin bar items, but I'd like them to appear all the way to the left. I know I can add and remove menu items with <code>$wp_admin_bar->add_menu()</code> etc, but how can I reorder them? </p>
<p>Edit: It looks like the admin bar menu item orders are defined in <a href="https://git... | [
{
"answer_id": 125874,
"author": "Jeppe",
"author_id": 28415,
"author_profile": "https://wordpress.stackexchange.com/users/28415",
"pm_score": -1,
"selected": false,
"text": "<pre><code>function custom_menu_order($menu_ord) { \n if (!$menu_ord) return true; \n\n return array( \n... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26588/"
] | I have a plugin that adds custom admin bar items, but I'd like them to appear all the way to the left. I know I can add and remove menu items with `$wp_admin_bar->add_menu()` etc, but how can I reorder them?
Edit: It looks like the admin bar menu item orders are defined in [wp-includes/class-wp-admin-bar.php](https:/... | This is an old question, but for others in the future the answer is.
You can add the following code to `functions.php`.
```
function reorder_admin_bar() {
global $wp_admin_bar;
// The desired order of identifiers (items)
$IDs_sequence = array(
'wp-logo',
'site-name',
'new-content'... |
125,877 | <p>Is there a way to handle base directories for taxonomies that result in a 404. For example my URLs are:</p>
<p><a href="http://skipology.com/category/" rel="nofollow">http://skipology.com/category/</a>...<br>
<a href="http://skipology.com/app/" rel="nofollow">http://skipology.com/app/</a>...</p>
<p>but the taxonom... | [
{
"answer_id": 125884,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": true,
"text": "<p>You can manually create pages named <code>category</code> and <code>app</code> in admin under the <code>Pages</code... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26824/"
] | Is there a way to handle base directories for taxonomies that result in a 404. For example my URLs are:
<http://skipology.com/category/>...
<http://skipology.com/app/>...
but the taxonomies / base directories above result in 404. Can they be redirected to a taxonomy index page (which I may need to create) for exam... | You can manually create pages named `category` and `app` in admin under the `Pages` menu, and use a [custom page template](http://codex.wordpress.org/Page_Templates) for each to list out taxonomy terms or whatever you need.
EDIT - 301 redirect a request that matches the `pagename` rewrite to another page:
```
functio... |
125,886 | <p>I was wondering how i can remove the prefix from the slugs of custom post types using htaccess rules or any other appropriate method.</p>
<p>Currently my custom post types look like this:</p>
<pre><code>http://www.domain.com/os_estate/5-bedroom-property-for-sale
</code></pre>
<p>and i would simply like this to be... | [
{
"answer_id": 125888,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 0,
"selected": false,
"text": "<p>// Well then, first use a function to mention your custom post types.</p>\n\n<pre><code>function my_custom_po... | 2013/12/09 | [
"https://wordpress.stackexchange.com/questions/125886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I was wondering how i can remove the prefix from the slugs of custom post types using htaccess rules or any other appropriate method.
Currently my custom post types look like this:
```
http://www.domain.com/os_estate/5-bedroom-property-for-sale
```
and i would simply like this to be:
```
http://www.domain.com/5-be... | There is a simpler and lighter solution:
First: set the slug argument for your custom post type to '/' when registering the post type:
```
add_action( 'init', 'register_my_post_type' );
function register_my_post_type() {
$args = array(
//The rest of arguments you are currently using goes here
... |
125,891 | <p><strong>QUESTION:</strong> Is it necessary to include the wordpress loop in page.php? If it is not necessary, why do many themes (including the wordpress 2013 default theme) include it?</p>
<p>I noticed <a href="http://wordpress.org/support/topic/pagephp-and-the-loop?replies=9" rel="nofollow noreferrer">this</a> dis... | [
{
"answer_id": 125888,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 0,
"selected": false,
"text": "<p>// Well then, first use a function to mention your custom post types.</p>\n\n<pre><code>function my_custom_po... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41479/"
] | **QUESTION:** Is it necessary to include the wordpress loop in page.php? If it is not necessary, why do many themes (including the wordpress 2013 default theme) include it?
I noticed [this](http://wordpress.org/support/topic/pagephp-and-the-loop?replies=9) discussion on the wordpress forums, but I didn't understand th... | There is a simpler and lighter solution:
First: set the slug argument for your custom post type to '/' when registering the post type:
```
add_action( 'init', 'register_my_post_type' );
function register_my_post_type() {
$args = array(
//The rest of arguments you are currently using goes here
... |
125,905 | <p>(Using Wordpress 3.7.1) Adding the string <code>define(‘WP_ALLOW_MULTISITE’, true);</code> to my <code>wp-config.php</code> file isn't giving me the 'Network' choice in the Tools menu, even after multiple logouts and waiting a bit. </p>
<p>I didn't anticipate ever needing this feature, but...well..ya know. </p>
<p... | [
{
"answer_id": 125888,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 0,
"selected": false,
"text": "<p>// Well then, first use a function to mention your custom post types.</p>\n\n<pre><code>function my_custom_po... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125905",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43702/"
] | (Using Wordpress 3.7.1) Adding the string `define(‘WP_ALLOW_MULTISITE’, true);` to my `wp-config.php` file isn't giving me the 'Network' choice in the Tools menu, even after multiple logouts and waiting a bit.
I didn't anticipate ever needing this feature, but...well..ya know.
Can anyone help me out with this? I ca... | There is a simpler and lighter solution:
First: set the slug argument for your custom post type to '/' when registering the post type:
```
add_action( 'init', 'register_my_post_type' );
function register_my_post_type() {
$args = array(
//The rest of arguments you are currently using goes here
... |
125,906 | <p>I have an existing legacy PHP site of 15000 users with base64 hashed passwords , I would like to import all these users into the new wordpress site with their passwords , What would be the best approach to realize this?</p>
<p>Praveen</p>
| [
{
"answer_id": 125908,
"author": "Subharanjan",
"author_id": 13615,
"author_profile": "https://wordpress.stackexchange.com/users/13615",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress uses MD5 for encrypting the passwords. So I don't think direct import of users will work here. ... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26393/"
] | I have an existing legacy PHP site of 15000 users with base64 hashed passwords , I would like to import all these users into the new wordpress site with their passwords , What would be the best approach to realize this?
Praveen | You can use `wp_insert_user`. Since your old database has passwords in base64, you can easily get the original password string using `base64_decode`.
```
$new_user_data = array(
'user_pass' => 'password',//pass your decoded password string
'user_login' => 'username',//pass your username
'user_e... |
125,928 | <p>WordPress or my theme fails to embed this video URL:</p>
<p><code>https://www.youtube.com/embed/vsTrAfJFLXI?rel=0?controls=0</code> </p>
<p>but works with this URL:</p>
<pre><code>https://www.youtube.com/watch?v=vsTrAfJFLXI
</code></pre>
<p>I need to get rid of the youtube control buttons in the preview, but ca... | [
{
"answer_id": 125936,
"author": "SixfootJames",
"author_id": 12589,
"author_profile": "https://wordpress.stackexchange.com/users/12589",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried switching off all your plugins and changing the theme to see if anything might be causing... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125928",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34301/"
] | WordPress or my theme fails to embed this video URL:
`https://www.youtube.com/embed/vsTrAfJFLXI?rel=0?controls=0`
but works with this URL:
```
https://www.youtube.com/watch?v=vsTrAfJFLXI
```
I need to get rid of the youtube control buttons in the preview, but cannot use embed or the iframe because that just creat... | Having `&controls=0` instead of `?controls=0`solved the issue for me. |
125,941 | <p>I want to apply this filter from <a href="https://wordpress.stackexchange.com/questions/91720/replace-html-entities-in-posts-between-pre-tags">this question.</a></p>
<pre><code>add_filter( 'the_content', 'pre_content_filter', 0 );
function pre_content_filter( $content ) {
return preg_replace_callback( '|<pr... | [
{
"answer_id": 125942,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>You can use <code>has_filter()</code> to check for registered filers.</p>\n\n<p>Example:</p>\n\n<pre><code>add_filter(... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38849/"
] | I want to apply this filter from [this question.](https://wordpress.stackexchange.com/questions/91720/replace-html-entities-in-posts-between-pre-tags)
```
add_filter( 'the_content', 'pre_content_filter', 0 );
function pre_content_filter( $content ) {
return preg_replace_callback( '|<pre.*>(.*)</pre|isU' , 'conver... | You can use `has_filter()` to check for registered filers.
Example:
```
add_filter( 'the_content', function( $content )
{
if ( has_filter( 'the_content', 'pre_content_filter' ) )
return 'pre_content_filter() is active<br>' . $content;
return $content;
}, -1 );
``` |
125,946 | <p>I want to add quantity field with each product on shop page. I have used </p>
<pre><code><input type="number" step="1" min="1" name="quantity" value="" title="Qty" class="input-text qty text"/>
</code></pre>
<p>code in woocommerce/templates/loop/add-to-cart.php</p>
<p>But its not able to add quantity at the... | [
{
"answer_id": 125961,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>Here is how i modified my loop/add-to-cart.php to achieve this:</p>\n\n<pre><code><?php\n/**\n * Loop Add ... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125946",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41003/"
] | I want to add quantity field with each product on shop page. I have used
```
<input type="number" step="1" min="1" name="quantity" value="" title="Qty" class="input-text qty text"/>
```
code in woocommerce/templates/loop/add-to-cart.php
But its not able to add quantity at the time of submission. Please give me any... | Here is how i modified my loop/add-to-cart.php to achieve this:
```
<?php
/**
* Loop Add to Cart
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $product;
?>
<?php if ( ! $product->is_in_stock() ) :... |
125,947 | <p>I would like to know how I could get the offset of a custom post or its page, outside the get_posts loop.</p>
<p>I developed an external web application which connects to the wordpress blog with JSON API plugin, and show a given posts page using an AJAX request like :</p>
<pre><code>?json=get_posts&orderby=dat... | [
{
"answer_id": 125974,
"author": "temkin",
"author_id": 23245,
"author_profile": "https://wordpress.stackexchange.com/users/23245",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think that you can get an offset of the page outside of the loop, since it will be out of the context.... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43707/"
] | I would like to know how I could get the offset of a custom post or its page, outside the get\_posts loop.
I developed an external web application which connects to the wordpress blog with JSON API plugin, and show a given posts page using an AJAX request like :
```
?json=get_posts&orderby=date&order=desc&count=x&pag... | Thank you for you answers, I finally succeeded to do what I wanted with a custom SQL query :)
Here is how I achieved this :
First, I got the SQL query generated with WP\_QUERY by adding this code :
```
$query = new WP_Query( $query_args );
//write the SQL query
echo $query->request;
```
I got something like :
```... |
125,950 | <p>Without the date - I'm trying to integrate - the code is working: outputting the user with the most comments. But currently I try to get the user with <strong>most comments of today</strong> but that does not work. What am I doing wrong?</p>
<pre><code> <?php
global $wpdb;
$today = date('Y-m-d');
$to... | [
{
"answer_id": 125958,
"author": "Marin Bînzari",
"author_id": 35115,
"author_profile": "https://wordpress.stackexchange.com/users/35115",
"pm_score": 0,
"selected": false,
"text": "<p>Try to replace your <code>where</code> condition variable with this:</p>\n\n<pre><code>$where = 'WHERE ... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43713/"
] | Without the date - I'm trying to integrate - the code is working: outputting the user with the most comments. But currently I try to get the user with **most comments of today** but that does not work. What am I doing wrong?
```
<?php
global $wpdb;
$today = date('Y-m-d');
$tomorrow = date('Y-m-d', time() ... | You can use this query instead to select comments count grouped by user id.
```
SELECT user_id, COUNT( * ) AS total FROM wp_comments WHERE DATE(comment_date) = CURDATE() AND user_id <> 0 GROUP BY user_id
```
by the way, in your where variable you should use $wpdb->prepare() to assign values with variables ( if you... |
125,952 | <p>I just want to redirect the users to their current page after logged in my wordpress website.
I have used the following but it won`t work for me since it is in page that created from the admin side. </p>
<pre><code><?php echo wp_login_url(get_permalink()); ?>
</code></pre>
| [
{
"answer_id": 125955,
"author": "TomC",
"author_id": 36980,
"author_profile": "https://wordpress.stackexchange.com/users/36980",
"pm_score": 1,
"selected": false,
"text": "<p>Try wp_redirect() <a href=\"http://codex.wordpress.org/Function_Reference/wp_redirect\" rel=\"nofollow\">http://... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37788/"
] | I just want to redirect the users to their current page after logged in my wordpress website.
I have used the following but it won`t work for me since it is in page that created from the admin side.
```
<?php echo wp_login_url(get_permalink()); ?>
``` | You can use the [`login_redirect`](http://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect) filter to do this. One of the parameters is `$request`, which
>
> is the URL the user is coming from
>
>
>
```
function wpse125952_redirect_to_request( $redirect_to, $request, $user ){
// instead of usin... |
125,969 | <p>I am having a weird situation, I have two meta keys in my custom posts. Start Date and End Date,</p>
<p>In simple SQL, I want to execute following query</p>
<p><code>where startDate > '2013-12-10' and (startDate <= '2013-12-10' and endDate >= '2013-12-10')</code></p>
<p>I am basically looking for posts w... | [
{
"answer_id": 125955,
"author": "TomC",
"author_id": 36980,
"author_profile": "https://wordpress.stackexchange.com/users/36980",
"pm_score": 1,
"selected": false,
"text": "<p>Try wp_redirect() <a href=\"http://codex.wordpress.org/Function_Reference/wp_redirect\" rel=\"nofollow\">http://... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125969",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1743/"
] | I am having a weird situation, I have two meta keys in my custom posts. Start Date and End Date,
In simple SQL, I want to execute following query
`where startDate > '2013-12-10' and (startDate <= '2013-12-10' and endDate >= '2013-12-10')`
I am basically looking for posts which are between a range of startDate and en... | You can use the [`login_redirect`](http://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect) filter to do this. One of the parameters is `$request`, which
>
> is the URL the user is coming from
>
>
>
```
function wpse125952_redirect_to_request( $redirect_to, $request, $user ){
// instead of usin... |
125,993 | <p>How accurately does the P3 Plugin Profiler plugin measure the loading time of plugins, and what mechanism does it uses to estimate the loading time?</p>
| [
{
"answer_id": 125955,
"author": "TomC",
"author_id": 36980,
"author_profile": "https://wordpress.stackexchange.com/users/36980",
"pm_score": 1,
"selected": false,
"text": "<p>Try wp_redirect() <a href=\"http://codex.wordpress.org/Function_Reference/wp_redirect\" rel=\"nofollow\">http://... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | How accurately does the P3 Plugin Profiler plugin measure the loading time of plugins, and what mechanism does it uses to estimate the loading time? | You can use the [`login_redirect`](http://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect) filter to do this. One of the parameters is `$request`, which
>
> is the URL the user is coming from
>
>
>
```
function wpse125952_redirect_to_request( $redirect_to, $request, $user ){
// instead of usin... |
125,997 | <p>I want to add a link to my site in the admin bar, and make that link the leftmost item in the admin bar. I can add a link with this in a plugin function: </p>
<pre><code>$wp_admin_bar->add_menu( array(
'id' => 'my-link',
'title' => __('MySite'),
'href' => site_url()
) );
</c... | [
{
"answer_id": 126326,
"author": "Charles",
"author_id": 15605,
"author_profile": "https://wordpress.stackexchange.com/users/15605",
"pm_score": 4,
"selected": true,
"text": "<p>If I am correct these are the default positions:</p>\n\n<ul>\n<li>wp_admin_bar_wp_menu - 10<br /></li>\n<li>wp... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/125997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26588/"
] | I want to add a link to my site in the admin bar, and make that link the leftmost item in the admin bar. I can add a link with this in a plugin function:
```
$wp_admin_bar->add_menu( array(
'id' => 'my-link',
'title' => __('MySite'),
'href' => site_url()
) );
```
But I'd like to make it... | If I am correct these are the default positions:
* wp\_admin\_bar\_wp\_menu - 10
* wp\_admin\_bar\_my\_sites\_menu - 20
* wp\_admin\_bar\_site\_menu - 30
* wp\_admin\_bar\_updates\_menu - 40
* wp\_admin\_bar\_comments\_menu - 60
* wp\_admin\_bar\_new\_content\_menu - 70
* wp\_admin\_bar\_edit\_menu - 80
small code sn... |
126,007 | <p>I need to use the following redirect on my site: </p>
<pre><code>RewriteEngine on
RewriteCond %{HTTP_HOST} name.com
RewriteCond %{REQUEST_URI} ^/(1[0-9]{3}|200[0-9]|201[0-3])
RewriteCond %{REQUEST_URI} !/2013/12
RewriteRule ^([0-9]{4})/([0-9]{2})/(.*)$ http://v2.name.com/$1/$2/$3 [NC,R=301]
</code></pre>
<p>How... | [
{
"answer_id": 126013,
"author": "Androliyah",
"author_id": 17636,
"author_profile": "https://wordpress.stackexchange.com/users/17636",
"pm_score": 0,
"selected": false,
"text": "<p>Yes. Deleting the code may cause infinite looping.</p>\n"
},
{
"answer_id": 126014,
"author": ... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/126007",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43736/"
] | I need to use the following redirect on my site:
```
RewriteEngine on
RewriteCond %{HTTP_HOST} name.com
RewriteCond %{REQUEST_URI} ^/(1[0-9]{3}|200[0-9]|201[0-3])
RewriteCond %{REQUEST_URI} !/2013/12
RewriteRule ^([0-9]{4})/([0-9]{2})/(.*)$ http://v2.name.com/$1/$2/$3 [NC,R=301]
```
However, it only works if I d... | Adding the `[L]` flag to the `[NC,R=301]` piece (ie, `[NC,R=301,L]`), which tells the RewriteEngine that the RewriteRule is the last one for the block of `RewriteCond`s, apparently solved the problem.
```
RewriteEngine on
RewriteCond %{HTTP_HOST} name.com
RewriteCond %{REQUEST_URI} ^/(1[0-9]{3}|200[0-9]|201[0-3])
Rew... |
126,024 | <p>When interacting with the admin menu, for instance via <a href="http://codex.wordpress.org/Function_Reference/add_menu_page"><code>add_menu_page</code></a>, there is a <code>$position</code> parameter. The inline docs indicate that this should be an integer. The Codex agrees, but adds a note that you can use a float... | [
{
"answer_id": 126013,
"author": "Androliyah",
"author_id": 17636,
"author_profile": "https://wordpress.stackexchange.com/users/17636",
"pm_score": 0,
"selected": false,
"text": "<p>Yes. Deleting the code may cause infinite looping.</p>\n"
},
{
"answer_id": 126014,
"author": ... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/126024",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12324/"
] | When interacting with the admin menu, for instance via [`add_menu_page`](http://codex.wordpress.org/Function_Reference/add_menu_page), there is a `$position` parameter. The inline docs indicate that this should be an integer. The Codex agrees, but adds a note that you can use a float if you make it a string (e.g. `'63.... | Adding the `[L]` flag to the `[NC,R=301]` piece (ie, `[NC,R=301,L]`), which tells the RewriteEngine that the RewriteRule is the last one for the block of `RewriteCond`s, apparently solved the problem.
```
RewriteEngine on
RewriteCond %{HTTP_HOST} name.com
RewriteCond %{REQUEST_URI} ^/(1[0-9]{3}|200[0-9]|201[0-3])
Rew... |
126,030 | <p>Going to install a wordpress multisite in a subdirectory format. So a new site will be <code>site.com/sitetwo/</code> or <code>site.com/sitethree/</code> but what I need to do for the specific task at hand is change the url to <code>site.com/string/sitetwo</code> </p>
<p>I could easily accomplish it with a second i... | [
{
"answer_id": 126036,
"author": "user42826",
"author_id": 42826,
"author_profile": "https://wordpress.stackexchange.com/users/42826",
"pm_score": 0,
"selected": false,
"text": "<p>You can install <a href=\"http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory\" rel=\"nofollow\">... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/126030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26352/"
] | Going to install a wordpress multisite in a subdirectory format. So a new site will be `site.com/sitetwo/` or `site.com/sitethree/` but what I need to do for the specific task at hand is change the url to `site.com/string/sitetwo`
I could easily accomplish it with a second install of wordpress in the `/string/` folde... | One way to achieve this, is to alter the way WordPress maps the request to a blog in your multisite network by using the `sunrise.php` drop-in. Sunrise overwrite the default setup in `wp-includes/ms-settings.php`. There, a bunch of global variables are set up like `$current_blog` or `$current_site`.
To activate this ... |
126,042 | <p>I'm trying to include a file in the docroot when I'm in the admin area. (Yes, I know this is bad form: I'm only doing it for debugging purposes.) How do I get the fully qualified docroot directory?</p>
| [
{
"answer_id": 126036,
"author": "user42826",
"author_id": 42826,
"author_profile": "https://wordpress.stackexchange.com/users/42826",
"pm_score": 0,
"selected": false,
"text": "<p>You can install <a href=\"http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory\" rel=\"nofollow\">... | 2013/12/10 | [
"https://wordpress.stackexchange.com/questions/126042",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5397/"
] | I'm trying to include a file in the docroot when I'm in the admin area. (Yes, I know this is bad form: I'm only doing it for debugging purposes.) How do I get the fully qualified docroot directory? | One way to achieve this, is to alter the way WordPress maps the request to a blog in your multisite network by using the `sunrise.php` drop-in. Sunrise overwrite the default setup in `wp-includes/ms-settings.php`. There, a bunch of global variables are set up like `$current_blog` or `$current_site`.
To activate this ... |
126,051 | <p>How can I allow a user to register on the site and ignore the error WP throws back if email is already registered - "This email is already registered, please choose another one."</p>
<p>I tried writing my own plugin but it isn't working:</p>
<pre><code>if($errors['field'.$field->id] == 'This email is already r... | [
{
"answer_id": 126066,
"author": "TomC",
"author_id": 36980,
"author_profile": "https://wordpress.stackexchange.com/users/36980",
"pm_score": 1,
"selected": false,
"text": "<p>I'm assuming you've already looked at <code>wp-includes/user.php</code>, which I'm referring to below</p>\n\n<p>... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43746/"
] | How can I allow a user to register on the site and ignore the error WP throws back if email is already registered - "This email is already registered, please choose another one."
I tried writing my own plugin but it isn't working:
```
if($errors['field'.$field->id] == 'This email is already registered, please choose ... | So unfortunately without major revisions to both code and database structure this is not possible because WordPress stores the user email in a "UNIQUE" row in the database. Just unsetting the error message will not solve this issue because the user does not get created. |
126,058 | <p>I'm not sure where the problem lies, but the code below just doesn't have the effect of ordering by ID in descending order.</p>
<pre><code>$args['role'] = 'subscriber';
$args['orderby'] = 'ID';
$args['order'] = 'DESC';
$args['fields'] = 'all_with_meta';
$args['meta_query'] = $meta_query; // $meta_query is an ... | [
{
"answer_id": 126060,
"author": "josh",
"author_id": 24323,
"author_profile": "https://wordpress.stackexchange.com/users/24323",
"pm_score": 2,
"selected": false,
"text": "<p>Try putting the args into an array.</p>\n\n<pre><code>$args = array(\n 'role' => 'subscriber',\n ... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41357/"
] | I'm not sure where the problem lies, but the code below just doesn't have the effect of ordering by ID in descending order.
```
$args['role'] = 'subscriber';
$args['orderby'] = 'ID';
$args['order'] = 'DESC';
$args['fields'] = 'all_with_meta';
$args['meta_query'] = $meta_query; // $meta_query is an array specifie... | Try putting the args into an array.
```
$args = array(
'role' => 'subscriber',
'orderby' => 'ID',
'order' => 'DESC',
'fields' => 'all_with_meta',
'meta_query' => $meta_query
);
$my_users = get_users( $args );
``` |
126,067 | <p>After studying several blogs, I figured out that to add/edit/delete admin bar items need to do something like this:</p>
<pre><code>add_action( 'wp_before_admin_bar_render', 'wpse20131211_admin_bar' );
function wpse20131211_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_a... | [
{
"answer_id": 126068,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 3,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>$wp_admin_bar->remove_node( 'new-post' );\n</code></pre>\n\n<p>It will r... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126067",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | After studying several blogs, I figured out that to add/edit/delete admin bar items need to do something like this:
```
add_action( 'wp_before_admin_bar_render', 'wpse20131211_admin_bar' );
function wpse20131211_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_... | Try this:
```
$wp_admin_bar->remove_node( 'new-post' );
```
It will remove **Post** link under the admin bar's **+ New** link.
**LEARN MORE:** [**`remove_node()`**](http://codex.wordpress.org/Function_Reference/remove_node) - WordPress Codex |
126,080 | <p><code>paginate_links()</code> function returns unordered list with class named "page-numbers". How can I change this class?</p>
<p>EDIT</p>
<p>Currently, I am using the band-aid method below.</p>
<pre><code>$return = paginate_links( $arg );
echo str_replace( "<ul class='page-numbers'>", '<ul class="pagin... | [
{
"answer_id": 126084,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/paginate_links\" rel=\"noreferrer\"><code>pa... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126080",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40607/"
] | `paginate_links()` function returns unordered list with class named "page-numbers". How can I change this class?
EDIT
Currently, I am using the band-aid method below.
```
$return = paginate_links( $arg );
echo str_replace( "<ul class='page-numbers'>", '<ul class="pagination">', $return );
```
Is there any better w... | [`paginate_links()`](http://codex.wordpress.org/Function_Reference/paginate_links) doesn't offer a parameter and there are no hooks - see [source](https://github.com/WordPress/WordPress/blob/master/wp-includes/general-template.php#L3160) - available to change the class(es). Which means you can do it like you have done ... |
126,089 | <p>I'm trying to get user profile values using an AJAX call, but the response is always 0. Here's my PHP:</p>
<pre><code>wp_enqueue_script( // Add JS to <head>
'cc-author-change-post-author',
plugins_url( 'assets/js/change-post-author.js', dirname( __FILE__ ) ),
'jquery'
);
wp_localize_script( // Loc... | [
{
"answer_id": 126092,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": 1,
"selected": false,
"text": "<p>Your action hook should be </p>\n\n<pre><code>add_action( 'wp_ajax_cc_author_change_postauthor', 'cc_author_chang... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126089",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3792/"
] | I'm trying to get user profile values using an AJAX call, but the response is always 0. Here's my PHP:
```
wp_enqueue_script( // Add JS to <head>
'cc-author-change-post-author',
plugins_url( 'assets/js/change-post-author.js', dirname( __FILE__ ) ),
'jquery'
);
wp_localize_script( // Localize script for AJA... | Your action hook should be
```
add_action( 'wp_ajax_cc_author_change_postauthor', 'cc_author_change_postauthor_callback' );
```
I think because of your wrong hook, your callback function is never called.
You might have got this wrong aswell. In your JS code please change your action from
```
cc-author-change-pos... |
126,096 | <p>What is the capability that let users to edit their own posts and not others? I am trying to enable the post authors to avail a plugin function only on the posts they own. </p>
<p>The permission to access the option should be only to that particular post authors and even the editors shouldn't have access. Next to t... | [
{
"answer_id": 126119,
"author": "RachieVee",
"author_id": 42783,
"author_profile": "https://wordpress.stackexchange.com/users/42783",
"pm_score": 1,
"selected": false,
"text": "<p>An author is someone who can publish and manage their own posts. Perhaps taking a look <a href=\"http://cod... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2078/"
] | What is the capability that let users to edit their own posts and not others? I am trying to enable the post authors to avail a plugin function only on the posts they own.
The permission to access the option should be only to that particular post authors and even the editors shouldn't have access. Next to the post au... | The capabilities that you are trying to restrict are
* delete\_others\_posts
* edit\_others\_posts
Apart from Super Admin and Administrator, the only Role that have these permission is Editor. So, removing these capabilities from Editor should accomplish this.
```
/**
* Remove capabilities from editors.
*
* Call ... |
126,110 | <p>I already tried all of the solutions you can find online like adding this to <code>wp-config.php</code>:</p>
<blockquote>
<p>1 define('CONCATENATE_SCRIPTS', false);</p>
<p>2 I also deactivated all plugins and changed the theme, still no dice </p>
<p>3 Verified that permissions are correct and visual edi... | [
{
"answer_id": 126156,
"author": "mashup",
"author_id": 7820,
"author_profile": "https://wordpress.stackexchange.com/users/7820",
"pm_score": 2,
"selected": false,
"text": "<p>I forgot to add the solution. Turns out for some reason my <code>php.ini</code> dropped the apc segmentation and... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126110",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7820/"
] | I already tried all of the solutions you can find online like adding this to `wp-config.php`:
>
> 1 define('CONCATENATE\_SCRIPTS', false);
>
>
> 2 I also deactivated all plugins and changed the theme, still no dice
>
>
> 3 Verified that permissions are correct and visual editor is enabled
>
>
> 4 Tried replac... | I had a related issue and it wasn't solved using the above answers. I lost access to the Visual Editor in the classic editor, and was stuck in HTML. When using Gutenberg, I lost access to the visual editor, could not add blocks, and could not switch from Visual to Code tabs.
The problem was caused by AWS CloudFront re... |
126,113 | <p>I need to list out specific custom field items that contain an associated custom field entry. For example, the custom fields are named "type" and "food". I would like to list out all of the breakfast foods. "Breakfast" being the "type" custom field and "bacon", "eggs", "biscuits" being the "food". Right now, I have ... | [
{
"answer_id": 126120,
"author": "David",
"author_id": 31323,
"author_profile": "https://wordpress.stackexchange.com/users/31323",
"pm_score": 1,
"selected": false,
"text": "<p>Let's see if I got you right. Try this one:</p>\n\n<pre><code>SELECT m.meta_value FROM wp_postmeta m\n INNER... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13096/"
] | I need to list out specific custom field items that contain an associated custom field entry. For example, the custom fields are named "type" and "food". I would like to list out all of the breakfast foods. "Breakfast" being the "type" custom field and "bacon", "eggs", "biscuits" being the "food". Right now, I have thi... | Ok, if i understand you clearly, then this is the solution
```
// first get the post ids that have the breakfast food type
$post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = 'type' AND meta_value='Breakfast'" );
// now get the food names
$stocktypes = $wpdb->get_col( "SELECT DI... |
126,114 | <p>I tried putting this snippet in my functions.php</p>
<pre><code>add_filter( 'avatar_defaults', 'newgravatar' );
function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo('template_directory') . '/images/default_avatar.png';
$avatar_defaults[$myavatar] = "Locale";
return $avatar_defaults;
}
</c... | [
{
"answer_id": 126120,
"author": "David",
"author_id": 31323,
"author_profile": "https://wordpress.stackexchange.com/users/31323",
"pm_score": 1,
"selected": false,
"text": "<p>Let's see if I got you right. Try this one:</p>\n\n<pre><code>SELECT m.meta_value FROM wp_postmeta m\n INNER... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23296/"
] | I tried putting this snippet in my functions.php
```
add_filter( 'avatar_defaults', 'newgravatar' );
function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo('template_directory') . '/images/default_avatar.png';
$avatar_defaults[$myavatar] = "Locale";
return $avatar_defaults;
}
```
A new avata... | Ok, if i understand you clearly, then this is the solution
```
// first get the post ids that have the breakfast food type
$post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = 'type' AND meta_value='Breakfast'" );
// now get the food names
$stocktypes = $wpdb->get_col( "SELECT DI... |
126,128 | <p>I've been busy thinking about a problem, and so far I didn't find a solution to it.</p>
<h3>The <em>abstract</em> scenario</h3>
<p>On admin page A, I would like to print the value of a (global) variable—in the context of admin page B, though.</p>
<h3>The <em>concrete</em> scenario</h3>
<p>On a custom user-... | [
{
"answer_id": 126132,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 2,
"selected": false,
"text": "<p>Ok, this could be achieved this way, probably.</p>\n\n<pre><code>add_action('add_meta_boxes_my_super_duper_po... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126128",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27722/"
] | I've been busy thinking about a problem, and so far I didn't find a solution to it.
### The *abstract* scenario
On admin page A, I would like to print the value of a (global) variable—in the context of admin page B, though.
### The *concrete* scenario
On a custom user-options page, I would like to list all metaboxe... | Thanks to @Shazzad and @G.M., I found the right track.
Here is a short outline of what I did:
### The JavaScript/AJAX action
```
jQuery(function($) {
for (var i = 0; i < localizedData.postTypes.length; ++i) {
$.ajax({
type: 'post',
url: 'post-new.php?post_type='+localizedData.post... |
126,131 | <p>I have created a custom taxonomy Region and I would like to query this taxonomy for all results and display them. My query is:</p>
<pre><code>$args = array(
'tax_query' => array(
array(
'taxonomy' => 'region',
'field' => 'slug',
'terms' => array( 'north', 'east', 'west', 'sou... | [
{
"answer_id": 126132,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 2,
"selected": false,
"text": "<p>Ok, this could be achieved this way, probably.</p>\n\n<pre><code>add_action('add_meta_boxes_my_super_duper_po... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126131",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43783/"
] | I have created a custom taxonomy Region and I would like to query this taxonomy for all results and display them. My query is:
```
$args = array(
'tax_query' => array(
array(
'taxonomy' => 'region',
'field' => 'slug',
'terms' => array( 'north', 'east', 'west', 'south' )
)
)
);
$query = ... | Thanks to @Shazzad and @G.M., I found the right track.
Here is a short outline of what I did:
### The JavaScript/AJAX action
```
jQuery(function($) {
for (var i = 0; i < localizedData.postTypes.length; ++i) {
$.ajax({
type: 'post',
url: 'post-new.php?post_type='+localizedData.post... |
126,164 | <p>As far as I know using Actions and Filters hooks is the best approach for developing on WordPress. I have just to ask if there is any way to track down which Actions and Filters are applied on WordPress rendering.</p>
<p>My question is based on the fact that hooks may be applied by on WordPress through various plug... | [
{
"answer_id": 126182,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>Know which file call a filter or an action is not possible running code, you have to search and read the sourc... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126164",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40631/"
] | As far as I know using Actions and Filters hooks is the best approach for developing on WordPress. I have just to ask if there is any way to track down which Actions and Filters are applied on WordPress rendering.
My question is based on the fact that hooks may be applied by on WordPress through various plugins or the... | Know which file call a filter or an action is not possible running code, you have to search and read the source code or use some documentation.
There are different plugins that help you to debug the hook being fired in a page, search codex and/or Google for them.
However, to have a quick idea, add this snippet in you... |
126,170 | <p>I'm using get_the_ID() in my wp_enqueue_scripts action due to some needs, But as result I'm getting the following notice (wp-debug is on):</p>
<blockquote>
<p>Notice: Trying to get property of non-object in C:\wamp\www\WordPress\wp-includes\post-template.php on line 29</p>
</blockquote>
<p>I know why this happen... | [
{
"answer_id": 126171,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p>You can check to see if you're in a 404 page:</p>\n\n<pre><code>if( is_404() ) {\n return;\n}\nget_the_ID();... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126170",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32014/"
] | I'm using get\_the\_ID() in my wp\_enqueue\_scripts action due to some needs, But as result I'm getting the following notice (wp-debug is on):
>
> Notice: Trying to get property of non-object in C:\wamp\www\WordPress\wp-includes\post-template.php on line 29
>
>
>
I know why this happens, My question is why should... | `get_the_ID()` is broken.
```
function get_the_ID() {
return get_post()->ID;
}
```
It tries to use the member `ID` on a function that returns a `post` object *sometimes:*
```
/*
* @return WP_Post|null WP_Post on success or null on failure
*/
function get_post( $post = null, $output = OBJECT, $filter = 'raw'... |
126,174 | <p>I'd like to customize my WordPress blog in such a way that it is no more possible to access the comments feed.</p>
<p>Other feeds should still be available, and it should still be possible to add comments to any article.</p>
<p>I tried to find a plugin to do this, but what I found is a all or nothing feature, with... | [
{
"answer_id": 126177,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 4,
"selected": true,
"text": "<pre><code>function remove_comment_feeds( $for_comments ){\n if( $for_comments ){\n remove_action( 'do_... | 2013/12/11 | [
"https://wordpress.stackexchange.com/questions/126174",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10979/"
] | I'd like to customize my WordPress blog in such a way that it is no more possible to access the comments feed.
Other feeds should still be available, and it should still be possible to add comments to any article.
I tried to find a plugin to do this, but what I found is a all or nothing feature, without the possibili... | ```
function remove_comment_feeds( $for_comments ){
if( $for_comments ){
remove_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 );
remove_action( 'do_feed_atom', 'do_feed_atom', 10, 1 );
}
}
add_action( 'do_feed_rss2', 'remove_comment_feeds', 9, 1 );
add_action( 'do_feed_atom', 'remove_comment_fee... |
126,209 | <p>My question is pretty much in the title.</p>
<p>I have 2 or more administrators, but I only want the admin with X username to edit the title of the posts while others can only view them.</p>
<p>Feel free suggesting solutions that involve scripting or the use of plugins. Thanks!</p>
<p>Note: This is only for the b... | [
{
"answer_id": 126235,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p>Once you say \"edit\" I think you are no worried about new posts, just edit existent post.</p>\n\n<p>So, my i... | 2013/12/12 | [
"https://wordpress.stackexchange.com/questions/126209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40834/"
] | My question is pretty much in the title.
I have 2 or more administrators, but I only want the admin with X username to edit the title of the posts while others can only view them.
Feel free suggesting solutions that involve scripting or the use of plugins. Thanks!
Note: This is only for the backend/dashboard. | Once you say "edit" I think you are no worried about new posts, just edit existent post.
So, my idea is remove the support fot title when the admin is no the one allowed.
I'll write a separate function that retturn true if the current user is the wanted admin, in this way it can be used in different part of the site.... |
126,226 | <p>I have different categories called as reviews, ideas etc. I have a page called as review, I want to display review category to the review page (only review category). Is this possible? Which file I have to change? I have the code below, but it is displaying only the texts not any links to the posts, 7 is my category... | [
{
"answer_id": 126227,
"author": "Scuba Kay",
"author_id": 28916,
"author_profile": "https://wordpress.stackexchange.com/users/28916",
"pm_score": 1,
"selected": false,
"text": "<p>Go to your settings and enable permalinks. Set it to 'Post name'. Now you can just go to www.example.com/ca... | 2013/12/12 | [
"https://wordpress.stackexchange.com/questions/126226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32819/"
] | I have different categories called as reviews, ideas etc. I have a page called as review, I want to display review category to the review page (only review category). Is this possible? Which file I have to change? I have the code below, but it is displaying only the texts not any links to the posts, 7 is my category id... | From what I understand, the question is, how can you show only one category on a WordPress Page?
What Scuba Kay is suggesting is the default category archive, if you want to go that route, WordPress already has archive pages with your posts for each category without you having to create your own Page. If you want to m... |
126,252 | <p>I'm using the following <code>WP_Query</code> within my <code>search.php</code> template in order to only search the 'products' custom post type. For some reason, its returning other post types with some search terms.</p>
<p>Any Ideas where I'm going wrong?</p>
<pre><code><?php global $query_string; ?>
<... | [
{
"answer_id": 126254,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 1,
"selected": false,
"text": "<p>Add this line -</p>\n\n<pre><code><?php $search_query['post_type'] = 'products'; ?>\n</code></pre>\n\n<... | 2013/12/12 | [
"https://wordpress.stackexchange.com/questions/126252",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43831/"
] | I'm using the following `WP_Query` within my `search.php` template in order to only search the 'products' custom post type. For some reason, its returning other post types with some search terms.
Any Ideas where I'm going wrong?
```
<?php global $query_string; ?>
<?php $query_args = explode("&", $query_string); ?>
... | Add this line -
```
<?php $search_query['post_type'] = 'products'; ?>
```
Just before the line -
```
<?php $search = new WP_Query($search_query); ?>
``` |
126,275 | <p>I have a custom post type called "work" and it has a taxonomy called "categories". Currently "/work" and "/work/category_slug/work_slug" works great. However "/work/category_slug" does not. I get a 404 page. Any ideas what I can do? </p>
<pre><code>register_post_type('work', array(
'label' => 'Work',
'descriptio... | [
{
"answer_id": 126254,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 1,
"selected": false,
"text": "<p>Add this line -</p>\n\n<pre><code><?php $search_query['post_type'] = 'products'; ?>\n</code></pre>\n\n<... | 2013/12/12 | [
"https://wordpress.stackexchange.com/questions/126275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24054/"
] | I have a custom post type called "work" and it has a taxonomy called "categories". Currently "/work" and "/work/category\_slug/work\_slug" works great. However "/work/category\_slug" does not. I get a 404 page. Any ideas what I can do?
```
register_post_type('work', array(
'label' => 'Work',
'description' => '',
'pub... | Add this line -
```
<?php $search_query['post_type'] = 'products'; ?>
```
Just before the line -
```
<?php $search = new WP_Query($search_query); ?>
``` |
126,287 | <p>A previous developer created a plugin for a website I manage and everything seems to work okay, except I'm getting the error "Missing argument 2 for wpdb::prepare()". I understand that the arguments need to be added, but I'm not clear how to add them in to this specific code, or what arguments to add in this case.</... | [
{
"answer_id": 126254,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 1,
"selected": false,
"text": "<p>Add this line -</p>\n\n<pre><code><?php $search_query['post_type'] = 'products'; ?>\n</code></pre>\n\n<... | 2013/12/12 | [
"https://wordpress.stackexchange.com/questions/126287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4132/"
] | A previous developer created a plugin for a website I manage and everything seems to work okay, except I'm getting the error "Missing argument 2 for wpdb::prepare()". I understand that the arguments need to be added, but I'm not clear how to add them in to this specific code, or what arguments to add in this case.
The... | Add this line -
```
<?php $search_query['post_type'] = 'products'; ?>
```
Just before the line -
```
<?php $search = new WP_Query($search_query); ?>
``` |
126,301 | <p>With the new Wordpress 3.8 under Screen Options they seem to have misplaced the "Columns" feature where you could put your widgets into 1 Column, 2 Columns, 3 Columns, or 4 Columns. My question is how to I force my Dashboard Widgets to only be 1 column, or in other words, take up the whole width of the screen versus... | [
{
"answer_id": 126304,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>This happens because of the new media queries. A very unfortunate change …</p>\n\n<p>Anyway, you can change it by set... | 2013/12/12 | [
"https://wordpress.stackexchange.com/questions/126301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | With the new Wordpress 3.8 under Screen Options they seem to have misplaced the "Columns" feature where you could put your widgets into 1 Column, 2 Columns, 3 Columns, or 4 Columns. My question is how to I force my Dashboard Widgets to only be 1 column, or in other words, take up the whole width of the screen versus ju... | Another solution is to add the columns setting back to the settings.
```
function wpse126301_dashboard_columns() {
add_screen_option(
'layout_columns',
array(
'max' => 2,
'default' => 1
)
);
}
add_action( 'admin_head-index.php', 'wpse126301_dashboard_columns'... |
126,303 | <p>WordPress 3.8 is out I have the following code to remove admin bar logo. </p>
<pre><code> function no_wp_logo_admin_bar_remove() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'no_wp_logo_admin_bar_remove', 0);
</code></pre>
<p>However I would l... | [
{
"answer_id": 126306,
"author": "Ipstenu",
"author_id": 7886,
"author_profile": "https://wordpress.stackexchange.com/users/7886",
"pm_score": 2,
"selected": false,
"text": "<p>That's controlled by a Dashicon (font icon) and a before statement:</p>\n\n<pre class=\"lang-css prettyprint-ov... | 2013/12/12 | [
"https://wordpress.stackexchange.com/questions/126303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17073/"
] | WordPress 3.8 is out I have the following code to remove admin bar logo.
```
function no_wp_logo_admin_bar_remove() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'no_wp_logo_admin_bar_remove', 0);
```
However I would like to know how can I replace... | That's controlled by a Dashicon (font icon) and a before statement:
```css
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {
content: '\f120';
top: 2px;
}
```
What you'd want is to replace the content call.
Use a built in Dashicon from here: <http://melchoyce.github.io/dashicons/>
So the smilie would ... |
126,311 | <p>Struggling here with the excerpt and options for it.<br />
<em>(NOT looking for a plugin and not extracting from the content, we add seperate excerpt content)</em><br /></p>
<p>We want to have an excerpt limited to a max. amount of words, using HTML code when needed and showing an image.</p>
<p>The theme we use di... | [
{
"answer_id": 126339,
"author": "markcbain",
"author_id": 24573,
"author_profile": "https://wordpress.stackexchange.com/users/24573",
"pm_score": -1,
"selected": false,
"text": "<p>I'd try this plugin: <a href=\"http://wordpress.org/plugins/advanced-excerpt/\" rel=\"nofollow\">http://wo... | 2013/12/12 | [
"https://wordpress.stackexchange.com/questions/126311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15605/"
] | Struggling here with the excerpt and options for it.
*(NOT looking for a plugin and not extracting from the content, we add seperate excerpt content)*
We want to have an excerpt limited to a max. amount of words, using HTML code when needed and showing an image.
The theme we use didn't have the excerpt option so... | Answer on my own question (without using a plugin and choosing a middle way) for what we want to achieve.
Because the template has also a code *starting* with:
```
if ( has_post_thumbnail() && ( $post->post_type == 'post' ) )
```
we have taken that part of code away. (we won't used it in postings/pages, therefore... |
126,315 | <p>I have a WordPress function that I want to run once daily at a specific time. How should I go about doing this, since WP cron cannot be set to a particular time?</p>
| [
{
"answer_id": 126337,
"author": "Ravi Barnwal",
"author_id": 43858,
"author_profile": "https://wordpress.stackexchange.com/users/43858",
"pm_score": 0,
"selected": false,
"text": "<p>You can go through this link.</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_sched... | 2013/12/13 | [
"https://wordpress.stackexchange.com/questions/126315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I have a WordPress function that I want to run once daily at a specific time. How should I go about doing this, since WP cron cannot be set to a particular time? | you can absolutely use wp\_cron to specify a time:
```
add_action( 'my_scheduled_event', 'prefix_my_scheduled_event' );
/**
* On the scheduled action hook, run a function.
*/
function prefix_my_scheduled_event() {
// do something
}
//going to use the strtotime function, so a good habit to get into is to set the... |
126,340 | <p>I am trying to load the script in footer but always it shows that it is added in header.</p>
<pre><code>function tabbed_scripts()
{
wp_register_script( 'tabbed-scripts', plugins_url( '/js/jquery.responsiveTabs.min.js', __FILE__ ) );
wp_enqueue_script( 'tabbed-scripts' );
}
</code></pre>
<p>add_action( ... | [
{
"answer_id": 126343,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": 2,
"selected": false,
"text": "<p>You must remember there is $in_footer parameter with <a href=\"http://codex.wordpress.org/Function_Reference/wp_r... | 2013/12/13 | [
"https://wordpress.stackexchange.com/questions/126340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30937/"
] | I am trying to load the script in footer but always it shows that it is added in header.
```
function tabbed_scripts()
{
wp_register_script( 'tabbed-scripts', plugins_url( '/js/jquery.responsiveTabs.min.js', __FILE__ ) );
wp_enqueue_script( 'tabbed-scripts' );
}
```
add\_action( 'wp\_enqueue\_scripts', '... | You must remember there is $in\_footer parameter with [wp\_register\_script](http://codex.wordpress.org/Function_Reference/wp_register_script) function.
By default it is set to false. Try setting it to TRUE(I don't see you doing it) and the jQuery should appear in your footer. |
126,346 | <p>I'm trying to use nested loops with the posts to posts plugin. The loops both work, but the problem arises after the second nested loop ($issue). I want to access the $publication loop again, but the data is still the $issue data.</p>
<p><code>wp_reset_query()</code> will reset right back to the main loop in single... | [
{
"answer_id": 126348,
"author": "kdev",
"author_id": 6681,
"author_profile": "https://wordpress.stackexchange.com/users/6681",
"pm_score": 5,
"selected": false,
"text": "<p>I'm going to answer this myself, but it was the very clever @simonwheatley of Code for the People that solved this... | 2013/12/13 | [
"https://wordpress.stackexchange.com/questions/126346",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6681/"
] | I'm trying to use nested loops with the posts to posts plugin. The loops both work, but the problem arises after the second nested loop ($issue). I want to access the $publication loop again, but the data is still the $issue data.
`wp_reset_query()` will reset right back to the main loop in single.php which I don't wa... | I'm going to answer this myself, but it was the very clever @simonwheatley of Code for the People that solved this one for me.
Instead of using `wp_reset_postdata()` or `wp_reset_query()`, you can use the following:
```
$publication->reset_postdata();
```
Where $publication is your query object.
The working code n... |
126,355 | <p>I kinda did something stupid. To test something I created a couple of plugins and during testing I think I renamed the plugin. Now I deleted the plugins but I'm still getting an error message saying the plugin couldn't be found:</p>
<pre><code>The plugin something else has been deactivated due to an error: Plugin f... | [
{
"answer_id": 126356,
"author": "Scuba Kay",
"author_id": 28916,
"author_profile": "https://wordpress.stackexchange.com/users/28916",
"pm_score": 0,
"selected": false,
"text": "<p>So I fixed my problem. Here's how:</p>\n\n<pre><code>a:4:{\n i:0;s:23:\"bandpress/bootstrap.php\";\n ... | 2013/12/13 | [
"https://wordpress.stackexchange.com/questions/126355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28916/"
] | I kinda did something stupid. To test something I created a couple of plugins and during testing I think I renamed the plugin. Now I deleted the plugins but I'm still getting an error message saying the plugin couldn't be found:
```
The plugin something else has been deactivated due to an error: Plugin file does not e... | The approach in the answer by Scuba Kay is technically possible but easy to get wrong. Small mistakes will cause the data to fail to unserialize correctly. You are better off "editing" the serialized data with PHP:
```
$str = 'a:4:{i:0;s:23:"bandpress/bootstrap.php";i:3;s:56:"posts-from-single-category-widget/post_fr... |
126,361 | <p>I want to do a regex match to each post before it gets published, and if the regex fails to match, delete the post entirely, what hook should I use?</p>
| [
{
"answer_id": 126356,
"author": "Scuba Kay",
"author_id": 28916,
"author_profile": "https://wordpress.stackexchange.com/users/28916",
"pm_score": 0,
"selected": false,
"text": "<p>So I fixed my problem. Here's how:</p>\n\n<pre><code>a:4:{\n i:0;s:23:\"bandpress/bootstrap.php\";\n ... | 2013/12/13 | [
"https://wordpress.stackexchange.com/questions/126361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43865/"
] | I want to do a regex match to each post before it gets published, and if the regex fails to match, delete the post entirely, what hook should I use? | The approach in the answer by Scuba Kay is technically possible but easy to get wrong. Small mistakes will cause the data to fail to unserialize correctly. You are better off "editing" the serialized data with PHP:
```
$str = 'a:4:{i:0;s:23:"bandpress/bootstrap.php";i:3;s:56:"posts-from-single-category-widget/post_fr... |
126,362 | <p>I'm trying to use pre_get_posts for the first time without any success. It's a very simple piece of code on the index page of an otherwise empty theme, purely to get the hang of the action hook:</p>
<pre><code>function just_one( $query )
{
$query->set( 'posts_per_page', 1 );
}
add_action( 'pre_get_posts', 'j... | [
{
"answer_id": 126372,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": -1,
"selected": false,
"text": "<p>Try this instead. You always need to check for the <strong><a href=\"http://codex.wordpress.org/Funct... | 2013/12/13 | [
"https://wordpress.stackexchange.com/questions/126362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28735/"
] | I'm trying to use pre\_get\_posts for the first time without any success. It's a very simple piece of code on the index page of an otherwise empty theme, purely to get the hang of the action hook:
```
function just_one( $query )
{
$query->set( 'posts_per_page', 1 );
}
add_action( 'pre_get_posts', 'just_one' );
``... | >
> ... It's a very simple piece of code on the **index** page of an
> otherwise empty theme...
>
>
>
If you are running this code on the ***index page*** of your theme and expect it to effect the main query, then you are adding the action too late. The main query runs well before your theme template loads. You w... |