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 |
|---|---|---|---|---|---|---|
174,175 | <p>I have this :</p>
<pre><code> <?php the_posts_pagination( array(
'prev_text' => __( 'Previous page', 'twentyfifteen' ),
'next_text' => __( 'Next page', 'twentyfifteen' ),
) ); ?>
</code></pre>
<p>Which gives this output : </p>
<p><img src="https://i.stack.imgur.com... | [
{
"answer_id": 174176,
"author": "Rich",
"author_id": 27716,
"author_profile": "https://wordpress.stackexchange.com/users/27716",
"pm_score": 3,
"selected": true,
"text": "<p>Do this to output only links for previous and next pages:</p>\n\n<pre><code><?php previous_posts_link ( 'Previ... | 2015/01/07 | [
"https://wordpress.stackexchange.com/questions/174175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2000/"
] | I have this :
```
<?php the_posts_pagination( array(
'prev_text' => __( 'Previous page', 'twentyfifteen' ),
'next_text' => __( 'Next page', 'twentyfifteen' ),
) ); ?>
```
Which gives this output :

What I wan... | Do this to output only links for previous and next pages:
```
<?php previous_posts_link ( 'Previous' ) ?>
<?php next_posts_link ( 'Next' ); ?>
```
Then add filters to your functions.php to add a class to each link:
```
function next_posts_link_css ( $content ) {
return 'class="next"';
}
add_filter( 'next_posts_... |
174,178 | <p>I've created multiple custom post types with archives set to true with a custom slug. However, all of these archives have the body class of <code>blog</code> and <code>home</code> and no class related to the post type.</p>
<p>I'm using <code><body <?php body_class(); ?>></code> in the header file that g... | [
{
"answer_id": 174209,
"author": "setterGetter",
"author_id": 8756,
"author_profile": "https://wordpress.stackexchange.com/users/8756",
"pm_score": 0,
"selected": false,
"text": "<p>You said:</p>\n\n<blockquote>\n <p>I do have the body_class() filter inside the body tag in the header.ph... | 2015/01/07 | [
"https://wordpress.stackexchange.com/questions/174178",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16605/"
] | I've created multiple custom post types with archives set to true with a custom slug. However, all of these archives have the body class of `blog` and `home` and no class related to the post type.
I'm using `<body <?php body_class(); ?>>` in the header file that get's called on every page, but somehow it doesn't recog... | There's filter called `body_class` for that.
```
function my_own_body_classes($classes) {
// Add Classes to body if the post type archive is 'publikasjoner'
if ( is_post_type_archive( 'publikasjoner' ) ) {
$classes[] = 'publikasjoner-archive';
}
// Go for other posts types here
return $c... |
174,185 | <p>I'm trying to debug a strange issue that happens on one my plugin's users system.
The issue: When i submit my Plugin's Settings form (option-general.php?page=pluginname), I get a 500 error message. Other setting pages work fine, just this one.</p>
<p>I couldn't reproduce the error when simply using my plugin on a ... | [
{
"answer_id": 174207,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>500 errors can be for many reasons. In context of submitting form they are more common because of security setup, t... | 2015/01/07 | [
"https://wordpress.stackexchange.com/questions/174185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82/"
] | I'm trying to debug a strange issue that happens on one my plugin's users system.
The issue: When i submit my Plugin's Settings form (option-general.php?page=pluginname), I get a 500 error message. Other setting pages work fine, just this one.
I couldn't reproduce the error when simply using my plugin on a fresh wordp... | It turns out it was a bug after all: one of my plugin options is a textfield in which the user can specify a message. It is provided with a default value, but that user chose not to have any message, so emptied it. It looked ok on the backend (field looked empty), but when i looked into the database it had become zilli... |
174,220 | <p>I have a couple of actions setup:</p>
<pre><code>add_action('publish_post', array($this, 'newPost'), 10, 2);
add_action('post_updated', array($this, 'updatePost'), 10, 3);
</code></pre>
<p>When I update an already published post the 'newPost' method is fired as opposed to the 'updatePost' method. I imagine this ... | [
{
"answer_id": 174224,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Post_Status_Transitions\" rel=\"nofollow\">post status transition... | 2015/01/07 | [
"https://wordpress.stackexchange.com/questions/174220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3264/"
] | I have a couple of actions setup:
```
add_action('publish_post', array($this, 'newPost'), 10, 2);
add_action('post_updated', array($this, 'updatePost'), 10, 3);
```
When I update an already published post the 'newPost' method is fired as opposed to the 'updatePost' method. I imagine this is because the post is alre... | As an alternative, you can make use of the 'transition\_post\_status' hook for this. This hook is fired whenever a post's status is changed. In your case, you need to check whether the old and new status of the post is the same, which is `publish`
You can also set conditionals according to `$post`, which is the curre... |
174,259 | <p>I want to add a custom fields ("introduction" and "ensavoirplus") to search of Wordpress, but the SQL code is not exact. I don't understand if i do a mistake or if WP don't can do this.
But my attempt fail... I don't know why because I do exactly what the codex says.</p>
<p>This is my code :</p>
<pre><code>functio... | [
{
"answer_id": 174356,
"author": "ArnaudBan",
"author_id": 25514,
"author_profile": "https://wordpress.stackexchange.com/users/25514",
"pm_score": 1,
"selected": false,
"text": "<p>Thanks to WordPress 4.1 you can do better for meta_query :\n<a href=\"https://make.wordpress.org/core/2014/... | 2015/01/08 | [
"https://wordpress.stackexchange.com/questions/174259",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65699/"
] | I want to add a custom fields ("introduction" and "ensavoirplus") to search of Wordpress, but the SQL code is not exact. I don't understand if i do a mistake or if WP don't can do this.
But my attempt fail... I don't know why because I do exactly what the codex says.
This is my code :
```
function recherche_avancee( ... | Thanks to WordPress 4.1 you can do better for meta\_query :
<https://make.wordpress.org/core/2014/10/20/update-on-query-improvements-in-4-1/>
```
function recherche_avancee($query) {
if (!is_admin() && $query->is_search) {
$meta_query = array(
'relation' => 'OR',
array(
... |
174,260 | <p>in my Wordpress plugin i used the post_where filter but it's effect all other post type of my site.</p>
<p>my question is how to set this filter only for "property" post only</p>
<pre><code>add_filter('posts_where', 'posts_where');
function posts_where($where)
{
global $wpdb,$wp_query;
$where .= ' ... | [
{
"answer_id": 174896,
"author": "guest1",
"author_id": 66040,
"author_profile": "https://wordpress.stackexchange.com/users/66040",
"pm_score": 0,
"selected": false,
"text": "<pre><code>add_filter( 'posts_where' , 'posts_where', 10, 2);\n\nfunction posts_where( $where, $query ) {\n gl... | 2015/01/08 | [
"https://wordpress.stackexchange.com/questions/174260",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41546/"
] | in my Wordpress plugin i used the post\_where filter but it's effect all other post type of my site.
my question is how to set this filter only for "property" post only
```
add_filter('posts_where', 'posts_where');
function posts_where($where)
{
global $wpdb,$wp_query;
$where .= ' AND latitude.meta_ke... | Please note that the post\_Type query variable is not set for standard types (page, post and attachment, see [WP\_QUery class file line 2396 on trac](https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes/class-wp-query.php#L2396)), only for custom post types, so this is how you can test for each type,
```
a... |
174,266 | <p>I posted a similar question about this before but I changed a bit of the code so I figured I'd start a new topic. Below is the setup I currently have to load single posts on the front page.</p>
<p><a href="http://themetrust.com/demos/reveal/" rel="nofollow noreferrer">This is what I'm trying to do.</a> Notice that ... | [
{
"answer_id": 174290,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>The difference between the code you linked and your version, is that your post link has the permalink as the href v... | 2015/01/08 | [
"https://wordpress.stackexchange.com/questions/174266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I posted a similar question about this before but I changed a bit of the code so I figured I'd start a new topic. Below is the setup I currently have to load single posts on the front page.
[This is what I'm trying to do.](http://themetrust.com/demos/reveal/) Notice that when you click a post, it loads in a hidden con... | The difference between the code you linked and your version, is that your post link has the permalink as the href value, where the original has just a hash. When you add a click handler to an anchor tag, it doesn't prevent what normally occurs when you click that link, it just executes the javascript and normal link be... |
174,276 | <p>I was trying to make the "name field" & "phone field" in the events booking form a required field as well and I managed to look for some answers from here --> <a href="https://wordpress.org/support/topic/booking-form-required-fields?replies=13" rel="nofollow">https://wordpress.org/support/topic/booking-form-requ... | [
{
"answer_id": 174374,
"author": "stanley",
"author_id": 65709,
"author_profile": "https://wordpress.stackexchange.com/users/65709",
"pm_score": 2,
"selected": false,
"text": "<p>I manage to get the answers from this post --> <a href=\"https://wordpress.org/support/topic/change-required-... | 2015/01/08 | [
"https://wordpress.stackexchange.com/questions/174276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65709/"
] | I was trying to make the "name field" & "phone field" in the events booking form a required field as well and I managed to look for some answers from here --> <https://wordpress.org/support/topic/booking-form-required-fields?replies=13>. Have also added the below codes into my child theme functions.php. On the single e... | I manage to get the answers from this post --> <https://wordpress.org/support/topic/change-required-fields-in-registration-form?replies=3>
Instead of using 'em\_event\_validate'
```
add_filter('em_event_validate','em_validate', 1, 2);
```
should be using 'em\_booking\_validate' in the filter hook
```
add_filter('e... |
174,287 | <p>Most of (if not all) the <code>is_*</code> methods in the <code>WP_Query</code> class have a matching public property and the methods appear to just return the property e.g:</p>
<pre><code>public function is_search() {
return (bool) $this->is_search;
}
</code></pre>
<p>What is the purpose of the method when... | [
{
"answer_id": 174294,
"author": "Andrew Bartel",
"author_id": 17879,
"author_profile": "https://wordpress.stackexchange.com/users/17879",
"pm_score": 0,
"selected": false,
"text": "<p>Makes it easier for people getting started with development who are only used to using function templat... | 2015/01/08 | [
"https://wordpress.stackexchange.com/questions/174287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43719/"
] | Most of (if not all) the `is_*` methods in the `WP_Query` class have a matching public property and the methods appear to just return the property e.g:
```
public function is_search() {
return (bool) $this->is_search;
}
```
What is the purpose of the method when the property is already set? Are there use cases w... | While your example of is\_search() is a rather trivial one and harder to justify, it's generally recommended in OOP styles to use getters and setters for things like this instead of public properties, for a number of reasons.
* Encapsulation. The behavior of `is_search()` returns a boolean, but the method by which it ... |
174,304 | <p>For one of my project I just want to change the post status of all the posts inside a specific category from publish to pending.</p>
<p>It is possible to change status of multiple posts at once? I want to use this functionality in a custom theme I am developing.</p>
<p>thanks</p>
| [
{
"answer_id": 174310,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 2,
"selected": true,
"text": "<p>I am sure there's an easier way to accomplish this, but this how I would've done.</p>\n\n<ol>\n<li>Query all p... | 2015/01/08 | [
"https://wordpress.stackexchange.com/questions/174304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65347/"
] | For one of my project I just want to change the post status of all the posts inside a specific category from publish to pending.
It is possible to change status of multiple posts at once? I want to use this functionality in a custom theme I am developing.
thanks | I am sure there's an easier way to accomplish this, but this how I would've done.
1. Query all posts with category X and status X
2. Update query results with status Y.
```
$target_category = 'news';
$change_status_from = 'draft';
$change_status_to = 'publish';
$update_query = new WP_Query(array('post_status'=>$chang... |
174,308 | <p>I have a list of post ids and need to get all the standard data plus the thumbnail of the posts.
As there will be several hundred posts i need an efficient way to retrieve the data, just looping over all the ids and using has_thummbnail... and all the other versions of the same 'one by one' approach will just not wo... | [
{
"answer_id": 174392,
"author": "Larzan",
"author_id": 34517,
"author_profile": "https://wordpress.stackexchange.com/users/34517",
"pm_score": 3,
"selected": true,
"text": "<p><strong>EXPLANATION</strong></p>\n\n<p>As mentioned in my update above, to retrieve the ID of a thumbnail the <... | 2015/01/08 | [
"https://wordpress.stackexchange.com/questions/174308",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34517/"
] | I have a list of post ids and need to get all the standard data plus the thumbnail of the posts.
As there will be several hundred posts i need an efficient way to retrieve the data, just looping over all the ids and using has\_thummbnail... and all the other versions of the same 'one by one' approach will just not work... | **EXPLANATION**
As mentioned in my update above, to retrieve the ID of a thumbnail the [get\_post\_meta](http://codex.wordpress.org/Function_Reference/get_post_meta) function can be used without any additional DB overhead.
The 'normal' way to get the url to a thumbnail id is with [wp\_get\_attachment\_image\_src](http... |
174,333 | <p>I am making some changes to a custom WP template and have hit an odd issue. Published posts work absolutely fine, but when you view a scheduled post the Featured Image disappears.</p>
<p>It's as if there was no featured image at all and <code>has_post_thumbnail()</code> returns false. Here's the relevant piece of c... | [
{
"answer_id": 174352,
"author": "Irfan",
"author_id": 65344,
"author_profile": "https://wordpress.stackexchange.com/users/65344",
"pm_score": -1,
"selected": false,
"text": "<p>Its too much simple</p>\n\n<pre><code>while (have_posts()) : the_post();\n if (has_post_thumbnail($post->... | 2015/01/09 | [
"https://wordpress.stackexchange.com/questions/174333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49386/"
] | I am making some changes to a custom WP template and have hit an odd issue. Published posts work absolutely fine, but when you view a scheduled post the Featured Image disappears.
It's as if there was no featured image at all and `has_post_thumbnail()` returns false. Here's the relevant piece of code I'm working with,... | Well it turns out that the reason `has_post_thumbnail()` was failing was because `get_post_meta()` was returning empty for scheduled posts. I'm still not sure why, but in case someone else has the issue, my workaround was to create a new function to fetch the featured image ID without relying on `get_post_meta()`:
```... |
174,369 | <p>is there any way to add "follow" functionality to Wordpress ?</p>
<p>so that every logged-in user can follow his favorite author</p>
<p>and only can see post from authors that he followed them ..</p>
<p>A possible solution would be that if a logged-in user (call it user #1) is clicking "follow" on another user's ... | [
{
"answer_id": 174352,
"author": "Irfan",
"author_id": 65344,
"author_profile": "https://wordpress.stackexchange.com/users/65344",
"pm_score": -1,
"selected": false,
"text": "<p>Its too much simple</p>\n\n<pre><code>while (have_posts()) : the_post();\n if (has_post_thumbnail($post->... | 2015/01/09 | [
"https://wordpress.stackexchange.com/questions/174369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65758/"
] | is there any way to add "follow" functionality to Wordpress ?
so that every logged-in user can follow his favorite author
and only can see post from authors that he followed them ..
A possible solution would be that if a logged-in user (call it user #1) is clicking "follow" on another user's profile (call it user #2... | Well it turns out that the reason `has_post_thumbnail()` was failing was because `get_post_meta()` was returning empty for scheduled posts. I'm still not sure why, but in case someone else has the issue, my workaround was to create a new function to fetch the featured image ID without relying on `get_post_meta()`:
```... |
174,402 | <p>When creating meta boxes, in each meta box function it seems a reference to the <code>global $post</code> is passed as a parameter <code>($event)</code>. I prefer this as it seems consistent and less likely to fudge the <code>$post</code> var by declaring it explicitly as I have read elsewhere.</p>
<pre><code>add_a... | [
{
"answer_id": 174451,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p><code>admin_head-{$hook_suffix}</code> is triggered on every admin page, so passing anything to that function prob... | 2015/01/09 | [
"https://wordpress.stackexchange.com/questions/174402",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51823/"
] | When creating meta boxes, in each meta box function it seems a reference to the `global $post` is passed as a parameter `($event)`. I prefer this as it seems consistent and less likely to fudge the `$post` var by declaring it explicitly as I have read elsewhere.
```
add_action('admin_init', 'events_admin');
function e... | When I need to deal with `$post` variable on admin, I usually use a class to early catch and wrap global `$post` variable, obtaining an *universal* way to access to it, without repetitely relying on the global variable.
```
class MyAdminPost
{
private static $post;
public static function init()
{
$p_g... |
174,403 | <p>I'd like my homepage to only display posts from a single tag. Is this possible? If yes, please advise.</p>
<p>For instance,</p>
<blockquote>
<p>www.mysite.com/tag/sometag </p>
</blockquote>
<p>will only display posts with the <code>sometag</code> tag, but how do I get www.mysite.com to automatically display onl... | [
{
"answer_id": 174411,
"author": "Mohammad Mursaleen",
"author_id": 35899,
"author_profile": "https://wordpress.stackexchange.com/users/35899",
"pm_score": 0,
"selected": false,
"text": "<p>For that; first you have to make <a href=\"http://codex.wordpress.org/Tag_Templates\" rel=\"nofoll... | 2015/01/09 | [
"https://wordpress.stackexchange.com/questions/174403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64181/"
] | I'd like my homepage to only display posts from a single tag. Is this possible? If yes, please advise.
For instance,
>
> www.mysite.com/tag/sometag
>
>
>
will only display posts with the `sometag` tag, but how do I get www.mysite.com to automatically display only the posts seen on
>
> www.mysite.com/tag/somet... | You should use [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) to alter the main query on the home page.
With the proper conditional tags and parameters (check [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) for available parameters) you can achieve what you n... |
174,412 | <p>I am using a plugin called The Events Calendar. I don't always set the featured image for each individual event. Each event has an organizer ID (tribe_get_organizer_id).</p>
<p>I want to add a filter that looks if an event from a custom post type (tribe_events) has a featured image attached. If not, than the filter... | [
{
"answer_id": 174411,
"author": "Mohammad Mursaleen",
"author_id": 35899,
"author_profile": "https://wordpress.stackexchange.com/users/35899",
"pm_score": 0,
"selected": false,
"text": "<p>For that; first you have to make <a href=\"http://codex.wordpress.org/Tag_Templates\" rel=\"nofoll... | 2015/01/09 | [
"https://wordpress.stackexchange.com/questions/174412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65779/"
] | I am using a plugin called The Events Calendar. I don't always set the featured image for each individual event. Each event has an organizer ID (tribe\_get\_organizer\_id).
I want to add a filter that looks if an event from a custom post type (tribe\_events) has a featured image attached. If not, than the filter shoul... | You should use [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) to alter the main query on the home page.
With the proper conditional tags and parameters (check [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) for available parameters) you can achieve what you n... |
174,447 | <p>Is there a way to get all users that: 1) uploaded an avatar or 2) have a Gravatar? I want to filter users that doesn't meet one of these conditions.</p>
<p><strong>UPDATE</strong></p>
<p>I forget to mention that this is for Buddypress. Anyway, I found an answer for the first condition, this is the <code>bp_get_use... | [
{
"answer_id": 174448,
"author": "Brandt Solovij",
"author_id": 38927,
"author_profile": "https://wordpress.stackexchange.com/users/38927",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_avatar\" rel=\"nofollow\">http://codex.wor... | 2015/01/10 | [
"https://wordpress.stackexchange.com/questions/174447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | Is there a way to get all users that: 1) uploaded an avatar or 2) have a Gravatar? I want to filter users that doesn't meet one of these conditions.
**UPDATE**
I forget to mention that this is for Buddypress. Anyway, I found an answer for the first condition, this is the `bp_get_user_has_avatar()` function that check... | This function `bp_get_user_has_avatar()` calls `bp_core_fetch_avatar` with this argument `'no_grav' => true` so you could write your own function to see if a user is not using the default avatar:
```
function lurie_avatar_check( $user_id ) {
$retval = false;
if ( bp_core_fetch_avatar( array( 'item_id' => $us... |
174,480 | <p>I created a style sheet </p>
<blockquote>
<p>editor-style.css</p>
</blockquote>
<p>I want to load this css file using add_editor_style() function, </p>
<p>In my functions.php</p>
<pre><code>function my_theme_add_editor_styles() {
add_editor_style( 'css/editor-style.css' );
}
add_action( 'after_setup_theme'... | [
{
"answer_id": 174482,
"author": "jetlej",
"author_id": 9862,
"author_profile": "https://wordpress.stackexchange.com/users/9862",
"pm_score": 4,
"selected": true,
"text": "<p>You shouldn't need an action to add an editor style. Simple add the following anywhere in your functions.php:</p>... | 2015/01/10 | [
"https://wordpress.stackexchange.com/questions/174480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64198/"
] | I created a style sheet
>
> editor-style.css
>
>
>
I want to load this css file using add\_editor\_style() function,
In my functions.php
```
function my_theme_add_editor_styles() {
add_editor_style( 'css/editor-style.css' );
}
add_action( 'after_setup_theme', 'my_theme_add_editor_styles' );
```
I also t... | You shouldn't need an action to add an editor style. Simple add the following anywhere in your functions.php:
```
add_editor_style('css/editor-style.css');
``` |
174,485 | <p>so I am trying to use a foreach to pull content from a custom field in multiple posts, but it just wont work. I can get it to work for a simple textarea string but I am struggling getting it to work for arrays. This is the working code for a string:</p>
<pre><code>$posts = get_posts(array(
'numberposts' => -1,
'... | [
{
"answer_id": 174482,
"author": "jetlej",
"author_id": 9862,
"author_profile": "https://wordpress.stackexchange.com/users/9862",
"pm_score": 4,
"selected": true,
"text": "<p>You shouldn't need an action to add an editor style. Simple add the following anywhere in your functions.php:</p>... | 2015/01/10 | [
"https://wordpress.stackexchange.com/questions/174485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37486/"
] | so I am trying to use a foreach to pull content from a custom field in multiple posts, but it just wont work. I can get it to work for a simple textarea string but I am struggling getting it to work for arrays. This is the working code for a string:
```
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'po... | You shouldn't need an action to add an editor style. Simple add the following anywhere in your functions.php:
```
add_editor_style('css/editor-style.css');
``` |
174,502 | <p>Something is going wrong when I try to use the bootstrap nav with a child theme and I can't figure it out for the life of me. </p>
<p>The parent theme is called Revera.</p>
<p>This is a bootstrap theme. It includes bootstrap.min.js and bootstrap.min.css files. However, the version used appears old and I think it i... | [
{
"answer_id": 174482,
"author": "jetlej",
"author_id": 9862,
"author_profile": "https://wordpress.stackexchange.com/users/9862",
"pm_score": 4,
"selected": true,
"text": "<p>You shouldn't need an action to add an editor style. Simple add the following anywhere in your functions.php:</p>... | 2015/01/11 | [
"https://wordpress.stackexchange.com/questions/174502",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65830/"
] | Something is going wrong when I try to use the bootstrap nav with a child theme and I can't figure it out for the life of me.
The parent theme is called Revera.
This is a bootstrap theme. It includes bootstrap.min.js and bootstrap.min.css files. However, the version used appears old and I think it is what is causing... | You shouldn't need an action to add an editor style. Simple add the following anywhere in your functions.php:
```
add_editor_style('css/editor-style.css');
``` |
174,517 | <p>How can group posts by month and year by a separate headline?</p>
<p>Example (output with this date format):</p>
<p>Dezmber 2014<br>
- 4. Dez 2014<br>
- 5. Dez 2014</p>
<p>I have a custom field (datepicker) "event_date". </p>
<pre><code> <?php
$the_query = new WP_Query( array(
'post_status' => 'p... | [
{
"answer_id": 224133,
"author": "Fint",
"author_id": 92618,
"author_profile": "https://wordpress.stackexchange.com/users/92618",
"pm_score": 0,
"selected": false,
"text": "<p>Following the advanced example on <a href=\"https://www.advancedcustomfields.com/resources/date-picker/\" rel=\"... | 2015/01/11 | [
"https://wordpress.stackexchange.com/questions/174517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65842/"
] | How can group posts by month and year by a separate headline?
Example (output with this date format):
Dezmber 2014
- 4. Dez 2014
- 5. Dez 2014
I have a custom field (datepicker) "event\_date".
```
<?php
$the_query = new WP_Query( array(
'post_status' => 'publish',
'meta_key' => 'event_date'... | When you query the posts with `orderby` argument as a `event_date` (it could be any field with date format) the posts are ordered by date, desc or asc. So the only thing you have to do afterwards is to group them by year and month.
So:
```
<?php
$posts = get_posts(array(
'post_type' => '... |
174,582 | <p>The default behavior when it comes to full-width images in posts is this:</p>
<ul>
<li>If you insert an image alone, this HTML structure is produced: <code><p><img/></p></code></li>
<li>If you insert an image <strong>with a caption</strong>, the HTML structure is produced: <code><figure><... | [
{
"answer_id": 174585,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>You can try the <a href=\"https://developer.wordpress.org/reference/hooks/image_send_to_editor/\" rel=\"norefe... | 2015/01/12 | [
"https://wordpress.stackexchange.com/questions/174582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12248/"
] | The default behavior when it comes to full-width images in posts is this:
* If you insert an image alone, this HTML structure is produced: `<p><img/></p>`
* If you insert an image **with a caption**, the HTML structure is produced: `<figure><img/><figcaption/></figure>`
For the sake of styling (I want to have larger ... | You can try the [`image_send_to_editor`](https://developer.wordpress.org/reference/hooks/image_send_to_editor/) filter:
```
/**
* Wrap the inserted image html with <figure>
* if the theme supports html5 and the current image has no caption:
*/
add_filter( 'image_send_to_editor',
function( $html, $id, $captio... |
174,586 | <p>I'm trying to do a string replacement using <code>gettext</code> filter (<a href="https://wordpress.stackexchange.com/a/127590/22728">source</a>):</p>
<pre><code>function theme_change_comments_label( $translated_text, $untranslated_text, $domain ) {
if( stripos( $untranslated_text, 'comment' !== FALSE ) ) {
... | [
{
"answer_id": 174588,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>According <a href=\"http://codex.wordpress.org/Function_Reference/get_current_screen#Usage_Restrictions\" rel=... | 2015/01/12 | [
"https://wordpress.stackexchange.com/questions/174586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | I'm trying to do a string replacement using `gettext` filter ([source](https://wordpress.stackexchange.com/a/127590/22728)):
```
function theme_change_comments_label( $translated_text, $untranslated_text, $domain ) {
if( stripos( $untranslated_text, 'comment' !== FALSE ) ) {
$translated_text = str_ireplace... | According [with the codex](http://codex.wordpress.org/Function_Reference/get_current_screen#Usage_Restrictions), `get_current_screen()` has to be used later than `admin_init` hook. After a few tests, it seems that the safiest way is to use `current_screen` action hook instead of `get_current_screen()`:
```
add_action(... |
174,587 | <p>I used the code provided in <a href="http://code.tutsplus.com/articles/quick-tip-create-a-wordpress-global-options-page--wp-24570" rel="nofollow">this tutorial</a> to create an option menu in dashboard, but contrary to what was expected, I don't see any new menu in dashboard:</p>
<pre><code><?php
add_action('adm... | [
{
"answer_id": 174588,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>According <a href=\"http://codex.wordpress.org/Function_Reference/get_current_screen#Usage_Restrictions\" rel=... | 2015/01/12 | [
"https://wordpress.stackexchange.com/questions/174587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I used the code provided in [this tutorial](http://code.tutsplus.com/articles/quick-tip-create-a-wordpress-global-options-page--wp-24570) to create an option menu in dashboard, but contrary to what was expected, I don't see any new menu in dashboard:
```
<?php
add_action('admin_menu', 'add_global_custom_options');
fun... | According [with the codex](http://codex.wordpress.org/Function_Reference/get_current_screen#Usage_Restrictions), `get_current_screen()` has to be used later than `admin_init` hook. After a few tests, it seems that the safiest way is to use `current_screen` action hook instead of `get_current_screen()`:
```
add_action(... |
174,593 | <p>I am looking for a way to show all post tags on post edit screen/tags sidebox in WordPress admin section. By default WordPress shows 45 most used tags but I need a way to list all tags there or at least increase this limit.</p>
<p>I found similar question here <a href="https://wordpress.stackexchange.com/questions/... | [
{
"answer_id": 174597,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>I'd say the easiest way to do it is use the <code>get_terms_args</code> filter and unset the <code>number</... | 2015/01/12 | [
"https://wordpress.stackexchange.com/questions/174593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22461/"
] | I am looking for a way to show all post tags on post edit screen/tags sidebox in WordPress admin section. By default WordPress shows 45 most used tags but I need a way to list all tags there or at least increase this limit.
I found similar question here [Showing all tags in admin -> edit post](https://wordpress.stacke... | I'd say the easiest way to do it is use the `get_terms_args` filter and unset the `number` limit if the context is right (the AJAX request to get the tag cloud):
```
function wpse_64058_all_tags ( $args ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] === 'get-tagclou... |
174,605 | <p>Im working on some customizer settings for my theme. Im using chrome. I created a number input field:</p>
<pre><code>$wp_customize->add_setting( 'st_opacity',
array(
'default' => '100',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => 'postMessage... | [
{
"answer_id": 174597,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>I'd say the easiest way to do it is use the <code>get_terms_args</code> filter and unset the <code>number</... | 2015/01/12 | [
"https://wordpress.stackexchange.com/questions/174605",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48867/"
] | Im working on some customizer settings for my theme. Im using chrome. I created a number input field:
```
$wp_customize->add_setting( 'st_opacity',
array(
'default' => '100',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
)
);
$wp_customi... | I'd say the easiest way to do it is use the `get_terms_args` filter and unset the `number` limit if the context is right (the AJAX request to get the tag cloud):
```
function wpse_64058_all_tags ( $args ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] === 'get-tagclou... |
174,646 | <p>I have a page where I show the teams of a football club. I order these with 'order' => 'ASC'. But the problem is that the teams order like I want it to.</p>
<p>It orders like this:
Team E1, Team E10, Team E11, Team E2</p>
<p>It must be like this:
Team E1, Team E2 ..... Team E10, Team E11</p>
<p>What is the best... | [
{
"answer_id": 174676,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 0,
"selected": false,
"text": "<p>PHP has a <a href=\"http://php.net/manual/en/function.sort.php\" rel=\"nofollow\">sort_natural</a> flag on its ... | 2015/01/12 | [
"https://wordpress.stackexchange.com/questions/174646",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9513/"
] | I have a page where I show the teams of a football club. I order these with 'order' => 'ASC'. But the problem is that the teams order like I want it to.
It orders like this:
Team E1, Team E10, Team E11, Team E2
It must be like this:
Team E1, Team E2 ..... Team E10, Team E11
What is the best solution to order this ... | **Old answer (which no longer works):**
A sneaky way to do it using MySQL, assuming the number's always at the end, is to reverse the title, convert it to a number (`+0`), and then reverse again and convert it to a number:
```
function wpse174646_posts_orderby( $orderby, $query ) {
if ( $query->get( 'orderby' ) !... |
174,662 | <p>While I was trying to convert a Static HTML page to Wordpress Theme , I had an issue .
the page Doesn't run properly
After Checking Google Chrome Console
it turns that it loads the CSS file with the wrong path</p>
<p>it loads Website/css/styles.css
and Website/css/style-desktop.css</p>
<p>here are how I've impor... | [
{
"answer_id": 174674,
"author": "shuvroMithun",
"author_id": 65928,
"author_profile": "https://wordpress.stackexchange.com/users/65928",
"pm_score": 0,
"selected": false,
"text": "<p>Try like this </p>\n\n<pre><code><script src=\"<?php echo get_template_directory_uri(); ?>/js/j... | 2015/01/13 | [
"https://wordpress.stackexchange.com/questions/174662",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65924/"
] | While I was trying to convert a Static HTML page to Wordpress Theme , I had an issue .
the page Doesn't run properly
After Checking Google Chrome Console
it turns that it loads the CSS file with the wrong path
it loads Website/css/styles.css
and Website/css/style-desktop.css
here are how I've imported stylesheets f... | As said, you should enqueue your style sheets like this in your functions.php in your theme:
```
function adds_to_the_head() { // Our own unique function called adds_to_the_head
wp_register_style( 'custom-style-css', get_stylesheet_directory_uri() . '/css/styles.css','','', 'screen' ); // Register style.css
wp_enque... |
174,669 | <p>I'm trying to figure out how to do this. I have many posts. I want it so that when someone pulls up the site, the front page shows all the posts that were done on the same month and day -- but disregards the year. So, if I were to pull up the website on Jan. 30, I would see all posts done on Jan. 30th of ANY year...... | [
{
"answer_id": 174670,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 1,
"selected": false,
"text": "<p>If you go the Category route, you could do something like this:</p>\n\n<p>First, get a slug of today's date:</p... | 2015/01/13 | [
"https://wordpress.stackexchange.com/questions/174669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65925/"
] | I'm trying to figure out how to do this. I have many posts. I want it so that when someone pulls up the site, the front page shows all the posts that were done on the same month and day -- but disregards the year. So, if I were to pull up the website on Jan. 30, I would see all posts done on Jan. 30th of ANY year... a ... | You can achieve this with the [`date_query` parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters) added in version 3.7.
To modify the main query on your posts page before it is run and apply the `date_query` parameters, we use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Actio... |
174,709 | <p>I am loading my php file by putting this into my theme's functions.php:</p>
<pre><code>require get_stylesheet_directory() . '/inc/manage-menus.php';
alter_menu('my-user', 'plugins.php', false);
</code></pre>
<p>The code in manage-menus.php looks like this:</p>
<pre><code>function alter_item ($user, $items, $actio... | [
{
"answer_id": 174722,
"author": "Михаил Семёнов",
"author_id": 65524,
"author_profile": "https://wordpress.stackexchange.com/users/65524",
"pm_score": 1,
"selected": false,
"text": "<p>It's becouse you'r calling alter_item function outside action <code>admin_menu</code></p>\n\n<p>here's... | 2015/01/13 | [
"https://wordpress.stackexchange.com/questions/174709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48146/"
] | I am loading my php file by putting this into my theme's functions.php:
```
require get_stylesheet_directory() . '/inc/manage-menus.php';
alter_menu('my-user', 'plugins.php', false);
```
The code in manage-menus.php looks like this:
```
function alter_item ($user, $items, $action) {
global $current_user, $menu;... | I think Михаил Семёнов is right, but I had to get another push by cybmeta in another thread, which lead to this:
functions.php:
```
$menu_alterations = array(
'user' => array('my-userA', 'my-userB'),
'items' => array('plugins.php', 'options-general.php'),
'action' => false,
);
... |
174,738 | <p>I am trying to add active states for my custom menu navigation, but so far everything I try
is just not working. I have set the navigation menu in a separate file nav.php,
then I included the nav.php into my header.php file like this:</p>
<pre><code><?php include('nav.php'); ?>
</code></pre>
<p>I created cu... | [
{
"answer_id": 174741,
"author": "Dan ",
"author_id": 5827,
"author_profile": "https://wordpress.stackexchange.com/users/5827",
"pm_score": 1,
"selected": false,
"text": "<p>If your theme is using wp_nav_menu() you will have the class <code>current-menu-item</code> added to the relevant ... | 2015/01/13 | [
"https://wordpress.stackexchange.com/questions/174738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65923/"
] | I am trying to add active states for my custom menu navigation, but so far everything I try
is just not working. I have set the navigation menu in a separate file nav.php,
then I included the nav.php into my header.php file like this:
```
<?php include('nav.php'); ?>
```
I created custom Wordpress pages in the chil... | In your PHP file, set `$thisPage` before you `include('nav.php');`. Then, the variable `$thisPage` will be passed to `nav.php` and processed in its `if` statement.
This is *really* bad practice though, and a better way of doing it would be by creating your menu in WordPress itself and hooking it into your template. Wo... |
174,744 | <p>I wrote some code, that helps secure my clients files, and added it to wordpresses function file. however, whenever updates come in, it obviously overwrites my function.</p>
<p>So I wanted to create it as a plugin.</p>
<p>However, I keep getting this error:</p>
<pre><code>PHP Warning: Cannot modify header inform... | [
{
"answer_id": 174745,
"author": "Rizzo",
"author_id": 37054,
"author_profile": "https://wordpress.stackexchange.com/users/37054",
"pm_score": 2,
"selected": false,
"text": "<p>use <code>add_action('init', 'your_function');</code></p>\n\n<p>or any action hook before headers are sent: <a ... | 2015/01/13 | [
"https://wordpress.stackexchange.com/questions/174744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65966/"
] | I wrote some code, that helps secure my clients files, and added it to wordpresses function file. however, whenever updates come in, it obviously overwrites my function.
So I wanted to create it as a plugin.
However, I keep getting this error:
```
PHP Warning: Cannot modify header information - headers already sent... | The correct hook to use is `template_redirect` which allows you to have the necessary info available to do checks while also early enough to actually redirect. As per the example on the codex page:
```
function my_page_template_redirect()
{
if( is_page( 'goodies' ) && ! is_user_logged_in() )
{
wp_r... |
174,753 | <p>I'm using the following code to display the WP Editor on the front end page:</p>
<pre><code>$content = '';
$editor_id = 'mycustomeditor';
wp_editor( $content, $editor_id );
</code></pre>
<p>When a user clicks on an image in the Media Library I would like to take away the ability to Permanently delete the image.</p... | [
{
"answer_id": 174762,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 2,
"selected": false,
"text": "<p>That link is hard-coded in <code>/wp-includes/media-template.php</code> ~ln 526. Since it can't be removed via... | 2015/01/13 | [
"https://wordpress.stackexchange.com/questions/174753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13472/"
] | I'm using the following code to display the WP Editor on the front end page:
```
$content = '';
$editor_id = 'mycustomeditor';
wp_editor( $content, $editor_id );
```
When a user clicks on an image in the Media Library I would like to take away the ability to Permanently delete the image.
I unset some options for th... | I actually found this:
<https://stackoverflow.com/questions/25894288/wordpress-remove-attachment-fields>
I actually just added the following in my CSS file to basically remove the links at all times:
```
.media-sidebar .details .edit-attachment {
display: none;
}
.media-sidebar .details .delete-attachment {
... |
174,769 | <p>I have this piece of code which works but it's showing only 5 posts (with custom taxonomy) where should be 7. If I hit the tag url, it shows the 7 registries, so the problem it's in this code and its query. I already tried nopaging = true, posts_per_page = -1 numberposts = -1 and setting the last two to fixed number... | [
{
"answer_id": 174762,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 2,
"selected": false,
"text": "<p>That link is hard-coded in <code>/wp-includes/media-template.php</code> ~ln 526. Since it can't be removed via... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174769",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65980/"
] | I have this piece of code which works but it's showing only 5 posts (with custom taxonomy) where should be 7. If I hit the tag url, it shows the 7 registries, so the problem it's in this code and its query. I already tried nopaging = true, posts\_per\_page = -1 numberposts = -1 and setting the last two to fixed numbers... | I actually found this:
<https://stackoverflow.com/questions/25894288/wordpress-remove-attachment-fields>
I actually just added the following in my CSS file to basically remove the links at all times:
```
.media-sidebar .details .edit-attachment {
display: none;
}
.media-sidebar .details .delete-attachment {
... |
174,800 | <p>I have a lot of <code>Pages</code> which can be (need to be) grouped under a number of different Categories. ** Then the more important thing is, i need to control those pages (of different groups) programatically via <code>functions.php</code>.</p>
<p>Lets say, i would have:</p>
<ul>
<li>Page A (Categorized as: <... | [
{
"answer_id": 174762,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 2,
"selected": false,
"text": "<p>That link is hard-coded in <code>/wp-includes/media-template.php</code> ~ln 526. Since it can't be removed via... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35907/"
] | I have a lot of `Pages` which can be (need to be) grouped under a number of different Categories. \*\* Then the more important thing is, i need to control those pages (of different groups) programatically via `functions.php`.
Lets say, i would have:
* Page A (Categorized as: `Fruits`)
* Page B (Categorized as: `Vehic... | I actually found this:
<https://stackoverflow.com/questions/25894288/wordpress-remove-attachment-fields>
I actually just added the following in my CSS file to basically remove the links at all times:
```
.media-sidebar .details .edit-attachment {
display: none;
}
.media-sidebar .details .delete-attachment {
... |
174,816 | <p>Our client would like to embed his site into an iframe in their software backend. I get a query string on the first link but need to make sure that string persists across URLs for all links and navigation on the iframed site. How do I do that? </p>
<p>This only needs to happen when the query string is present. </p>... | [
{
"answer_id": 174928,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 0,
"selected": false,
"text": "<p>As I understand your Question, you need to hook into most of the Link Filters (which are listed here:... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65999/"
] | Our client would like to embed his site into an iframe in their software backend. I get a query string on the first link but need to make sure that string persists across URLs for all links and navigation on the iframed site. How do I do that?
This only needs to happen when the query string is present.
EDIT: Come t... | You could use some JavaScript to change all links on page load. It's maybe not the best solution, but it works. I've written a [JSFiddle](https://jsfiddle.net/ahendwh2/9L0wyjs6/) for demonstration. |
174,831 | <p>I've scoured the web for the solution to this small issue, but I keep getting results that tell me how to customise the notification e-mail not the email address.</p>
<p>I have the admin email address in the WP settings as abc@xyz.tld which is great, but all new user registrations I want to go to a different email ... | [
{
"answer_id": 174837,
"author": "krishna",
"author_id": 66009,
"author_profile": "https://wordpress.stackexchange.com/users/66009",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, you can Change email address by using wp_mail function.\nYou can check this how to do this \n<a href=\"h... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174831",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66010/"
] | I've scoured the web for the solution to this small issue, but I keep getting results that tell me how to customise the notification e-mail not the email address.
I have the admin email address in the WP settings as abc@xyz.tld which is great, but all new user registrations I want to go to a different email address.
... | Yes, you can Change email address by using wp\_mail function.
You can check this how to do this
<http://www.butlerblog.com/2011/07/14/changing-the-wp_mail-from-address-with-a-plugin/>
Use this plugin for user management it supports email address when new user registers
<https://wordpress.org/plugins/wp-members/>
Use... |
174,836 | <p>I'm facing a strange problem. After I've moved to another server, my wp_enqueue_script calls don't do anything. I do have this function:</p>
<pre><code>function moemax_scripts() {
wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.min.css' );
wp_enqueue_script( '... | [
{
"answer_id": 174837,
"author": "krishna",
"author_id": 66009,
"author_profile": "https://wordpress.stackexchange.com/users/66009",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, you can Change email address by using wp_mail function.\nYou can check this how to do this \n<a href=\"h... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64921/"
] | I'm facing a strange problem. After I've moved to another server, my wp\_enqueue\_script calls don't do anything. I do have this function:
```
function moemax_scripts() {
wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.min.css' );
wp_enqueue_script( 'bootstrap-js... | Yes, you can Change email address by using wp\_mail function.
You can check this how to do this
<http://www.butlerblog.com/2011/07/14/changing-the-wp_mail-from-address-with-a-plugin/>
Use this plugin for user management it supports email address when new user registers
<https://wordpress.org/plugins/wp-members/>
Use... |
174,850 | <p>I'm creating a function in functions.php with a custom hook, and from what I've read somewhere, <strong>it's good practice to return instead of use echo in a WordPress function</strong>? Correct me if I'm wrong.</p>
<p>Anyway, so with echo, my function works, but breaks everything else. With return, the function is... | [
{
"answer_id": 174852,
"author": "Privateer",
"author_id": 66020,
"author_profile": "https://wordpress.stackexchange.com/users/66020",
"pm_score": 1,
"selected": false,
"text": "<p>From my understanding of actions (as opposed to filters), an action simply does something and stops process... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42783/"
] | I'm creating a function in functions.php with a custom hook, and from what I've read somewhere, **it's good practice to return instead of use echo in a WordPress function**? Correct me if I'm wrong.
Anyway, so with echo, my function works, but breaks everything else. With return, the function is no longer outputting a... | If you use `do_action( 'woo_collections_menu' );` in the template, then your function must echo its value. Otherwise, you are `return`ing the data into a black hole, nothing is outputting what you're returning.
If you use a filter, then you should `return` the value. The point of a filter is to take a value, filter th... |
174,855 | <p>I created a page and selected the "Full-width Page Template, No Sidebar" option in the Twenty-Twelve Theme. The viewed page has the following body tag:</p>
<pre><code><body class="page page-id-2 page-template page-template-page-templates page-template-full-width page-template-page-templatesfull-width-php logged-... | [
{
"answer_id": 174858,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>Those classes are output by the <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64351/"
] | I created a page and selected the "Full-width Page Template, No Sidebar" option in the Twenty-Twelve Theme. The viewed page has the following body tag:
```
<body class="page page-id-2 page-template page-template-page-templates page-template-full-width page-template-page-templatesfull-width-php logged-in admin-bar full... | Those classes are output by the [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) function, which can be filtered by plugins to add their own classes. You don't need to (and shouldn't) harcode classes into the body tag in your template, just add that function within the body tag:
```
<body <?php... |
174,859 | <p>I have created custom post type for videos. Here is my code.</p>
<pre><code>function video_register() {
$labels = array(
'name' => _x('Video', 'post type general name'),
'singular_name' => _x('Video', 'post type singular name'),
'add_new' => _x('Add New', 'video'),
'add_... | [
{
"answer_id": 174858,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>Those classes are output by the <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66024/"
] | I have created custom post type for videos. Here is my code.
```
function video_register() {
$labels = array(
'name' => _x('Video', 'post type general name'),
'singular_name' => _x('Video', 'post type singular name'),
'add_new' => _x('Add New', 'video'),
'add_new_item' => __('Add Ne... | Those classes are output by the [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) function, which can be filtered by plugins to add their own classes. You don't need to (and shouldn't) harcode classes into the body tag in your template, just add that function within the body tag:
```
<body <?php... |
174,863 | <p>I have the following filter, but do not know how to add custom attributes to image field, when attaching media to post.</p>
<p>example</p>
<pre><code><img data-ext-link-title="" data-ext-link-url="">
</code></pre>
<p>functions.php</p>
<pre><code>function pp_external_link_edit( $form_fields, $post ) {
$... | [
{
"answer_id": 175804,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>I wonder if you want to modify the HTML of the inserted image, with the <code>image_send_to_editor</code> or <... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3178/"
] | I have the following filter, but do not know how to add custom attributes to image field, when attaching media to post.
example
```
<img data-ext-link-title="" data-ext-link-url="">
```
functions.php
```
function pp_external_link_edit( $form_fields, $post ) {
$form_fields['pp-external-link-title'] = array(
... | I wonder if you want to modify the HTML of the inserted image, with the `image_send_to_editor` or `get_image_tag` filters?
If that's the case, then here's one example:
```
/**
* Add the data-ext-link-title and data-ext-link-url attributes to inserted images.
*/
add_filter( 'image_send_to_editor',
function(... |
174,874 | <p>For example somebody replies-</p>
<p>Hi! This is a Comment!</p>
<p>but is published as </p>
<p>Text- Hi! This is a Comment!</p>
<p>Any ideas folks? I'm totally stumped. I want to add the extra text so it appears within the comment rather than before/around it in the theme.</p>
| [
{
"answer_id": 174877,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You can try the <a href=\"https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/comment-template.ph... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65965/"
] | For example somebody replies-
Hi! This is a Comment!
but is published as
Text- Hi! This is a Comment!
Any ideas folks? I'm totally stumped. I want to add the extra text so it appears within the comment rather than before/around it in the theme. | You can try the [`comment_text`](https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/comment-template.php#L852) filter:
```
/**
* Prepend text to each comment content.
*/
add_filter( 'comment_text', function( $comment_text )
{
$text = 'Some text';
return $text . $comment_text;
});
```
if you'... |
174,880 | <p>Specifically, I am using the <code>add_image_attachment_fields_to_edit</code> function. I have my declaration of label, input..</p>
<pre><code>$form_fields["custom4"]["label"] = __("Custom Select");
$form_fields["custom4"]["input"] = "html";
</code></pre>
<p>But when I try to iterate through my categories for the ... | [
{
"answer_id": 174877,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You can try the <a href=\"https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/comment-template.ph... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65912/"
] | Specifically, I am using the `add_image_attachment_fields_to_edit` function. I have my declaration of label, input..
```
$form_fields["custom4"]["label"] = __("Custom Select");
$form_fields["custom4"]["input"] = "html";
```
But when I try to iterate through my categories for the select, I get errors, or an empty htm... | You can try the [`comment_text`](https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/comment-template.php#L852) filter:
```
/**
* Prepend text to each comment content.
*/
add_filter( 'comment_text', function( $comment_text )
{
$text = 'Some text';
return $text . $comment_text;
});
```
if you'... |
174,885 | <p>Is there a way for the menu to be translated when I choose the website language? Does anyone have a solution to do it without using the plugin?</p>
| [
{
"answer_id": 175073,
"author": "Vincent Wong",
"author_id": 66041,
"author_profile": "https://wordpress.stackexchange.com/users/66041",
"pm_score": 1,
"selected": false,
"text": "<p>You can create a menu use another language. Then you use conditional code to switch the menu. or you can... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174885",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65666/"
] | Is there a way for the menu to be translated when I choose the website language? Does anyone have a solution to do it without using the plugin? | You can create a menu use another language. Then you use conditional code to switch the menu. or you can use title attribute of menu.
```
if($language=='us'):
wp_nav_menu(menu1);
else:
wp_nav_menu(menu2);
endif;
```
 |
174,886 | <p>How can limit the size of posts that authors can create on my WordPress site and the number of posts they can create?</p>
| [
{
"answer_id": 174901,
"author": "Privateer",
"author_id": 66020,
"author_profile": "https://wordpress.stackexchange.com/users/66020",
"pm_score": 2,
"selected": true,
"text": "<p>The best way I know of would be to filter the data.</p>\n\n<p>For posts, you might do:</p>\n\n<pre><code>fun... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64351/"
] | How can limit the size of posts that authors can create on my WordPress site and the number of posts they can create? | The best way I know of would be to filter the data.
For posts, you might do:
```
function my_check_post_not_crazy( $data, $post_arr ) {
$max_content_length = 2048; # max length in characters
$max_num_posts = 200; # maximum number of posts
if ( !current_user_can('activate_plugins') && empty( $po... |
174,889 | <p>By default whenever you disable indexing via Admin Settings </p>
<blockquote>
<p>[ x ] Discourage search engines from indexing this site</p>
</blockquote>
<p>It adds a meta tag in the header like so:</p>
<pre><code><meta name='robots' content='noindex,follow' />
</code></pre>
<p>How do I change that to b... | [
{
"answer_id": 174891,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": false,
"text": "<p>I suppose this ended up working for me. I was more hoping for some kind of better filter but it works just ... | 2015/01/14 | [
"https://wordpress.stackexchange.com/questions/174889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | By default whenever you disable indexing via Admin Settings
>
> [ x ] Discourage search engines from indexing this site
>
>
>
It adds a meta tag in the header like so:
```
<meta name='robots' content='noindex,follow' />
```
How do I change that to be `nofollow` instead of `follow`? I find it odd it enables "f... | Thought this was a great question so I went digging. In default-filters.php on line 208 there's `add_action('wp_head', 'noindex', 1);` as of WordPress 4.1. The noindex() function in turn checks to see if you have set blog\_public option to 0. If you have, it calls wp\_no\_robots() which is simply:
```
function wp_no_r... |
174,900 | <p>I have a wordpress page which loads all the artists in two columns... here is what I believe to be the relevant bit of code</p>
<pre><code><?php
global $paged;
if ( is_front_page() ) {
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
} else {
... | [
{
"answer_id": 174902,
"author": "Henry Aspden",
"author_id": 58960,
"author_profile": "https://wordpress.stackexchange.com/users/58960",
"pm_score": 0,
"selected": false,
"text": "<p>so i removed the pagination by removing this from lower</p>\n\n<pre><code><?php get_template_part('in... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58960/"
] | I have a wordpress page which loads all the artists in two columns... here is what I believe to be the relevant bit of code
```
<?php
global $paged;
if ( is_front_page() ) {
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
} else {
$p... | if you want to show only 2, put it as a value, like so:
```
'posts_per_page' => 2
```
For the newest posts, you need to change the sort using the order and orderby params:
```
'orderby' => 'date',
'order' => 'ASC'
```
Details about orderby params here: <http://codex.wordpress.org/Class_Reference/WP_Query#Order_... |
174,906 | <p>I have done this before but it doesn't seem to be working in this case. I am trying to get the category ID from the supplied slug and then add a metabox to the page if the page id matches the category id. My site is throwing me two errors in the admin area </p>
<p>Undefined index: post and undefined index post_id</... | [
{
"answer_id": 174909,
"author": "Privateer",
"author_id": 66020,
"author_profile": "https://wordpress.stackexchange.com/users/66020",
"pm_score": 0,
"selected": false,
"text": "<p>I'd recommend using an action to place your meta box:</p>\n\n<pre><code>function my_add_meta_box() {\n g... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14761/"
] | I have done this before but it doesn't seem to be working in this case. I am trying to get the category ID from the supplied slug and then add a metabox to the page if the page id matches the category id. My site is throwing me two errors in the admin area
Undefined index: post and undefined index post\_id
```
a... | I got it to work by doing it this way
```
if (is_admin() ){
$post_id = isset($_GET['post']) ? $_GET['post'] : isset($_POST['post_ID']) ;
if( $post_id && in_category('audio', $post_id) ){
add_action('admin_init', 'add_meta_boxes', 1);
}
}
```
The only problem with this method is that it won't display the me... |
174,907 | <p>WordPress have <code>the_posts_navigation</code> function since 4.1.0. But I don't know how to use with <code>wp_query</code> or <code>get_posts</code>. the following code is in a template file of page.<br><strong>wp_query method:</strong></p>
<pre><code> <?php
if ( get_query_var('paged') ) {
$paged =... | [
{
"answer_id": 174910,
"author": "Leo Caseiro",
"author_id": 52791,
"author_profile": "https://wordpress.stackexchange.com/users/52791",
"pm_score": 2,
"selected": false,
"text": "<p>This function uses the <a href=\"https://developer.wordpress.org/reference/functions/get_the_posts_pagina... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66041/"
] | WordPress have `the_posts_navigation` function since 4.1.0. But I don't know how to use with `wp_query` or `get_posts`. the following code is in a template file of page.
**wp\_query method:**
```
<?php
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ... | `the_posts_navigation()` is simply a wrapper function for [`get_the_posts_navigation()`](https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/link-template.php#L2233) which issimply a wrapper function for `paginate_links`. The first two functions uses the the same exact parameters that is being used by `pag... |
174,912 | <p>I need to order my Wordpress posts (that happen to be Woocommerce products) alphabetically, but I want to ignore certain words, eg. 'The' and 'A' and 'An'.</p>
<p>Is there a function or filter that can be targeted to the custom post query on top of orderby=ASC to ignore certain chosen words?</p>
<pre><code><?ph... | [
{
"answer_id": 174916,
"author": "Leo Caseiro",
"author_id": 52791,
"author_profile": "https://wordpress.stackexchange.com/users/52791",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress runs with MySQL and it's not really possible to do using MySQL: \n<a href=\"https://stackoverfl... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48568/"
] | I need to order my Wordpress posts (that happen to be Woocommerce products) alphabetically, but I want to ignore certain words, eg. 'The' and 'A' and 'An'.
Is there a function or filter that can be targeted to the custom post query on top of orderby=ASC to ignore certain chosen words?
```
<?php
// My custom query
$ar... | Ok, worked it out via a little workaround.
1. Add a new sorting function in Woocommerce, something like: <https://gist.githubusercontent.com/bekarice/0df2b2d54d6ac8076f84/raw/wc-sort-by-postmeta.php> works nicely, but remove the bit about meta values and keys since we're not sorting by custom fields (though that coul... |
174,924 | <p><strong>What I have done</strong></p>
<p>I have a developed a custom WordPress plugin for displaying a custom calculator on my website. And regarding the same I have created a short-code for it which I am using to place it on any page of my website.</p>
<p><strong>What I want to achieve</strong></p>
<p>Now I want... | [
{
"answer_id": 174916,
"author": "Leo Caseiro",
"author_id": 52791,
"author_profile": "https://wordpress.stackexchange.com/users/52791",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress runs with MySQL and it's not really possible to do using MySQL: \n<a href=\"https://stackoverfl... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174924",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65707/"
] | **What I have done**
I have a developed a custom WordPress plugin for displaying a custom calculator on my website. And regarding the same I have created a short-code for it which I am using to place it on any page of my website.
**What I want to achieve**
Now I want to create an embedded code for it so that by usin... | Ok, worked it out via a little workaround.
1. Add a new sorting function in Woocommerce, something like: <https://gist.githubusercontent.com/bekarice/0df2b2d54d6ac8076f84/raw/wc-sort-by-postmeta.php> works nicely, but remove the bit about meta values and keys since we're not sorting by custom fields (though that coul... |
174,932 | <p>Migrating between local and server with Wordpress (SQL) is a bit time consuming, and I'm wondering if there is a better way to do it. With Drupal, there is a module called BackUp&Migrate, which lets you push SQL updates <strong>immediately</strong> from within the Drupal framework to the server. Is there somethi... | [
{
"answer_id": 174916,
"author": "Leo Caseiro",
"author_id": 52791,
"author_profile": "https://wordpress.stackexchange.com/users/52791",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress runs with MySQL and it's not really possible to do using MySQL: \n<a href=\"https://stackoverfl... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174932",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58166/"
] | Migrating between local and server with Wordpress (SQL) is a bit time consuming, and I'm wondering if there is a better way to do it. With Drupal, there is a module called BackUp&Migrate, which lets you push SQL updates **immediately** from within the Drupal framework to the server. Is there something similar for Wordp... | Ok, worked it out via a little workaround.
1. Add a new sorting function in Woocommerce, something like: <https://gist.githubusercontent.com/bekarice/0df2b2d54d6ac8076f84/raw/wc-sort-by-postmeta.php> works nicely, but remove the bit about meta values and keys since we're not sorting by custom fields (though that coul... |
174,934 | <p>Sometimes, due to meta boxes added by plugins, the excerpt gets moved down the order in the admin page.</p>
<p>Is there a way I can force it to <em>always</em> be directly below the post content?</p>
<p>Here is the way I've tried:</p>
<pre><code>function remove_wordpress_meta_boxes() {
remove_meta_box( 'postex... | [
{
"answer_id": 174980,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>The reason why your code doesn't work is most likely that you've ordered your metaboxes before, and the that o... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60608/"
] | Sometimes, due to meta boxes added by plugins, the excerpt gets moved down the order in the admin page.
Is there a way I can force it to *always* be directly below the post content?
Here is the way I've tried:
```
function remove_wordpress_meta_boxes() {
remove_meta_box( 'postexcerpt', 'page', 'normal' );
add_... | The reason why your code doesn't work is most likely that you've ordered your metaboxes before, and the that order has been saved into the `meta-box-order_page` meta value. This overrides the default setup.
Here's an example of the `meta-box-order_post` meta value:
```
a:3:{
s:4:"side";
s:61:"submit... |
174,939 | <p>Does someone know how to write the next line in wordpress PHP, because i'm not that great with PHP.</p>
<p>If_theme_mode has content echo { my content } else { other content };</p>
<p>thnx</p>
| [
{
"answer_id": 174941,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 2,
"selected": false,
"text": "<p>try this code:</p>\n\n<pre><code>if( get_theme_mod('your_setting_name') ){\n //your code\n}else{\n /... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174939",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65451/"
] | Does someone know how to write the next line in wordpress PHP, because i'm not that great with PHP.
If\_theme\_mode has content echo { my content } else { other content };
thnx | try this code:
```
if( get_theme_mod('your_setting_name') ){
//your code
}else{
//your code
}
```
**Note:** [get\_theme\_mod()](http://codex.wordpress.org/Function_Reference/get_theme_mod) return false if no value exist for your setting |
174,962 | <p>I have posts whose each contains 4 attached images.
what i'm trying to do in my single.php is to get all the 4 images src to be abble to add different classes to each images.</p>
<pre><code><img class="image_1 no_lazy" src="first attached image src"/>
<img class="image_2" src="second attached image src"/&g... | [
{
"answer_id": 174973,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p><code>wp_get_attachment_image_src</code> returns an array with 3 elements; the image URL, the width, and t... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40572/"
] | I have posts whose each contains 4 attached images.
what i'm trying to do in my single.php is to get all the 4 images src to be abble to add different classes to each images.
```
<img class="image_1 no_lazy" src="first attached image src"/>
<img class="image_2" src="second attached image src"/>
<img class="image_3" sr... | If you only want to add an extra class, then you should use `wp_get_attachment_image`. It has few extra params, and the last one is used for setting class names.
Sample usage:
```
<?php echo wp_get_attachment_image( get_the_ID(), 'thumbnail', "", ["class" => "my-custom-class"] ); ?>
```
The main advantage of this a... |
174,978 | <p>I'm in kind of a weird situation (for me)<br>
My client has a website that runs on a custom CMS<br>
He wants an online site that loads some data from the existing database.<br>
This is an external MSSQL database and for security reasons a serialized table is created.
So there is no way for me to "read" from the data... | [
{
"answer_id": 174979,
"author": "Brandt Solovij",
"author_id": 38927,
"author_profile": "https://wordpress.stackexchange.com/users/38927",
"pm_score": 1,
"selected": false,
"text": "<p>I setup something similar. Using IIS - look into writing a .bat file which fires off a php shell scrip... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/174978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52240/"
] | I'm in kind of a weird situation (for me)
My client has a website that runs on a custom CMS
He wants an online site that loads some data from the existing database.
This is an external MSSQL database and for security reasons a serialized table is created.
So there is no way for me to "read" from the database.
... | I setup something similar. Using IIS - look into writing a .bat file which fires off a php shell script to do whatever it is you need to accomplish.
once you have that bat file working, setup a "scheduled task" in IIS <http://technet.microsoft.com/en-us/library/cc721871.aspx>
if you are on a linux system, then use cr... |
175,011 | <p>I have an issue that has me scratching my head and if I scratch anymore I'm gonna go bald. I have looked all over for a solution but have not found anything so I thought I'd stop by and see if maybe any of you experts out there can assist.</p>
<p>I created a theme called WP-Forge and then I created a child theme to... | [
{
"answer_id": 175021,
"author": "user3325126",
"author_id": 56674,
"author_profile": "https://wordpress.stackexchange.com/users/56674",
"pm_score": 0,
"selected": false,
"text": "<p>Did you try adding the next line of code as it says in the codex?</p>\n\n<p><strong>Codex:</strong></p>\n... | 2015/01/15 | [
"https://wordpress.stackexchange.com/questions/175011",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65047/"
] | I have an issue that has me scratching my head and if I scratch anymore I'm gonna go bald. I have looked all over for a solution but have not found anything so I thought I'd stop by and see if maybe any of you experts out there can assist.
I created a theme called WP-Forge and then I created a child theme to be used w... | Actually @Pieter Goosen took care of the issue when he corrected the Codex and removed the call to the extra style sheet. So in fact this works the way it should
```
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_director... |
175,028 | <p>I'm trying to put 4 news with pictures 3 small and one large, have gotten displaying them but the "large" is repeated with the last "small"</p>
<p><img src="https://i.stack.imgur.com/aWaTq.jpg" alt="enter image description here"></p>
<pre><code><?php
$b=1;
$args = array(
'tax_query' => array... | [
{
"answer_id": 175021,
"author": "user3325126",
"author_id": 56674,
"author_profile": "https://wordpress.stackexchange.com/users/56674",
"pm_score": 0,
"selected": false,
"text": "<p>Did you try adding the next line of code as it says in the codex?</p>\n\n<p><strong>Codex:</strong></p>\n... | 2015/01/16 | [
"https://wordpress.stackexchange.com/questions/175028",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54649/"
] | I'm trying to put 4 news with pictures 3 small and one large, have gotten displaying them but the "large" is repeated with the last "small"

```
<?php
$b=1;
$args = array(
'tax_query' => array(
array(
'tax... | Actually @Pieter Goosen took care of the issue when he corrected the Codex and removed the call to the extra style sheet. So in fact this works the way it should
```
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_director... |
175,090 | <p>I am able to implement http basic auth in <code>wp_remote_get</code> using the following code</p>
<pre><code>$args = array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( $username . ':' . $password )
)
);
wp_remote_request( $url, $args );
</code></pre>
<p>Is it possible to ... | [
{
"answer_id": 179825,
"author": "Saurabh Shukla",
"author_id": 20375,
"author_profile": "https://wordpress.stackexchange.com/users/20375",
"pm_score": 0,
"selected": false,
"text": "<p>Isn't that obvious? <em>wp_remote_get</em> is just a single request response function. The difference,... | 2015/01/16 | [
"https://wordpress.stackexchange.com/questions/175090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24579/"
] | I am able to implement http basic auth in `wp_remote_get` using the following code
```
$args = array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( $username . ':' . $password )
)
);
wp_remote_request( $url, $args );
```
Is it possible to do http digest based authentication using `... | It is possible to do HTTP DIGEST authentication with `wp_remote_get()`, but it's somewhat complicated. I've written a [short wrapper function](http://blog.handbuilt.co/2016/01/08/using-http-digest-authentication-with-wordpress-wp_remote_get/) you can use. |
175,106 | <p>I want to list all posts with a corresponding template for a custom taxonomy term of a custom post type. To make it easier to understand: </p>
<p>The custom post type is called PUBLICATIONS and has a custom taxonomy called LISTS. Each list template is slighty different, so when all posts are listed on the archive-p... | [
{
"answer_id": 175187,
"author": "gfaw",
"author_id": 29222,
"author_profile": "https://wordpress.stackexchange.com/users/29222",
"pm_score": 1,
"selected": false,
"text": "<p><strong>I solved it.</strong></p>\n\n<p>SOLUTION:</p>\n\n<pre><code><?php \nif ( has_term( 'downloads', 'list... | 2015/01/16 | [
"https://wordpress.stackexchange.com/questions/175106",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29222/"
] | I want to list all posts with a corresponding template for a custom taxonomy term of a custom post type. To make it easier to understand:
The custom post type is called PUBLICATIONS and has a custom taxonomy called LISTS. Each list template is slighty different, so when all posts are listed on the archive-publication... | **I solved it.**
SOLUTION:
```
<?php
if ( has_term( 'downloads', 'listen', $post->ID ) ) {
get_template_part( 'templates/content-downloads-vergriffener-baende' );
}
elseif ( has_term( 'untersuchungen', 'listen', $post->ID ) ) {
get_template_part( 'templates/content-untersuchungen' );
}
elseif ( has_term... |
175,203 | <p>I want to structure my site like such:</p>
<pre><code>http://www.website.com/cars/
http://www.website.com/cars/blue/
http://www.website.com/cars/red/
</code></pre>
<p>Where both <code>/cars/</code> and <code>/blue/</code> would be articles that can receive comments. If you went to <code>cars/</code> you would be a... | [
{
"answer_id": 175235,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>The thing about WordPress, while it doesn't have a <em>neat</em> routing system in principle it does same operation.... | 2015/01/17 | [
"https://wordpress.stackexchange.com/questions/175203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65675/"
] | I want to structure my site like such:
```
http://www.website.com/cars/
http://www.website.com/cars/blue/
http://www.website.com/cars/red/
```
Where both `/cars/` and `/blue/` would be articles that can receive comments. If you went to `cars/` you would be able to display a listing of all of the children so you coul... | The thing about WordPress, while it doesn't have a *neat* routing system in principle it does same operation. It takes the URL input and matches it to a set of query variables.
The not–neat thing about it is that it uses regular expressions for these not–quite–routes and *a lot* of them. The total number of rules fluc... |
175,226 | <p>I have a custom post type archive archive-projects.php that I am using as a page template because I have some custom fields that I want to display. I am trying to get the post id of this page but either get null or the id of the first post in the archive depending on what I try. I have tried putting my code above th... | [
{
"answer_id": 175228,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<h2>EDIT</h2>\n\n<p>I get the idea that I might have misread your question</p>\n\n<p>Just a few notes here<... | 2015/01/18 | [
"https://wordpress.stackexchange.com/questions/175226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38099/"
] | I have a custom post type archive archive-projects.php that I am using as a page template because I have some custom fields that I want to display. I am trying to get the post id of this page but either get null or the id of the first post in the archive depending on what I try. I have tried putting my code above the l... | EDIT
----
I get the idea that I might have misread your question
Just a few notes here
* If `archive-projects.php` is a page template, rename it. You should not use *archive* as a prefix for a page template, or for that matter any other reserved template name. Page templates should be named `page-{$name}.php` or any... |
175,227 | <p>I just encountered weird problem.
My shortcode output which is something like</p>
<pre><code>'<span class="link_container"><a href="#">'.$content.'</a></span>
<div class="upgrade_box">
some more divs here
</div>'
</code></pre>
<p>is being broken by random <code></p></c... | [
{
"answer_id": 175238,
"author": "NickFMC",
"author_id": 56566,
"author_profile": "https://wordpress.stackexchange.com/users/56566",
"pm_score": 1,
"selected": false,
"text": "<p>Try this function out, be sure to add your shortcode in the array</p>\n\n<pre><code>// (OPT) STOP SHORTCODES ... | 2015/01/18 | [
"https://wordpress.stackexchange.com/questions/175227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13986/"
] | I just encountered weird problem.
My shortcode output which is something like
```
'<span class="link_container"><a href="#">'.$content.'</a></span>
<div class="upgrade_box">
some more divs here
</div>'
```
is being broken by random `</p>` closing tag inserted after `</span>`
Changing wpautop priority didn't wor... | Try this function out, be sure to add your shortcode in the array
```
// (OPT) STOP SHORTCODES THAT DON'T USE INLINE CONTENT FROM BEING WRAPPED IN A P TAG (until WP fixes this)
// ** NOTE -> BE SURE TO change the array to the shortcodes you are using!
add_filter('the_content', 'the_content_filter');
function the_con... |
175,232 | <p>I am just getting reaquainted with writing plugins, after writing a whole two about three years ago. Following some example code I found:</p>
<pre><code>if(!class_exists('QuizMaster_Plugin_Template')) {
class QuizMaster_Plugin_Template
{
public function __construct()
{
// registe... | [
{
"answer_id": 175234,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>WP plugins are meant to be loaded in context of WordPress core load. They won't work as vanilla PHP, unless you pur... | 2015/01/18 | [
"https://wordpress.stackexchange.com/questions/175232",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7268/"
] | I am just getting reaquainted with writing plugins, after writing a whole two about three years ago. Following some example code I found:
```
if(!class_exists('QuizMaster_Plugin_Template')) {
class QuizMaster_Plugin_Template
{
public function __construct()
{
// register actions.
... | WP plugins are meant to be loaded in context of WordPress core load. They won't work as vanilla PHP, unless you purposely abstract some parts completely away from WordPress.
The typical practice is to have actual working WP installation locally and develop in its context. |
175,260 | <p>I want to change the language of my WordPress installation based on a choice the user can make in his profile (dropdown menu).</p>
<p>As I want to change frontend (prepared .mo files for the theme) and backend language I thought I could change the <code>$locale</code> variable and it would work out.</p>
<p>So I ca... | [
{
"answer_id": 175275,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": true,
"text": "<p>Your use of <code>$current_user</code> is a little wrong, you should include the <code>global $current_user</c... | 2015/01/19 | [
"https://wordpress.stackexchange.com/questions/175260",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65455/"
] | I want to change the language of my WordPress installation based on a choice the user can make in his profile (dropdown menu).
As I want to change frontend (prepared .mo files for the theme) and backend language I thought I could change the `$locale` variable and it would work out.
So I came up with the following cod... | Your use of `$current_user` is a little wrong, you should include the `global $current_user` or assign it to a variable, or shorter and cleaner just `get_current_user_id()`:
```
add_filter('locale', 'change_lang');
function change_lang( $locale ) {
if( $lang = get_user_meta( get_current_user_id(), 'user_lang', tru... |
175,285 | <p>I have a single page site with posts that get loaded via Ajax on the same page via slide down div. When a post is 'activated,' I want that state to be set so that when I visit the url directly, it goes to that specific post already showing in the div.</p>
<p><strong>My question is:</strong></p>
<p>Do I create the ... | [
{
"answer_id": 175275,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": true,
"text": "<p>Your use of <code>$current_user</code> is a little wrong, you should include the <code>global $current_user</c... | 2015/01/19 | [
"https://wordpress.stackexchange.com/questions/175285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I have a single page site with posts that get loaded via Ajax on the same page via slide down div. When a post is 'activated,' I want that state to be set so that when I visit the url directly, it goes to that specific post already showing in the div.
**My question is:**
Do I create the posts in single.php and call t... | Your use of `$current_user` is a little wrong, you should include the `global $current_user` or assign it to a variable, or shorter and cleaner just `get_current_user_id()`:
```
add_filter('locale', 'change_lang');
function change_lang( $locale ) {
if( $lang = get_user_meta( get_current_user_id(), 'user_lang', tru... |
175,307 | <p>I am using jQuery tinyMCE to populate dynamically generated text areas with tiny MCE editors.</p>
<p>When I use the WordPress <code>wp_editor</code> function before I call the jQuery version, I have no issues. If I do not, I get;</p>
<blockquote>
<p>Uncaught ReferenceError: tinymce is not defined</p>
</blockquot... | [
{
"answer_id": 176222,
"author": "myol",
"author_id": 51823,
"author_profile": "https://wordpress.stackexchange.com/users/51823",
"pm_score": 4,
"selected": true,
"text": "<p>With help from a colleague, we dug through <code>class-wp-editor.php</code></p>\n\n<p>Here are the necessary scri... | 2015/01/19 | [
"https://wordpress.stackexchange.com/questions/175307",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51823/"
] | I am using jQuery tinyMCE to populate dynamically generated text areas with tiny MCE editors.
When I use the WordPress `wp_editor` function before I call the jQuery version, I have no issues. If I do not, I get;
>
> Uncaught ReferenceError: tinymce is not defined
>
>
>
As a dreadful hack, I have used;
```
wp_ed... | With help from a colleague, we dug through `class-wp-editor.php`
Here are the necessary scripts to initialise jQuery tinyMCE if `wp_editor` has not been used beforehand (which calls these scripts).
```
// Get the necessary scripts to launch tinymce
$baseurl = includes_url( 'js/tinymce' );
$cssurl = includes_url('css... |
175,333 | <p>I have 1458 post in category name news that id is 5.</p>
<p>And i wont to copy all of this post and transfer it to custom post type name news.</p>
<p>How can do that ??</p>
| [
{
"answer_id": 175334,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 0,
"selected": false,
"text": "<p>I would suggest an export/import procedure using a tool such as WP CSV. <a href=\"https://wordpress.org/plug... | 2015/01/19 | [
"https://wordpress.stackexchange.com/questions/175333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66189/"
] | I have 1458 post in category name news that id is 5.
And i wont to copy all of this post and transfer it to custom post type name news.
How can do that ?? | Create your custom post type and then try this. (BACKUP FIRST AS THIS IS UNTESTED).
```
<?php
// Get all posts in category "5"
$news_posts = get_posts(
array(
'category' => 5
)
);
// Loop through them
foreach($news_posts as $p):
// Update the post type
wp_update_post(
array(
... |
175,346 | <p>I finally managed to <strong>update an old WP 3.3.1 site to WP 4.1</strong> with few issues, but one unexpected change seems to have come about with relation to file uploads.</p>
<p>In the WP 3.3.1 version of the plugin, I enabled uploads for a custom Role via 'read' and 'upload_files'.</p>
<p>NOTE: This is for co... | [
{
"answer_id": 231207,
"author": "user97667",
"author_id": 97667,
"author_profile": "https://wordpress.stackexchange.com/users/97667",
"pm_score": 2,
"selected": false,
"text": "<p>Found the basic problem! Although a different context than the one you described, the root cause is probabl... | 2015/01/19 | [
"https://wordpress.stackexchange.com/questions/175346",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60733/"
] | I finally managed to **update an old WP 3.3.1 site to WP 4.1** with few issues, but one unexpected change seems to have come about with relation to file uploads.
In the WP 3.3.1 version of the plugin, I enabled uploads for a custom Role via 'read' and 'upload\_files'.
NOTE: This is for content that is **NOT** post dr... | Found the basic problem! Although a different context than the one you described, the root cause is probably the same.
I was trying to allow users to setup a personal page and upload an image to display there. I kept getting the dreaded "You don't have permission to attach files to this post".
The message itself comes... |
175,393 | <p>We have a custom post type <code>testimonial</code> and want to show the 1st, 2nd and 3rd in various bespoke locations on the page.</p>
<p>Here's how we would do it if we just wanted to loop over testimonials and show them one after another (this works):</p>
<pre><code><?php
$args = array('post_type' => 'tes... | [
{
"answer_id": 175399,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Make use of an offset to skip the first 2 posts if you need the third post only, and then set you <code>... | 2015/01/20 | [
"https://wordpress.stackexchange.com/questions/175393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/875/"
] | We have a custom post type `testimonial` and want to show the 1st, 2nd and 3rd in various bespoke locations on the page.
Here's how we would do it if we just wanted to loop over testimonials and show them one after another (this works):
```
<?php
$args = array('post_type' => 'testimonial');
$testimonials = new WP_Que... | Make use of an offset to skip the first 2 posts if you need the third post only, and then set you `posts_per_page` to `1` to get only that specific post
You can try something like this in your arguments
```
$args = array(
'post_type' => 'testimonial',
'offset' => 2,
'posts_per_page' => 1
);
$testimonials ... |
175,418 | <p>I have a page that is calling in the content from other posts (a custom post type, specifically) and inserting it into the page. It all works great, but I'm losing the functionality of WordPress taking youtube (and other embeddable links) and automatically inserting the embedded video.</p>
<p>I've tried <code>apply... | [
{
"answer_id": 175421,
"author": "Maks",
"author_id": 66236,
"author_profile": "https://wordpress.stackexchange.com/users/66236",
"pm_score": 0,
"selected": false,
"text": "<p>try to use <code>get_the_content()</code>, like:</p>\n\n<pre><code>$my_content = get_the_content();\n$my_content... | 2015/01/20 | [
"https://wordpress.stackexchange.com/questions/175418",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45132/"
] | I have a page that is calling in the content from other posts (a custom post type, specifically) and inserting it into the page. It all works great, but I'm losing the functionality of WordPress taking youtube (and other embeddable links) and automatically inserting the embedded video.
I've tried `apply_filters( 'the_... | I think the solution is amazingly simple here:
You're just missing a single line of code in your *ajax* callback, namely:
```
global $post;
```
where I assume you're using:
```
$post = get_post( $post_id );
```
The reason is that there's a global post check in the `WP_Embed::shortcode()` method.
More details in... |
175,521 | <p>I found this code on stackoverflow, but how do I output the actual content rather than just that ID line in the example!</p>
<pre><code><?php
$the_slug = 'my-page';
$args=array(
'name' => $the_slug,
'post_type' => 'page',
'post_status' => 'publish',
'numbe... | [
{
"answer_id": 175522,
"author": "Михаил Семёнов",
"author_id": 65524,
"author_profile": "https://wordpress.stackexchange.com/users/65524",
"pm_score": 0,
"selected": false,
"text": "<p><code>$my_posts[0]->post_content</code></p>\n\n<p>for proper look you'll need to apply filter <code... | 2015/01/21 | [
"https://wordpress.stackexchange.com/questions/175521",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50150/"
] | I found this code on stackoverflow, but how do I output the actual content rather than just that ID line in the example!
```
<?php
$the_slug = 'my-page';
$args=array(
'name' => $the_slug,
'post_type' => 'page',
'post_status' => 'publish',
'numberposts' => 1
);
... | This is a "custom" loop outside of the main WordPress query (`query_posts`), you will have to tell WordPress to setup the post data using `setup_postdata()`
More info on `get_posts()` is found here, giving you basically what I am about to write below: <http://codex.wordpress.org/Template_Tags/get_posts>
Tip: The Word... |
175,554 | <p>I'm creating a theme option page and i try to display the values of two input in my front end : </p>
<pre><code>function register_my_header() {
register_setting( 'header_options', 'header_options');
}
add_action('admin_init', 'register_my_header');
function add_header_settings() {
add_menu_page('Options h... | [
{
"answer_id": 175584,
"author": "jetlej",
"author_id": 9862,
"author_profile": "https://wordpress.stackexchange.com/users/9862",
"pm_score": -1,
"selected": true,
"text": "<p>Make the $options variable global by changing the header_add_content() function to the following: </p>\n\n<pre><... | 2015/01/21 | [
"https://wordpress.stackexchange.com/questions/175554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66091/"
] | I'm creating a theme option page and i try to display the values of two input in my front end :
```
function register_my_header() {
register_setting( 'header_options', 'header_options');
}
add_action('admin_init', 'register_my_header');
function add_header_settings() {
add_menu_page('Options header', 'Optio... | Make the $options variable global by changing the header\_add\_content() function to the following:
```
function header_add_content() {
global $options;
$options = get_option('header_options');
}
add_filter("the_content", "header_add_content");
```
Then declare $options as the global $options on the front-... |
175,558 | <p>I've set up some custom post types, and created custom archives, eg in the following format:</p>
<p>archive-books.php (With a template name of "Books Template").
I then have a page (/books/) created in wordpress, with the above archive-books.php assigned as the template.</p>
<p>How would I get the the meta title (... | [
{
"answer_id": 175584,
"author": "jetlej",
"author_id": 9862,
"author_profile": "https://wordpress.stackexchange.com/users/9862",
"pm_score": -1,
"selected": true,
"text": "<p>Make the $options variable global by changing the header_add_content() function to the following: </p>\n\n<pre><... | 2015/01/21 | [
"https://wordpress.stackexchange.com/questions/175558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19452/"
] | I've set up some custom post types, and created custom archives, eg in the following format:
archive-books.php (With a template name of "Books Template").
I then have a page (/books/) created in wordpress, with the above archive-books.php assigned as the template.
How would I get the the meta title (wp\_title) to be ... | Make the $options variable global by changing the header\_add\_content() function to the following:
```
function header_add_content() {
global $options;
$options = get_option('header_options');
}
add_filter("the_content", "header_add_content");
```
Then declare $options as the global $options on the front-... |
175,564 | <p>I want to know how wordpress displaying shortcode inserted in post content, so I can replicate what it does and implement it to my plugin.</p>
<p><strong>Here is an example:</strong></p>
<p>I want to show shortcode inserted between an html codes like this:</p>
<pre><code> <div class="akismet_activate">
... | [
{
"answer_id": 175584,
"author": "jetlej",
"author_id": 9862,
"author_profile": "https://wordpress.stackexchange.com/users/9862",
"pm_score": -1,
"selected": true,
"text": "<p>Make the $options variable global by changing the header_add_content() function to the following: </p>\n\n<pre><... | 2015/01/21 | [
"https://wordpress.stackexchange.com/questions/175564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32989/"
] | I want to know how wordpress displaying shortcode inserted in post content, so I can replicate what it does and implement it to my plugin.
**Here is an example:**
I want to show shortcode inserted between an html codes like this:
```
<div class="akismet_activate">
<div class="aa_a">A</div>
<div onclick="... | Make the $options variable global by changing the header\_add\_content() function to the following:
```
function header_add_content() {
global $options;
$options = get_option('header_options');
}
add_filter("the_content", "header_add_content");
```
Then declare $options as the global $options on the front-... |
175,597 | <p>Here is the code I have. It is showing 100 custom post known as campaigns. I need it to only show the current users. So author/joe should only show joe's campaigns. </p>
<pre><code> <?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get... | [
{
"answer_id": 175601,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 0,
"selected": false,
"text": "<p><strong>i dont see the problam in using WP_Query...</strong><br>\nit has an author parameter.</p>\n\n<pre><code>... | 2015/01/22 | [
"https://wordpress.stackexchange.com/questions/175597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49017/"
] | Here is the code I have. It is showing 100 custom post known as campaigns. I need it to only show the current users. So author/joe should only show joe's campaigns.
```
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($aut... | Do not use `query_posts`, and for that matter any custom query to replace the main query. It is always problematic and it creates more problems that solving it.
Use the main query and make use of `pre_get_posts` to alter the main query as needed.
To solve your issue, remove the `query_posts` line, this is how author... |
175,613 | <p>I created a plugin with a cron to update all posts of a certain type every 5 minutes. I installed WP Crontrol to check if the cron is registered correctly and everything seems to be okay.</p>
<p>This is how I registered my cron:</p>
<pre><code>function custom_cron_interval( $schedules ) {
$schedules['fiveminut... | [
{
"answer_id": 176312,
"author": "mtt_g",
"author_id": 63255,
"author_profile": "https://wordpress.stackexchange.com/users/63255",
"pm_score": 0,
"selected": false,
"text": "<p>I was having the same issue recently, until I followed an example from the <a href=\"http://codex.wordpress.org... | 2015/01/22 | [
"https://wordpress.stackexchange.com/questions/175613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43586/"
] | I created a plugin with a cron to update all posts of a certain type every 5 minutes. I installed WP Crontrol to check if the cron is registered correctly and everything seems to be okay.
This is how I registered my cron:
```
function custom_cron_interval( $schedules ) {
$schedules['fiveminutes'] = array(
... | I was having the same issue recently, until I followed an example from the [Wordpress Codex](http://codex.wordpress.org/Function_Reference/wp_schedule_event) which suggests using action hooks to run the function.
I think if you add the following...
```
add_action( 'recalculate_all_scores_hook', 'recalculate_all_score... |
175,647 | <p>Unless i use:</p>
<pre><code>wp_enqueue_style( 'dazzling-style', get_template_directory_uri() . '/css/main.css?ver=', array(), rand(10,99999), 'all' );
</code></pre>
<p>Then everytime I visit my site, be it local or live, I see that the version is 4.1 and even though I upload a new stylesheet or js, the browser st... | [
{
"answer_id": 175650,
"author": "Maikal",
"author_id": 38034,
"author_profile": "https://wordpress.stackexchange.com/users/38034",
"pm_score": 0,
"selected": false,
"text": "<p>try to remove <code>?ver=</code></p>\n\n<p>4.1 is coming from wordpress, by default it set's a wordpress versi... | 2015/01/22 | [
"https://wordpress.stackexchange.com/questions/175647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14378/"
] | Unless i use:
```
wp_enqueue_style( 'dazzling-style', get_template_directory_uri() . '/css/main.css?ver=', array(), rand(10,99999), 'all' );
```
Then everytime I visit my site, be it local or live, I see that the version is 4.1 and even though I upload a new stylesheet or js, the browser still sees that 4.1 version.... | 4.1 is coming from your WordPress version.
Also you should not append `ver=` to the src manually but use the fourth parameter of [wp\_enqueue\_style](http://codex.wordpress.org/Function_Reference/wp_enqueue_style). |
175,699 | <p>Is there a way we can set these to list the posts in the category by alphabetical order?</p>
| [
{
"answer_id": 175701,
"author": "Monkey Puzzle",
"author_id": 48568,
"author_profile": "https://wordpress.stackexchange.com/users/48568",
"pm_score": 0,
"selected": false,
"text": "<p>If you're talking about general Wordpress coding, have a look here:\n<a href=\"http://codex.wordpress.o... | 2015/01/22 | [
"https://wordpress.stackexchange.com/questions/175699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66442/"
] | Is there a way we can set these to list the posts in the category by alphabetical order? | Yes, there is. Paste this in your `function.php`
```
add_action('pre_get_posts','wpse_175699_alphabetical_order');
function wpse_175699_alphabetical_order($query) {
if (is_category()) {
$query->set('orderby', 'title');
$query->set('order', 'ASC');
}
}
``` |
175,712 | <p>I made a custom post type with taxonomies and when I go to the taxonomy page and view one of the taxonomies I get a page not found error like the taxonomy wasnt made.</p>
<p>Any suggestions?</p>
<pre><code>/*Products*/
$labels = array(
'name' => _x('Products', 'post type general name'),
'singular_name' ... | [
{
"answer_id": 175714,
"author": "Privateer",
"author_id": 66020,
"author_profile": "https://wordpress.stackexchange.com/users/66020",
"pm_score": 1,
"selected": false,
"text": "<p>I'd recommend at least two things:</p>\n\n<ol>\n<li><p>Change the priority for your <code>products_create_t... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2635/"
] | I made a custom post type with taxonomies and when I go to the taxonomy page and view one of the taxonomies I get a page not found error like the taxonomy wasnt made.
Any suggestions?
```
/*Products*/
$labels = array(
'name' => _x('Products', 'post type general name'),
'singular_name' => _x('Product', 'post t... | After some research I have found a blog who actually had an answer to this problem.
Here is the function along with the [blog url](http://someweblog.com/wordpress-custom-taxonomy-with-same-slug-as-custom-post-type/).
```
function taxonomy_slug_rewrite($wp_rewrite) {
$rules = array();
// get all custom taxonom... |
175,728 | <p>I can log into <a href="http://localhost/wp/wp-admin/" rel="nofollow">http://localhost/wp/wp-admin/</a> fine, but logging into <a href="http://localhost/wp/wp-admin/network/" rel="nofollow">http://localhost/wp/wp-admin/network/</a> produces a network redirect loop (ERR_TOO_MANY_REDIRECTS). The site also loads just f... | [
{
"answer_id": 175753,
"author": "Arshad Hussain",
"author_id": 45086,
"author_profile": "https://wordpress.stackexchange.com/users/45086",
"pm_score": 1,
"selected": false,
"text": "<p>In your wp-config.php, you should overwrite the given server-variables that cause the problem by addin... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66079/"
] | I can log into <http://localhost/wp/wp-admin/> fine, but logging into <http://localhost/wp/wp-admin/network/> produces a network redirect loop (ERR\_TOO\_MANY\_REDIRECTS). The site also loads just fine even when logged in.
How can I find out what is causing this? Wordpress 4.1 installed into subdirectory 'wp', then co... | Problem is here: in htaccess, instead of this:
```
RewriteBase /
```
you should have
```
RewriteBase /wp/
```
in `wp-config.php`, there should be:
```
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false); //or true, depends on your chosen way
define('DOMAIN_CURR... |
175,729 | <p>I'm trying to disable a checkbox depending on the state of another checkbox.</p>
<pre><code><form action="options.php" method="post" id="form_submission">
<table>
<tr>
<td width="200px">
<label for="first_option"><?php _e('First Option:', 'my_... | [
{
"answer_id": 175737,
"author": "Alexey",
"author_id": 7314,
"author_profile": "https://wordpress.stackexchange.com/users/7314",
"pm_score": 0,
"selected": false,
"text": "<p>The state of checkbox you can know only with JavaScript.\nIn jQuery it could be look like this:</p>\n\n<pre><cod... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66412/"
] | I'm trying to disable a checkbox depending on the state of another checkbox.
```
<form action="options.php" method="post" id="form_submission">
<table>
<tr>
<td width="200px">
<label for="first_option"><?php _e('First Option:', 'my_plugin'); ?></label>
</td>
... | This may be a little overkill for you needs, but I use a bulked up version of this to great effect on my site.
This script will -
* Check what state the `first_option_required` option shold be in on page load (and set)
* Change the state of the `first_option_required` button upon changes to the `first_option_show` o... |
175,771 | <p>I'm not sure if this is possible - but checking before re-writing the template.</p>
<p>I've extended wp_query to allow for a geocode/location search to be performed.
This is working in itself and returning posts in a nearest to search point first order.</p>
<p>In the query generated now by wp_query it's calculatin... | [
{
"answer_id": 175737,
"author": "Alexey",
"author_id": 7314,
"author_profile": "https://wordpress.stackexchange.com/users/7314",
"pm_score": 0,
"selected": false,
"text": "<p>The state of checkbox you can know only with JavaScript.\nIn jQuery it could be look like this:</p>\n\n<pre><cod... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66428/"
] | I'm not sure if this is possible - but checking before re-writing the template.
I've extended wp\_query to allow for a geocode/location search to be performed.
This is working in itself and returning posts in a nearest to search point first order.
In the query generated now by wp\_query it's calculating the distance ... | This may be a little overkill for you needs, but I use a bulked up version of this to great effect on my site.
This script will -
* Check what state the `first_option_required` option shold be in on page load (and set)
* Change the state of the `first_option_required` button upon changes to the `first_option_show` o... |
175,782 | <p>I set the content and the wordpress directory of wordpress like described <a href="http://codex.wordpress.org/Editing_wp-config.php" rel="nofollow">in the codex</a>:</p>
<pre><code>define('WP_SITEURL', 'https://' . $_SERVER['SERVER_NAME'] . '/wordpress');
define('WP_CONTENT_DIR', dirname(__FILE__) . '/content');
</... | [
{
"answer_id": 176022,
"author": "mcnesium",
"author_id": 22572,
"author_profile": "https://wordpress.stackexchange.com/users/22572",
"pm_score": 4,
"selected": true,
"text": "<p>With credits to <a href=\"/users/4209/petermolnar\">petermolnar</a> via <code>irc://freenode.net/wordpress</c... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175782",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22572/"
] | I set the content and the wordpress directory of wordpress like described [in the codex](http://codex.wordpress.org/Editing_wp-config.php):
```
define('WP_SITEURL', 'https://' . $_SERVER['SERVER_NAME'] . '/wordpress');
define('WP_CONTENT_DIR', dirname(__FILE__) . '/content');
```
Now what I want to do is set an indi... | With credits to [petermolnar](/users/4209/petermolnar) via `irc://freenode.net/wordpress` I can answer my own question. The key is to set an `upload-dir` filter in the theme's `functions.php`:
```
function per_user_upload_dir( $original ){
// use the original array for initial setup
$modified = $original;
... |
175,785 | <p>I need create a file (any type: json, php, csv, txt) when I create or update a post from WPadmin. The format structure would be:</p>
<p>ID, "operation to execute" (new post, update post, delete post), title, field2, field3</p>
<p>Thanks!
martin</p>
| [
{
"answer_id": 176022,
"author": "mcnesium",
"author_id": 22572,
"author_profile": "https://wordpress.stackexchange.com/users/22572",
"pm_score": 4,
"selected": true,
"text": "<p>With credits to <a href=\"/users/4209/petermolnar\">petermolnar</a> via <code>irc://freenode.net/wordpress</c... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47361/"
] | I need create a file (any type: json, php, csv, txt) when I create or update a post from WPadmin. The format structure would be:
ID, "operation to execute" (new post, update post, delete post), title, field2, field3
Thanks!
martin | With credits to [petermolnar](/users/4209/petermolnar) via `irc://freenode.net/wordpress` I can answer my own question. The key is to set an `upload-dir` filter in the theme's `functions.php`:
```
function per_user_upload_dir( $original ){
// use the original array for initial setup
$modified = $original;
... |
175,793 | <p>The goal is to grab the first video (embed or shortcode) from the post.
So we need to check post content if it has embedded videos ( supported by WP ) or [video] shortcodes. Multiple videos and embeds could exist in the single post.
If found any - return the very first of them, not depending on order of given patter... | [
{
"answer_id": 175795,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": false,
"text": "<p>You can use the <a href=\"https://developer.wordpress.org/reference/functions/get_media_embedded_in_content/\... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31277/"
] | The goal is to grab the first video (embed or shortcode) from the post.
So we need to check post content if it has embedded videos ( supported by WP ) or [video] shortcodes. Multiple videos and embeds could exist in the single post.
If found any - return the very first of them, not depending on order of given patterns ... | You could try mashing all the patterns together in one big regexp or and then doing a simple line by line parse of the content:
```
function theme_oembed_videos() {
global $post;
if ( $post && $post->post_content ) {
global $shortcode_tags;
// Make a copy of global shortcode tags - we'll tem... |
175,806 | <p>We are managing the sales, subscriptions and customer profiles/accounts to our products via WP 4.1. The subscriptions are to products on a separate server with .NET. After a customer makes a purchase on the WP side, we'd like to push the customer account details (i.e. user name, password, etc.) to the .NET applicati... | [
{
"answer_id": 194526,
"author": "maxkoryukov",
"author_id": 76217,
"author_profile": "https://wordpress.stackexchange.com/users/76217",
"pm_score": 2,
"selected": false,
"text": "<p>Here is the library: <a href=\"http://www.zer7.com/software/cryptsharp\" rel=\"nofollow\">http://www.zer7... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175806",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66482/"
] | We are managing the sales, subscriptions and customer profiles/accounts to our products via WP 4.1. The subscriptions are to products on a separate server with .NET. After a customer makes a purchase on the WP side, we'd like to push the customer account details (i.e. user name, password, etc.) to the .NET application ... | Here is the library: <http://www.zer7.com/software/cryptsharp>
And this is "howtouse":
```
public override bool ValidateUser(string name, string password)
{
if (string.IsNullOrWhiteSpace(name))
return false;
if (string.IsNullOrWhiteSpace(password))
return false;
... |
175,811 | <p>I am trying to allow my editors and admins to click to "Edit Author" as they would "Edit Post" or "Edit [Custom Post Type]" from the admin bar when they are on a page like /authors/jdoe</p>
<p>(Note: I do <code>$wp_rewrite->author_base = 'people'</code> so that my addresses are /people/jdoe ... not sure if that ... | [
{
"answer_id": 175813,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You could try this modification of your code:</p>\n\n<pre><code>function add_author_edit_link( $wp_admin_bar )... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66490/"
] | I am trying to allow my editors and admins to click to "Edit Author" as they would "Edit Post" or "Edit [Custom Post Type]" from the admin bar when they are on a page like /authors/jdoe
(Note: I do `$wp_rewrite->author_base = 'people'` so that my addresses are /people/jdoe ... not sure if that creates any potential is... | You could try this modification of your code:
```
function add_author_edit_link( $wp_admin_bar )
{
if ( is_author() && current_user_can( 'add_users' ) )
{
$args = array(
'id' => 'author-edit',
'title' => __( 'Edit Author' ),
'href' => admin_url( sprintf(
... |
175,818 | <p>I have used the <a href="http://www.advancedcustomfields.com" rel="nofollow noreferrer">Advanced Custom Fields</a> plugin to create all the data elements for a company leadership directory page and management bio pages.</p>
<p>On the site blog, management will not be posting articles themselves, but it should appea... | [
{
"answer_id": 176219,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>If you want something to behave like a \"normal\" wordpress author then the best thing to do is to create... | 2015/01/23 | [
"https://wordpress.stackexchange.com/questions/175818",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66492/"
] | I have used the [Advanced Custom Fields](http://www.advancedcustomfields.com) plugin to create all the data elements for a company leadership directory page and management bio pages.
On the site blog, management will not be posting articles themselves, but it should appear as if they have. I think this practice is ref... | You could have saved yourself a ton of work and just used the Co-Authors Plus plugin. It has a guest author function. You do have to set them up, but there is no account/password for them, and they can have author pages. (I am not affiliated with them, just use it on several sites.) |
175,843 | <p>I have a custom post type that have a meta_key <code>custom_meta_sponsored</code> that owns alphabetical values. "X" means post doesn't sponsored. I want to show the archive page in custom order, sponsored first in random order.</p>
<p>I use <code>pre_get_posts</code> hook, but it doesn't work as I expected:</p>
<... | [
{
"answer_id": 175853,
"author": "bonger",
"author_id": 57034,
"author_profile": "https://wordpress.stackexchange.com/users/57034",
"pm_score": 1,
"selected": false,
"text": "<p>You could use the <code>'posts_orderby'</code> filter:</p>\n\n<pre><code>function custom_loops($query) {\n ... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175843",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9909/"
] | I have a custom post type that have a meta\_key `custom_meta_sponsored` that owns alphabetical values. "X" means post doesn't sponsored. I want to show the archive page in custom order, sponsored first in random order.
I use `pre_get_posts` hook, but it doesn't work as I expected:
```
function custom_loops($query) {
... | You could use the `'posts_orderby'` filter:
```
function custom_loops($query) {
if ( is_post_type_archive('my_post_type') ){
$query->set( 'posts_per_page', 40);
$query->set( 'meta_key', 'custom_meta_sponsored');
$query->set( 'orderby', 'custom_meta_sponsored');
$query->set( 'order',... |
175,851 | <p>Seriously, I lost my whole day with this... Either I completely missed the point... Or I really cannot find the proper information on the internet... </p>
<p>Everywhere I find they say to load jQuery in the following way, in my main file of my plugin I do the following</p>
<p>This is the wp_enqueue_scripts (with a... | [
{
"answer_id": 175855,
"author": "bonger",
"author_id": 57034,
"author_profile": "https://wordpress.stackexchange.com/users/57034",
"pm_score": -1,
"selected": false,
"text": "<p>You need to make sure jQuery has been loaded, so output your code in a late action, eg for front end you coul... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175851",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66412/"
] | Seriously, I lost my whole day with this... Either I completely missed the point... Or I really cannot find the proper information on the internet...
Everywhere I find they say to load jQuery in the following way, in my main file of my plugin I do the following
This is the wp\_enqueue\_scripts (with an S) to load th... | You need specify jquery as a dependency of your custom script, setting the 3rd parameter of [wp\_enqueue\_script()](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) to `array('jquery')`, like this:
```
wp_enqueue_script(
'yourCustomScript',
plugins_url('js/yourCustomScript.js', __FILE__),
a... |
175,867 | <p>I came across <a href="http://blog.g-design.net/post/60019471157/managing-and-deploying-wordpress-with-git" rel="nofollow">this site</a> and I was wondering why WordPress isn't using this as default:</p>
<pre><code>define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME']);
define('WP_HOME', 'http://' . $_SERVER[... | [
{
"answer_id": 175868,
"author": "karpstrucking",
"author_id": 55214,
"author_profile": "https://wordpress.stackexchange.com/users/55214",
"pm_score": 1,
"selected": false,
"text": "<p>With these constants defined, your WP site will work both with and without the preceding www. (as well ... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65855/"
] | I came across [this site](http://blog.g-design.net/post/60019471157/managing-and-deploying-wordpress-with-git) and I was wondering why WordPress isn't using this as default:
```
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME']);
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME']);
```
So nobody has to ... | With these constants defined, your WP site will work both with and without the preceding www. (as well as on any other URLs that correctly resolve to the site, like hosting-provided staging URLs, etc), which search engines will penalize as duplicate content. |
175,878 | <p>I discovered that I have 29,000 cron jobs in my WordPress database from deactivated and deleted plugins. I have tried a number of optimizer plugins but the huge number of cron jobs means I can't delete them using plugins.</p>
<p>I also tried this in my functions.php without success:</p>
<pre><code>add_action("init... | [
{
"answer_id": 175880,
"author": "Privateer",
"author_id": 66020,
"author_profile": "https://wordpress.stackexchange.com/users/66020",
"pm_score": 3,
"selected": false,
"text": "<p>Try </p>\n\n<pre><code>SELECT * FROM `wp_options` WHERE option_name = 'cron'\n</code></pre>\n\n<p>If you fi... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175878",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66530/"
] | I discovered that I have 29,000 cron jobs in my WordPress database from deactivated and deleted plugins. I have tried a number of optimizer plugins but the huge number of cron jobs means I can't delete them using plugins.
I also tried this in my functions.php without success:
```
add_action("init", "clear_crons_left"... | Thanks Privateer for the prompt reply and advice.
I found a way around it before I saw your answer. Here is a step-by-step method for deleting thousands of old cron jobs and may be of use to someone else.
I logged on to phpMyAdmin. I clicked on my database and then the 'search' tab. I typed in 'cron' then selected 'a... |
175,881 | <p>I'm stuck on loading page content by id (through a plugin). What I have is the following:</p>
<pre><code><?php $my_query = new WP_Query('page_id=39'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
</code></pre>
... | [
{
"answer_id": 175880,
"author": "Privateer",
"author_id": 66020,
"author_profile": "https://wordpress.stackexchange.com/users/66020",
"pm_score": 3,
"selected": false,
"text": "<p>Try </p>\n\n<pre><code>SELECT * FROM `wp_options` WHERE option_name = 'cron'\n</code></pre>\n\n<p>If you fi... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66531/"
] | I'm stuck on loading page content by id (through a plugin). What I have is the following:
```
<?php $my_query = new WP_Query('page_id=39'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
```
Instead of entering the id "39" though, it needs to c... | Thanks Privateer for the prompt reply and advice.
I found a way around it before I saw your answer. Here is a step-by-step method for deleting thousands of old cron jobs and may be of use to someone else.
I logged on to phpMyAdmin. I clicked on my database and then the 'search' tab. I typed in 'cron' then selected 'a... |
175,883 | <p>I have a simple custom query driven by <code>get_posts</code>:</p>
<pre><code><ul>
<?php
$args = array('post_type' => 'event', 'numberposts' => 6 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
echo '<li><a href="' . get_permalink() . '">' . ... | [
{
"answer_id": 175888,
"author": "bonger",
"author_id": 57034,
"author_profile": "https://wordpress.stackexchange.com/users/57034",
"pm_score": 0,
"selected": false,
"text": "<p><del>Yes, I think the only way is</del> (See \nAndrei Gheorghiu's answer) If you choose to remake the loop, th... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17702/"
] | I have a simple custom query driven by `get_posts`:
```
<ul>
<?php
$args = array('post_type' => 'event', 'numberposts' => 6 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
endforeach;
wp_reset_... | You can filter any WP query using [`pre_get_posts()`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts). The (sometimes) tricky part is that it is run against all queries of WP so you need to pinpoint your query using WP conditionals (`is_admin()`, `is_page()`, `is_archive()`, etc... ).
You'll fin... |
175,884 | <p>In my child theme's <code>archive.php</code>, I have the following code for displaying the title of my archive pages:</p>
<pre><code><?php
the_archive_title( '<h1 class="page-title">', '</h1>' );
?>
</code></pre>
<p>But that displays my titles as "Category: <em>Category Title</em... | [
{
"answer_id": 175900,
"author": "tao",
"author_id": 45169,
"author_profile": "https://wordpress.stackexchange.com/users/45169",
"pm_score": 3,
"selected": false,
"text": "<p>You could use </p>\n\n<pre><code>echo '<h1 class=\"page-title\">' . single_cat_title( '', false ) . '</h... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175884",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66533/"
] | In my child theme's `archive.php`, I have the following code for displaying the title of my archive pages:
```
<?php
the_archive_title( '<h1 class="page-title">', '</h1>' );
?>
```
But that displays my titles as "Category: *Category Title*" instead of simply the title without the prepended "Category: ".
My firs... | If you look at [the source code of `get_the_archive_title()`](https://developer.wordpress.org/reference/functions/get_the_archive_title/), you will see that there is a filter supplied, called `get_the_archive_title`, through which you can filter the output from the function.
You can use the following to change the out... |
175,890 | <p>I would like to have a few pages which can be reached by anyone who knows the URL, but which are not listed on the WordPress menu. I would like those pages to have a name rather than a number, but I don't see a way to do any of these things.</p>
<p>That is, I can create a page named "Special" and not include it in ... | [
{
"answer_id": 175892,
"author": "OnethingSimple",
"author_id": 66538,
"author_profile": "https://wordpress.stackexchange.com/users/66538",
"pm_score": 2,
"selected": true,
"text": "<p>If you tried to create a static file and then load it like a normal file, you may have had trouble beca... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66537/"
] | I would like to have a few pages which can be reached by anyone who knows the URL, but which are not listed on the WordPress menu. I would like those pages to have a name rather than a number, but I don't see a way to do any of these things.
That is, I can create a page named "Special" and not include it in the menu, ... | If you tried to create a static file and then load it like a normal file, you may have had trouble because a WP page as we call it, is actually not actually 1 file, but rather a lot of files that tell Wordpress how to put together information queried from the database based on the query that is used in the URL. Most mo... |
175,893 | <p>I'm still quite new to Wordpress - after a pointer or two.</p>
<p>I've created a archive page for a custom post type of 'property'.
This is set-up, working from an admin point of view, and I have a listing/index page showing the content created using a template I've themed called 'archive-property.php'.</p>
<p>Whi... | [
{
"answer_id": 175892,
"author": "OnethingSimple",
"author_id": 66538,
"author_profile": "https://wordpress.stackexchange.com/users/66538",
"pm_score": 2,
"selected": true,
"text": "<p>If you tried to create a static file and then load it like a normal file, you may have had trouble beca... | 2015/01/24 | [
"https://wordpress.stackexchange.com/questions/175893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66428/"
] | I'm still quite new to Wordpress - after a pointer or two.
I've created a archive page for a custom post type of 'property'.
This is set-up, working from an admin point of view, and I have a listing/index page showing the content created using a template I've themed called 'archive-property.php'.
While this archive t... | If you tried to create a static file and then load it like a normal file, you may have had trouble because a WP page as we call it, is actually not actually 1 file, but rather a lot of files that tell Wordpress how to put together information queried from the database based on the query that is used in the URL. Most mo... |
175,917 | <p>I'm trying to get all arguments for function <code>get_the_author_meta()</code> or <code>the_author_meta()</code>
because I have custom profile fields such as "parent name" and so, not only the normal arguments which is in <a href="http://codex.wordpress.org/Function_Reference/the_author_meta" rel="nofollow">Functio... | [
{
"answer_id": 175925,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 3,
"selected": true,
"text": "<p>I think you are confusing function arguments with author (user) meta fields. To get all user meta fields you c... | 2015/01/25 | [
"https://wordpress.stackexchange.com/questions/175917",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37854/"
] | I'm trying to get all arguments for function `get_the_author_meta()` or `the_author_meta()`
because I have custom profile fields such as "parent name" and so, not only the normal arguments which is in [Function\_Reference/the\_author\_meta](http://codex.wordpress.org/Function_Reference/the_author_meta)
I tried php `fu... | I think you are confusing function arguments with author (user) meta fields. To get all user meta fields you can use [`get_user_meta()`](http://codex.wordpress.org/Function_Reference/get_user_meta) with empty `$key` parameter. For example, for user with ID 45:
```
$user_meta = get_user_meta( 45 );
```
`$user_meta` w... |