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 |
|---|---|---|---|---|---|---|
159,789 | <p>I am working on a wordpress site and I am using wordpress native search. When we search for a string like "example" it searches inside html tags. ie if there is any html tag like <code><a href="http://example.com"></code> in the page or post then the search result will show that particular page or post. I dont... | [
{
"answer_id": 159791,
"author": "Silenced",
"author_id": 59029,
"author_profile": "https://wordpress.stackexchange.com/users/59029",
"pm_score": -1,
"selected": false,
"text": "<p>I can't comment yet, so I ll try to guess that the one that is getting duplicated is the post and not just ... | 2014/09/01 | [
"https://wordpress.stackexchange.com/questions/159789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47454/"
] | I am working on a wordpress site and I am using wordpress native search. When we search for a string like "example" it searches inside html tags. ie if there is any html tag like `<a href="http://example.com">` in the page or post then the search result will show that particular page or post. I dont want to search insi... | First of: Your custom title suffix getting duplicated might not be what you want to happen, but is expected behavior as per your code sample.
The [`save_post`](http://codex.wordpress.org/Plugin_API/Action_Reference/save_post) *[action hook](http://codex.wordpress.org/Plugin_API/Action_Reference/)* runs everytime a pos... |
159,797 | <p>I am not getting any results back using this code, even though I am passing in correct values. Can someone please take a look?</p>
<pre><code>function webinar_list_shortcode($atts) {
global $post;
// Defaults
extract( shortcode_atts ( array (
'posts' => '5',
'status' => 'future',
'e... | [
{
"answer_id": 159791,
"author": "Silenced",
"author_id": 59029,
"author_profile": "https://wordpress.stackexchange.com/users/59029",
"pm_score": -1,
"selected": false,
"text": "<p>I can't comment yet, so I ll try to guess that the one that is getting duplicated is the post and not just ... | 2014/09/01 | [
"https://wordpress.stackexchange.com/questions/159797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48012/"
] | I am not getting any results back using this code, even though I am passing in correct values. Can someone please take a look?
```
function webinar_list_shortcode($atts) {
global $post;
// Defaults
extract( shortcode_atts ( array (
'posts' => '5',
'status' => 'future',
'eventcat' => ''
)... | First of: Your custom title suffix getting duplicated might not be what you want to happen, but is expected behavior as per your code sample.
The [`save_post`](http://codex.wordpress.org/Plugin_API/Action_Reference/save_post) *[action hook](http://codex.wordpress.org/Plugin_API/Action_Reference/)* runs everytime a pos... |
159,818 | <p>Showing "Undefined variable" and "Trying to get property of non-object" notice when using the following code</p>
<pre><code> while($q->have_posts()) : $q->the_post();
$newsbox_post_img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '', false, '' );
$list .= '<li class="news-item"... | [
{
"answer_id": 159791,
"author": "Silenced",
"author_id": 59029,
"author_profile": "https://wordpress.stackexchange.com/users/59029",
"pm_score": -1,
"selected": false,
"text": "<p>I can't comment yet, so I ll try to guess that the one that is getting duplicated is the post and not just ... | 2014/09/01 | [
"https://wordpress.stackexchange.com/questions/159818",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57832/"
] | Showing "Undefined variable" and "Trying to get property of non-object" notice when using the following code
```
while($q->have_posts()) : $q->the_post();
$newsbox_post_img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '', false, '' );
$list .= '<li class="news-item">
<table cellpadding="4">
... | First of: Your custom title suffix getting duplicated might not be what you want to happen, but is expected behavior as per your code sample.
The [`save_post`](http://codex.wordpress.org/Plugin_API/Action_Reference/save_post) *[action hook](http://codex.wordpress.org/Plugin_API/Action_Reference/)* runs everytime a pos... |
159,851 | <p>So I would like to have an archive that displays its posts in a random order.</p>
<pre><code><?php
$query = new WP_Query($query_string."&orderby=rand");
?>
</code></pre>
<p>But also then if the user chooses they can order the posts differently by clicking a button.</p>
<pre><code><?php
$s... | [
{
"answer_id": 159791,
"author": "Silenced",
"author_id": 59029,
"author_profile": "https://wordpress.stackexchange.com/users/59029",
"pm_score": -1,
"selected": false,
"text": "<p>I can't comment yet, so I ll try to guess that the one that is getting duplicated is the post and not just ... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159851",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50184/"
] | So I would like to have an archive that displays its posts in a random order.
```
<?php
$query = new WP_Query($query_string."&orderby=rand");
?>
```
But also then if the user chooses they can order the posts differently by clicking a button.
```
<?php
$sort_date = add_query_arg(array('orderby'=>'date','... | First of: Your custom title suffix getting duplicated might not be what you want to happen, but is expected behavior as per your code sample.
The [`save_post`](http://codex.wordpress.org/Plugin_API/Action_Reference/save_post) *[action hook](http://codex.wordpress.org/Plugin_API/Action_Reference/)* runs everytime a pos... |
159,870 | <p>I have used <code>excerpt_more</code> filter in a theme's functions.php and in a plugin's functions.php. Here is the code for the theme</p>
<pre><code> function theme_excerpt_more( $more ) {
return '...';
}
add_filter('excerpt_more', 'theme_excerpt_more');
</code></pre>
<p>and here is the code for the p... | [
{
"answer_id": 159871,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 0,
"selected": false,
"text": "<p>You dont need to install plugins to do this. \nGo to Settings-->Permalinks-->Custom Structure--> \nAnd now set... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57832/"
] | I have used `excerpt_more` filter in a theme's functions.php and in a plugin's functions.php. Here is the code for the theme
```
function theme_excerpt_more( $more ) {
return '...';
}
add_filter('excerpt_more', 'theme_excerpt_more');
```
and here is the code for the plugin
```
function newsbox_excerpt... | Don't need to do anything except change permalink.Just go to
settings->permalink->Custom Structure and add '/%category%/%postname%/' to text box.
It will work same exactly what you want. |
159,894 | <p>I wanted to find out, how many queries does wordpress core run, and how many queries the theme run. Is there any way to get they number of both of them separately ? As i run </p>
<pre><code>`echo get_num_queries();
queries in
timer_stop(1);`
</code></pre>
<p>It gives me total of queries, but i want to have the num... | [
{
"answer_id": 159897,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 3,
"selected": true,
"text": "<p>You can use <a href=\"http://wordpress.org/plugins/query-monitor/\" rel=\"nofollow\">Query Monitor</a> plug... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33028/"
] | I wanted to find out, how many queries does wordpress core run, and how many queries the theme run. Is there any way to get they number of both of them separately ? As i run
```
`echo get_num_queries();
queries in
timer_stop(1);`
```
It gives me total of queries, but i want to have the number separate, of how many ... | You can use [Query Monitor](http://wordpress.org/plugins/query-monitor/) plugin for that
Not quite sure if it distinguish between both but it's a great plugin for query monitoring and debugging. |
159,903 | <p>I'm currently building a college football blog and I have 2 custom post types: <code>conference</code> and <code>team</code>.</p>
<p>Each <code>conference</code> post type will be a horizontal list consisting of each teams' logo and will be displayed on every <code>single</code> <code>team</code> post so long as th... | [
{
"answer_id": 159904,
"author": "Scott Nelle",
"author_id": 52296,
"author_profile": "https://wordpress.stackexchange.com/users/52296",
"pm_score": 2,
"selected": true,
"text": "<p>The code you need will vary slightly depending on whether the Conference field is storing a text string (l... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159903",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51546/"
] | I'm currently building a college football blog and I have 2 custom post types: `conference` and `team`.
Each `conference` post type will be a horizontal list consisting of each teams' logo and will be displayed on every `single` `team` post so long as the team is in the respective conference. It will look virtually id... | The code you need will vary slightly depending on whether the Conference field is storing a text string (like "Big Ten") vs. the ID of the Conference post. I'll include both:
**Text String Example**
```
// place this code inside the loop of your single-team template
$conference_name = get_post_meta( get_the_id(), 'co... |
159,906 | <p>I have a few custom post types (books, films etc) created with WP-Types.</p>
<p>I then have a custom field called Genre, created with ACF.</p>
<p>If a user selects "Books" from the dropdown on the frontpage, he is taking to an archive page displaying all the books available. What I would like now is to create a dr... | [
{
"answer_id": 159910,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/AJAX_in_Plugins\" rel=\"nofollow\">Wordpress and AJAX.</a></p>\n\n<p>F... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58166/"
] | I have a few custom post types (books, films etc) created with WP-Types.
I then have a custom field called Genre, created with ACF.
If a user selects "Books" from the dropdown on the frontpage, he is taking to an archive page displaying all the books available. What I would like now is to create a dropdown on that ar... | Filtrify doesn't actually use AJAX to get a new data set, it simply hides all of the elements which don't match your current filter. Because you already have a page displaying all books (for example) you are already pretty well set up to use Filtrify.
The only extra step that you need to take is to add the data-genre ... |
159,911 | <p>I am working on creating a plugin for a multisite wordpress framework that is enabled by default for all (by me, the <em>super administrator</em>)</p>
<p>When it activates it is required to create 2 tables where it will store some precedural information. Right now I am working on creating the first (most important)... | [
{
"answer_id": 160387,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>From the <a href=\"http://codex.wordpress.org/Creating_Tables_with_Plugins\" rel=\"nofollow\"><code>dbDelta()</... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159911",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58040/"
] | I am working on creating a plugin for a multisite wordpress framework that is enabled by default for all (by me, the *super administrator*)
When it activates it is required to create 2 tables where it will store some precedural information. Right now I am working on creating the first (most important) table.
The p\_i... | And the answer is that a `datetime` cant have the `CURRENT_TIMESTAMP` default value since **MySQL 5.6.5** so I changed `modify_date` from `datetime` to `timestamp` and all is good. |
159,913 | <p>At present I have a basic query that outputs 12 custom posts, each in a div.</p>
<p>I need to restructure this to output four divs, each with three of these items inside. So it's sort of like a nested div.</p>
<p>To explain, here is the current HTML output (for 12 items)</p>
<pre><code><div class="item">the... | [
{
"answer_id": 159914,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the variable <code>$current_post</code>, something like this.</p>\n\n<pre><code> <?php \n... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159913",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34215/"
] | At present I have a basic query that outputs 12 custom posts, each in a div.
I need to restructure this to output four divs, each with three of these items inside. So it's sort of like a nested div.
To explain, here is the current HTML output (for 12 items)
```
<div class="item">the content comes out here</div>
<div... | You can use the variable `$current_post`, something like this.
```
<?php
$query = new WP_Query(array(
'post_type' => 'custom_job',
'showposts' => 12
) );
?>
<?php while ($query->have_posts()) : $query->the_post(); ?>
... |
159,942 | <p>I am not sure how to ask this, which is why I have been having trouble finding anything via google searches. I am hoping someone here will understand what I am looking for and be able to direct me to information about how to implement it.</p>
<p>I am working on a custom theme.
What I want to do is have on my templa... | [
{
"answer_id": 159967,
"author": "icicleking",
"author_id": 45454,
"author_profile": "https://wordpress.stackexchange.com/users/45454",
"pm_score": 0,
"selected": false,
"text": "<p>I would second Howdy_McGee suggestion. Before you start thinking about creating custom templates you need ... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159942",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/53998/"
] | I am not sure how to ask this, which is why I have been having trouble finding anything via google searches. I am hoping someone here will understand what I am looking for and be able to direct me to information about how to implement it.
I am working on a custom theme.
What I want to do is have on my template page, s... | Thank you all for your help and direction. I decided to go a different route, using a post category for the home page sections. It is not exactly what I wanted to do but seemed the most expedient way to achieve the end result I was looking for. It is easy for the client to update, although not as easy as if I had been ... |
159,955 | <p>I making some updates to a theme I'm currently working on.</p>
<p>I've moved a bunch of categories that have custom post items under them into a parent category that's all within a custom taxonomy.</p>
<p>e.g.:</p>
<pre><code>Parent Category
-Child Category
--Item
--Item
--Item
-Child Category
--Item
--Item
-Chil... | [
{
"answer_id": 159963,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 1,
"selected": false,
"text": "<p>Two things!</p>\n\n<p>1) Don't use <code>query_posts()</code>! Instead, for situations like this, use the <a hre... | 2014/09/02 | [
"https://wordpress.stackexchange.com/questions/159955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16613/"
] | I making some updates to a theme I'm currently working on.
I've moved a bunch of categories that have custom post items under them into a parent category that's all within a custom taxonomy.
e.g.:
```
Parent Category
-Child Category
--Item
--Item
--Item
-Child Category
--Item
--Item
-Child Category
--Item
--Item
--I... | Two things!
1) Don't use `query_posts()`! Instead, for situations like this, use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to modify the query.
2) I don't think you actually want to be using a loop here at all (so neither `query_posts()` nor `pre_get_posts` or ... |
160,006 | <p>I changed the primary domain on a website I'm working on, but now when I go to wp-admin page and try to login it wont work. I assume this is because of this most recent change. Like changing something with my hosting company, is there somewhere in the FTP of wordpress that I have to update to tell it to now head to ... | [
{
"answer_id": 160009,
"author": "kia4567",
"author_id": 25108,
"author_profile": "https://wordpress.stackexchange.com/users/25108",
"pm_score": 2,
"selected": false,
"text": "<p>I figured it out! </p>\n\n<p><a href=\"http://codex.wordpress.org/Changing_The_Site_URL\" rel=\"nofollow\">ht... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | I changed the primary domain on a website I'm working on, but now when I go to wp-admin page and try to login it wont work. I assume this is because of this most recent change. Like changing something with my hosting company, is there somewhere in the FTP of wordpress that I have to update to tell it to now head to thi... | I figured it out!
<http://codex.wordpress.org/Changing_The_Site_URL>
All I did was add this to my wp-config file after the define('WP\_DEBUG', true); command
```
define('WP_HOME','http://mydomain.com');
define('WP_SITEURL','http://mydomain.com');
``` |
160,008 | <p>I have a site where the options_id field in the wp_options table has grown very, very large. A month and a half after the installation, the auto_increment value is now at over 10 million. </p>
<p>While there are a number of plugins installed (such as ACF and W3 Total Cache) they do not seem to be the cause. They ha... | [
{
"answer_id": 160009,
"author": "kia4567",
"author_id": 25108,
"author_profile": "https://wordpress.stackexchange.com/users/25108",
"pm_score": 2,
"selected": false,
"text": "<p>I figured it out! </p>\n\n<p><a href=\"http://codex.wordpress.org/Changing_The_Site_URL\" rel=\"nofollow\">ht... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59133/"
] | I have a site where the options\_id field in the wp\_options table has grown very, very large. A month and a half after the installation, the auto\_increment value is now at over 10 million.
While there are a number of plugins installed (such as ACF and W3 Total Cache) they do not seem to be the cause. They have been... | I figured it out!
<http://codex.wordpress.org/Changing_The_Site_URL>
All I did was add this to my wp-config file after the define('WP\_DEBUG', true); command
```
define('WP_HOME','http://mydomain.com');
define('WP_SITEURL','http://mydomain.com');
``` |
160,017 | <p>I am trying to create form and send it to my e-mail address using wp_mail.
my wp_mail() code is:</p>
<pre><code>if($_POST["submit"]) {
$to="my email";
$subject ="My subject";
$sender=$_POST["sendername"];
$senderEmail=$_POST["senderEmail"];
$message=$_POST["message"];
$name_title=$_POST... | [
{
"answer_id": 160019,
"author": "Chris Morris",
"author_id": 39242,
"author_profile": "https://wordpress.stackexchange.com/users/39242",
"pm_score": 5,
"selected": true,
"text": "<p>If I'm understanding you right you just are having trouble getting the from set? The easiest way would ju... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43764/"
] | I am trying to create form and send it to my e-mail address using wp\_mail.
my wp\_mail() code is:
```
if($_POST["submit"]) {
$to="my email";
$subject ="My subject";
$sender=$_POST["sendername"];
$senderEmail=$_POST["senderEmail"];
$message=$_POST["message"];
$name_title=$_POST["name_title... | If I'm understanding you right you just are having trouble getting the from set? The easiest way would just be adding the **from** in the **email headers** in the **wp\_mail** function.
Here is an example of one of my old simple email sending functions that works:
```
function contact_send() {
$title = 'New mes... |
160,040 | <p>My aim is to use the Heartbeat API to check if new posts have been published since the blog's homepage was loaded. If new posts have been published, I will display a link at the top of the screen "16 new posts" which, when clicked, will insert the new posts into the DOM.</p>
<p><strong>My problem:</strong></p>
<p>... | [
{
"answer_id": 160074,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<h2>Determining the current time</h2>\n<p>There's the <a href=\"http://queryposts.com/function/current_time/\" rel=\"n... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22599/"
] | My aim is to use the Heartbeat API to check if new posts have been published since the blog's homepage was loaded. If new posts have been published, I will display a link at the top of the screen "16 new posts" which, when clicked, will insert the new posts into the DOM.
**My problem:**
How can I check if new posts h... | Determining the current time
----------------------------
There's the [`current_time()`](http://queryposts.com/function/current_time/) function in core that allows to pass three different values as first argument and `gmt` (the offset) as second argument. About the 1st:
1. `mysql` -> [`gmdate( 'Y-m-d H:i:s' )`](http:... |
160,054 | <p>I published an article with permalink slug:</p>
<pre><code>http://domain.com/writing
</code></pre>
<p>Then after publishing, I changed the permalink slug to <code>writing-lorem</code>. Now, whenever I visit <code>/writing</code>, it redirects to <code>/writing-lorem</code>.</p>
<p>I want to use the <code>writing<... | [
{
"answer_id": 160073,
"author": "Greg McMullen",
"author_id": 36028,
"author_profile": "https://wordpress.stackexchange.com/users/36028",
"pm_score": 3,
"selected": false,
"text": "<p>It's in the table <code>postmeta</code> with the meta_key of <code>_wp_old_slug</code></p>\n\n<p>If you... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | I published an article with permalink slug:
```
http://domain.com/writing
```
Then after publishing, I changed the permalink slug to `writing-lorem`. Now, whenever I visit `/writing`, it redirects to `/writing-lorem`.
I want to use the `writing` slug for a new category but can't, it changes to `writing-2`.
To att... | We determined that the slug was not stored in `postmeta` meta\_key `_wp_old_slug`.
In a final attempt to find where this slug is stored. I performed a search for the exact phrase of `writing` and found a few results. The one of interest was in `wp_terms`.
I deleted that entry and then changed the slug of the category... |
160,069 | <p>How can I use code to limit users from sharing there ids and password and login muliple times? what i want to do is not allow the user to login multiple times at the same time.</p>
| [
{
"answer_id": 160076,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": -1,
"selected": false,
"text": "<p>By Otto.</p>\n\n<p>Not, easy. Quite a lot of hacking would be needed.</p>\n\n<p>WordPress doesn't have an... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160069",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59167/"
] | How can I use code to limit users from sharing there ids and password and login muliple times? what i want to do is not allow the user to login multiple times at the same time. | This will log a user out of all other sessions before logging in. Essentially ensuring that a user will only be allowed one session at a time.
```
add_filter('authenticate', 'wpse_12282015_single_login_authenticate', 0, 3);
function wpse_12282015_single_login_authenticate($user, $username, $password) {
$user = ... |
160,082 | <p>Hi i am new on wordpress and has been given a task to make such a script that will fetch posts by categories and shoot email to subscribers.</p>
<p>The table structure for subscriber is below</p>
<pre><code>Subscriber Id - primary key
Subscriber email - varchar
Category Id - int
</code></pre>
<p>Now the task is t... | [
{
"answer_id": 160083,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress already has a cron style mechanism, <a href=\"http://codex.wordpress.org/Function_Reference/wp_cro... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160082",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Hi i am new on wordpress and has been given a task to make such a script that will fetch posts by categories and shoot email to subscribers.
The table structure for subscriber is below
```
Subscriber Id - primary key
Subscriber email - varchar
Category Id - int
```
Now the task is to fetch post for last week for ea... | Yes, you can make a plugin. Following is the way to add cron job functionality in WordPress plugin.
<http://codex.wordpress.org/Function_Reference/wp_schedule_event>
<http://codex.wordpress.org/Function_Reference/wp_cron>
However, please note that this does not provide a real (system based) cron. It requires at least... |
160,098 | <p>I want to change the login url of my Wordpress install away from /wp-admin.php</p>
<p>I am aiming to do so and am looking at changing the .htaccess file to add in:</p>
<pre><code>RewriteRule ^login$ http://yourdomain.com/wp-login.php [NC, L]
</code></pre>
<p>From what I gather however, going to /wp-admin will sti... | [
{
"answer_id": 214610,
"author": "Huy Nguyen",
"author_id": 86851,
"author_profile": "https://wordpress.stackexchange.com/users/86851",
"pm_score": 3,
"selected": false,
"text": "<p>About changing the login url, i already did by mysel. \nIt help me protect my site and prevent brute force... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58657/"
] | I want to change the login url of my Wordpress install away from /wp-admin.php
I am aiming to do so and am looking at changing the .htaccess file to add in:
```
RewriteRule ^login$ http://yourdomain.com/wp-login.php [NC, L]
```
From what I gather however, going to /wp-admin will still allows people to login using t... | About changing the login url, i already did by mysel.
It help me protect my site and prevent brute force
You can change it in htaccess.
But you also need to add the filter to replace old login url in wordpress.
Example to my website:
File .htaccess:
```
RewriteRule ^signin(.*) wp-login.php?%{QUERY_STRING}
```
In y... |
160,100 | <p>Looking over the current WordPress codebase it's clear that functions are over-used. My count is over 8,100 functions/methods are defined inside the WordPress codebase. That is terrible, and a terrible use of resources.</p>
<p><strong>The problem with that many functions (or classes) is that means wordpress is not ... | [
{
"answer_id": 160105,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": false,
"text": "<p>You are acting on awfully big assumption that something like that would improve performance. Spoiler — no, it won't... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12292/"
] | Looking over the current WordPress codebase it's clear that functions are over-used. My count is over 8,100 functions/methods are defined inside the WordPress codebase. That is terrible, and a terrible use of resources.
**The problem with that many functions (or classes) is that means wordpress is not DRY (do not repe... | You are acting on awfully big assumption that something like that would improve performance. Spoiler — no, it won't.
The load process *in very loose terms* consists of:
1. Optionally running code responsible for looking up definitions (autoload or custom).
2. Parsing the file or retrieving results from opcode cache.
... |
160,113 | <p>I have looked over many posts on here and other websites and nothing I do seems to work.</p>
<p>What I am doing is, I have a custom template file and inside that file I have a div that I want to populate using jquery ajax. The problem is that the response is always 0.</p>
<p><strong>Note:</strong> I have used this... | [
{
"answer_id": 160129,
"author": "Tommy Wilkey",
"author_id": 59188,
"author_profile": "https://wordpress.stackexchange.com/users/59188",
"pm_score": 0,
"selected": false,
"text": "<p>For anyone that may come across this issue, my problem was that I included the tw_pages_results.php file... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59188/"
] | I have looked over many posts on here and other websites and nothing I do seems to work.
What I am doing is, I have a custom template file and inside that file I have a div that I want to populate using jquery ajax. The problem is that the response is always 0.
**Note:** I have used this code before in a plugin and n... | Add `die();` to the end of the function handle ajax.
Add return `false;` after jQuery.ajax
```
function tw_pages_results() {
//stuff
die(); }
jQuery(document).ready(function() {
jQuery.ajax({
type : "post",
dataType : "html",
url : "<?php echo site_url(); ?>/wp-admin/admin-ajax.php",
data : {a... |
160,114 | <p>This may seem like a stupid question, and it probably isn't possible, but is it possible for me to set a static home page (using <code>front-page.php</code>) and a blog page (using <code>home.php</code>, I think) in my theme, <strong>and</strong> have the blog page appear on a separate slug WITHOUT changing the page... | [
{
"answer_id": 160379,
"author": "eyedarts",
"author_id": 59011,
"author_profile": "https://wordpress.stackexchange.com/users/59011",
"pm_score": 1,
"selected": false,
"text": "<p>The answer appears to be that it is possible:</p>\n\n<p><a href=\"http://codex.wordpress.org/Creating_a_Stat... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36204/"
] | This may seem like a stupid question, and it probably isn't possible, but is it possible for me to set a static home page (using `front-page.php`) and a blog page (using `home.php`, I think) in my theme, **and** have the blog page appear on a separate slug WITHOUT changing the page settings in my Wordpress installation... | The answer appears to be that it is possible:
<http://codex.wordpress.org/Creating_a_Static_Front_Page>
**Configuration of front-page.php**
>
> If it exists, the front-page.php template file is used on the site's
> front page regardless of whether 'Settings > Reading ->Front page
> displays' is set to "A static p... |
160,115 | <p>Below is some basic code to call specficic categories to our front page post loop. It works fine, except my client wants the categories displayed in a particular order. I know there are other posts about this on the internet, but I didn't see any that addressed it the way my client is asking.</p>
<p>Can I take the ... | [
{
"answer_id": 160261,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>I think the most sane way and easiest way of doing this is to unset the first value in the returned arra... | 2014/09/03 | [
"https://wordpress.stackexchange.com/questions/160115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2391/"
] | Below is some basic code to call specficic categories to our front page post loop. It works fine, except my client wants the categories displayed in a particular order. I know there are other posts about this on the internet, but I didn't see any that addressed it the way my client is asking.
Can I take the $categorie... | I think the most sane way and easiest way of doing this is to unset the first value in the returned array, and then adding it back at the end of the returned array before your `foreach` loop
For this to work, you will need to sort your categories by ID as you need to take category ID 1 and add that to the back. Someth... |
160,128 | <p>I am trying to display a list of event producers, which are stored as a taxonomy. For each event (custom post type) there can be anywhere between 1 and many producers, so I would like to list them, comma separated, with a "&" between the second to last one and last one. The below function does the job, except in... | [
{
"answer_id": 160261,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>I think the most sane way and easiest way of doing this is to unset the first value in the returned arra... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160128",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | I am trying to display a list of event producers, which are stored as a taxonomy. For each event (custom post type) there can be anywhere between 1 and many producers, so I would like to list them, comma separated, with a "&" between the second to last one and last one. The below function does the job, except in the ca... | I think the most sane way and easiest way of doing this is to unset the first value in the returned array, and then adding it back at the end of the returned array before your `foreach` loop
For this to work, you will need to sort your categories by ID as you need to take category ID 1 and add that to the back. Someth... |
160,163 | <p>I am a n00b at wordpress. I'd like my blog to be secret while I finish the design. How do I do this?
Thank you! </p>
| [
{
"answer_id": 160164,
"author": "AnC",
"author_id": 58091,
"author_profile": "https://wordpress.stackexchange.com/users/58091",
"pm_score": 0,
"selected": false,
"text": "<p>thats easy.</p>\n\n<p>I use a Pluing for this \"Private Only\"</p>\n\n<p>Go to add new plugins section and search... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160163",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59044/"
] | I am a n00b at wordpress. I'd like my blog to be secret while I finish the design. How do I do this?
Thank you! | You can use htaccess to disable public access.
in your .htaccess file add this.
```
AuthName "Secure Area"
AuthType Basic
AuthUserFile /path/to/htpasswd/file/.htpasswd
AuthGroupFile /dev/null
require valid-user
```
don't forget to change htpasswd address in this.
You can create .htpasswd from here.
<http://www.htac... |
160,175 | <p>I'm having trouble adding pagination to a page. I'm using <code>WP_query</code> and would like to pull back 4 posts per page. The basic query seems to work OK but I must be missing something regarding pagination.</p>
<pre><code>// The query for 4 posts
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : ... | [
{
"answer_id": 160177,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>Please do not use <code>showposts</code> it got replaced by <code>posts_per_page</code> ages ago.</p... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34215/"
] | I'm having trouble adding pagination to a page. I'm using `WP_query` and would like to pull back 4 posts per page. The basic query seems to work OK but I must be missing something regarding pagination.
```
// The query for 4 posts
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$query = new WP_Query(... | Please do not use `showposts` it got replaced by `posts_per_page` ages ago.
Personally I would add the arguments to the `WP_Query` like shown below, additionally pagination should work like shown below:
```
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 4,... |
160,185 | <p>I have WordPress multisite install, everything was working properly. Developed a custom pugin on my local server (same configuration of Nginx, PHP, MySQL, Memcached, the only difference is OS - Windows 7 locally vs Ubuntu 14.04 LTS on server) and it works just fine. Plugin handles custom front-end reistration, login... | [
{
"answer_id": 160177,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>Please do not use <code>showposts</code> it got replaced by <code>posts_per_page</code> ages ago.</p... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47359/"
] | I have WordPress multisite install, everything was working properly. Developed a custom pugin on my local server (same configuration of Nginx, PHP, MySQL, Memcached, the only difference is OS - Windows 7 locally vs Ubuntu 14.04 LTS on server) and it works just fine. Plugin handles custom front-end reistration, login, p... | Please do not use `showposts` it got replaced by `posts_per_page` ages ago.
Personally I would add the arguments to the `WP_Query` like shown below, additionally pagination should work like shown below:
```
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 4,... |
160,194 | <p>I'm using the following code to display an archive of posts.</p>
<pre><code><?php
// Get years that have posts
$years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" );
// For each year, do the following
foreach ( $y... | [
{
"answer_id": 160177,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>Please do not use <code>showposts</code> it got replaced by <code>posts_per_page</code> ages ago.</p... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59109/"
] | I'm using the following code to display an archive of posts.
```
<?php
// Get years that have posts
$years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" );
// For each year, do the following
foreach ( $years as $year ) {
... | Please do not use `showposts` it got replaced by `posts_per_page` ages ago.
Personally I would add the arguments to the `WP_Query` like shown below, additionally pagination should work like shown below:
```
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 4,... |
160,205 | <p>Currently, I'm trying to display all posts from an author(e.x admin) in a custom page with name that is completely different than these template file listed <strong><a href="http://codex.wordpress.org/Author_Templates#Which_Template_File_is_Used.3F" rel="nofollow">here</a></strong>. </p>
<p>So inside this page, I'm... | [
{
"answer_id": 160177,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>Please do not use <code>showposts</code> it got replaced by <code>posts_per_page</code> ages ago.</p... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59227/"
] | Currently, I'm trying to display all posts from an author(e.x admin) in a custom page with name that is completely different than these template file listed **[here](http://codex.wordpress.org/Author_Templates#Which_Template_File_is_Used.3F)**.
So inside this page, I'm using WP query to get posts from admin like this... | Please do not use `showposts` it got replaced by `posts_per_page` ages ago.
Personally I would add the arguments to the `WP_Query` like shown below, additionally pagination should work like shown below:
```
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 4,... |
160,217 | <p>I have two post types, <em>news</em> and <em>events</em> :</p>
<ul>
<li>A <em>news</em> has no custom fields. </li>
<li>An <em>event</em> has two custom fields : <em>start-date</em> and <em>end-date</em>.</li>
</ul>
<p>I want to display <em>news</em> and <em>events</em> on the same page, ideally with one single qu... | [
{
"answer_id": 237162,
"author": "italiansoda",
"author_id": 71608,
"author_profile": "https://wordpress.stackexchange.com/users/71608",
"pm_score": 2,
"selected": false,
"text": "<p>You can add another array into your meta_query to include all posts from your second post type. </p>\n\n<... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1381/"
] | I have two post types, *news* and *events* :
* A *news* has no custom fields.
* An *event* has two custom fields : *start-date* and *end-date*.
I want to display *news* and *events* on the same page, ideally with one single query.
One important fact is that *events* have to be ordered by *end-date* and that only fut... | You can add another array into your meta\_query to include all posts from your second post type.
Given in your example, you have 2 post types
1. events
2. news
If you can pick a `meta_key` that only exists for `news` but doesn't exist on `events`, then this set of args would return all news post types and still fil... |
160,219 | <p>I moved from <code>www.domain1.com</code> to <code>www.domain2.com</code></p>
<p>However, the image paths are still pointing at <code>www.domain1.com/wp-content/uploads...</code>. So when <code>www.domain1.com</code> went down, all my images are not showing anymore.</p>
<p>I updated the <code>wp_posts</code> table... | [
{
"answer_id": 160226,
"author": "Steve Mitchell",
"author_id": 59233,
"author_profile": "https://wordpress.stackexchange.com/users/59233",
"pm_score": 4,
"selected": false,
"text": "<p>It sounds like you need to change the URLs for the old images. The easiest & quickest way of doing... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16266/"
] | I moved from `www.domain1.com` to `www.domain2.com`
However, the image paths are still pointing at `www.domain1.com/wp-content/uploads...`. So when `www.domain1.com` went down, all my images are not showing anymore.
I updated the `wp_posts` table where all attachments now point to `www.domain2.com/wp-content/uploads.... | It sounds like you need to change the URLs for the old images. The easiest & quickest way of doing that is to do a find and replace on the MySQL database.
You can use PHPMyAdmin (usually provided by your web host) or other MySQL editing software such as Sequel Pro to make changes to your MySQL database without touchin... |
160,224 | <p>I have a custom menu using <code>add_menu_page</code>:</p>
<pre><code>add_menu_page('My menu' , 'Some text', 'read', 'nwcm');
</code></pre>
<p>Under it, I show a custom post type menu item;</p>
<pre><code>// Create the news custom post type
register_post_type('nwcm_news', array(
'labels' => array(
... | [
{
"answer_id": 160235,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 5,
"selected": true,
"text": "<p>You have some messed up code. </p>\n\n<p>I have reformatted your code to code which actually works.</p>\... | 2014/09/04 | [
"https://wordpress.stackexchange.com/questions/160224",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7515/"
] | I have a custom menu using `add_menu_page`:
```
add_menu_page('My menu' , 'Some text', 'read', 'nwcm');
```
Under it, I show a custom post type menu item;
```
// Create the news custom post type
register_post_type('nwcm_news', array(
'labels' => array(
'name' => __('News for clients', NWCM_TEXT_DOMAIN) ... | You have some messed up code.
I have reformatted your code to code which actually works.
The following solution allows you to give your Custom Post Type menu a menu name of what ever you want. Just change the label "menu\_name".
**POST TYPE**
```
// Create the news custom post type
register_post_type('nwcm_news', ... |
160,249 | <p>I have a lot of plugins using external scripts from googleapis - these are throttled/blocked in China and it causes a lot of problems. Without rewriting the lines in all the plugins/themes and break my upgrade path, is there a way we can do it in my themes function.php file so I rewrite all the $src urls to local ur... | [
{
"answer_id": 160252,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 3,
"selected": true,
"text": "<p>Well of course you can. All you need to find is what handle they are using for those scripts. let's say the... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160249",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59252/"
] | I have a lot of plugins using external scripts from googleapis - these are throttled/blocked in China and it causes a lot of problems. Without rewriting the lines in all the plugins/themes and break my upgrade path, is there a way we can do it in my themes function.php file so I rewrite all the $src urls to local urls? | Well of course you can. All you need to find is what handle they are using for those scripts. let's say they are uing plugin-script handle. Then you deregister and register script again with your URL. Like this.
```
function wcs_scripts_styles() {
wp_deregister_script( 'plugin-script' );
wp_register_script( 'p... |
160,272 | <p>I'm pretty new to wordpress (been using wordpress for a week now) and took over a site from a colleague of mine . He partially created a plugin to input "Specials" onto the site. At the moment, the fields that it shows is "Title", and "Body" with a featured image. This is what the code looks like:</p>
<pre><code>pu... | [
{
"answer_id": 160252,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 3,
"selected": true,
"text": "<p>Well of course you can. All you need to find is what handle they are using for those scripts. let's say the... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160272",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59212/"
] | I'm pretty new to wordpress (been using wordpress for a week now) and took over a site from a colleague of mine . He partially created a plugin to input "Specials" onto the site. At the moment, the fields that it shows is "Title", and "Body" with a featured image. This is what the code looks like:
```
public function ... | Well of course you can. All you need to find is what handle they are using for those scripts. let's say they are uing plugin-script handle. Then you deregister and register script again with your URL. Like this.
```
function wcs_scripts_styles() {
wp_deregister_script( 'plugin-script' );
wp_register_script( 'p... |
160,273 | <p>I just updated WordPress to the latest version, 4.0, and I had a bad surprise - timthumb stopped working. the thumbnails are not generated. I cleared theme's cache folder, and checked to see if chmod is 755 - it is. timthumb is also updated to the latest version.
this is how I call the thumbnail </p>
<pre><code>&l... | [
{
"answer_id": 160274,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 1,
"selected": false,
"text": "<p>If folder permission are correct then it should work.\nAnyway try this one. And let me know how it goes.</... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160273",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6927/"
] | I just updated WordPress to the latest version, 4.0, and I had a bad surprise - timthumb stopped working. the thumbnails are not generated. I cleared theme's cache folder, and checked to see if chmod is 755 - it is. timthumb is also updated to the latest version.
this is how I call the thumbnail
```
<img src="<?php ... | solved. seems that the problem was with a file added in wp-content - for security reasons, I added a .htaccess file to wp-content folder, and that was blocking timthumb. In case others have problems, remember not to limit access to wp-content. |
160,279 | <p>Does WordPress work without a theme? If so, then how does it work? Please explain in brief.</p>
<p>If WordPress is displaying content without a theme, what controls the output?</p>
| [
{
"answer_id": 160285,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 5,
"selected": false,
"text": "<p>I think there's a song for that:</p>\n\n<blockquote>\n <p>\"Imagine there's no <strong>theme</strong>. It's ... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57794/"
] | Does WordPress work without a theme? If so, then how does it work? Please explain in brief.
If WordPress is displaying content without a theme, what controls the output? | I think there's a song for that:
>
> "Imagine there's no **theme**. It's easy if you try. No hell below us.
> Above us only sky ..." ;-)
>
>
>
So in that imaginary dream:
* you can still fetch the RSS feeds from your site:
```
example.com/feed/
```
* you can still login to your backend:
```
example.com/wp-l... |
160,287 | <p>Is it possible to add meta title, meta description, meta keywords in every page without installing plugin? </p>
<p>My client require not to install plugin. I am curious about this case, all I know is the admin should install the seo plugin in their wordpress to have an insertion of meta.</p>
| [
{
"answer_id": 160294,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 4,
"selected": false,
"text": "<p>Although I would advice you to avoid this and use a plugin for this work. Because only a dedicated plugin ... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59015/"
] | Is it possible to add meta title, meta description, meta keywords in every page without installing plugin?
My client require not to install plugin. I am curious about this case, all I know is the admin should install the seo plugin in their wordpress to have an insertion of meta. | Although I would advice you to avoid this and use a plugin for this work. Because only a dedicated plugin can help SEO. "WordPress SEO" from yoost is a great plugin for SEO.
That being said, here is the code for adding meta description and keywords in header. Paste this in theme's functions.php file.
```
function add... |
160,308 | <p>I have a very strange problem and I am stuck. I want the single page to display posts with the post_status of publish and future. So I added this code to my functions.php in my theme:</p>
<pre><code>function display_future_posts() {
global $wp_query;
if( !is_admin() && $wp_query->is_main_query() ... | [
{
"answer_id": 160309,
"author": "Remy Sheppard",
"author_id": 25105,
"author_profile": "https://wordpress.stackexchange.com/users/25105",
"pm_score": 0,
"selected": false,
"text": "<p>It won't let me comment because I'm not cool enough yet.</p>\n\n<p>Have you considered using wordpress'... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160308",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59278/"
] | I have a very strange problem and I am stuck. I want the single page to display posts with the post\_status of publish and future. So I added this code to my functions.php in my theme:
```
function display_future_posts() {
global $wp_query;
if( !is_admin() && $wp_query->is_main_query() && $wp_query->is_single(... | You are stepping on a query mine. It is easy to assume that:
1. You can change query.
2. Parameters are well defined.
3. So by changing of parameters you can achieve desired results.
In reality there are plenty of query parameters, touching which leads into horrible dead ends. WordPress is engineered to query and sho... |
160,322 | <p>I have social icons that are being set via my theme options in WP. Of course if they are not entered I am getting an Undefined Index error. I tried wrapping isset around which removes the error, but when my options panel is saved it shows all the icons? Even if they have not been set? Confused on how to do the isset... | [
{
"answer_id": 160309,
"author": "Remy Sheppard",
"author_id": 25105,
"author_profile": "https://wordpress.stackexchange.com/users/25105",
"pm_score": 0,
"selected": false,
"text": "<p>It won't let me comment because I'm not cool enough yet.</p>\n\n<p>Have you considered using wordpress'... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59286/"
] | I have social icons that are being set via my theme options in WP. Of course if they are not entered I am getting an Undefined Index error. I tried wrapping isset around which removes the error, but when my options panel is saved it shows all the icons? Even if they have not been set? Confused on how to do the isset co... | You are stepping on a query mine. It is easy to assume that:
1. You can change query.
2. Parameters are well defined.
3. So by changing of parameters you can achieve desired results.
In reality there are plenty of query parameters, touching which leads into horrible dead ends. WordPress is engineered to query and sho... |
160,326 | <p>I am trying to add a list of terms as a class for custom post types.</p>
<pre><code><?php while($portfolio->have_posts()) : $portfolio->the_post(); ?>
<?php $categories = get_the_terms($post->ID, 'project_type');
foreach($categories as $category){
... | [
{
"answer_id": 160329,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 2,
"selected": false,
"text": "<p>If you use <code>return</code> then your loop will not work properly. You can try the code this wa... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160326",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58541/"
] | I am trying to add a list of terms as a class for custom post types.
```
<?php while($portfolio->have_posts()) : $portfolio->the_post(); ?>
<?php $categories = get_the_terms($post->ID, 'project_type');
foreach($categories as $category){
return $... | I found that the best way to handle this problem was to leverage the post\_class function and add the loop through the function.php file. this is the code in the function.php file:
```
function term_class($classes){
global $post;
$taxonomies = array('project_type');
$terms = get_the_terms( $post->ID , $taxonomies);
... |
160,345 | <p>I'm currently trying to create/update one post while also saving the current post that I'm on. It's all happening here:</p>
<pre><code>add_action('save_post', 'wysiwyg_save_meta');
function wysiwyg_save_meta(){
global $post;
$editor_id = WYSIWYG_EDITOR_ID;
$meta_key = WYSIWYG_META_KEY;
if(isset($_R... | [
{
"answer_id": 160329,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 2,
"selected": false,
"text": "<p>If you use <code>return</code> then your loop will not work properly. You can try the code this wa... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50740/"
] | I'm currently trying to create/update one post while also saving the current post that I'm on. It's all happening here:
```
add_action('save_post', 'wysiwyg_save_meta');
function wysiwyg_save_meta(){
global $post;
$editor_id = WYSIWYG_EDITOR_ID;
$meta_key = WYSIWYG_META_KEY;
if(isset($_REQUEST[$editor... | I found that the best way to handle this problem was to leverage the post\_class function and add the loop through the function.php file. this is the code in the function.php file:
```
function term_class($classes){
global $post;
$taxonomies = array('project_type');
$terms = get_the_terms( $post->ID , $taxonomies);
... |
160,355 | <p>I'm using the native Wordpress menu. I have two top-level links with sub menus - I'd like for those sub menus to display the name of the parent menu item. So if I have a parent menu item named "Gardens" containing a sub menu of "Flowers" and "Plants", that sub menu should say "Gardens" at the top, and then list the ... | [
{
"answer_id": 160809,
"author": "hmakein",
"author_id": 49874,
"author_profile": "https://wordpress.stackexchange.com/users/49874",
"pm_score": 2,
"selected": true,
"text": "<p>I ended up removing that code from my functions.php file and used jQuery instead. Here's how I took care of i... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49874/"
] | I'm using the native Wordpress menu. I have two top-level links with sub menus - I'd like for those sub menus to display the name of the parent menu item. So if I have a parent menu item named "Gardens" containing a sub menu of "Flowers" and "Plants", that sub menu should say "Gardens" at the top, and then list the sub... | I ended up removing that code from my functions.php file and used jQuery instead. Here's how I took care of it, if anyone wants to know:
```
$('.menu-item-has-children > a').each(function(){
var submenuHeading = $(this).text();
$('.sub-menu', ($(this).parent('.menu-item-has-children'))).prepend('<h... |
160,359 | <p>Does anyone know how to include the admin bar in a page template where <code>wp_head()</code> and <code>wp_footer()</code> are not present? I'm developing a template other scripts and styles are just getting in the way. Rather than go through and dequeue all of the stuff I don't need, I've simple removed the two hoo... | [
{
"answer_id": 160809,
"author": "hmakein",
"author_id": 49874,
"author_profile": "https://wordpress.stackexchange.com/users/49874",
"pm_score": 2,
"selected": true,
"text": "<p>I ended up removing that code from my functions.php file and used jQuery instead. Here's how I took care of i... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41461/"
] | Does anyone know how to include the admin bar in a page template where `wp_head()` and `wp_footer()` are not present? I'm developing a template other scripts and styles are just getting in the way. Rather than go through and dequeue all of the stuff I don't need, I've simple removed the two hooks altogether. All I want... | I ended up removing that code from my functions.php file and used jQuery instead. Here's how I took care of it, if anyone wants to know:
```
$('.menu-item-has-children > a').each(function(){
var submenuHeading = $(this).text();
$('.sub-menu', ($(this).parent('.menu-item-has-children'))).prepend('<h... |
160,362 | <p>I have a shortcode defined in a plugin as follows:</p>
<pre><code>// [tag1] -> Some Longer Text
function shortcode_example1() {
return 'Some Longer Text';
}
add_shortcode('tag1', 'shortcode_example1');
</code></pre>
<p>Now within a wordpress page I am trying to access the plugin as follows:</p>
<pre><code>... | [
{
"answer_id": 160504,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 5,
"selected": false,
"text": "<p>There are a couple of things to check here</p>\n\n<ul>\n<li><p>One: Is your plugin activated. </p></li>... | 2014/09/05 | [
"https://wordpress.stackexchange.com/questions/160362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59298/"
] | I have a shortcode defined in a plugin as follows:
```
// [tag1] -> Some Longer Text
function shortcode_example1() {
return 'Some Longer Text';
}
add_shortcode('tag1', 'shortcode_example1');
```
Now within a wordpress page I am trying to access the plugin as follows:
```
[tag1]
```
However, the shortcode is n... | Thanks for your responses. After further investigation, I found that the plugin file where my shortcode was defined was showing up as "inactive". Once I moved my shortcode definitions into an active file, then everything began to work. I hope this is useful for anybody who runs into this in the future.
Thanks again! |
160,390 | <p>I am trying to set up my new theme in a proper way. I have created a custom home page for my new theme called "template-home.php" and then I created a "blog" page. I went to settings and changed my "Reading" settings to "A static page" and I set my front page to my home template and then I set my "Posts page" to "bl... | [
{
"answer_id": 160392,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>Your blog page is actually your home page, so you need to use <code>is_home()</code>. For the static fr... | 2014/09/06 | [
"https://wordpress.stackexchange.com/questions/160390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14761/"
] | I am trying to set up my new theme in a proper way. I have created a custom home page for my new theme called "template-home.php" and then I created a "blog" page. I went to settings and changed my "Reading" settings to "A static page" and I set my front page to my home template and then I set my "Posts page" to "blog"... | Your blog page is actually your home page, so you need to use `is_home()`. For the static frontpage, `is_front_page()` would be used
**EDIT**
Sorry for being confusing :-). This how it works when a static frontpage is set
The page set as your frontpage is actaully just a cover page. When you think of a book, this is... |
160,391 | <p>I worked on a Drupal site for a client, but he wanted to keep his blog on WP, so I manually created a 'blog' folder on the root of the Drupal site and moved all the WP content there. I uploaded the database and change the wp-config.php settings accordingly.</p>
<p>The main Drupal site (example.com) works fine, and ... | [
{
"answer_id": 160394,
"author": "Jamie",
"author_id": 14761,
"author_profile": "https://wordpress.stackexchange.com/users/14761",
"pm_score": 3,
"selected": true,
"text": "<p>make a backup of your SQL database for the site and try running these queries manually on the database through p... | 2014/09/06 | [
"https://wordpress.stackexchange.com/questions/160391",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14482/"
] | I worked on a Drupal site for a client, but he wanted to keep his blog on WP, so I manually created a 'blog' folder on the root of the Drupal site and moved all the WP content there. I uploaded the database and change the wp-config.php settings accordingly.
The main Drupal site (example.com) works fine, and when I cli... | make a backup of your SQL database for the site and try running these queries manually on the database through php myadmin. change the URLs to match your site <http://example.com/blog>
As always, be careful when running queries on the database
```
UPDATE wp_options SET option_value = replace(option_value, 'http://ww... |
160,416 | <p>I'm currently using <code>archive.php</code> as a generic listing for categories, tags, authors, etc. However, my custom post types have a very customized archive page that's completely different from <code>archive.php</code>.</p>
<p>I'm wondering if there's a way to create one archive file that acts as a generic t... | [
{
"answer_id": 160420,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 3,
"selected": true,
"text": "<pre><code>add_filter( 'template_include', 'wpsites_cpt_archive_page_template', 99 );\n\nfunction wpsites_cpt_a... | 2014/09/06 | [
"https://wordpress.stackexchange.com/questions/160416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20963/"
] | I'm currently using `archive.php` as a generic listing for categories, tags, authors, etc. However, my custom post types have a very customized archive page that's completely different from `archive.php`.
I'm wondering if there's a way to create one archive file that acts as a generic template for **only** my custom p... | ```
add_filter( 'template_include', 'wpsites_cpt_archive_page_template', 99 );
function wpsites_cpt_archive_page_template( $template ) {
if ( is_post_type_archive() ) {
$new_template = locate_template( array( 'your-cpt-template.php' ) );
if ( '' != $new_template ) {
return $new_templa... |
160,453 | <p>It is irritating me why AJAX response is 0 !. I want to check whether the email address is valid or invalid on blur.Please suggest me here is my code
This is my php code</p>
<pre><code> add_action('wp_ajax_send_message_to_customer','add_send_msg');?>
<form>
<input type="text" name="email_customer" ... | [
{
"answer_id": 160461,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 0,
"selected": false,
"text": "<p>Try to write the 'data' and 'action' like this -</p>\n\n<p>action: 'send_message_to_customer'</p>\n\n<p>data:{... | 2014/09/06 | [
"https://wordpress.stackexchange.com/questions/160453",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59333/"
] | It is irritating me why AJAX response is 0 !. I want to check whether the email address is valid or invalid on blur.Please suggest me here is my code
This is my php code
```
add_action('wp_ajax_send_message_to_customer','add_send_msg');?>
<form>
<input type="text" name="email_customer" id="email_customer"/>
</fo... | First, don't enqueue on the `init` action. Enqueue on the `wp_enqueue_scripts` action for the front end, or the `admin_enqueue_scripts` action for the back end.
Second, the `wp_ajax_*` action will only work for logged in users. For non-logged in users, you must use the `wp_ajax_nopriv_*` action instead. If it needs to... |
160,456 | <p>I would like to change the body of the password reset email that WP sends out with something more friendly.</p>
<p>I am trying to use the <a href="http://developer.wordpress.org/reference/hooks/retrieve_password_message/" rel="nofollow">"retrieve_password_message"</a> filter but I am messing it up. </p>
<p>Can so... | [
{
"answer_id": 160458,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 0,
"selected": false,
"text": "<pre><code>add_filter(\"retrieve_password_message\", \"your_custom_message\", 99, 2);\n\n function your_custom_m... | 2014/09/06 | [
"https://wordpress.stackexchange.com/questions/160456",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38513/"
] | I would like to change the body of the password reset email that WP sends out with something more friendly.
I am trying to use the ["retrieve\_password\_message"](http://developer.wordpress.org/reference/hooks/retrieve_password_message/) filter but I am messing it up.
Can someone kindly post a sample code? | the given answers have good intentions. But are not good. There are more parameters to the filter function call, 4 to be exact.
this worked for me for the message (i wanted to replace username with user email)
note we have a multi site page. You might want to replace network\_site\_url with `get_site_url()`
typicall... |
160,459 | <p>I was thinking of putting this on the wordpress stackexchange site but it has to do more with CSS then Wordpress.</p>
<p>However unless I have to go into some plugin css files to customize the css then I have to go there and ask this question?</p>
<p>I'm looking to overwrite some !important css styles that are com... | [
{
"answer_id": 160466,
"author": "Seamus Leahy",
"author_id": 33106,
"author_profile": "https://wordpress.stackexchange.com/users/33106",
"pm_score": 1,
"selected": false,
"text": "<p>Some of these plugins and frameworks allow you to disable the default styles which then allows you to co... | 2014/09/06 | [
"https://wordpress.stackexchange.com/questions/160459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | I was thinking of putting this on the wordpress stackexchange site but it has to do more with CSS then Wordpress.
However unless I have to go into some plugin css files to customize the css then I have to go there and ask this question?
I'm looking to overwrite some !important css styles that are coming from either t... | Some of these plugins and frameworks allow you to disable the default styles which then allows you to copy theirs and then alter it for your theme. But let us say that isn't going to be possible. Then you need to have a higher [CSS selector precedent](http://www.vanseodesign.com/css/css-specificity-inheritance-cascaade... |
160,509 | <p>How I can display content for a single post?
My code:</p>
<pre><code>if (is_single()){
get_header();
get_sidebar('left-article');
render_article();
get_footer();
}
</code></pre>
<p>In <code>render_article</code> I call <code>single_post_title()</code> to get title of post.
However I don't know how ... | [
{
"answer_id": 160510,
"author": "kabr",
"author_id": 22821,
"author_profile": "https://wordpress.stackexchange.com/users/22821",
"pm_score": 5,
"selected": true,
"text": "<ol>\n<li><p>Create a file named single.php. This will automatically get all you single posts. For more information ... | 2014/09/07 | [
"https://wordpress.stackexchange.com/questions/160509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59358/"
] | How I can display content for a single post?
My code:
```
if (is_single()){
get_header();
get_sidebar('left-article');
render_article();
get_footer();
}
```
In `render_article` I call `single_post_title()` to get title of post.
However I don't know how to get time and contents of the post as I can't ... | 1. Create a file named single.php. This will automatically get all you single posts. For more information about WordPress' template hierarchy, [read the Codex](http://codex.wordpress.org/Template_Hierarchy)
2. Inside single.php, run the default loop and get header.php, sidebar.php and footer.php
```
<?php get_header()... |
160,524 | <p>i want to know what is wrong with this code:</p>
<pre><code>if ( !empty( $_POST['email'] ) ){
if (!is_email(esc_attr( $_POST['email'] )))
$error[] = __('The Email you entered is not valid. please try again.', 'profile');
elseif(email_exists(esc_attr( $_POST['email'] )) != $current_user-... | [
{
"answer_id": 160526,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": true,
"text": "<p>Well, you comparing the results of the <code>email_exists</code> function with <code>$current_user->ID</cod... | 2014/09/07 | [
"https://wordpress.stackexchange.com/questions/160524",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58718/"
] | i want to know what is wrong with this code:
```
if ( !empty( $_POST['email'] ) ){
if (!is_email(esc_attr( $_POST['email'] )))
$error[] = __('The Email you entered is not valid. please try again.', 'profile');
elseif(email_exists(esc_attr( $_POST['email'] )) != $current_user->ID )
... | Well, you comparing the results of the `email_exists` function with `$current_user->ID`. If email exists, `email_exists()` return the ID of the user using that email or false if the email doesn't exists. Imaging you are checking a email not being using, `email_exists()` return false and this `if` will validate:
```
el... |
160,529 | <p>I want to display the number of comments on a post using the template tag </p>
<pre><code> <?php comments_number( $zero, $one, $more ); ?>
</code></pre>
<p>However, for some reason this tag does nothing and it is not printed to the page. You can view an example of what I mean at <a href="http://bl... | [
{
"answer_id": 160536,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 0,
"selected": false,
"text": "<p>You will have to use this function in <strong>loop</strong>.</p>\n\n<p>\"Displays the total number of comm... | 2014/09/07 | [
"https://wordpress.stackexchange.com/questions/160529",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58657/"
] | I want to display the number of comments on a post using the template tag
```
<?php comments_number( $zero, $one, $more ); ?>
```
However, for some reason this tag does nothing and it is not printed to the page. You can view an example of what I mean at <http://blog.diginomics.com/bitcoins-innate-regula... | use it for comment number `<?php comments_number( 'no responses', 'one response', '% responses' ); ?>` |
160,538 | <p>I allow uploading a selected few types of files from the frontend, e.g. .zip, .mp4, .jpeg and .pdf. Till now all these file types had no issues getting attached to the post it is uploaded to. However after upgrading to WordPress 4.0, I have not been able to upload specific .zip file type from the frontend, although ... | [
{
"answer_id": 160536,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 0,
"selected": false,
"text": "<p>You will have to use this function in <strong>loop</strong>.</p>\n\n<p>\"Displays the total number of comm... | 2014/09/07 | [
"https://wordpress.stackexchange.com/questions/160538",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | I allow uploading a selected few types of files from the frontend, e.g. .zip, .mp4, .jpeg and .pdf. Till now all these file types had no issues getting attached to the post it is uploaded to. However after upgrading to WordPress 4.0, I have not been able to upload specific .zip file type from the frontend, although it ... | use it for comment number `<?php comments_number( 'no responses', 'one response', '% responses' ); ?>` |
160,568 | <p>If I want to create a link that will always show the latest post how can i do that? </p>
<p>Lets say I have three post types and there are three links with posts names (like a nav list) to those post types. How do I make it dynamic? I can't make it like this: <code>blah.com/post</code>, because it always will be al... | [
{
"answer_id": 160571,
"author": "DrewAPicture",
"author_id": 33309,
"author_profile": "https://wordpress.stackexchange.com/users/33309",
"pm_score": 2,
"selected": false,
"text": "<p>You could run three <code>get_posts()</code> calls to snag the latest post from each post type, and buil... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160568",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27789/"
] | If I want to create a link that will always show the latest post how can i do that?
Lets say I have three post types and there are three links with posts names (like a nav list) to those post types. How do I make it dynamic? I can't make it like this: `blah.com/post`, because it always will be always changing. | If I understand well you want to show the last post (one post) from one of the 3 post types you have, using a dynamic url like `http://example.com/latest`.
First of all lets add a filter to [`'do_parse_request'`](http://developer.wordpress.org/reference/hooks/do_parse_request/) filter:
```
add_filter( 'do_parse_reque... |
160,569 | <p><a href="https://core.trac.wordpress.org/ticket/20276" rel="nofollow">Cookies are now tied to internal sessions in WordPress 4.0</a>. </p>
<p>This means plugins using basic cookie authentication will have trouble because a token is required for publishing a post or page (as well as update a plugin or core). I've se... | [
{
"answer_id": 167334,
"author": "here",
"author_id": 28978,
"author_profile": "https://wordpress.stackexchange.com/users/28978",
"pm_score": 0,
"selected": false,
"text": "<p>Revised: After adding an early test to avoid trying to re-login an already-logged-in user, I was able to remove ... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47326/"
] | [Cookies are now tied to internal sessions in WordPress 4.0](https://core.trac.wordpress.org/ticket/20276).
This means plugins using basic cookie authentication will have trouble because a token is required for publishing a post or page (as well as update a plugin or core). I've seen this reported for three different... | Actually, just doing this check fixed this issue.
```
if(!is_user_logged_in())
{
wp_set_current_user($userid);
if(wp_validate_auth_cookie()==FALSE)
{
wp_set_auth_cookie($userid, true, false);
}
}
```
seems to have fixed this issue.
@here,your proposed solutio... |
160,583 | <pre><code><div class="text_area">
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
the_content();
} // end while
} // end if
?>
<div class="publish_date">Post Date: <?php the_time('F jS, Y');?> By <?php the_author_posts_link(); ?><?php _e( ' Posted i... | [
{
"answer_id": 160586,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": true,
"text": "<p>This part</p>\n\n<pre><code><div class=\"publish_date\">Post Date: <?php the_time('F jS, Y');?&... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160583",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59321/"
] | ```
<div class="text_area">
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
the_content();
} // end while
} // end if
?>
<div class="publish_date">Post Date: <?php the_time('F jS, Y');?> By <?php the_author_posts_link(); ?><?php _e( ' Posted in' ); ?> <?php the_category( ', ' ); ?>·... | This part
```
<div class="publish_date">Post Date: <?php the_time('F jS, Y');?> By <?php the_author_posts_link(); ?><?php _e( ' Posted in' ); ?> <?php the_category( ', ' ); ?>· Tags: <a href="#">CSS</a> · <a href="#">Web Design</a> · <a href="#">Full Story</a></div>
</div>
```
should be **inside** the loop (just... |
160,598 | <p>I need a page to display all posts (in Foods custom post type) that have comments by the logged in user.</p>
<p>The list just needs to show the title with link to the title.</p>
<p>Is this possible?</p>
<p>What I've tried so far:</p>
<pre><code><?php if (is_user_logged_in() ) : ?>
<?php
if ( is... | [
{
"answer_id": 160607,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>If we want to avoid any filters and manual SQL queries, we could try (untested):</p>\n\n<pre><code>$args = arr... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160598",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48370/"
] | I need a page to display all posts (in Foods custom post type) that have comments by the logged in user.
The list just needs to show the title with link to the title.
Is this possible?
What I've tried so far:
```
<?php if (is_user_logged_in() ) : ?>
<?php
if ( is_user_logged_in()) {
global $curren... | If we want to avoid any filters and manual SQL queries, we could try (untested):
```
$args = array(
'post_type' => 'foods',
'posts_per_page' => 5,
'post__in' => array_unique(
wp_list_pluck(
get_comments( array(
'user_id' => get_current_user_id()
... |
160,608 | <p>I'm working at a WordPress theme. Since I need to display featured posts, related posts, some widgets with recent posts and so on, I need to use multiple custom loops. Because of this, the number of database queries have also increased.</p>
<p>In an attempt to optimize the theme for better performance I came across... | [
{
"answer_id": 160618,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>I have actually worked on a post yesterday (check it out <a href=\"https://wordpress.stackexchange.com/a... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160608",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59391/"
] | I'm working at a WordPress theme. Since I need to display featured posts, related posts, some widgets with recent posts and so on, I need to use multiple custom loops. Because of this, the number of database queries have also increased.
In an attempt to optimize the theme for better performance I came across <http://c... | I have actually worked on a post yesterday (check it out [here](https://wordpress.stackexchange.com/a/145960/31545)) and was hit by the same problem. I'm also new to the [Transient API](http://codex.wordpress.org/Transients_API), never actually worked with it :-).
The problem here is that for a specific loop you need ... |
160,633 | <p>I am setting up a new WordPress Multisite instance, and am still working out some kinks in the stack. Most significantly at the moment, user registration emails are not being delivered for some reason. As a result, several usernames are stuck in limbo as the confirmation emails necessary to activate them are lost.</... | [
{
"answer_id": 160639,
"author": "DrewAPicture",
"author_id": 33309,
"author_profile": "https://wordpress.stackexchange.com/users/33309",
"pm_score": 3,
"selected": false,
"text": "<p>If you want a quick solution for deleting a signup in the database for a specific user, this should do w... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59396/"
] | I am setting up a new WordPress Multisite instance, and am still working out some kinks in the stack. Most significantly at the moment, user registration emails are not being delivered for some reason. As a result, several usernames are stuck in limbo as the confirmation emails necessary to activate them are lost.
For... | DB Access layer & deleting rows
-------------------------------
WordPress uses the `wpdb` class to manage access to the database layer using the `global $wpdb`. The class provides a method named [`delete()`](http://codex.wordpress.org/Class_Reference/wpdb#DELETE_Rows) to delete rows from tables:
```
$wpdb->delete( $t... |
160,652 | <p>I have this code:</p>
<pre><code>$args = array(
'posts_per_page' => -1,
'post_type' => 'product',
'meta_key' => 'custom key',
'orderby' => 'meta_value',
'order' => 'ASC',
'no_found_rows' => true,
'cache_results' => false,
'include_children' =>... | [
{
"answer_id": 160657,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 4,
"selected": true,
"text": "<p>No, not as a straight WP_Query. This is because of several factors, with the main one being that mySQL doesn't nati... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38848/"
] | I have this code:
```
$args = array(
'posts_per_page' => -1,
'post_type' => 'product',
'meta_key' => 'custom key',
'orderby' => 'meta_value',
'order' => 'ASC',
'no_found_rows' => true,
'cache_results' => false,
'include_children' => false,
'tax_query' => array(
... | No, not as a straight WP\_Query. This is because of several factors, with the main one being that mySQL doesn't natively have a natural sort for alphanumeric columns.
WordPress does support a "meta\_value\_num" for the orderby parameter, which causes it to cast the values to numeric to perform the sort, and this works... |
160,679 | <p>I have posts that are full posts with page content and images, etc. Then I have potential future posts, which I still want to list on my category pages, but that do not have content yet and do not deserve their own page. I want to be able to set their slug to nothing, or to a standard "null" sort of value that I can... | [
{
"answer_id": 160681,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>If you are using pretty permalinks, all posts will have slugs.</p>\n\n<p>If you want to list these posts but... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56908/"
] | I have posts that are full posts with page content and images, etc. Then I have potential future posts, which I still want to list on my category pages, but that do not have content yet and do not deserve their own page. I want to be able to set their slug to nothing, or to a standard "null" sort of value that I can qu... | ```
add_filter('wp_unique_post_slug', 'my_unique_slug', 1, 5);
function my_unique_slug($slug, $post_ID, $post_status, $post_type, $post_parent = 0){
$p = get_post_field('post_content', $post_ID);
if($p){
return $slug;
}
return 'NULL';
}
```
This basically overrides Wordpress' default unique po... |
160,682 | <p>Based on the link maioman posted, below I have revised this question: </p>
<p>I am having trouble getting a custom post type/taxonomy to work. I want a custom post type of Episodes, and the taxonomy for the custom post type to be Episodes with terms that are generated by the user. </p>
<p>I was able to get</p>
<p... | [
{
"answer_id": 160683,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>You can't do this, at least not in any non-hacky way. You basically want \"episodes\" to represent 2 differe... | 2014/09/08 | [
"https://wordpress.stackexchange.com/questions/160682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33102/"
] | Based on the link maioman posted, below I have revised this question:
I am having trouble getting a custom post type/taxonomy to work. I want a custom post type of Episodes, and the taxonomy for the custom post type to be Episodes with terms that are generated by the user.
I was able to get
episodes/custom-term-na... | You can't do this, at least not in any non-hacky way. You basically want "episodes" to represent 2 different things at the same time, but WP has no way of knowing which is intended for any given path.
I guess you could put some logic at the top of your single post template for your CPT, to check if the "post name" is ... |
160,701 | <p><strong>Here's what I'm trying to do:</strong></p>
<ol>
<li>Make it so the first 6 posts are displayed differently on the homepage than posts 7 and on. The first six posts should grab their featured thumbnail images and use them as a background, then overlay the background with its title.</li>
<li>Posts 7~ have the... | [
{
"answer_id": 160816,
"author": "Nerolathe",
"author_id": 59458,
"author_profile": "https://wordpress.stackexchange.com/users/59458",
"pm_score": 0,
"selected": false,
"text": "<h1>The Problem</h1>\n\n<p>It's been awhile since I have messed with HTML, but if I remember correctly the <co... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59417/"
] | **Here's what I'm trying to do:**
1. Make it so the first 6 posts are displayed differently on the homepage than posts 7 and on. The first six posts should grab their featured thumbnail images and use them as a background, then overlay the background with its title.
2. Posts 7~ have their own separate style, in this c... | Solution was to remove the style tag and and write the background styling right into the .featured\_box div. Thank you to @ckhicks on Twitter for the solution, and thank you everyone else for trying to help out too <3
```
<?php $background = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'full' ); ?... |
160,702 | <p>question seems to be similar to the one <a href="https://wordpress.stackexchange.com/questions/139089/space-in-wordpress-attribute-causing-problems">asked here</a> but the answer went down a different path.</p>
<p>Pretty much if a user enters a shortcode attribute with a space it will get overwritten by the default... | [
{
"answer_id": 160726,
"author": "csilk",
"author_id": 20232,
"author_profile": "https://wordpress.stackexchange.com/users/20232",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like I was multi-lining the shortcode itself, wordpress wasn't a fan.</p>\n\n<p>Thanks @bonger</p>\n"
}... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160702",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20232/"
] | question seems to be similar to the one [asked here](https://wordpress.stackexchange.com/questions/139089/space-in-wordpress-attribute-causing-problems) but the answer went down a different path.
Pretty much if a user enters a shortcode attribute with a space it will get overwritten by the default value and I can't fi... | Looks like I was multi-lining the shortcode itself, wordpress wasn't a fan.
Thanks @bonger |
160,705 | <p>I have a category archive page at: <a href="http://mysite.com/news" rel="noreferrer">http://mysite.com/news</a></p>
<p>It displays an archive of items from the category 'news-article'</p>
<p>I'd like to redirect any requests for <a href="http://mysite.com/category/news-article" rel="noreferrer">http://mysite.com/c... | [
{
"answer_id": 160853,
"author": "Pat Gilmour",
"author_id": 48679,
"author_profile": "https://wordpress.stackexchange.com/users/48679",
"pm_score": 2,
"selected": false,
"text": "<p>Thanks to @Layka above, I tweaked the code slightly and this does what I needed.</p>\n\n<p>It could perha... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48679/"
] | I have a category archive page at: <http://mysite.com/news>
It displays an archive of items from the category 'news-article'
I'd like to redirect any requests for <http://mysite.com/category/news-article> to <http://mysite.com/news> (so that the former is never directly accessible).
Is there a best practice? Should ... | I don't know for some reason, the add\_filter caused error. I used the following one:
```
function my_page_template_redirect()
{
if ( is_category( 'news-articles' ) ) {
$url = site_url( '/news' );
wp_safe_redirect( $url, 301 );
exit();
}
}
add_action( 'template_redirect', 'my_page_templ... |
160,748 | <p>I want my categories to be active and at the same time I want to make the category pages inaccessible. Is it possible? If yes, How?</p>
<p><strong>Why I want to do this? (Possibly this may help)</strong></p>
<p>I am working on a ugc website. I am asked to bring <code>/category/cat-name</code> to <code>/cat-name</c... | [
{
"answer_id": 160751,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 2,
"selected": false,
"text": "<p>You can add something like this in your category.php.</p>\n\n<pre><code>if ( ! is_admin() ) {\n wp_red... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160748",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14518/"
] | I want my categories to be active and at the same time I want to make the category pages inaccessible. Is it possible? If yes, How?
**Why I want to do this? (Possibly this may help)**
I am working on a ugc website. I am asked to bring `/category/cat-name` to `/cat-name`. I am also asked to add another page `/cat-name... | You can add something like this in your category.php.
```
if ( ! is_admin() ) {
wp_redirect( home_url() );
exit;
}
```
This will redirect viewers to website homepage but category pages will be active and accessable to admins only. |
160,765 | <p>I'm using the cherry framework on a WP site. It comes with a custom post type that can be used to add 'Team Members' and create staff pages etc.</p>
<p>I need to expand this so that I can add tags to each 'team member' inorder that I can essentially tag them as working in a department a / b / c / etc.</p>
<p>The c... | [
{
"answer_id": 160769,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<pre><code>register_post_type( 'team',\n array(\n 'label' => theme_locals(\"our_tea... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55152/"
] | I'm using the cherry framework on a WP site. It comes with a custom post type that can be used to add 'Team Members' and create staff pages etc.
I need to expand this so that I can add tags to each 'team member' inorder that I can essentially tag them as working in a department a / b / c / etc.
The custom post type i... | It seems the issue was in part down to their being a theme-init.php in the child theme which was overwritting parts of the theme-init.php in the parent / cherry framework theme.
I resolved the issue by adding the following code into my child theme's theme-init.php;
```
register_taxonomy('team_tag', 'team', array(
... |
160,788 | <p>Is there a way to implement a single loop with dual content area. </p>
<p><strong>E.g. A single loop having 2 of</strong> </p>
<p><code><?php the_content(); ?></code></p>
<p><strong>Dinstinguished as shown bellow with video and write-up respectively</strong></p>
<pre><code><?php the_content('video'); ?&... | [
{
"answer_id": 160797,
"author": "aifrim",
"author_id": 58040,
"author_profile": "https://wordpress.stackexchange.com/users/58040",
"pm_score": 2,
"selected": false,
"text": "<p>Lets first start with a bit of knowledge-base:\n<a href=\"http://developer.wordpress.org/reference/functions/t... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160788",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4401/"
] | Is there a way to implement a single loop with dual content area.
**E.g. A single loop having 2 of**
`<?php the_content(); ?>`
**Dinstinguished as shown bellow with video and write-up respectively**
```
<?php the_content('video'); ?>
<?php the_content('write-up'); ?>
``` | Lets first start with a bit of knowledge-base:
[`the_content`](http://developer.wordpress.org/reference/functions/the_content/) is this
```
/**
* Display the post content.
*
* @since 0.71
*
* @param string $more_link_text Optional. Content for when there is more text.
* @param bool $strip_teaser Optional. Strip ... |
160,790 | <p>I'm using the Theme My Login plugin and trying to allow subscribers to change their profiles to one uploaded from their computer.</p>
<p>I've tried the following plugins:</p>
<ul>
<li>Simple Local Avatars</li>
<li>User Avatar</li>
<li>WP User Avatar</li>
<li>Avatar manager</li>
</ul>
<p>I can g... | [
{
"answer_id": 160901,
"author": "Chris",
"author_id": 25430,
"author_profile": "https://wordpress.stackexchange.com/users/25430",
"pm_score": 1,
"selected": true,
"text": "<p>Okay, I think I've got it working using the WP User Avatar plugin.</p>\n\n<p>I added this to Theme My Login's pr... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160790",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25430/"
] | I'm using the Theme My Login plugin and trying to allow subscribers to change their profiles to one uploaded from their computer.
I've tried the following plugins:
* Simple Local Avatars
* User Avatar
* WP User Avatar
* Avatar manager
I can get the file upload form to appear, but when clicking upload or update profi... | Okay, I think I've got it working using the WP User Avatar plugin.
I added this to Theme My Login's profile-form.php, copied to the root of my theme folder.
```
<?php
global $current_user;
get_currentuserinfo();
do_action('edit_user_avatar', $current_user);
?>
```
Then I added this to my functions.php file... |
160,813 | <p>At the top of the source file <code>wp-includes/wp-db.php</code> I can find the following comment:</p>
<pre><code>/**
* WordPress Database Access Abstraction Object
*
* It is possible to replace this class with your own
* by setting the $wpdb global variable in wp-content/db.php
* file to your class. The wpdb ... | [
{
"answer_id": 160815,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 3,
"selected": true,
"text": "<p>You would create your own <code>dp.php</code> file in the <code>wp-content</code> directory; if you define <code... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59435/"
] | At the top of the source file `wp-includes/wp-db.php` I can find the following comment:
```
/**
* WordPress Database Access Abstraction Object
*
* It is possible to replace this class with your own
* by setting the $wpdb global variable in wp-content/db.php
* file to your class. The wpdb class will still be inclu... | You would create your own `dp.php` file in the `wp-content` directory; if you define `$wpdb` in there, it will replace WordPress's default `$wpdb` object.
It's not listed on the [Pluggable Functions](http://codex.wordpress.org/Pluggable_Functions) list (not a big surprise, as `$wpdb` is a class, not a function), but i... |
160,814 | <p>Hope someone can help me with this. I have a custom post type ('article') in my WordPress installation, and I'd like to display those posts alongside the default posts in the regular post feed.</p>
<p>This is my current loop:</p>
<pre><code><?php
if ( have_posts() ) {
while ( have_posts() ) {
th... | [
{
"answer_id": 160821,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 4,
"selected": false,
"text": "<p>You need something like this in you functions.php file, I'm using the action Pieter suggested.</p>\n\n<pre>... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59459/"
] | Hope someone can help me with this. I have a custom post type ('article') in my WordPress installation, and I'd like to display those posts alongside the default posts in the regular post feed.
This is my current loop:
```
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
global... | You need something like this in you functions.php file, I'm using the action Pieter suggested.
```
function add_custom_post_type_to_query( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'post_type', array('post', 'article') );
}
}
add_action( 'pre_get_posts', 'add_custom_... |
160,817 | <p>I am new to WordPress development (the most I've ever done on the web design/development side of things is creating basic HTML sites); so this may be an extremely simple question, but I am trying to create a multi-page site.</p>
<p>I want 3 static pages, a Homepage, About page and Portfolio page and a Blog which is... | [
{
"answer_id": 160825,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 0,
"selected": false,
"text": "<p>See, if your files are just simple php files (not hooked in WordPress by any way), the WordPress functions wil... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160817",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59452/"
] | I am new to WordPress development (the most I've ever done on the web design/development side of things is creating basic HTML sites); so this may be an extremely simple question, but I am trying to create a multi-page site.
I want 3 static pages, a Homepage, About page and Portfolio page and a Blog which is populated... | You need to learn how the WordPress template hierarchy works.
It is very important for any individual who wants to learn WordPress or take their current WordPress experience to the next level to know of and understand all of the different aspects of the WordPress Template Hierarchy.
If you plan on consolidating, or o... |
160,818 | <p>I was expecting to be able to do something like the following which I thought would return all users that have registered before a given date:</p>
<pre><code>$args = array(
'post_type' => 'post',
'date_query' => array(
array(
'before' => current_time( 'mysql' )
)
)
)... | [
{
"answer_id": 160826,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<h2>Method #1: The <code>pre_user_query</code> hook:</h2>\n\n<p>There are not many filters available, but you can... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160818",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22599/"
] | I was expecting to be able to do something like the following which I thought would return all users that have registered before a given date:
```
$args = array(
'post_type' => 'post',
'date_query' => array(
array(
'before' => current_time( 'mysql' )
)
)
);
$query = new WP_User_... | Method #1: The `pre_user_query` hook:
-------------------------------------
There are not many filters available, but you can try the [`pre_user_query`](https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/user.php#L706) hook:
```
// Add filter:
add_action( 'pre_user_query', 'wpse_filter_by_reg_date' )... |
160,822 | <p>I've been attempting to add an image size to my code, for an image that needs to be 708px wide. Height can be variable. I've added the code this way:</p>
<pre><code>add_image_size( 'full-blog-width', 708 );
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
retu... | [
{
"answer_id": 160826,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<h2>Method #1: The <code>pre_user_query</code> hook:</h2>\n\n<p>There are not many filters available, but you can... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160822",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56556/"
] | I've been attempting to add an image size to my code, for an image that needs to be 708px wide. Height can be variable. I've added the code this way:
```
add_image_size( 'full-blog-width', 708 );
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( ... | Method #1: The `pre_user_query` hook:
-------------------------------------
There are not many filters available, but you can try the [`pre_user_query`](https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/user.php#L706) hook:
```
// Add filter:
add_action( 'pre_user_query', 'wpse_filter_by_reg_date' )... |
160,836 | <p>I am trying to retrieve each user's first and last name, phone, email, and address from the usermeta table. I'm having trouble selecting multiple meta_values, each with its own meta_key, using a single sql query.</p>
<p>I would like the data returned as</p>
<p>First Name, Last Name, Phone, Address, Email
First Nam... | [
{
"answer_id": 160866,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": false,
"text": "<p>You can just call <code>get_user_meta</code> without specifying a key, and it will return all MetaValues for t... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31468/"
] | I am trying to retrieve each user's first and last name, phone, email, and address from the usermeta table. I'm having trouble selecting multiple meta\_values, each with its own meta\_key, using a single sql query.
I would like the data returned as
First Name, Last Name, Phone, Address, Email
First Name, Last Name, P... | You can just call `get_user_meta` without specifying a key, and it will return all MetaValues for the user.
```
$userdata = get_user_meta( $userID );
```
You may have to do a mapping for displaytitles of the Metavalue, as they are returned in an `array`, where the `keys` are the databasevalues of your `metakeys`.
F... |
160,839 | <p>In my pages title I got for example "home-my title' and 'Books Archieves- my title',
I want to drop those prefixes so I have only on page (home) 'My title' and on archive(category) 'Books- my title'.
that's what I got inside the <code>head</code>: <code><head>
<?php wp_head(); ?>
</head></code>... | [
{
"answer_id": 160866,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": false,
"text": "<p>You can just call <code>get_user_meta</code> without specifying a key, and it will return all MetaValues for t... | 2014/09/09 | [
"https://wordpress.stackexchange.com/questions/160839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50830/"
] | In my pages title I got for example "home-my title' and 'Books Archieves- my title',
I want to drop those prefixes so I have only on page (home) 'My title' and on archive(category) 'Books- my title'.
that's what I got inside the `head`: `<head>
<?php wp_head(); ?>
</head>` | You can just call `get_user_meta` without specifying a key, and it will return all MetaValues for the user.
```
$userdata = get_user_meta( $userID );
```
You may have to do a mapping for displaytitles of the Metavalue, as they are returned in an `array`, where the `keys` are the databasevalues of your `metakeys`.
F... |
160,858 | <p>How do I add Facebook OpenGraph tags in the header when the header has already been called, and the values I need to add are obtained in the body? This is a highly customized theme (which I did not create).</p>
<p>Here is the <code>image.php</code> file which contains the attachment page for an image:</p>
<pre><co... | [
{
"answer_id": 160866,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": false,
"text": "<p>You can just call <code>get_user_meta</code> without specifying a key, and it will return all MetaValues for t... | 2014/09/10 | [
"https://wordpress.stackexchange.com/questions/160858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57947/"
] | How do I add Facebook OpenGraph tags in the header when the header has already been called, and the values I need to add are obtained in the body? This is a highly customized theme (which I did not create).
Here is the `image.php` file which contains the attachment page for an image:
```
<div class="posted-att">
... | You can just call `get_user_meta` without specifying a key, and it will return all MetaValues for the user.
```
$userdata = get_user_meta( $userID );
```
You may have to do a mapping for displaytitles of the Metavalue, as they are returned in an `array`, where the `keys` are the databasevalues of your `metakeys`.
F... |
160,865 | <blockquote>
<p>Warning: urlencode() expects parameter 1 to be string, array given in <code>D:\xamppp\htdocs\sample\wp-includes\formatting.php</code> on line 3690</p>
</blockquote>
<p>When I try to give the <code>category_name</code> in the <code>query_post</code>,</p>
<pre><code><?php
$args=query_posts(
... | [
{
"answer_id": 160867,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>First of all, never use <a href=\"https://developer.wordpress.org/reference/functions/query_posts/\" rel... | 2014/09/10 | [
"https://wordpress.stackexchange.com/questions/160865",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58570/"
] | >
> Warning: urlencode() expects parameter 1 to be string, array given in `D:\xamppp\htdocs\sample\wp-includes\formatting.php` on line 3690
>
>
>
When I try to give the `category_name` in the `query_post`,
```
<?php
$args=query_posts(
array(
'posts_per_page' => -1,
'category_name' =>array('Breaking... | First of all, never use [`query_posts`](https://developer.wordpress.org/reference/functions/query_posts/). Rather use [`WP_Query`](https://developer.wordpress.org/reference/classes/wp_query/) to construct your custom query which is the prefered way
You are also using the `category_name` parameter wrong. If you look at... |
160,872 | <p>I am really new to WordPress programming and I am not even sure if this feature exists. What I am trying to do is send an email to users (not admin) when an admin changes their password/email? </p>
<p>At present when I add a new user, an email is sent to them but no email is sent to them when I change their passwor... | [
{
"answer_id": 160902,
"author": "SolaceBeforeDawn",
"author_id": 12651,
"author_profile": "https://wordpress.stackexchange.com/users/12651",
"pm_score": 2,
"selected": false,
"text": "<p>There are a few ways to accomplish this;</p>\n\n<p>1) [easy] Send your user to the login screen and ... | 2014/09/10 | [
"https://wordpress.stackexchange.com/questions/160872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51683/"
] | I am really new to WordPress programming and I am not even sure if this feature exists. What I am trying to do is send an email to users (not admin) when an admin changes their password/email?
At present when I add a new user, an email is sent to them but no email is sent to them when I change their password/email.
... | Here's one way to add this feature using the following flowline :
```
The admin updates the user option page:
-> edit_user_profile_update or personal_options_update hooks activated
-> edit_user() function is called
-> wp_update_user() function is called within edit_user()
-> wp_insert_user() function is c... |
160,889 | <p>Here is the constructor for the wpdb class as found in the source code.
According to a google search this has been recently renamed from USE_EXT_MYSQL.
However I cannot find anywhere in the source code where either constant is defined.</p>
<pre><code>function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
... | [
{
"answer_id": 160894,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>This constant is actually never defined in core code at all. You can define it yourself in <code>wp-config.php</code... | 2014/09/10 | [
"https://wordpress.stackexchange.com/questions/160889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59435/"
] | Here is the constructor for the wpdb class as found in the source code.
According to a google search this has been recently renamed from USE\_EXT\_MYSQL.
However I cannot find anywhere in the source code where either constant is defined.
```
function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
register... | This constant is actually never defined in core code at all. You can define it yourself in `wp-config.php` configuration if you need to, but core doesn't *need* it defined for normal operation. It only exists for re–configuring into running untypical setup. |
160,900 | <p>I have a custom post type for a slider and I'm using the Featured Image thumbnail uploader to set the image. </p>
<p>I've relocated the Featured Image meta box to be underneath the title section in the admin. Now, to avoid user confusion, I would like the Featured Image "thumbnail" to display (in the admin CPT ed... | [
{
"answer_id": 161521,
"author": "SolaceBeforeDawn",
"author_id": 12651,
"author_profile": "https://wordpress.stackexchange.com/users/12651",
"pm_score": 3,
"selected": true,
"text": "<p>Righto, I found the answer in this <a href=\"https://core.trac.wordpress.org/ticket/28512\" rel=\"nof... | 2014/09/10 | [
"https://wordpress.stackexchange.com/questions/160900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12651/"
] | I have a custom post type for a slider and I'm using the Featured Image thumbnail uploader to set the image.
I've relocated the Featured Image meta box to be underneath the title section in the admin. Now, to avoid user confusion, I would like the Featured Image "thumbnail" to display (in the admin CPT editor screen)... | Righto, I found the answer in this [trac ticket](https://core.trac.wordpress.org/ticket/28512), so kudos to @SergeyBiryukov. I'm posting here for anyone else that wants to know ;-) However, I've not cracked custom size (e.g. 800px wide by 200px high for example) which would be nice.
```
// move the featured image box ... |
160,906 | <p>I am using the twenty twelve theme and in this theme I used the <code>Main Sidebar</code> for widgets. I used the code below to make the widgets disappear in my <code>homepage ( front page )</code>. The code works however, the widget area is still taking the space. How can I stretch my content to fill the whole widt... | [
{
"answer_id": 160908,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 0,
"selected": false,
"text": "<p>You can write a plugin that will remove the widget and free up the space.\nWrite this in a new plugin.</p>\n\n... | 2014/09/10 | [
"https://wordpress.stackexchange.com/questions/160906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59388/"
] | I am using the twenty twelve theme and in this theme I used the `Main Sidebar` for widgets. I used the code below to make the widgets disappear in my `homepage ( front page )`. The code works however, the widget area is still taking the space. How can I stretch my content to fill the whole width?
```
<?php If ( !is_f... | There are some confusing information in your question and some important information missing
* Did you set a static front page as it is suggested in your code
* Do you need to achieve this on your front page or homepage
* Why aren't you using the front-page.php template included if you have set a static front page, th... |
160,954 | <p>This may be a very basic question, but I could not find the answer.
The following documentation <a href="http://codex.wordpress.org/Class_Reference/WP_Query" rel="nofollow">http://codex.wordpress.org/Class_Reference/WP_Query</a>
shows the code</p>
<pre><code>// The Query
$the_query = new WP_Query( $args );
</code><... | [
{
"answer_id": 160960,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>You have to read the documentation thoroughly, for example:</p>\n\n<blockquote>\n <p>The second is... | 2014/09/10 | [
"https://wordpress.stackexchange.com/questions/160954",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59435/"
] | This may be a very basic question, but I could not find the answer.
The following documentation <http://codex.wordpress.org/Class_Reference/WP_Query>
shows the code
```
// The Query
$the_query = new WP_Query( $args );
```
but when I look at `wp-contents/themese/twentytwelve/index.php`
I see calls to `have_posts()` a... | This is because `WP_Query` is user generated when you want to display your recent blog posts, featured posts, posts with a tag, the best place to find them is in shortcodes folder. All other files serve as templates to iterate, filter and show results. |
161,008 | <p>I have the CPT "event". I have created single-event.php.</p>
<p>I want one particular event to use a different template than single-event.</p>
<p>I read elsewhere that this could be done by creating a single-event-[slug].php but I tried it and it does not work. WP uses single-event.php. (I can't find this in the W... | [
{
"answer_id": 161009,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>For the templates WordPress uses, please always refer to <a href=\"http://codex.wordpress.org/Template_Hierarc... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59536/"
] | I have the CPT "event". I have created single-event.php.
I want one particular event to use a different template than single-event.
I read elsewhere that this could be done by creating a single-event-[slug].php but I tried it and it does not work. WP uses single-event.php. (I can't find this in the WordPress document... | For the templates WordPress uses, please always refer to [Template hierarchy scheme](http://codex.wordpress.org/Template_Hierarchy#Visual_Overview) in the Codex.
As you can see there, `single-{$posttype}-{$slug}.php` does not exist, there is only `single-{$posttype}.php`.
To do what you want, have a look at the filte... |
161,028 | <p>I have a function setup as follows:</p>
<pre><code><?php $terms = get_terms("wpsc_product_category");
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) { ?>
<li class="calendar-filter-menu-item" data-filter=".<?php echo $term->slug; ?>"><?ph... | [
{
"answer_id": 161031,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 4,
"selected": true,
"text": "<p>You can make use of the <code>hide_empty</code> <a href=\"http://codex.wordpress.org/Function_Refere... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161028",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28065/"
] | I have a function setup as follows:
```
<?php $terms = get_terms("wpsc_product_category");
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) { ?>
<li class="calendar-filter-menu-item" data-filter=".<?php echo $term->slug; ?>"><?php echo $term->count; ?></li>
<?php }
} ?>... | You can make use of the `hide_empty` [argument of `get_terms()`](http://codex.wordpress.org/Function_Reference/get_terms#Possible_Arguments). It's default value is set to `true`.
Do it somewhat like this:
```
$args = array(
'hide_empty' => false
);
$terms = get_terms( 'wpsc_product_category', $args );
``` |
161,037 | <p>I have this simple shortcode to display the last posts with it's title and except:</p>
<pre><code>add_shortcode('latest3', function(){
$recent_posts = wp_get_recent_posts(
array(
'numberposts' => 3,
'orderby' => 'post_date',
'order' ... | [
{
"answer_id": 161038,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 3,
"selected": true,
"text": "<p>The <code>post_excerpt</code> value is empty because you have no explicit excerpts for your posts. W... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47901/"
] | I have this simple shortcode to display the last posts with it's title and except:
```
add_shortcode('latest3', function(){
$recent_posts = wp_get_recent_posts(
array(
'numberposts' => 3,
'orderby' => 'post_date',
'order' => 'DESC',
... | The `post_excerpt` value is empty because you have no explicit excerpts for your posts. While `the_excerpt()` does generate an excerpt from the posts content if the post excerpt is empty, the function `wp_get_recent_posts()`, which is basically a wrapper for `get_posts()`, doesn't. |
161,040 | <p>I'm using <a href="http://rudrastyh.com/wordpress/duplicate-post.html" rel="nofollow">this</a> code to have a duplicate post function in WordPress Admin. However, when I add the filter for a custom post type, like this: </p>
<pre><code>add_filter( 'directory_row_actions', 'rd_duplicate_post_link', 10, 2 );
</code><... | [
{
"answer_id": 172341,
"author": "jammypeach",
"author_id": 11332,
"author_profile": "https://wordpress.stackexchange.com/users/11332",
"pm_score": 4,
"selected": false,
"text": "<p>As @bonger commented, there is no custom post type filter despite what you've read.</p>\n\n<p>To use this ... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27548/"
] | I'm using [this](http://rudrastyh.com/wordpress/duplicate-post.html) code to have a duplicate post function in WordPress Admin. However, when I add the filter for a custom post type, like this:
```
add_filter( 'directory_row_actions', 'rd_duplicate_post_link', 10, 2 );
```
(The Custom Post Type has a registered nam... | As @bonger commented, there is no custom post type filter despite what you've read.
To use this filter for a specific post type, the best way is to use the `post_row_actions` filter and then test against the passed in `$post->post_type`.
I've used the code below to add links to the actions row for a specific post typ... |
161,069 | <p>I've written a custom theme which does some one-time setup chores after activation - things which I need to do every time I use it on a fresh copy of wordpress, like creating a nav menu and configuring discussion settings.</p>
<p>I've automated these things in my theme rather than a plugin because they are directly... | [
{
"answer_id": 161083,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>I'd suggest that you still use a plugin. It's a one time task and you can deactivate the plugin automatically when... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161069",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11332/"
] | I've written a custom theme which does some one-time setup chores after activation - things which I need to do every time I use it on a fresh copy of wordpress, like creating a nav menu and configuring discussion settings.
I've automated these things in my theme rather than a plugin because they are directly related t... | After delving into the codex and hacking around I figured out how to do this.
**Short answer** - use thickbox (<http://codex.wordpress.org/ThickBox>).
**Longer answer**....
Hooking into `after_setup_theme` isn't ideal for inserting any content into the admin page, as it runs on each page load when that theme is acti... |
161,071 | <p>Hi I am using some code to display posts in a slider on a page, and at the top I have some code to filter it using WP_Query. Here it is, not sure what is wrong:</p>
<pre><code><?php
/**
* Featured Content 2
*
*/
$args = array(
'post_type' => 'iv_post_type',
'category' => 'commitment',
);
$lo... | [
{
"answer_id": 161074,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": false,
"text": "<p><code>category</code> is a valid parameter for <a href=\"http://codex.wordpress.org/Template_Tags/get_p... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161071",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59511/"
] | Hi I am using some code to display posts in a slider on a page, and at the top I have some code to filter it using WP\_Query. Here it is, not sure what is wrong:
```
<?php
/**
* Featured Content 2
*
*/
$args = array(
'post_type' => 'iv_post_type',
'category' => 'commitment',
);
$loop = new WP_Query( $ar... | `category` is a valid parameter for [`get_posts`](http://codex.wordpress.org/Template_Tags/get_posts), not for [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query). Here are the valid category parameters for `WP_Query`
* **cat (int)** - use category id.
* **category\_name (string)**- use category **slug (... |
161,076 | <p>I have a custom Post Type of "Portfolio" with a rewrite slug of <code>portfolio</code>. So the URL on the frontend is: <code>domain.com/portfolio</code>.</p>
<p>I have a custom Taxonomy of "Categories" with a rewrite slug of <code>portfolio/category</code>. So the URL on the frontend is: <code>domain.com/portfolio/... | [
{
"answer_id": 161077,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>That is expected and how <a href=\"http://codex.wordpress.org/Template_Hierarchy\" rel=\"nofollow\">Tem... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9579/"
] | I have a custom Post Type of "Portfolio" with a rewrite slug of `portfolio`. So the URL on the frontend is: `domain.com/portfolio`.
I have a custom Taxonomy of "Categories" with a rewrite slug of `portfolio/category`. So the URL on the frontend is: `domain.com/portfolio/category/<term-slug>/`
When I visit `domain.com... | [Appending Taxonomy Terms to Post Type URLs](https://wordpress.stackexchange.com/a/161102/9579)
-----------------------------------------------------------------------------------------------
I believe I have come up with a temporary solution from random miscellaneous sources online.
I would love for someone to expan... |
161,087 | <p>My current author list shows authors with posts only, but its not ordered by <code>ASC</code> and its not working. Any ideas?</p>
<pre><code><ul class="authorlist">
<?php
// displays all users with their avatar and their posts (titles)
$blogusers = get_users_of_blog();
if ($blogusers) {
foreach ($blogu... | [
{
"answer_id": 161095,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://queryposts.com/function/get_users_of_blog/\" rel=\"nofollow\"><code>get_users_of_blog()</code></a>... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59114/"
] | My current author list shows authors with posts only, but its not ordered by `ASC` and its not working. Any ideas?
```
<ul class="authorlist">
<?php
// displays all users with their avatar and their posts (titles)
$blogusers = get_users_of_blog();
if ($blogusers) {
foreach ($blogusers as $bloguser) {
$user... | To add to @Rarst answer, there are a couple of other problems in your code.
As stated, `get_users_of_blog()` has been depreciated. You've said that you did try [`get_users()`](http://codex.wordpress.org/Function_Reference/get_users), but it did not work. The reason for that is, the returned objects have changed with ... |
161,088 | <p>I've been reading several articles dissuading WP developers from replacing the enqueued jQuery with the Google CDN version of jQuery. I'm sold.</p>
<p>I am now enqueueing the WP jQuery version which uses jQuery.noConflict(). </p>
<p>However, I am getting the 'undefined is not a function' error in a home-grown .js ... | [
{
"answer_id": 161095,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://queryposts.com/function/get_users_of_blog/\" rel=\"nofollow\"><code>get_users_of_blog()</code></a>... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43498/"
] | I've been reading several articles dissuading WP developers from replacing the enqueued jQuery with the Google CDN version of jQuery. I'm sold.
I am now enqueueing the WP jQuery version which uses jQuery.noConflict().
However, I am getting the 'undefined is not a function' error in a home-grown .js file that uses $ ... | To add to @Rarst answer, there are a couple of other problems in your code.
As stated, `get_users_of_blog()` has been depreciated. You've said that you did try [`get_users()`](http://codex.wordpress.org/Function_Reference/get_users), but it did not work. The reason for that is, the returned objects have changed with ... |
161,120 | <p>I want to send an automatic email every day at 10:00</p>
<p>I tried this code</p>
<pre><code>$timeN = date('H:i');
$timeS = date('10:00');
if ($timeS == $timeN) {
$to = get_option('admin_email');
$nfrom = "my site";
$subject = "test";
$body = " Hello";
$headers = 'From: "'. $nfrom .'" <' . $... | [
{
"answer_id": 161145,
"author": "T.Todua",
"author_id": 33667,
"author_profile": "https://wordpress.stackexchange.com/users/33667",
"pm_score": -1,
"selected": false,
"text": "<p>You should insert the validator, like this, so it will send only 1 mail in a day:</p>\n\n<pre><code>$timeN =... | 2014/09/11 | [
"https://wordpress.stackexchange.com/questions/161120",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59581/"
] | I want to send an automatic email every day at 10:00
I tried this code
```
$timeN = date('H:i');
$timeS = date('10:00');
if ($timeS == $timeN) {
$to = get_option('admin_email');
$nfrom = "my site";
$subject = "test";
$body = " Hello";
$headers = 'From: "'. $nfrom .'" <' . $to . '>';
wp_mail=$m... | **Creating a Scheduled Event**
First we’ll create a function that will schedule our event. Mine is called “mycronjob” and it will run once every day. All this code can go into your plugin’s main file, outside the main function:
```
// create a scheduled event (if it does not exist already)
function cronstarter_activa... |
161,127 | <p>If I use on my Wordpress 4.0 the beautiful playlist shortcode I don't see the famous "Next" and "Prev" icons, but only this code in my Html code:</p>
<p><code><div class="wp-playlist-next"></div></code></p>
<p>and</p>
<p><code><div class="wp-playlist-prev"></div></code></p>
<p>How to disp... | [
{
"answer_id": 161142,
"author": "T.Todua",
"author_id": 33667,
"author_profile": "https://wordpress.stackexchange.com/users/33667",
"pm_score": 2,
"selected": false,
"text": "<p>in stylesheet:</p>\n\n<pre><code>.wp-playlist-prev{\n width:20px;\n height:20px;\n background-image: ur... | 2014/09/12 | [
"https://wordpress.stackexchange.com/questions/161127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58810/"
] | If I use on my Wordpress 4.0 the beautiful playlist shortcode I don't see the famous "Next" and "Prev" icons, but only this code in my Html code:
`<div class="wp-playlist-next"></div>`
and
`<div class="wp-playlist-prev"></div>`
How to display icons to next and prev commands? | in stylesheet:
```
.wp-playlist-prev{
width:20px;
height:20px;
background-image: url("./theme_images_folder/something_icon.png");
}
```
*same for the next button.* |
161,133 | <p>I've written this login/logout for my functions.php in my wordpress theme. The problem is, it's showing a login/logout link in all menus both primary and secondary. Is there a way to get it to appear only in secondary?</p>
<pre><code>add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_lo... | [
{
"answer_id": 161135,
"author": "Gabriel",
"author_id": 54569,
"author_profile": "https://wordpress.stackexchange.com/users/54569",
"pm_score": 1,
"selected": false,
"text": "<p>Change the filter hook to <code>wp_nav_menu_{menu-name}_items</code>, so it will only run on a specific menu.... | 2014/09/12 | [
"https://wordpress.stackexchange.com/questions/161133",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59588/"
] | I've written this login/logout for my functions.php in my wordpress theme. The problem is, it's showing a login/logout link in all menus both primary and secondary. Is there a way to get it to appear only in secondary?
```
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link(... | Change the filter hook to `wp_nav_menu_{menu-name}_items`, so it will only run on a specific menu. For example, if the menu name is "Secondary", use the hook `wp_nav_menu_secondary_items`, or if the menu name is "Top Navigation", use `wp_nav_menu_top-navigation_items` (replace spaces in the menu name with dashes).
You... |
161,179 | <p>I have working on <code>xx.xyz.com</code> then my project is move on <code>xyz.com</code> </p>
<p>In which I have gave in project the previous link is as below </p>
<blockquote>
<p>.xyz.com/?page_id=634</p>
</blockquote>
<p>And now my link is as belows </p>
<blockquote>
<p>xyz.com/?page_id=634</p>
</blockqu... | [
{
"answer_id": 161182,
"author": "user3042036",
"author_id": 59606,
"author_profile": "https://wordpress.stackexchange.com/users/59606",
"pm_score": -1,
"selected": false,
"text": "<p>Declare first page id <code>$page_id = 634;</code> , because you will need it to get page url by id. Y... | 2014/09/12 | [
"https://wordpress.stackexchange.com/questions/161179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59477/"
] | I have working on `xx.xyz.com` then my project is move on `xyz.com`
In which I have gave in project the previous link is as below
>
> .xyz.com/?page\_id=634
>
>
>
And now my link is as belows
>
> xyz.com/?page\_id=634
>
>
>
I have tried to put link relative like
>
> ../?page\_id=634
>
>
>
but its ... | You should be using [home\_url()](http://codex.wordpress.org/Function_Reference/home_url) ( or something similar ) in your links for theme files when linking to pages. This will allow the domain to change and not affect your hardcoded links - assuming the ID's are the same of course.
```
<a href="<?php echo home_url()... |
161,187 | <p>I wanted that when i access my site with specific parameter, my site used a different theme at that moment (only temporarily, to show only to me as a preview). I want it for test purposes. Is there any way to do/activate that using php codes?</p>
| [
{
"answer_id": 268190,
"author": "JItendra Rana",
"author_id": 87433,
"author_profile": "https://wordpress.stackexchange.com/users/87433",
"pm_score": 2,
"selected": false,
"text": "<p>You can Detect <code>Server Remote Address</code> and if it matches with your IP then you can use diffe... | 2014/09/12 | [
"https://wordpress.stackexchange.com/questions/161187",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33667/"
] | I wanted that when i access my site with specific parameter, my site used a different theme at that moment (only temporarily, to show only to me as a preview). I want it for test purposes. Is there any way to do/activate that using php codes? | You can Detect `Server Remote Address` and if it matches with your IP then you can use different theme following way.
```
function wp_set_preview_theme( $current_theme ) {
if ( 'YOUR_IP_ADDRESS' === $_SERVER['REMOTE_ADDR'] ){
// Use your preview theme instead
return 'THEME_YOU_WANT_TO_USE';
} e... |
161,216 | <p>I have a custom taxonomy of "crb_issues" that has a custom field associated with it that is "issue_date" which outputs a date value for each term to looks a lot like "20140601" yearmonthday.</p>
<p>I am trying to out put all the Taxonomies terms using get_terms and order them by that custom field. Below is the code... | [
{
"answer_id": 161223,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 3,
"selected": true,
"text": "<p>Rather than outputting your terms in that initial loop, I would use it instead to build a new array, with you... | 2014/09/12 | [
"https://wordpress.stackexchange.com/questions/161216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26936/"
] | I have a custom taxonomy of "crb\_issues" that has a custom field associated with it that is "issue\_date" which outputs a date value for each term to looks a lot like "20140601" yearmonthday.
I am trying to out put all the Taxonomies terms using get\_terms and order them by that custom field. Below is the code I have... | Rather than outputting your terms in that initial loop, I would use it instead to build a new array, with your issue\_date as the key:
```
$my_new_array = array( );
foreach ( $terms as $term ) {
$issue_date = get_field( 'issue_date', $term );
$my_new_array[$issue_date] = $term->name;
}
```
You can then loop ... |