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 |
|---|---|---|---|---|---|---|
99,414 | <p>One of the examples using <code>add_rewrite_rule</code> function in wordpress is</p>
<pre><code>add_rewrite_rule('^nutrition/([^/]*)/([^/]*)/?','index.php?page_id=12&food=$matches[1]&variety=$matches[2]','top');
</code></pre>
<p>I can understand where matches[1] is and where matches[2] is, but is there any... | [
{
"answer_id": 100875,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The function arguments are computed at the time of function call, so when rewrite rule is being registered rather t... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99414",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23653/"
] | One of the examples using `add_rewrite_rule` function in wordpress is
```
add_rewrite_rule('^nutrition/([^/]*)/([^/]*)/?','index.php?page_id=12&food=$matches[1]&variety=$matches[2]','top');
```
I can understand where matches[1] is and where matches[2] is, but is there any way to change these matches, something like:... | Rewrite rules don't call functions like you're asking. WordPress is far more flexible than that, because you might want to run your code at any one of an unlimited set of points in the processing of the page and not be restricted to that *one specific moment* in the code when the rewrite rule is processed.
Taking it b... |
99,415 | <p>In a site that uses Bones theme, I am trying to localize the search results page and would like to replace the "read more" text with something else. I tried editing the search.php but it is useless as the search.php <a href="https://wordpress.stackexchange.com/questions/99409/why-does-bones-theme-call-the-excerpt-fu... | [
{
"answer_id": 99416,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Filter <code>'the_excerpt'</code> on the search page only:</p>\n\n<pre><code>add_filter( 'the_excerpt', 'wpse_99415_se... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32821/"
] | In a site that uses Bones theme, I am trying to localize the search results page and would like to replace the "read more" text with something else. I tried editing the search.php but it is useless as the search.php [seems to have a bug](https://wordpress.stackexchange.com/questions/99409/why-does-bones-theme-call-the-... | Filter `'the_excerpt'` on the search page only:
```
add_filter( 'the_excerpt', 'wpse_99415_search_excerpt' );
function wpse_99415_search_excerpt( $excerpt )
{
if ( ! is_search() )
return $excerpt;
global $post;
// create a custom excerpt
return $custom_excerpt;
}
``` |
99,431 | <p>I hav been having some difficulties getting authorship set up for a multi-author blog. Everything appears to be set up correctly, but I am wondering if having multiple rel="author" tags on the home page is preventing the Google+ Profile of the main author from appearing in search results.</p>
<p>By default, the wo... | [
{
"answer_id": 99510,
"author": "Jash Jacob",
"author_id": 32738,
"author_profile": "https://wordpress.stackexchange.com/users/32738",
"pm_score": 2,
"selected": false,
"text": "<p>I think it might take some time for the google to update this information to the search index.</p>\n\n<p>As... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99431",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I hav been having some difficulties getting authorship set up for a multi-author blog. Everything appears to be set up correctly, but I am wondering if having multiple rel="author" tags on the home page is preventing the Google+ Profile of the main author from appearing in search results.
By default, the wordpress the... | I think it might take some time for the google to update this information to the search index.
As far i've seen the older posts on my blog (multi user) show the author information in a google search. The latest posts don't really get updated with that information.
**A post from Feb 2013**
![enter image description h... |
99,444 | <p>So I have the following in an include in my theme file:</p>
<pre><code>include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
$shop_id = woocommerce_get_page_id( 'shop' );
$shop_page = get_page( $shop_id );
}
</code></pre>
<p>but <c... | [
{
"answer_id": 99445,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 6,
"selected": true,
"text": "<p><code>is_plugin_active()</code> expects just the base name of the plugin as parameter:</p>\n\n<p>So use:</p>\n\n<pre><c... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2527/"
] | So I have the following in an include in my theme file:
```
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
$shop_id = woocommerce_get_page_id( 'shop' );
$shop_page = get_page( $shop_id );
}
```
but `is_plugin_active( WP_PLUGIN... | `is_plugin_active()` expects just the base name of the plugin as parameter:
So use:
```
is_plugin_active( 'woocommerce/woocommerce.php' );
```
The function will use the option `'active_plugins'` which is a list of plugins paths relative to the plugin directory already.
On a multi-site installation it will search i... |
99,459 | <p>Is it possible to set the position of an item in the admin menu? I'm trying to move the media link under my custom post types. I know that the media link is position 10. Is it possible to set it to 14?</p>
<p>I know that I can change the position of all the links using the <code>custom_menu_order</code> filter but ... | [
{
"answer_id": 99480,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": true,
"text": "<p><sup><em>This is not an exact answer, but I think there are enough elements to build the desired output.</em>... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2832/"
] | Is it possible to set the position of an item in the admin menu? I'm trying to move the media link under my custom post types. I know that the media link is position 10. Is it possible to set it to 14?
I know that I can change the position of all the links using the `custom_menu_order` filter but I'm not seeing a way ... | *This is not an exact answer, but I think there are enough elements to build the desired output.*
I sort the menu manipulating the global `$menu`, not really best practice, but for now it works.
The result of this example is moving Links Manager, Comments and Media Library to the end of the first block. The effect is... |
99,460 | <p>I explain my problem:</p>
<ol>
<li>I create a post with an image</li>
<li>get_children - wp_get_attachment_image functions returns that image</li>
<li>I delete post image and add a different one</li>
<li>get_children - wp_get_attachment_image functions returns the two images (although the image that has been remove... | [
{
"answer_id": 99480,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": true,
"text": "<p><sup><em>This is not an exact answer, but I think there are enough elements to build the desired output.</em>... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99460",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32837/"
] | I explain my problem:
1. I create a post with an image
2. get\_children - wp\_get\_attachment\_image functions returns that image
3. I delete post image and add a different one
4. get\_children - wp\_get\_attachment\_image functions returns the two images (although the image that has been removed and is no longer in t... | *This is not an exact answer, but I think there are enough elements to build the desired output.*
I sort the menu manipulating the global `$menu`, not really best practice, but for now it works.
The result of this example is moving Links Manager, Comments and Media Library to the end of the first block. The effect is... |
99,466 | <p>How could I add a style sheet at the bottom of the <code><head></code> tag, so if there´s a need to override some other styles added before, it will override.</p>
<p>I heard something about wp_enqueue_style, and it seems there´s a depth parameter.
Is that what I need? To make my style sheet be the last one a... | [
{
"answer_id": 99468,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>From the source, reformatted for better readability:</p>\n\n<pre><code>function wp_enqueue_style( \n $handle, // un... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30777/"
] | How could I add a style sheet at the bottom of the `<head>` tag, so if there´s a need to override some other styles added before, it will override.
I heard something about wp\_enqueue\_style, and it seems there´s a depth parameter.
Is that what I need? To make my style sheet be the last one at the `<head>` tag?
If y... | You can add a priority number to the wp\_enqueue\_scripts action. So you could could give the action hooked to the enqueue of yourstyle sheet a priority of 999. Like so:
```
function high_priority_style() {
Wp_enqueue_style('important', get_template_directory_uri() . '/css/important.css');
}
add_action('wp_enqueue_s... |
99,472 | <p>I am wondering if it is possible to export theme customizer settings(theme_mods) to be imported into another install of the same theme. I know that the settings are saved into the database so I am wondering if there is a plugin or tool to create a XML file for import like many themes have for settings.</p>
| [
{
"answer_id": 133828,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": false,
"text": "<p>Theme mod settings are stored as a single database entry in the options table.</p>\n\n<p>For example, If I look in... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99472",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | I am wondering if it is possible to export theme customizer settings(theme\_mods) to be imported into another install of the same theme. I know that the settings are saved into the database so I am wondering if there is a plugin or tool to create a XML file for import like many themes have for settings. | Theme mod settings are stored as a single database entry in the options table.
For example, If I look in my `wp_options` table in a localhost install, and find the key of `theme_mods_twentythirteen`, then this is the content of it:
```
a:3:{s:16:"header_textcolor";s:6:"220e10";s:12:"header_image";s:84:"http://localh... |
99,489 | <p>I'd like to protect the /wp-admin/ directory at the server level. This means two logins. One through the server and another through WordPress.</p>
<p>I believe this can be handled through .htaccess. Does anyone know how?</p>
<p>Also, are there any files that will need access (i.e., admin-ajax.php)?</p>
| [
{
"answer_id": 99507,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Basically, it should look like this:</p>\n\n<pre><code>AuthType Basic\nAuthName NAME_THIS_THING\nAuthUserFile ... | 2013/05/14 | [
"https://wordpress.stackexchange.com/questions/99489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22989/"
] | I'd like to protect the /wp-admin/ directory at the server level. This means two logins. One through the server and another through WordPress.
I believe this can be handled through .htaccess. Does anyone know how?
Also, are there any files that will need access (i.e., admin-ajax.php)? | Basically, it should look like this:
```
AuthType Basic
AuthName NAME_THIS_THING
AuthUserFile PATH_TO_USER_FILE
<Files '*'>
Require valid-user
</Files>
<Files 'admin-ajax.php'>
Allow from all
Satisfy any
</Files>
```
Replace the upper case parts with something real. `admin-ajax.php` is the only f... |
99,513 | <p>Like WP <code>get_adjacent_post</code> function gives the next and previous post data based on the parameters i want to get the next/previous category data is there any <code>WP</code> built in function which does the right job or i have to write a custom query for that.</p>
<pre><code>// Next/previous post example... | [
{
"answer_id": 99523,
"author": "Core",
"author_id": 27917,
"author_profile": "https://wordpress.stackexchange.com/users/27917",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure about bulit-in functions in WordPress but you can</p>\n\n<p>Get Next and Previous Pages and than th... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20920/"
] | Like WP `get_adjacent_post` function gives the next and previous post data based on the parameters i want to get the next/previous category data is there any `WP` built in function which does the right job or i have to write a custom query for that.
```
// Next/previous post example
$in_same_cat = false;
$excluded_cat... | This is what i came up with a custom query solution hope it help others i wrote a custom function for this it works for all post type categories (post,custom post types)
```
function get_adjacent_category($category_slug,$taxonomy,$type){
global $wpdb;
if($type=="next"){
$operater=" > ";
$orderb... |
99,518 | <p>I am customizing the admin panel of WordPress. I have users with roles to only write to 3 categories. I would like to design 3 buttons or divs to create a new post but each one for a different category. That in the dashboard.</p>
<p>I will have a different dashboard for role user</p>
<p>Any idea?</p>
<p><img src=... | [
{
"answer_id": 99523,
"author": "Core",
"author_id": 27917,
"author_profile": "https://wordpress.stackexchange.com/users/27917",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure about bulit-in functions in WordPress but you can</p>\n\n<p>Get Next and Previous Pages and than th... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99518",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32857/"
] | I am customizing the admin panel of WordPress. I have users with roles to only write to 3 categories. I would like to design 3 buttons or divs to create a new post but each one for a different category. That in the dashboard.
I will have a different dashboard for role user
Any idea?

```
function get_adjacent_category($category_slug,$taxonomy,$type){
global $wpdb;
if($type=="next"){
$operater=" > ";
$orderb... |
99,519 | <p>I have author pages for each author and I want to see all of their comments (or all of their recent comments) if I click on their nickname. How can I do this? I tried the beneath code, but that does not show the unique comments per user... It just outputs all recent comments from everyone combined, but I don't want ... | [
{
"answer_id": 99522,
"author": "Core",
"author_id": 27917,
"author_profile": "https://wordpress.stackexchange.com/users/27917",
"pm_score": 0,
"selected": false,
"text": "<p>Check This <a href=\"http://codebing.com/show-comments-by-user-id-in-wordpress/\" rel=\"nofollow\">Show Com... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99519",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | I have author pages for each author and I want to see all of their comments (or all of their recent comments) if I click on their nickname. How can I do this? I tried the beneath code, but that does not show the unique comments per user... It just outputs all recent comments from everyone combined, but I don't want tha... | your problem is using `author_email`, you need [`user_id`](http://codex.wordpress.org/Function_Reference/get_comments#Parameters):
i just use similar script.
```
<?php
$args = array(
'user_id' => get_the_author_meta('ID'),
'number' => 10, // how many comments to retrieve
'status' => 'appro... |
99,532 | <p>I’m using the plugin <a href="http://wordpress.org/extend/plugins/user-groups/" rel="nofollow noreferrer">User Groups</a> which lets me group users with categories. The plugin is working essentially the same as using the manual method (custom user taxonomies) described by <a href="http://justintadlock.com/archives/2... | [
{
"answer_id": 99693,
"author": "talven",
"author_id": 32862,
"author_profile": "https://wordpress.stackexchange.com/users/32862",
"pm_score": 0,
"selected": false,
"text": "<p>Ok, problem solved. I ditched the plugin and got another one called <a href=\"http://wordpress.org/extend/plugi... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32862/"
] | I’m using the plugin [User Groups](http://wordpress.org/extend/plugins/user-groups/) which lets me group users with categories. The plugin is working essentially the same as using the manual method (custom user taxonomies) described by [Justin Tadlock here](http://justintadlock.com/archives/2011/10/20/custom-user-taxon... | Try this suggestion:
```
$user_id = get_current_user_id(); // Get current user Id
$user_groups = wp_get_object_terms($user_id, 'user-group', array('fields' => 'all_with_object_id')); // Get user group detail
foreach($user_groups as $user_gro)
{
echo $user_gro->name; // Get current user group name
echo $user_... |
99,534 | <p>In my loop, I'm trying to set it so that certain text is displayed on certain pages, if there are no posts to display.</p>
<p>I thought this would be simple, using <code>is_post()</code>, but it seems that this function does not work when you are in The Loop.</p>
<p>Does any body know how I can identify the page t... | [
{
"answer_id": 99537,
"author": "Subharanjan",
"author_id": 13615,
"author_profile": "https://wordpress.stackexchange.com/users/13615",
"pm_score": -1,
"selected": false,
"text": "<p>Try <code>is_single( $page_id )</code> instead. Basically is_post() has been deprecated.</p>\n\n<p><a hre... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99534",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10097/"
] | In my loop, I'm trying to set it so that certain text is displayed on certain pages, if there are no posts to display.
I thought this would be simple, using `is_post()`, but it seems that this function does not work when you are in The Loop.
Does any body know how I can identify the page that is currently being shown... | I believe you want [`get_queried_object`](http://codex.wordpress.org/Function_Reference/get_queried_object). That will return information about the page *per se* and not necessarily about the posts/pages being displayed in the Loop.
Be aware that it returns very different information depending on the type of page you... |
99,538 | <p>I registered a custom post type using Custom Post Type UI, and created an archive page and named it archive-recipe.php, 'recipe' is my custom post type name. But its not working, instead its using the default <code>archive.php</code>. I set the <code>has-archive</code> to <code>true</code> but still not working. How... | [
{
"answer_id": 99547,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 5,
"selected": true,
"text": "<p>Given the standard registration, you should have the following:</p>\n<ul>\n<li>A post type with the name 'reci... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99538",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9583/"
] | I registered a custom post type using Custom Post Type UI, and created an archive page and named it archive-recipe.php, 'recipe' is my custom post type name. But its not working, instead its using the default `archive.php`. I set the `has-archive` to `true` but still not working. How to fix that?
Here's the code:
```... | Given the standard registration, you should have the following:
* A post type with the name 'recipe'
* A recipe post archive at example.com/recipe/
* Recipe posts with urls that take the form example.com/recipe/helloworldrecipe/
* A template `archive-recipe.php`
* A template `single-recipe.php`
However, I see this in... |
99,540 | <p>I am using Dzonia Lite theme in my website. When I try to remove the cufon script from my functions.php file the sliders that were present in the website are not working.</p>
<p>Colud anyone suggest me how to overcome this issue?</p>
<h1>scripts in my functions.php</h1>
<pre><code>function inkthemes_wp_enqueue_scrip... | [
{
"answer_id": 99542,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>You can remove scripts with <a href=\"https://codex.wordpress.org/Function_Reference/wp_dequeue_script\" rel=\"n... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23712/"
] | I am using Dzonia Lite theme in my website. When I try to remove the cufon script from my functions.php file the sliders that were present in the website are not working.
Colud anyone suggest me how to overcome this issue?
scripts in my functions.php
===========================
```
function inkthemes_wp_enqueue_scri... | You can remove scripts with [`wp_dequeue_script()`](https://codex.wordpress.org/Function_Reference/wp_dequeue_script):
```
function wpse99450_remove_cufon() {
wp_dequeue_script( 'inktheme-confu-ui' );
// inktheme-confu-ui is the script's handle, according to your posted code
}
add_action( 'wp_enqueue_scripts',... |
99,549 | <p>I am trying to create a widget that displays posts in the sidebar taking post IDs as input from the user.</p>
<p>The result of my code is that the widget displays just the first entered ID and ignores the others.</p>
<p>Example: if my input in the widget is 1236, 1234, 1235 the widget frontend will display just th... | [
{
"answer_id": 99564,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>If <code>$instance['postsToShow']</code> is a comma-separated string of IDs, then <code>array($instance['postsToSho... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99549",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31679/"
] | I am trying to create a widget that displays posts in the sidebar taking post IDs as input from the user.
The result of my code is that the widget displays just the first entered ID and ignores the others.
Example: if my input in the widget is 1236, 1234, 1235 the widget frontend will display just the post with id 12... | Try to replace
```
'post__in' => array($instance['postsToShow']),
```
with
```
'post__in' => explode(",", $instance['postsToShow']),
```
to feed the `post__in` with an array.
Your current array looks like
```
array("123,456,789")
```
but should be like
```
array("123", "456", "789")
``` |
99,563 | <p>I want to put a couple of quicktags/buttons on a textarea which is outputted by a plugin called <strong>user submitted posts</strong>. I have given this textarea an unique id and read this on the Quicktags documentation:</p>
<blockquote>
<ul>
<li>Run quicktags(settings) to initialize it, where settings is an ob... | [
{
"answer_id": 100171,
"author": "user1627363",
"author_id": 32731,
"author_profile": "https://wordpress.stackexchange.com/users/32731",
"pm_score": 1,
"selected": true,
"text": "<p>There is no possibility to make it work with a different plugin. Solution: use Javascript like <a href=\"h... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | I want to put a couple of quicktags/buttons on a textarea which is outputted by a plugin called **user submitted posts**. I have given this textarea an unique id and read this on the Quicktags documentation:
>
> * Run quicktags(settings) to initialize it, where settings is an object containing up to 3 properties:
> *... | There is no possibility to make it work with a different plugin. Solution: use Javascript like [**here**](https://stackoverflow.com/questions/15272451/make-tags-from-text-and-textarea-fields-content-with-javascript) |
99,584 | <p>i'm working on a website that is built on WordPress & the Genesis Framework. I'm looking to display an RSS feed <a href="http://assets3.feedstitch.com/12689/traffic-safety-news" rel="nofollow">From Feedstich</a> within WordPress pages in the middle of the content. What is my best bet of doing this, is there a pl... | [
{
"answer_id": 99592,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>You could use a wrapper for <code>fetch_feed()</code> as a simple shortcode.</p>\n\n<p>Very basic example; see the RSS ... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99584",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30778/"
] | i'm working on a website that is built on WordPress & the Genesis Framework. I'm looking to display an RSS feed [From Feedstich](http://assets3.feedstitch.com/12689/traffic-safety-news) within WordPress pages in the middle of the content. What is my best bet of doing this, is there a plugin that can use shortcodes or i... | You could use a wrapper for `fetch_feed()` as a simple shortcode.
Very basic example; see the RSS widget code for more options.
```
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Feed Shortcode
* Description: Use <code>[feed url="http://wordpress.stackexchange.com/feeds"]</code> to display a list of feed items... |
99,585 | <p>I'm looking to display a standard wordpress widget only on posts that are over X amount of characters in length (or another method that can roughly calculate the height of of a post.)</p>
<p>I am looking to include some additional advertising in the sidebar of my sites posts that are very long and thus have empty s... | [
{
"answer_id": 99588,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use the <a href=\"https://wordpress.stackexchange.com/a/54650/73\">function <code>t5_word_count()</code> from this ans... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25635/"
] | I'm looking to display a standard wordpress widget only on posts that are over X amount of characters in length (or another method that can roughly calculate the height of of a post.)
I am looking to include some additional advertising in the sidebar of my sites posts that are very long and thus have empty sidebar spa... | Use the [function `t5_word_count()` from this answer](https://wordpress.stackexchange.com/a/54650/73) and extend the method `widget()` in your widget class:
```
public function widget( $args, $instance )
{
if ( ! is_singular() )
return;
$content = get_the_content( '', TRUE );
$words = t5_word_co... |
99,587 | <p>I have a photoblog displaying posts as image galleries having width 500px and some posts as single image of width 900px. For posts with 900px width images, I made <code>category HQ</code>.</p>
<p>Posts with 500px width image galleries display fine. But those posts having single image doesn't display image of width ... | [
{
"answer_id": 99588,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use the <a href=\"https://wordpress.stackexchange.com/a/54650/73\">function <code>t5_word_count()</code> from this ans... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23717/"
] | I have a photoblog displaying posts as image galleries having width 500px and some posts as single image of width 900px. For posts with 900px width images, I made `category HQ`.
Posts with 500px width image galleries display fine. But those posts having single image doesn't display image of width 900px width instead 5... | Use the [function `t5_word_count()` from this answer](https://wordpress.stackexchange.com/a/54650/73) and extend the method `widget()` in your widget class:
```
public function widget( $args, $instance )
{
if ( ! is_singular() )
return;
$content = get_the_content( '', TRUE );
$words = t5_word_co... |
99,593 | <p>I'm aware that WordPress has <a href="http://codex.wordpress.org/Embeds" rel="nofollow">oEmbed functionality</a>. But the content to be embedded has to be on it's own line like so:</p>
<pre><code>Lorem Ipsum
http://www.youtube.com/link/to/content
More Lorem Ipsum
</code></pre>
<p>Unfortunately, my markup looks l... | [
{
"answer_id": 99607,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>There is bit of special filtering by <code>WP_Embed</code> class that turns standalone links into target for embeddi... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19620/"
] | I'm aware that WordPress has [oEmbed functionality](http://codex.wordpress.org/Embeds). But the content to be embedded has to be on it's own line like so:
```
Lorem Ipsum
http://www.youtube.com/link/to/content
More Lorem Ipsum
```
Unfortunately, my markup looks like this so oEmbed doesn't work and I have to use a ... | Just use the `[embed]` shortcode around your items.
```
<ul>
<li>[embed]http://www.youtube.com/link/to/content[/embed]</li>
...
``` |
99,602 | <p>Today I tried to access the admin panel for a basic Wordpress site. It has no plugins, and uses the default theme. I haven't modified any files. Any admin url returns an HTTP 406 "Not Acceptable". What's going on?</p>
| [
{
"answer_id": 99608,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 1,
"selected": false,
"text": "<p>I found this which might solve your problem:</p>\n\n<pre><code><IfModule mod_security.c>\nSecFilterEngine O... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99602",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7091/"
] | Today I tried to access the admin panel for a basic Wordpress site. It has no plugins, and uses the default theme. I haven't modified any files. Any admin url returns an HTTP 406 "Not Acceptable". What's going on? | I found this which might solve your problem:
```
<IfModule mod_security.c>
SecFilterEngine Off
</IfModule>
```
This code goes in a file called `.htaccess` and must be uploaded in `/wp-admin` directory. This will disable `mod_security` which is a module in Apache2 activated by default but it can be problematic.
**ED... |
99,609 | <p>I've looked and looked, I've read the codex, and tired several things to change this but nothing has worked. I don't know how to indicate what text to use for the Tag</p>
<p>I have a theme that is using some custom code for displaying a single post on the blog page. The theme options allow you to show full content... | [
{
"answer_id": 99611,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>Most of the time to change it your have to hook into <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Refer... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99609",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20553/"
] | I've looked and looked, I've read the codex, and tired several things to change this but nothing has worked. I don't know how to indicate what text to use for the Tag
I have a theme that is using some custom code for displaying a single post on the blog page. The theme options allow you to show full content or excerpt... | It's the first parameter to `the_content()`.
```
the_content('Read some more of this post');
```
<http://codex.wordpress.org/Function_Reference/the_content> |
99,617 | <p>The default search returns all post types, which is what I want. But for one specific custom post type I want to limit the result to a specific meta key value (a custom date that must be greater than today).</p>
<p>Using the pre_get_posts hook and setting the meta_query does get me the correct result for that post ... | [
{
"answer_id": 99619,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You can limit your query even further...</p>\n\n<pre><code>if (\n !is_admin() \n && $query->is_s... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32888/"
] | The default search returns all post types, which is what I want. But for one specific custom post type I want to limit the result to a specific meta key value (a custom date that must be greater than today).
Using the pre\_get\_posts hook and setting the meta\_query does get me the correct result for that post type, b... | This might not have worked before, but WordPress's meta queries now support the relation parameter. To complete what @s\_ha\_dum was looking to do, simply add the relation parameter (as OR) and add a second meta query for NOT EXISTS. Example:
```
function searchExcludeOldMatches( $query ) {
//if we're on the admin... |
99,621 | <p>I am wondering if anyone could help me accomplish something like this: <a href="https://medium.com/thoughts-and-words/5ccef7b3e1fc" rel="nofollow">https://medium.com/thoughts-and-words/5ccef7b3e1fc</a> with custom post types? </p>
<p>I have a custom post type called projects and custom taxonomy called project-cate... | [
{
"answer_id": 99750,
"author": "Curtis Flick",
"author_id": 32259,
"author_profile": "https://wordpress.stackexchange.com/users/32259",
"pm_score": 0,
"selected": false,
"text": "<p>Thanks to @Bash for getting me started, I've come up with a decent solution that's working well so far.</... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99621",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32259/"
] | I am wondering if anyone could help me accomplish something like this: <https://medium.com/thoughts-and-words/5ccef7b3e1fc> with custom post types?
I have a custom post type called projects and custom taxonomy called project-category. I would like to show the next 3 projects in the same project-category on the single... | From what I gather all you need to do is query the 3 posts and step though each one using **[the\_post()](http://codex.wordpress.org/Function_Reference/the_post)**. I have not used it like this so not 100% that is how it works.
>
> **the\_post()** Retrieves the next post, sets up the post, sets the 'in the loop' pro... |
99,625 | <p>I apologize as I realize this has been asked before and I believe the issue is with <code>wpautop</code> function adding closing p or br tags but every solution I've found has not worked so I'm at a loss for fixing the issue.</p>
<p>I'm doing:</p>
<pre><code>class my_plugin {
public static function init() {
... | [
{
"answer_id": 99645,
"author": "mindctrl",
"author_id": 28003,
"author_profile": "https://wordpress.stackexchange.com/users/28003",
"pm_score": 0,
"selected": false,
"text": "<p>Without seeing all the code it's hard to say. </p>\n\n<p>I have seen an issue a few times where certain line ... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99625",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23259/"
] | I apologize as I realize this has been asked before and I believe the issue is with `wpautop` function adding closing p or br tags but every solution I've found has not worked so I'm at a loss for fixing the issue.
I'm doing:
```
class my_plugin {
public static function init() {
remove_filter('the_content', 'w... | Not sure if this will be helpful to anyone else but the cause of the issue was a custom formatter the theme had:
```
function my_formatter($content) {
$new_content = '';
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
$pieces = preg_split($pat... |
99,631 | <p>I am trying to find a way to disable the twenty twelve stylesheet for anything in IE 8 or less. Is there a conditional code that I can put in my functions php file that will enable the default twentytwelve style sheet (and it's child themes child sheet) to be ignored in these particular browsers?</p>
<p>I want to s... | [
{
"answer_id": 99635,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_deregister_script\" rel=\"nofollow\">Deregister</a... | 2013/05/15 | [
"https://wordpress.stackexchange.com/questions/99631",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32893/"
] | I am trying to find a way to disable the twenty twelve stylesheet for anything in IE 8 or less. Is there a conditional code that I can put in my functions php file that will enable the default twentytwelve style sheet (and it's child themes child sheet) to be ignored in these particular browsers?
I want to start my IE... | [Deregister](http://codex.wordpress.org/Function_Reference/wp_deregister_script) `twentytwelve-ie`, which is registered (currently) in [`function.php` on line 157](http://core.trac.wordpress.org/browser/trunk/wp-content/themes/twentytwelve/functions.php#L157).
```
function dereg_ie_styles_wpse_99631() {
wp_deregiste... |
99,652 | <p>I have been attempting to create a theme reset button for the theme customizer that automatically removes all of the theme_mod settings. I have tried multiple ways to do this and have never been able to get it to work. <a href="https://wordpress.stackexchange.com/questions/97283/problem-with-function-not-executing">... | [
{
"answer_id": 99656,
"author": "Core",
"author_id": 27917,
"author_profile": "https://wordpress.stackexchange.com/users/27917",
"pm_score": 0,
"selected": false,
"text": "<p>So in your theme setting page do something like this:</p>\n\n<pre><code>if( isset( $_REQUEST['resetl_all'] ) ){\n... | 2013/05/16 | [
"https://wordpress.stackexchange.com/questions/99652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | I have been attempting to create a theme reset button for the theme customizer that automatically removes all of the theme\_mod settings. I have tried multiple ways to do this and have never been able to get it to work. [As seen here.](https://wordpress.stackexchange.com/questions/97283/problem-with-function-not-execu... | There is a function called [`remove_theme_mods`](https://codex.wordpress.org/Function_Reference/remove_theme_mods) that will kill all theme mods. Beware, however, that this will not only remove the mods that you have defined in your theme using the [customizer API](https://codex.wordpress.org/Theme_Customization_API). ... |
99,672 | <p>I want to hide the WordPress post from archives page using the 'private' option. I only want the post to be hidden from archives but visible to public. How to I do it?</p>
| [
{
"answer_id": 99677,
"author": "Fernando Silva",
"author_id": 32843,
"author_profile": "https://wordpress.stackexchange.com/users/32843",
"pm_score": -1,
"selected": false,
"text": "<p>I think the easiest way would be to control the loop in the <code>archive.php</code> file, IF it's jus... | 2013/05/16 | [
"https://wordpress.stackexchange.com/questions/99672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32907/"
] | I want to hide the WordPress post from archives page using the 'private' option. I only want the post to be hidden from archives but visible to public. How to I do it? | You'll want to filter the main query via `pre_get_posts` callback.
If you'll only want to handle one specific post in this manner, you can reference/exclude its post ID directly. If, however, you want this same behavior for any future private posts, then I would query all posts with `$post->post_status` of `private`, ... |
99,699 | <p>I have this snippet in a "portfolio-loop.php" file. I'm using get_template_part to display the loop on the front page and on other pages.</p>
<p>I have this within the loop:</p>
<pre><code><?php if( !is_home() || !is_front_page() ) { ?>
<p><?php the_time('F Y'); ?></p>
<?php endif } ?&... | [
{
"answer_id": 99702,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p>Let's see if I can confuse myself. </p>\n\n<p>If <em>either</em> of your two <code>OR</code> conditions is <c... | 2013/05/16 | [
"https://wordpress.stackexchange.com/questions/99699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32920/"
] | I have this snippet in a "portfolio-loop.php" file. I'm using get\_template\_part to display the loop on the front page and on other pages.
I have this within the loop:
```
<?php if( !is_home() || !is_front_page() ) { ?>
<p><?php the_time('F Y'); ?></p>
<?php endif } ?>
```
I can't seem to get it to exclude the f... | Let's see if I can confuse myself.
If *either* of your two `OR` conditions is `true` the code executes.
[`is_home`](http://codex.wordpress.org/Function_Reference/is_home) and `is_front_page` can return `true` for different pages, negated in your case. If you have a static from page, which it sounds like you do, the... |
99,710 | <p>On the Post edit page in the back-end, how do I echo the author's <code>user_nicename</code>? I am referring to the author of the post, not current user. </p>
| [
{
"answer_id": 99714,
"author": "Christine Cooper",
"author_id": 24875,
"author_profile": "https://wordpress.stackexchange.com/users/24875",
"pm_score": 3,
"selected": true,
"text": "<p>Found it:</p>\n\n<pre><code>global $post;\n$author_id=$post->post_author;\nthe_author_meta('user_ni... | 2013/05/16 | [
"https://wordpress.stackexchange.com/questions/99710",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | On the Post edit page in the back-end, how do I echo the author's `user_nicename`? I am referring to the author of the post, not current user. | Found it:
```
global $post;
$author_id=$post->post_author;
the_author_meta('user_nicename', $author_id );
``` |
99,748 | <p>I have created a new page with a jquery carousel which rotates between various different news topics. You can see <a href="http://www.touringcars.net/test1.php" rel="nofollow">here</a>:</p>
<p>However below the carousel is a static list of additional headlines. What I need to do is find php code that says IF a stor... | [
{
"answer_id": 99754,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Track the IDs, and "exclude" them with <code>post__not_in</code>. It is hard to tell exactly what d... | 2013/05/16 | [
"https://wordpress.stackexchange.com/questions/99748",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32941/"
] | I have created a new page with a jquery carousel which rotates between various different news topics. You can see [here](http://www.touringcars.net/test1.php):
However below the carousel is a static list of additional headlines. What I need to do is find php code that says IF a story appears in the carousel, THEN excl... | Track the IDs, and "exclude" them with `post__not_in`. It is hard to tell exactly what does what with the disjointed way you posted your code but the general case solution is ..
```
$c_posts = new WP_Query("showposts=10");
$tracker = array();
if ($c_posts->have_posts()) {
while ($c_posts->have_posts()) {
$c_posts... |
99,773 | <p>I need to update all meta keys in the postmeta table that have a value other than 0, to the value of 0.</p>
<p>I tried this.. no love (though I cannot figure out why....):</p>
<pre><code>$status = $wpdb->query("UPDATE {$wpdb->prefix}postmeta SET meta_value=0 WHERE meta_key = _wti_like_count AND meta_value &l... | [
{
"answer_id": 99774,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 0,
"selected": false,
"text": "<p>It does not look like it is possible to use != in the where. Here is the relevant code from the <code... | 2013/05/17 | [
"https://wordpress.stackexchange.com/questions/99773",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32951/"
] | I need to update all meta keys in the postmeta table that have a value other than 0, to the value of 0.
I tried this.. no love (though I cannot figure out why....):
```
$status = $wpdb->query("UPDATE {$wpdb->prefix}postmeta SET meta_value=0 WHERE meta_key = _wti_like_count AND meta_value <> '0'");
```
I'm on this c... | The `$wpdb` class properties
----------------------------
You can use *all* the default WordPress tables like this:
* `$GLOBALS['wpdb']->postmeta`
so no need to use `prefix`, etc.
`meta_query`
------------
As you can see from the [Custom field parameter](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_F... |
99,783 | <p>I want to get categories that had NO post.
Below is sql for getting category with post..</p>
<pre><code>SELECT terms.term_id,terms.name,COUNT(post.ID) FROM wp_posts as post
JOIN wp_term_relationships as rel ON post.ID = rel.object_ID
JOIN wp_term_taxonomy as ttax ON rel.term_taxonomy_id = ttax.term_taxonomy_id
JO... | [
{
"answer_id": 99790,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>You can try this to get empty categories:</p>\n\n<pre><code>$args = array( 'hide_empty' => 1, 'hierarchical... | 2013/05/17 | [
"https://wordpress.stackexchange.com/questions/99783",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23293/"
] | I want to get categories that had NO post.
Below is sql for getting category with post..
```
SELECT terms.term_id,terms.name,COUNT(post.ID) FROM wp_posts as post
JOIN wp_term_relationships as rel ON post.ID = rel.object_ID
JOIN wp_term_taxonomy as ttax ON rel.term_taxonomy_id = ttax.term_taxonomy_id
JOIN wp_terms as... | **Here is how you can list the empty cat's**
this way can also refrence each category data like ID, Name etc
```
$args = array(
'hide_empty' => 0,
'pad_counts' => true
);
$categories = get_categories( $args );
foreach($categories as $category) {
if($category->count == 0) {
echo $category->name.... |
99,788 | <p>I have a Wordpress theme bought from a well known site. I'm trying to change the location of the main site logo to where the page/post titles appear.</p>
<p>The page.php for the title is as follows;</p>
<p>How would I add an image to this?</p>
<pre><code><div class="clear headtop" style="height: auto;">
... | [
{
"answer_id": 99789,
"author": "Jared Cobb",
"author_id": 6737,
"author_profile": "https://wordpress.stackexchange.com/users/6737",
"pm_score": 3,
"selected": true,
"text": "<p>I would actually handle this with CSS. In your <code>style.css</code> file add something like this:</p>\n\n<p... | 2013/05/16 | [
"https://wordpress.stackexchange.com/questions/99788",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33245/"
] | I have a Wordpress theme bought from a well known site. I'm trying to change the location of the main site logo to where the page/post titles appear.
The page.php for the title is as follows;
How would I add an image to this?
```
<div class="clear headtop" style="height: auto;">
<div class="page-title" style="wi... | I would actually handle this with CSS. In your `style.css` file add something like this:
```
.page-title h1 {
text-indent: -9999px;
background: url(images/your_logo.png) 10px 10px no-repeat;
height: 100%;
}
```
You'll then make sure that your logo is added to your theme's `images` folder. Also, adjust th... |
99,792 | <p>I have created a custom widget that is supposed to display a select menu with all the categories the blog has. I have used get_categories to compile the list. This works fine and all categories appear in a drop down menu. Each time I save and refresh the widget page, the custom widget is not there anymore. I checked... | [
{
"answer_id": 100315,
"author": "kathrineh",
"author_id": 18937,
"author_profile": "https://wordpress.stackexchange.com/users/18937",
"pm_score": 4,
"selected": true,
"text": "<p>Ok I found a solution thanks to this: <a href=\"https://wordpress.stackexchange.com/questions/73956/using-wp... | 2013/05/17 | [
"https://wordpress.stackexchange.com/questions/99792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18937/"
] | I have created a custom widget that is supposed to display a select menu with all the categories the blog has. I have used get\_categories to compile the list. This works fine and all categories appear in a drop down menu. Each time I save and refresh the widget page, the custom widget is not there anymore. I checked `... | Ok I found a solution thanks to this: [Using wp\_dropdown\_categories in widget options](https://wordpress.stackexchange.com/questions/73956/using-wp-dropdown-categories-in-widget-options)
Here is the code I used instead:
```
function form( $instance ) {
/* Default Widget Settings */
$defaults = array(
... |
99,826 | <p>I can't add the title on a featured image in the recent posts.</p>
<p>try this but only get the alt</p>
<pre><code><?php
$default_attr = array(
'src' => $src,
'class' => "attachment-$size",
'alt' => trim(strip_tags( $attachment->post_excerpt )),
'title' => trim(stri... | [
{
"answer_id": 99829,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>To solve you problem</p>\n\n<pre><code><?php \n$pages = wp_get_recent_posts(); \n?>\n&l... | 2013/05/17 | [
"https://wordpress.stackexchange.com/questions/99826",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32879/"
] | I can't add the title on a featured image in the recent posts.
try this but only get the alt
```
<?php
$default_attr = array(
'src' => $src,
'class' => "attachment-$size",
'alt' => trim(strip_tags( $attachment->post_excerpt )),
'title' => trim(strip_tags( $attachment->post_title )),
);
... | Sorry, but I don't see any of those parameters in the parameter list for [`wp_get_recent_posts`](http://codex.wordpress.org/Function_Reference/wp_get_recent_posts).
```
$args = array(
'numberposts' => 10,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => ... |
99,832 | <p>I need to extend standard WP search functionality so that the search term is also applied to files attached to a post. In other words if user types in "annual report" then search results would include all pages and posts which have this search string in content and also in attached filename? </p>
<p>My current code... | [
{
"answer_id": 99874,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>If you look at the <code>$wpdb->posts</code> table in the database, you will notice that the file names, m... | 2013/05/17 | [
"https://wordpress.stackexchange.com/questions/99832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32975/"
] | I need to extend standard WP search functionality so that the search term is also applied to files attached to a post. In other words if user types in "annual report" then search results would include all pages and posts which have this search string in content and also in attached filename?
My current code is:
```
... | If you look at the `$wpdb->posts` table in the database, you will notice that the file names, minus the file type ending, are used for the `post_title` for attachments. This means that you can effectively search the file name if you can get your search function to search attachments, which the default search (almost) a... |
99,850 | <p>I'm not even sure if this is possible. But nevertheless I thought of asking. I'm in habit of wrapping/grouping AJAX calls for a particular need within a class. See below.</p>
<pre><code>class my_class {
function __construct() {
$this->hooks();
}
function hooks() {
add_action('wp_ajax... | [
{
"answer_id": 99855,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>If you are using class which needs an instance of, you have to create that instance <em>somewhere</em>. Currently WP ... | 2013/05/17 | [
"https://wordpress.stackexchange.com/questions/99850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9094/"
] | I'm not even sure if this is possible. But nevertheless I thought of asking. I'm in habit of wrapping/grouping AJAX calls for a particular need within a class. See below.
```
class my_class {
function __construct() {
$this->hooks();
}
function hooks() {
add_action('wp_ajax_my_action', arra... | If you are using class which needs an instance of, you have to create that instance *somewhere*. Currently WP has no designated convention for something like that.
Common practice is to use static methods, so your hook becomes `add_action('wp_ajax_my_action', array(__CLASS__, 'my_action_callback'));`. |
99,875 | <p>I've created a custom metabox with a textarea in it. How would I go about using Markdown in this textarea? I've seen some WP plugins but they seem to only be for the main editor.</p>
| [
{
"answer_id": 99879,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 1,
"selected": false,
"text": "<p>You can download a copy of <a href=\"https://github.com/michelf/php-markdown\" rel=\"nofollow\">PHP Markdown</a> ... | 2013/05/18 | [
"https://wordpress.stackexchange.com/questions/99875",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I've created a custom metabox with a textarea in it. How would I go about using Markdown in this textarea? I've seen some WP plugins but they seem to only be for the main editor. | You can download a copy of [PHP Markdown](https://github.com/michelf/php-markdown) and use it to parse the textarea contents before you save it:
```
if ( ! class_exists( 'Markdown' ) ) {
require_once( plugin_dir_path(__FILE__) . '/markdown.php' );
}
$textarea_contents = Markdown::defaultTransform( $textarea_conten... |
99,894 | <p>In per posts, there are <strong>"oo/x/"</strong>.</p>
<p>How to add "0" before "x" if <code>length(x) < 10</code> ?</p>
<p>Examples: </p>
<ul>
<li>x=12345678 ; length(x) = 8, so add "00" before x ===> x=0012345678</li>
<li>x=1234567 ; length(x) = 7, so add "000" before x ===> x=0001234567</li>
<li>x=123456789 ... | [
{
"answer_id": 99879,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 1,
"selected": false,
"text": "<p>You can download a copy of <a href=\"https://github.com/michelf/php-markdown\" rel=\"nofollow\">PHP Markdown</a> ... | 2013/05/18 | [
"https://wordpress.stackexchange.com/questions/99894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33001/"
] | In per posts, there are **"oo/x/"**.
How to add "0" before "x" if `length(x) < 10` ?
Examples:
* x=12345678 ; length(x) = 8, so add "00" before x ===> x=0012345678
* x=1234567 ; length(x) = 7, so add "000" before x ===> x=0001234567
* x=123456789 ; length(x) = 9, so add "0" before x ===> x=0123456789
Do you unders... | You can download a copy of [PHP Markdown](https://github.com/michelf/php-markdown) and use it to parse the textarea contents before you save it:
```
if ( ! class_exists( 'Markdown' ) ) {
require_once( plugin_dir_path(__FILE__) . '/markdown.php' );
}
$textarea_contents = Markdown::defaultTransform( $textarea_conten... |
99,910 | <p>I Create New Post Types and Taxonomies. This is the script:</p>
<pre><code>add_action('init', 'my_custom_post_type_init');
function my_custom_post_type_init()
{
$labels = array(
'name' => _x('Roundabouts', 'post type general name'),
'singular_name' => _x('Roundabout', 'post type singular name'),
... | [
{
"answer_id": 99879,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 1,
"selected": false,
"text": "<p>You can download a copy of <a href=\"https://github.com/michelf/php-markdown\" rel=\"nofollow\">PHP Markdown</a> ... | 2013/05/18 | [
"https://wordpress.stackexchange.com/questions/99910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18419/"
] | I Create New Post Types and Taxonomies. This is the script:
```
add_action('init', 'my_custom_post_type_init');
function my_custom_post_type_init()
{
$labels = array(
'name' => _x('Roundabouts', 'post type general name'),
'singular_name' => _x('Roundabout', 'post type singular name'),
'add_new' => _x('Ad... | You can download a copy of [PHP Markdown](https://github.com/michelf/php-markdown) and use it to parse the textarea contents before you save it:
```
if ( ! class_exists( 'Markdown' ) ) {
require_once( plugin_dir_path(__FILE__) . '/markdown.php' );
}
$textarea_contents = Markdown::defaultTransform( $textarea_conten... |
99,918 | <p>I needed a "Home" menu item in my wordpress website, so I created a new page and named it "Home", added it to my main menu item and then from Reading Settings I selected the "Home" as Front Page. </p>
<p>Now the problem is, the <code>Home</code> is using <code>page.php</code> instead of <code>index.php</code>. I re... | [
{
"answer_id": 99919,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>select home page as Posts page in setting>reading.it'll call you index.php.</p>\n\n<p>1.if you select h... | 2013/05/18 | [
"https://wordpress.stackexchange.com/questions/99918",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30913/"
] | I needed a "Home" menu item in my wordpress website, so I created a new page and named it "Home", added it to my main menu item and then from Reading Settings I selected the "Home" as Front Page.
Now the problem is, the `Home` is using `page.php` instead of `index.php`. I really need to get the home page using index.... | The simplest way would be to duplicate your index.php in to a file named home.php in your theme's folder.
Another way would be to create a new page template same thing (copy index.php into it) and add this at the very top
```
<?php
/*
Template Name: My Home Page
*/
```
Then head over to the page edit screen and sel... |
99,923 | <p>The codex provides a way to display the children and parent page for use as a sub-menu. However, this code displays the parent page in the list even when the parent has no children. How can I modify this code so it only displays if the parent has pages?</p>
<p>Functions.php</p>
<pre><code>if(!function_exists('ge... | [
{
"answer_id": 99926,
"author": "meekbot",
"author_id": 32804,
"author_profile": "https://wordpress.stackexchange.com/users/32804",
"pm_score": 3,
"selected": true,
"text": "<pre><code><?php \n if ($post->post_parent) { //We are a child, print out sub menu\n wp_li... | 2013/05/18 | [
"https://wordpress.stackexchange.com/questions/99923",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | The codex provides a way to display the children and parent page for use as a sub-menu. However, this code displays the parent page in the list even when the parent has no children. How can I modify this code so it only displays if the parent has pages?
Functions.php
```
if(!function_exists('get_post_top_ancestor_id'... | ```
<?php
if ($post->post_parent) { //We are a child, print out sub menu
wp_list_pages( array('title_li'=>'','include'=>$post->post_parent) );
wp_list_pages( array('title_li'=>'','depth'=>1,'child_of'=>$post->post_parent) );
}
//We are not a child but do we have children
$children ... |
99,925 | <p>I currently have this code in my functions file for the WooCommerce plugin.. </p>
<pre><code>function my_theme_wrapper_start()
{
echo the_breadcrumb();
echo '<section role="main"><div class="wrap">';
}
function my_theme_wrapper_end()
{
echo '</div></section>';
}
function mytheme_prep... | [
{
"answer_id": 99928,
"author": "Adam",
"author_id": 24587,
"author_profile": "https://wordpress.stackexchange.com/users/24587",
"pm_score": 6,
"selected": true,
"text": "<p>Ok I seem to have got it working. I added this in the functions file...</p>\n<pre><code>//Reposition WooCommerce b... | 2013/05/18 | [
"https://wordpress.stackexchange.com/questions/99925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24587/"
] | I currently have this code in my functions file for the WooCommerce plugin..
```
function my_theme_wrapper_start()
{
echo the_breadcrumb();
echo '<section role="main"><div class="wrap">';
}
function my_theme_wrapper_end()
{
echo '</div></section>';
}
function mytheme_prepare_woocommerce_wrappers()
{
remove_... | Ok I seem to have got it working. I added this in the functions file...
```
//Reposition WooCommerce breadcrumb
function woocommerce_remove_breadcrumb(){
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
}
add_action( 'woocommerce_before_main_content', 'woocommerce_remove_breadcrum... |
99,929 | <p>I am using <a href="http://wordpress.org/extend/plugins/magic-fields-2/" rel="nofollow noreferrer">Magic Fields 2</a> for custom meta boxes and custom fields, but this situation pertains to any meta box.</p>
<p>I have a custom meta box that I want to display on only 3 specific page IDs. </p>
<pre><code>function mf... | [
{
"answer_id": 99931,
"author": "Ciprian",
"author_id": 7349,
"author_profile": "https://wordpress.stackexchange.com/users/7349",
"pm_score": 1,
"selected": false,
"text": "<p>Try:</p>\n\n<p><code>if($_GET['post'] != 194 || $_GET['post'] != 185 || $_GET['post'] != 2)</code></p>\n\n<p>It ... | 2013/05/18 | [
"https://wordpress.stackexchange.com/questions/99929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | I am using [Magic Fields 2](http://wordpress.org/extend/plugins/magic-fields-2/) for custom meta boxes and custom fields, but this situation pertains to any meta box.
I have a custom meta box that I want to display on only 3 specific page IDs.
```
function mf_1_remove_meta_boxes() {
if( !in_array($_GET['post'],... | A simple and cleaner solution would be to use !in\_array ex:
```
function mf_1_remove_meta_boxes() {
if( !is_admin() && !isset( $_GET['post'] ) )
return;
if( !in_array($_GET['post'], array('194','185','2') ) )
remove_meta_box( 'mf_1', 'page', 'normal' );
}
```
this way you can just add the ... |
99,947 | <p>I'm building a theme that features a section wherein I'd like to have the single most recent post's thumbnail of a single category displayed between the header and blog sections. Something like </p>
<pre><code><?php if ( has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>... | [
{
"answer_id": 99949,
"author": "webdwall",
"author_id": 24229,
"author_profile": "https://wordpress.stackexchange.com/users/24229",
"pm_score": 0,
"selected": false,
"text": "<p>you can always do a new wp_query to get the latest post from given category and display its thumbnail etc.. S... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/99947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | I'm building a theme that features a section wherein I'd like to have the single most recent post's thumbnail of a single category displayed between the header and blog sections. Something like
```
<?php if ( has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
```
would work within the loo... | Use [`get_the_post_thumbnail`](http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail) with a new [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query).
```
<?php
if ( has_post_thumbnail()) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
echo '... |
99,950 | <p>I have created an 'event' custom post type and now I want to create a page that will allow users to create a custom post type from the front-end. Is there a standard way of doing this? I could create a template and then link it to a page that I create manually in the wordpress backend, but I would rather do it pro... | [
{
"answer_id": 99951,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 2,
"selected": true,
"text": "<p>So you want to allow people to create posts from the front-end? Sure...</p>\n\n<p><a href=\"https://wordpress.stac... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/99950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | I have created an 'event' custom post type and now I want to create a page that will allow users to create a custom post type from the front-end. Is there a standard way of doing this? I could create a template and then link it to a page that I create manually in the wordpress backend, but I would rather do it programa... | So you want to allow people to create posts from the front-end? Sure...
[In this answer here I explain a very basic way in which you can achieve this very thing, front-end posts to a post type of your choice.](https://wordpress.stackexchange.com/a/71386/13418)
Here is a basic example of what you might include in your... |
99,959 | <p>How do I <strong>redirect</strong> to a certain page <strong>after user deletion</strong>?</p>
<p>For demonstration purpose, let's say I want to <strong>redirect to the dashboard on user subscriber deletion</strong>. This is what I have tried so far:</p>
<pre><code>function mod_redirect_subscriber_delete($user_id)... | [
{
"answer_id": 99962,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<h2>a) <code>delete_user</code> hook:</h2>\n\n<p>Here is one idea: </p>\n\n<p>Add this into your code to delete t... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/99959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1044/"
] | How do I **redirect** to a certain page **after user deletion**?
For demonstration purpose, let's say I want to **redirect to the dashboard on user subscriber deletion**. This is what I have tried so far:
```
function mod_redirect_subscriber_delete($user_id) {
$user = get_user_by('id', $user_id);
$role = $user... | You could also do this,
```
function mod_redirect_subscriber_delete($user_id) {
$user = get_user_by('id', $user_id);
$role = $user->roles[0];
if ($role == 'subscriber') {
add_action("deleted_user", function(){
wp_redirect( admin_url('/index.php') );
exit;
});
}
}
add_action("delete_u... |
99,978 | <p>How can i add :</p>
<pre><code>class="youtube-player" type="text/html"
</code></pre>
<p>to iframe like :</p>
<pre><code> function Oembed_youtube_no_title($html,$url,$args){
$url_string = parse_url($url, PHP_URL_QUERY);
parse_str($url_string, $id);
if (isset($id['v'])) {
return '<iframe clas... | [
{
"answer_id": 99983,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": false,
"text": "<p>You can try this:</p>\n\n<pre><code>add_filter( 'embed_oembed_html', 'custom_youtube_oembed' );\nfunction cust... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/99978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33021/"
] | How can i add :
```
class="youtube-player" type="text/html"
```
to iframe like :
```
function Oembed_youtube_no_title($html,$url,$args){
$url_string = parse_url($url, PHP_URL_QUERY);
parse_str($url_string, $id);
if (isset($id['v'])) {
return '<iframe class="youtube-player" type="text/html" src=... | You can try this:
```
add_filter( 'embed_oembed_html', 'custom_youtube_oembed' );
function custom_youtube_oembed( $code ){
if( stripos( $code, 'youtube.com' ) !== FALSE && stripos( $code, 'iframe' ) !== FALSE )
$code = str_replace( '<iframe', '<iframe class="youtube-player" type="text/html" ', $code );
... |
99,987 | <p>On the main page of my blog, I have a section in the header with post thumbnails(140x170px) linking to specific categories. Below within the actual blog loop, I also have post previews- an image 440x265px, and the first paragraph or so of content.</p>
<p>I'm wondering how I can specify the size of the post preview ... | [
{
"answer_id": 99983,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": false,
"text": "<p>You can try this:</p>\n\n<pre><code>add_filter( 'embed_oembed_html', 'custom_youtube_oembed' );\nfunction cust... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/99987",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | On the main page of my blog, I have a section in the header with post thumbnails(140x170px) linking to specific categories. Below within the actual blog loop, I also have post previews- an image 440x265px, and the first paragraph or so of content.
I'm wondering how I can specify the size of the post preview image, wit... | You can try this:
```
add_filter( 'embed_oembed_html', 'custom_youtube_oembed' );
function custom_youtube_oembed( $code ){
if( stripos( $code, 'youtube.com' ) !== FALSE && stripos( $code, 'iframe' ) !== FALSE )
$code = str_replace( '<iframe', '<iframe class="youtube-player" type="text/html" ', $code );
... |
99,993 | <p>Reading the plugin FAQ:</p>
<p><a href="http://wordpress.org/extend/plugins/wp-super-cache/installation/" rel="nofollow">http://wordpress.org/extend/plugins/wp-super-cache/installation/</a></p>
<p>After you have enabled the plugin, look for the file "wp-content/cache/.htaccess". If it's not there you must create i... | [
{
"answer_id": 99995,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>The best value depends on the dynamic content you have:</p>\n\n<ul>\n<li>If there are widgets which should be up to dat... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/99993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30873/"
] | Reading the plugin FAQ:
<http://wordpress.org/extend/plugins/wp-super-cache/installation/>
After you have enabled the plugin, look for the file "wp-content/cache/.htaccess". If it's not there you must create it. It should read:
```
# BEGIN supercache <IfModule mod_mime.c> <FilesMatch "\.html\.gz$"> ForceType text/ht... | The best value depends on the dynamic content you have:
* If there are widgets which should be up to date each time, you cannot use a long value, or your visitors will get outdated content. That’s often not a problem though.
* The value should not be longer than your average post frequency. If you add a new post two t... |
100,000 | <p>in functions.php, I've defined the following:</p>
<pre><code>register_nav_menu( 'home_blocks', __( 'Home Page Posts', 'my_Theme' ) );
</code></pre>
<p>In <code>/wp-admin/nav-menus.php</code>, I've added a menu called Home Page Posts and assigned 3 posts to it and set it to be the item associated with Home Page Pos... | [
{
"answer_id": 100010,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": true,
"text": "<p>If you want to return the output of <code>wp_nav_menu()</code>, instead of echo-ing it, you should replace</p>... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/100000",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9688/"
] | in functions.php, I've defined the following:
```
register_nav_menu( 'home_blocks', __( 'Home Page Posts', 'my_Theme' ) );
```
In `/wp-admin/nav-menus.php`, I've added a menu called Home Page Posts and assigned 3 posts to it and set it to be the item associated with Home Page Posts as the menu location.
In `index.p... | If you want to return the output of `wp_nav_menu()`, instead of echo-ing it, you should replace
```
'echo' => 1,
```
with
```
'echo' => 0,
```
Then you should get something out of `var_dump( $menu );`.
You can read more about the input parameters in the [Codex](http://codex.wordpress.org/F... |
100,005 | <p>I have a custom post type called "videos" that I want to include in the Archives widget (stock widget in the TwentyTwelve theme). It DOES already appear on the archives page, but just not in the widget.</p>
<p>I already have</p>
<pre><code>add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
function add_m... | [
{
"answer_id": 100013,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>The <em>Archive</em> widget is using <code>wp_get_archives()</code> to display the archive.</p>\n\n<p>If you ... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/100005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32235/"
] | I have a custom post type called "videos" that I want to include in the Archives widget (stock widget in the TwentyTwelve theme). It DOES already appear on the archives page, but just not in the widget.
I already have
```
add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
function add_my_post_types_to_query... | The *Archive* widget is using `wp_get_archives()` to display the archive.
If you want to target all the `wp_get_archives()` functions, you can use the `getarchives_where` filter to add your custom post type:
```
add_filter( 'getarchives_where', 'custom_getarchives_where' );
function custom_getarchives_where( $where )... |
100,008 | <p>Looking in all posts with keywords "voting system, upvote, downvote", I can't find a satisfying solution for this issue, except accepting one of the available plugins, spend a lot of time undersanding it and try to modify its functionnalies so that they fit with the requirements. So, I am convinced in writing my own... | [
{
"answer_id": 100018,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, you can do this with built in functions. You've got a very broad question and a working solution would ... | 2013/05/19 | [
"https://wordpress.stackexchange.com/questions/100008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | Looking in all posts with keywords "voting system, upvote, downvote", I can't find a satisfying solution for this issue, except accepting one of the available plugins, spend a lot of time undersanding it and try to modify its functionnalies so that they fit with the requirements. So, I am convinced in writing my own co... | A simple user meta row can handle that for you (the second issue), you can store the post id and the vote (up/down) in an array and that is just the same as post meta ex
```
/**
* update user vote per post
* @param int $user_id
* @param int $post_id
* @param mixed $vote can be an integer 1 / -1 and can also b... |
100,040 | <p>Is there any way to guarantee that when I call get_option I will definitely get the value from the database and not from cache? </p>
| [
{
"answer_id": 100041,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You could delete an existing cache for your option before you call <code>get_option()</code>:</p>\n\n<pre><code>$GLOBA... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7905/"
] | Is there any way to guarantee that when I call get\_option I will definitely get the value from the database and not from cache? | You could delete an existing cache for your option before you call `get_option()`:
```
$GLOBALS['wp_object_cache']->delete( 'your_option_name', 'options' );
$value = get_option( 'your_option_name' );
``` |
100,043 | <p>Some easy points on offer...</p>
<p>I wish to action a PHP script from a WordPress page but where is the best place to store the script? The script works perfectly fine using a non-WordPress environment in a flat HTML directory structure.</p>
<p>and I want to action it from the page using the following code:</p>
... | [
{
"answer_id": 100163,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Do not call your PHP files directly. This will break, because in some setups, the <a href=\"https://wordpress.stackex... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29576/"
] | Some easy points on offer...
I wish to action a PHP script from a WordPress page but where is the best place to store the script? The script works perfectly fine using a non-WordPress environment in a flat HTML directory structure.
and I want to action it from the page using the following code:
```
<form class="cont... | You are actually closer in your first attempt.
My recommendation would be to create a folder called "scripts" in the WP root and put your PHP script files in here as well as your attachment(s). You will then need to declare the full path in your action attribute as the script does not now share the same file path as ... |
100,047 | <p>I'm trying to use <code>wp_mail</code> (testing on local machine) but no mail is received.
The <code>php.ini</code> has <code>smtp_port = 25</code> set and the php <code>mail()</code> is working so far.</p>
<ul>
<li>how can I check if wp_mail is working</li>
<li>what can fail</li>
</ul>
<p>Here is the code of my m... | [
{
"answer_id": 141999,
"author": "Andrew T",
"author_id": 13977,
"author_profile": "https://wordpress.stackexchange.com/users/13977",
"pm_score": 2,
"selected": false,
"text": "<p>I would start by enabling <a href=\"https://codex.wordpress.org/WP_DEBUG\" rel=\"nofollow\">WP_DEBUG</a> in ... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100047",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32871/"
] | I'm trying to use `wp_mail` (testing on local machine) but no mail is received.
The `php.ini` has `smtp_port = 25` set and the php `mail()` is working so far.
* how can I check if wp\_mail is working
* what can fail
Here is the code of my mail function:
```
function mv_optin_mail($id, $data){
$url = $id."-".mv_... | Wordpress relies on the PHPMailer class to send email through PHP's `mail` function.
Since PHP's `mail` function returns very little information after execution (only TRUE or FALSE), I suggest temporarily stripping down your `mv_optin_mail` function to a minimum in order to see if the `wp_mail` functions works.
Examp... |
100,055 | <p><a href="https://wordpress.stackexchange.com/questions/100004/cant-seem-to-get-shortcodes-to-work">I learned that I can only put in the code for handling my shortcode through the theme's <code>functions.php</code></a></p>
<p>But I was thinking of making it a plugin rather than a theme. How can I achieve that?</p>
| [
{
"answer_id": 100056,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>There is no difference. This is a complete shortcode plugin:</p>\n\n<pre><code>/* Plugin Name: blogname */\nadd_shortc... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15816/"
] | [I learned that I can only put in the code for handling my shortcode through the theme's `functions.php`](https://wordpress.stackexchange.com/questions/100004/cant-seem-to-get-shortcodes-to-work)
But I was thinking of making it a plugin rather than a theme. How can I achieve that? | There is no difference. This is a complete shortcode plugin:
```
/* Plugin Name: blogname */
add_shortcode( 'blogname', 'get_bloginfo' );
```
Usually, you should never register shortcodes in a theme, because the content will be useless after a a theme switch. So, a plugin is the better option. |
100,057 | <p>I have this form in my plugin function:</p>
<pre><code><form method="get" action="" enctype="multipart/form-data">
<p class="submit">
<input type="hidden" name="do_it_hidden" value="run">
<input name="do_it" type="submit" class="button-primary" value="DO IT!">
</p>
</fo... | [
{
"answer_id": 100058,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Use a redirect in your form handler:</p>\n\n<pre><code>if (isset($_GET['do_it_hidden'])) {\n // some code to execu... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I have this form in my plugin function:
```
<form method="get" action="" enctype="multipart/form-data">
<p class="submit">
<input type="hidden" name="do_it_hidden" value="run">
<input name="do_it" type="submit" class="button-primary" value="DO IT!">
</p>
</form>
```
And this php condition earlier in my ... | **SOLVED!** I find that GET is not working at all! You need to use POST and in the form action you need to type this:
`action="<?php admin_url('options-general.php?page=DD_Awesome_Plugin/DD_awesome_plugin.php'); ?>"`
Damn! It's sometimes so hard to do simple task in WP ;) |
100,068 | <p>I'm trying to list all the products tied to a specific taxonomy. For some reason the template won't work when trying to access "<a href="http://www.myexample.com/product_categories/funiture/" rel="nofollow">http://www.myexample.com/product_categories/funiture/</a>", I tried <code>taxonomy.php</code>, <code>taxonomy-... | [
{
"answer_id": 100063,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 2,
"selected": true,
"text": "<p><strong>Important Link:</strong></p>\n\n<ol>\n<li><a href=\"http://wordpress.org/plugins/bainternet-pos... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100068",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11331/"
] | I'm trying to list all the products tied to a specific taxonomy. For some reason the template won't work when trying to access "<http://www.myexample.com/product_categories/funiture/>", I tried `taxonomy.php`, `taxonomy-term.php` and nothing. Here's my code: <http://pastie.org/7934453>
```
add_action('init', 'register... | **Important Link:**
1. [Posts Creation Limits](http://wordpress.org/plugins/bainternet-posts-creation-limits/)
Dig into this plugin you easily get the code for limit posts/pages. |
100,091 | <p>So, I know that I can make a custom featured-image size by adding this to my functions.php file:</p>
<pre><code>add_image_size('newsize', 883, 300, true);
</code></pre>
<p>and calling it with:</p>
<pre><code>the_post_thumbnail('newsize');
</code></pre>
<p>But, I also have CSS rules to make images responsive by i... | [
{
"answer_id": 100094,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>So if you know your height of image is 300px, then not put height auto in css make it 300px. ( or adju... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12294/"
] | So, I know that I can make a custom featured-image size by adding this to my functions.php file:
```
add_image_size('newsize', 883, 300, true);
```
and calling it with:
```
the_post_thumbnail('newsize');
```
But, I also have CSS rules to make images responsive by including:
```
img { display:block; width:100%; h... | You can wrap the image in a figure.
```
<!-- html -->
<figure class="constrained-container">
<img src="my-image.jpg" alt="What my image is about"/>
</figure>
```
Then style the figure as well as the image.
```
/* css */
.constrained-container {
height: 300px;
overflow: hidden; /* this hides excess of th... |
100,100 | <p>I'm using 2 plugins in my wordpress blog - <a href="http://wordpress.org/plugins/wp-members/" rel="nofollow">WP-Members</a> and <a href="http://wordpress.org/plugins/dropbox-folder-share/" rel="nofollow">Dropbox Folder Share</a>. I want to do something like this:</p>
<pre><code>[dropbox-foldershare-hyno link="[wp-m... | [
{
"answer_id": 100107,
"author": "sabreuse",
"author_id": 2140,
"author_profile": "https://wordpress.stackexchange.com/users/2140",
"pm_score": 2,
"selected": false,
"text": "<p>Nested shortcodes only work in certain specific circumstances: </p>\n\n<ul>\n<li>Only enclosed shortcodes can ... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/447/"
] | I'm using 2 plugins in my wordpress blog - [WP-Members](http://wordpress.org/plugins/wp-members/) and [Dropbox Folder Share](http://wordpress.org/plugins/dropbox-folder-share/). I want to do something like this:
```
[dropbox-foldershare-hyno link="[wp-members field="some_link"]" ver_como='lista']
```
Is this possibl... | You cannot use shortcodes like this. The parser would not read that like you want.
But there is a workaround: Hijack the shortcode `dropbox-foldershare-hyno`, run the callback function for the `wp-members` on the link and pass the result to the original `dropbox-foldershare-hyno` callback.
Sample code, not tested:
`... |
100,117 | <p>Does anyone know of a way to provide an edit history for posts in production? That is, when people look at a post, they can see that it was modified and examine a list of changes like is possible with other sites (below).</p>
<p>I tried looking for a way but everything I found referred to revision histories in the ... | [
{
"answer_id": 100127,
"author": "Robert Isaev",
"author_id": 24011,
"author_profile": "https://wordpress.stackexchange.com/users/24011",
"pm_score": 2,
"selected": false,
"text": "<p>you can grab revisions from wpdb with smth like</p>\n\n<pre><code>$revisions = $wpdb->get_results(\"s... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121/"
] | Does anyone know of a way to provide an edit history for posts in production? That is, when people look at a post, they can see that it was modified and examine a list of changes like is possible with other sites (below).
I tried looking for a way but everything I found referred to revision histories in the dashboard,... | you can grab revisions from wpdb with smth like
```
$revisions = $wpdb->get_results("select * from {$wpdb->posts} where post_parent={$post_id} and post_type='revision'")
```
after selecting a revision you could use some js diff tool like
<http://cemerick.github.io/jsdifflib/demo.html> |
100,124 | <p>First, my problem is similar to <a href="https://wordpress.stackexchange.com/questions/7398/how-to-include-php-files-in-plugins-the-correct-way">this thread</a>. However, the solution posted there doesn't work for me.</p>
<p>I'm creating a plugin that displays a contact form on a page using the Shortcode API. </p>
... | [
{
"answer_id": 100130,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": true,
"text": "<p>You're POSTing the form to the validate.php file directly, so the WordPress code isn't loaded. Instead you need to ... | 2013/05/20 | [
"https://wordpress.stackexchange.com/questions/100124",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33064/"
] | First, my problem is similar to [this thread](https://wordpress.stackexchange.com/questions/7398/how-to-include-php-files-in-plugins-the-correct-way). However, the solution posted there doesn't work for me.
I'm creating a plugin that displays a contact form on a page using the Shortcode API.
Plugin folder contents:
... | You're POSTing the form to the validate.php file directly, so the WordPress code isn't loaded. Instead you need to POST the form to the current URL or the home\_url or something like that, and then have the plugin intercept the data and act accordingly, so that the WordPress code is loaded before you use its functions. |
100,150 | <p>This is driving me crazy. The code for the image is: <code><img src="MYLINK" /></code></p>
<p>Yet it keeps resizing my image down to 500x500 from 947x947. How do I fix this? </p>
<p>Also, it disregards the image map I have which lets you click on different parts of the image to go to different sites. </p>
<... | [
{
"answer_id": 100177,
"author": "zigojacko",
"author_id": 29524,
"author_profile": "https://wordpress.stackexchange.com/users/29524",
"pm_score": 0,
"selected": false,
"text": "<p>If you're uploading the image via Wordpress's Media Manager, goto 'Settings > Media' in your admin panel an... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33076/"
] | This is driving me crazy. The code for the image is: `<img src="MYLINK" />`
Yet it keeps resizing my image down to 500x500 from 947x947. How do I fix this?
Also, it disregards the image map I have which lets you click on different parts of the image to go to different sites.
EDIT: This is what I'm referring to: <h... | I figured it out. The hint from user29296 is what led me to this: I had to insert the image using CSS, not html. Check the page now: <http://macaulay.cuny.edu/eportfolios/menatwork/test-page/>
The code was this:
```
<style type="text/css">
#image
{
position:absolute;
width:947px !important;
height:947px;
background-... |
100,174 | <p>I would like to know if it's possible to get the complete name of each buyers for a specific product or the orders list of a specific product ?</p>
| [
{
"answer_id": 100188,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>Goto your wordpress phpmyadmin open database</p>\n\n<p>1.All Woocommerce orders save in table-prefix_p... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100174",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23524/"
] | I would like to know if it's possible to get the complete name of each buyers for a specific product or the orders list of a specific product ? | Goto your wordpress phpmyadmin open database
1.All Woocommerce orders save in table-prefix\_posts table
2.and Woocommerce order's meta info like :billing-addres,customer-name store in table-prefix\_postmeta table
run SQL command in phpmyadmin
```
SELECT *
FROM `table-prefix_postmeta`
WHERE `post_id` = any order... |
100,210 | <p>I;ve got a doman alias setup for one of my Wordpress sites and i'm trying to forward that particular domain to a page.</p>
<p>The 2 domains are -</p>
<p>www.alias.com
www.actual.com
When people use the <em>www.alias.com</em> domain i want them to be forwarded to <em>www.alias.com/content/</em> </p>
<p>I've tried ... | [
{
"answer_id": 100219,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 3,
"selected": true,
"text": "<p>First off -- does your server allow overrides in <code>.htaccess</code> files? If not, you need to get that tur... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100210",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | I;ve got a doman alias setup for one of my Wordpress sites and i'm trying to forward that particular domain to a page.
The 2 domains are -
www.alias.com
www.actual.com
When people use the *www.alias.com* domain i want them to be forwarded to *www.alias.com/content/*
I've tried several things with the htaccess file ... | First off -- does your server allow overrides in `.htaccess` files? If not, you need to get that turned on. My server has `AllowOverride All` set in its config file, which then allows my `.htaccess` rules to function.
Does `alias.com` point to the same directory as `actual.com`? If not, then you need to put a `.htacce... |
100,218 | <p>I am trying to display the post title if the custom field exists and has a value of apple...</p>
<pre><code><?php if ( isset ( get_post_meta($post->ID, 'mycustomvalue', true ) ) ) && if ( get_post_meta($post->ID, 'mycustomvalue', true ) == 'apple' ) : ?>
<?php the_title(); ?>
</code></pre... | [
{
"answer_id": 100223,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 1,
"selected": false,
"text": "<p>You can hook into <code>the_title()</code> to alter the output.</p>\n\n<p>In functions.php paste this:</p... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I am trying to display the post title if the custom field exists and has a value of apple...
```
<?php if ( isset ( get_post_meta($post->ID, 'mycustomvalue', true ) ) ) && if ( get_post_meta($post->ID, 'mycustomvalue', true ) == 'apple' ) : ?>
<?php the_title(); ?>
```
I am getting a white screen, anyone spot where... | You can hook into `the_title()` to alter the output.
In functions.php paste this:
```
function my_change_title( $title, $post_id ) {
$custom_title = get_post_meta($post_id, 'mycustomvalue', true);
if( isset($custom_title) && $custom_title == 'apple' )
return $custom_title;
return $title;
}
add_f... |
100,220 | <p>I am working with custom post types and I had trouble with the nav menu not getting the <code>.current-menu-item</code> on my <code>custom post archive page</code> menu item. In fact, when I was on that page or any of the <code>custom posts</code>, instead of the cpt archive menu item getting the current class, the ... | [
{
"answer_id": 100274,
"author": "GabLeRoux",
"author_id": 19537,
"author_profile": "https://wordpress.stackexchange.com/users/19537",
"pm_score": 3,
"selected": true,
"text": "<p>I found an answer by searching in similar posts and links. I added a line to fit my needs (I wanted to preve... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19537/"
] | I am working with custom post types and I had trouble with the nav menu not getting the `.current-menu-item` on my `custom post archive page` menu item. In fact, when I was on that page or any of the `custom posts`, instead of the cpt archive menu item getting the current class, the menu item pointing to the articles w... | I found an answer by searching in similar posts and links. I added a line to fit my needs (I wanted to prevent my blog page to get highlited when on a custom post).See this line: `unset($classes[array_search('current_page_parent',$classes)]);`
**Solution**
```
function add_parent_url_menu_class( $classes = array(), $... |
100,221 | <p>I am a bit confused on how this may be achieved. I have a website that I have coded already with static HTML/CSS and I am trying to incorporate it into wordpress. The challenge though is that the website is single page index.html file with 4 "sections". I want each section to be a page that can be accessed by anyone... | [
{
"answer_id": 100238,
"author": "webdwall",
"author_id": 24229,
"author_profile": "https://wordpress.stackexchange.com/users/24229",
"pm_score": 1,
"selected": false,
"text": "<p>well you can have conditional if else statements to output different html for different pages, based on page... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33102/"
] | I am a bit confused on how this may be achieved. I have a website that I have coded already with static HTML/CSS and I am trying to incorporate it into wordpress. The challenge though is that the website is single page index.html file with 4 "sections". I want each section to be a page that can be accessed by anyone to... | You could attack the `get_pages();` function another way to sort your code better and read it better as well, take a look at [this link](http://codex.wordpress.org/Function_Reference/get_pages) for more info.
```
<?php $args = array(
'sort_order' => 'ASC',
'sort_column' => 'post_title', // sorting by alphabeti... |
100,230 | <p>I am currently building a WordPress theme where I am using jQuery to append and prepend some ornate images to a h4 tag with a class of beechheader in the page template markup.</p>
<p>Before turning the static html files into a WordPress theme, the code below worked great. The code is in a separate file called test.... | [
{
"answer_id": 100231,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_localize_script\" rel=\"nofollow\"><code>wp_l... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23507/"
] | I am currently building a WordPress theme where I am using jQuery to append and prepend some ornate images to a h4 tag with a class of beechheader in the page template markup.
Before turning the static html files into a WordPress theme, the code below worked great. The code is in a separate file called test.js
The jQ... | well first of all, don't directly inject a script tag like that, use [`wp_enqueue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) to add your javascript file. additional data can then be passed from php to javascript via the [`wp_localize_script`](http://codex.wordpress.org/Function_Reference/... |
100,234 | <p>I am using wp-cli and I am having php notices and errors show up when running wp-export. Some of these warnings and errors are ending up in the output file. How can I force errors to NOT show up. I have tried <code>ini_set('display_errors', 0);</code> and <code>error_reporting(0);</code> in wp-wp-config.php</p>
<pr... | [
{
"answer_id": 100241,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>First, you have to do your PHP error settings in your <code>php.ini</code> file unless <a href=\"http://www.php.ne... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26819/"
] | I am using wp-cli and I am having php notices and errors show up when running wp-export. Some of these warnings and errors are ending up in the output file. How can I force errors to NOT show up. I have tried `ini_set('display_errors', 0);` and `error_reporting(0);` in wp-wp-config.php
```
root@roc-apache-4:/var/www/b... | First, you have to do your PHP error settings in your `php.ini` file unless [the PHP ini directives](http://www.php.net/manual/en/ini.list.php) don't list it as `PHP_INI_ALL` - which is the case for nearly error related definition.
So I'm assuming you just misread something and set stuff to `wp_settings.php` instead o... |
100,235 | <p>I have a couple of sites on a shared hosting server.</p>
<p>The sites load just fine, and everything appears to work, including local links. The only thing that isn't working is that the entire wp-admin directory is throwing a "too many redirects" error message.</p>
<p>Here is what my redirects look like to handle... | [
{
"answer_id": 100246,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>I do not really know where your problem comes from but I know a trick to fix this issue in some case :</p>\n\n<p... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26896/"
] | I have a couple of sites on a shared hosting server.
The sites load just fine, and everything appears to work, including local links. The only thing that isn't working is that the entire wp-admin directory is throwing a "too many redirects" error message.
Here is what my redirects look like to handle the domain (this... | I suggest you to enable WP\_DEBUG 'ON' to find out the error. You can enable WordPress debug editing wp-config.php file by adding `define( 'WP_DEBUG', true );`
Check the following document for better understanding
<https://codex.wordpress.org/Debugging_in_WordPress> |
100,248 | <p>I have my <a href="http://barnettconstruction.ca/home-builders-blog" rel="nofollow">blog page here</a> on a website I created, however I'm not understanding quite where to find the code to get rid of the images on my child theme. I'm using code from Twenty Ten and have set my own BLOG template page up but it's not w... | [
{
"answer_id": 100246,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>I do not really know where your problem comes from but I know a trick to fix this issue in some case :</p>\n\n<p... | 2013/05/21 | [
"https://wordpress.stackexchange.com/questions/100248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | I have my [blog page here](http://barnettconstruction.ca/home-builders-blog) on a website I created, however I'm not understanding quite where to find the code to get rid of the images on my child theme. I'm using code from Twenty Ten and have set my own BLOG template page up but it's not working so I'm obviously editi... | I suggest you to enable WP\_DEBUG 'ON' to find out the error. You can enable WordPress debug editing wp-config.php file by adding `define( 'WP_DEBUG', true );`
Check the following document for better understanding
<https://codex.wordpress.org/Debugging_in_WordPress> |
100,272 | <p>I've got the following code, which is supposed to run when a new post is published for the first time, check if a custom field 'specific_users' has data (this uses Advanced Custom Fields), and if so, send an email to each of the selected users.</p>
<pre><code>/**
* Send users a notification of new grower posts
*... | [
{
"answer_id": 100267,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>You could <a href=\"http://codex.wordpress.org/Function_Reference/add_meta_box\" rel=\"nofollow\">add a meta box</a... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100272",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32155/"
] | I've got the following code, which is supposed to run when a new post is published for the first time, check if a custom field 'specific\_users' has data (this uses Advanced Custom Fields), and if so, send an email to each of the selected users.
```
/**
* Send users a notification of new grower posts
*/
function no... | You could [add a meta box](http://codex.wordpress.org/Function_Reference/add_meta_box) to the post add/edit screen below the featured image box to allow selection of size via a dropdown select menu. You could generate the list from available sizes (via [`get_intermediate_image_sizes`](http://codex.wordpress.org/Functio... |
100,276 | <p>I have the following custom post type:</p>
<pre><code>if ( $args->has_archive ) {
$archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
if ( $args->rewrite['with_front'] )
$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
else... | [
{
"answer_id": 100277,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You can pass a string for <code>has_archive</code>. That string will be used as archive URL.</p>\n\n<p>So in your regi... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I have the following custom post type:
```
if ( $args->has_archive ) {
$archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
if ( $args->rewrite['with_front'] )
$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
else
$archive_slug = $wp_rew... | You can pass a string for `has_archive`. That string will be used as archive URL.
So in your registration code use:
```
'has_archive' => 'jobs'
```
From the `register_post_type()` declaration in WordPress core:
```
if ( $args->has_archive ) {
$archive_slug = $args->has_archive === true ? $args->rewrite['slug']... |
100,287 | <p>This is my code:</p>
<pre><code>$file_return = wp_handle_upload($_FILES['my-photo'], array('test_form' => FALSE));
if(isset($file_return['error']) || isset($file_return['upload_error_handler'])) {
echo "And so it DIED...";
print_r($file_return);
die;
}
</code></pre>
<p>Why is not uploading to the u... | [
{
"answer_id": 100289,
"author": "Sumit",
"author_id": 32475,
"author_profile": "https://wordpress.stackexchange.com/users/32475",
"pm_score": 1,
"selected": false,
"text": "<p>Check the documentation <a href=\"http://codex.wordpress.org/Function_Reference/wp_handle_upload\" rel=\"nofoll... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31565/"
] | This is my code:
```
$file_return = wp_handle_upload($_FILES['my-photo'], array('test_form' => FALSE));
if(isset($file_return['error']) || isset($file_return['upload_error_handler'])) {
echo "And so it DIED...";
print_r($file_return);
die;
}
```
Why is not uploading to the uploads dir and why is it thro... | Check the documentation [wp\_handle\_upload](http://codex.wordpress.org/Function_Reference/wp_handle_upload)
You need to include the file.php before calling `wp_handle_upload`
`require_once( ABSPATH . 'wp-admin/includes/file.php' )` |
100,298 | <p>I create a meta custom input to make a page builder. So i can drop & drag element to build content for post.</p>
<p>And when i save post, i want it will save directly to post content.</p>
<p>So i think i will change the $_POST and hook it to save_post action.</p>
<p><code>$_POST['content'] = $_POST['page-buil... | [
{
"answer_id": 100304,
"author": "Tomas Buteler",
"author_id": 5552,
"author_profile": "https://wordpress.stackexchange.com/users/5552",
"pm_score": 2,
"selected": true,
"text": "<p>The answer appears to be clear if you look at the source code. The action you're hooking to occurs inside ... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48231/"
] | I create a meta custom input to make a page builder. So i can drop & drag element to build content for post.
And when i save post, i want it will save directly to post content.
So i think i will change the $\_POST and hook it to save\_post action.
`$_POST['content'] = $_POST['page-builder-content'];`
I have try but... | The answer appears to be clear if you look at the source code. The action you're hooking to occurs inside `wp_insert_post`, and is called just before it returns the `$post_ID` variable. This means that all the manipulation and data insertion has already taken place, so modifying the `$_POST` array will do nothing. You ... |
100,301 | <p>So, I have a child-theme with nothing but the required CSS file in it. Once I activated this child-theme my entire site is down. I end up with 2 questions:</p>
<ol>
<li>How can activating a child-theme with nothing but a CSS in it break my site?</li>
<li>How can I revert to my original theme?</li>
</ol>
<p>These a... | [
{
"answer_id": 100302,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Your parent theme is probably broken. I guess it is using code like this:</p>\n\n<pre><code>require_once get_styleshe... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33143/"
] | So, I have a child-theme with nothing but the required CSS file in it. Once I activated this child-theme my entire site is down. I end up with 2 questions:
1. How can activating a child-theme with nothing but a CSS in it break my site?
2. How can I revert to my original theme?
These are the errors the site gives me:
... | Your parent theme is probably broken. I guess it is using code like this:
```
require_once get_stylesheet_directory() . '/admin/options-framework.php';
```
So it will search in the child theme for files that are present in the parent theme only. It should use `get_template_directory()` instead. |
100,311 | <p>I wanted to move my wordpress from <code>www.domain.com/old-name</code> to <code>www.domain.com/new-name</code>. I thought that this is no problem and I missed backing up...</p>
<p>Now if your are logged in into the dashboard the plugins are not working as expected. The problem is that the css and js files have an ... | [
{
"answer_id": 100357,
"author": "testing",
"author_id": 13921,
"author_profile": "https://wordpress.stackexchange.com/users/13921",
"pm_score": 2,
"selected": true,
"text": "<p>Perhaps the error was the trailing slash at end of my string (<code>www.domain.com/new-name</code>), because i... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13921/"
] | I wanted to move my wordpress from `www.domain.com/old-name` to `www.domain.com/new-name`. I thought that this is no problem and I missed backing up...
Now if your are logged in into the dashboard the plugins are not working as expected. The problem is that the css and js files have an **old absolute path** in it. Exa... | Perhaps the error was the trailing slash at end of my string (`www.domain.com/new-name`), because in the content I had links such as `www.domain.com/old-namewpcontent/uploads/2013/05/image.gif`. Undo the changes didn't worked.
I tried to install a fresh copy of Wordpress in the new folder and take over all files, them... |
100,334 | <p>I would like to override/update to core shortcodes.php file. Build an array and send data differently to other functions, but my question is how to do that without editing the core file? Is there a best practice way overriding core files and/or functions?</p>
| [
{
"answer_id": 100337,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Plugin_API/Hooks\" rel=\"nofollow\">Hooks</a> are a way to overri... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I would like to override/update to core shortcodes.php file. Build an array and send data differently to other functions, but my question is how to do that without editing the core file? Is there a best practice way overriding core files and/or functions? | You can't "override" whole files or functions, except in special circumstances. That is basic PHP.
WordPress has code in place that will let you override particular files and functions. For example, child themes can override parent theme files. That is because of the way the WordPress Template loader works. The overr... |
100,353 | <p>I have a plugin that lets users upload post attachments via AJAX in the admin area. I later try to push these files to DropBox via <a href="https://www.dropbox.com/developers/core/docs" rel="nofollow noreferrer">their REST API</a>. It <em>almost</em> works. The issue is with WP cron task which, when running, prevent... | [
{
"answer_id": 100755,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 2,
"selected": false,
"text": "<p>Cron tasks don't directly affect page load besides the 0.01s timeout (of course, they do affect server... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100353",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8105/"
] | I have a plugin that lets users upload post attachments via AJAX in the admin area. I later try to push these files to DropBox via [their REST API](https://www.dropbox.com/developers/core/docs). It *almost* works. The issue is with WP cron task which, when running, prevents the page from loading **until the push to Dro... | Cron tasks don't directly affect page load besides the 0.01s timeout (of course, they do affect server load, so they can impact page load *indirectly*).
My hunch is that your PHP config is the issue. The cron tasks run like any other web request, and they're subject to PHP's `max_execution_time` INI setting. If this i... |
100,386 | <p>So, I've been going crazy trying to figure this out. Essentially, I've created two custom post types, <code>'the_case_study</code>' and <code>'the_video'</code>, with respective slugs <code>'case-studies'</code> and <code>'videos'</code>.</p>
<p>I've also created three taxonomies which apply to both the_case_study ... | [
{
"answer_id": 100389,
"author": "Cole",
"author_id": 2130,
"author_profile": "https://wordpress.stackexchange.com/users/2130",
"pm_score": -1,
"selected": false,
"text": "<p>You could alter the query directly in your template or use the pre_get_posts action.</p>\n\n<p><strong>Inside arc... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32806/"
] | So, I've been going crazy trying to figure this out. Essentially, I've created two custom post types, `'the_case_study`' and `'the_video'`, with respective slugs `'case-studies'` and `'videos'`.
I've also created three taxonomies which apply to both the\_case\_study and the\_video. These are `'the_room'`, `'the_system... | This is very easy to do by adding custom rewrite rules. This should get you started:
```
add_action( 'init', 'wpse_100386_rewrites' );
function wpse_100386_rewrites() {
add_rewrite_rule( 'case-studies/room/([^/]+)/?', 'index.php?the_room=$matches[1]&post_type=the_case_study', 'top' );
add_rewrite_rule( 'videos... |
100,387 | <p>I already tried the plugins RSS Manager, Add featured image to RSS feed and Featured Image In Rss Feed. But all they do is add the image inside the <code><description></code> attribute of the xml feed.</p>
<p>There is at least 2 problems with that:</p>
<ul>
<li>The blog that's pulling the feed truncates the ... | [
{
"answer_id": 107207,
"author": "reidelliott",
"author_id": 31209,
"author_profile": "https://wordpress.stackexchange.com/users/31209",
"pm_score": 0,
"selected": false,
"text": "<p>I am attempting to do this same thing. \nA couple resources I have been looking at so far:</p>\n\n<p>Firs... | 2013/05/22 | [
"https://wordpress.stackexchange.com/questions/100387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13335/"
] | I already tried the plugins RSS Manager, Add featured image to RSS feed and Featured Image In Rss Feed. But all they do is add the image inside the `<description>` attribute of the xml feed.
There is at least 2 problems with that:
* The blog that's pulling the feed truncates the `<description>` at about 300 character... | The RSS2 feed is generated in the `wp-includes/feed-rss2.php` file. In this file, there is an action hook named `rss2_item`. You can use this action hook to add tags to each item in your feed.
There is a [codex article on `rss2_item`](http://codex.wordpress.org/Plugin_API/Action_Reference/rss2_item) with examples, inc... |
100,421 | <p>I currently have WordPress build an <code>XML Sitemap</code> everytime a <code>POST</code> or <code>PAGE</code> is <code>PUBLISHED</code> by using this Action... </p>
<pre><code>add_action("publish_post", "create_news_sitemap");
</code></pre>
<p>I am not doing the same process but for a <code>News Sitemap</code> w... | [
{
"answer_id": 100423,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>publish_post</code> action gets the post ID as argument, pass that to <a href=\"http://codex.wordpress.o... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8668/"
] | I currently have WordPress build an `XML Sitemap` everytime a `POST` or `PAGE` is `PUBLISHED` by using this Action...
```
add_action("publish_post", "create_news_sitemap");
```
I am not doing the same process but for a `News Sitemap` which has different criteria. Such as it can only show post that are no older then... | `publish_post` will give you a second parameter if you ask for it. Notice the fourth parameter of the `add_action` call. That is your post object.
```
function run_on_publish_wpse_100421( $postid, $post ) {
if ('news' == $post->post_type)
// your code
}
}
add_action('publish_post','run_on_publish_wpse_100421... |
100,427 | <p>Is it possible to add post count to menu links using wp_nav_menu?</p>
<p>For example:- </p>
<pre><code> Apple (3)
ball (6)
cat (2)
</code></pre>
| [
{
"answer_id": 100428,
"author": "Richard B",
"author_id": 1936,
"author_profile": "https://wordpress.stackexchange.com/users/1936",
"pm_score": 0,
"selected": false,
"text": "<p>Have you seen <a href=\"http://wordpress.org/support/topic/count-wp_nav_menu-items\" rel=\"nofollow\">this th... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25340/"
] | Is it possible to add post count to menu links using wp\_nav\_menu?
For example:-
```
Apple (3)
ball (6)
cat (2)
``` | Basically the easiest thing should be a callback to the `start_el()` method of the Walker class.
```
// From core:
apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
```
Just grab the data (whatever the actual data is and from wherever it comes) and append it.
```
add_action( 'walker_n... |
100,439 | <p>I used some of this code from this page on Stack Overflow:
<a href="https://wordpress.stackexchange.com/questions/14306/using-wp-query-is-it-possible-to-orderby-taxonomy/14313#14313">Using wp_query is it possible to orderby taxonomy?</a></p>
<p>It's about the function to be able to sort a query by a taxonomy value.... | [
{
"answer_id": 100455,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": true,
"text": "<p>Your question is more about SQL than WordPress.</p>\n\n<p>If you want to sort your term names as numbers, you ... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23478/"
] | I used some of this code from this page on Stack Overflow:
[Using wp\_query is it possible to orderby taxonomy?](https://wordpress.stackexchange.com/questions/14306/using-wp-query-is-it-possible-to-orderby-taxonomy/14313#14313)
It's about the function to be able to sort a query by a taxonomy value. Although it works p... | Your question is more about SQL than WordPress.
If you want to sort your term names as numbers, you can in general try
```
SELECT * FROM wp_terms ORDER BY name+0 ASC
```
or
```
SELECT * FROM wp_terms ORDER BY name*1 ASC
```
or use CAST:
```
SELECT * FROM wp_terms ORDER BY CAST(name AS SIGNED) ASC
```
where y... |
100,445 | <p>My page title is <code>This is my title</code>, if I try and retrieve the ID from the title like this then it does not work:</p>
<pre><code>$mytitle = 'This is my title';
$mytitle2 = get_page_by_title( $mytitle, OBJECT, 'mycustompost' );
print_r($mytitle2);
</code></pre>
<p>But if I do this it does work:</p>
<pre... | [
{
"answer_id": 100449,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 1,
"selected": false,
"text": "<p>Retrieve post/page/custom-post-type id it works fine</p>\n\n<pre><code>$mytitle = 'This is my title';\... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | My page title is `This is my title`, if I try and retrieve the ID from the title like this then it does not work:
```
$mytitle = 'This is my title';
$mytitle2 = get_page_by_title( $mytitle, OBJECT, 'mycustompost' );
print_r($mytitle2);
```
But if I do this it does work:
```
$mytitle2 = get_page_by_title( 'This is m... | Man this was an annoying problem for me as well because I a function passing the variable and when tested it showed a value (**with special characters, like "&"**. If I reset the value statically it worked but otherwise same issue. I ran html\_entity\_decode() on the variable and it now works perfectly so thought I wou... |
100,450 | <p>I'm facing a strange issue displaying all posts of a certain type of custom post sorted by their category. The code below to display them works fine locally but when I view the page on the server it returns an archive page with three posts instead. How is that possible?</p>
<p>This is the code to display the posts:... | [
{
"answer_id": 100458,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>Check <a href=\"http://codex.wordpress.org/Template_Tags/get_posts#Taxonomy_Parameters\" rel=\"nofollo... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100450",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28103/"
] | I'm facing a strange issue displaying all posts of a certain type of custom post sorted by their category. The code below to display them works fine locally but when I view the page on the server it returns an archive page with three posts instead. How is that possible?
This is the code to display the posts:
```
<?p... | Because it work fine in local, you can give a shot by changing .htaccess file(change permalink form WordPress setting , make sure you have the server write access to change . htaccess file) |
100,462 | <p>I have problem with post and taxonomy query. What i need is to get all post's from custom post type which starts with A and have defined term. Here is my sql:</p>
<pre><code>SELECT * FROM $wpdb->posts, $wpdb->terms
WHERE post_title LIKE 'А%'
AND post_type = 'filmi-i-serialii'
AND post_status = 'pu... | [
{
"answer_id": 100458,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>Check <a href=\"http://codex.wordpress.org/Template_Tags/get_posts#Taxonomy_Parameters\" rel=\"nofollo... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100462",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33191/"
] | I have problem with post and taxonomy query. What i need is to get all post's from custom post type which starts with A and have defined term. Here is my sql:
```
SELECT * FROM $wpdb->posts, $wpdb->terms
WHERE post_title LIKE 'А%'
AND post_type = 'filmi-i-serialii'
AND post_status = 'publish'
AND slug ... | Because it work fine in local, you can give a shot by changing .htaccess file(change permalink form WordPress setting , make sure you have the server write access to change . htaccess file) |
100,479 | <p>I have a website with 6000 posts and it is extremely slow.</p>
<p>Sometimes I get this error in my browser: </p>
<pre><code>Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Error: 503 Service Tempora... | [
{
"answer_id": 100512,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 3,
"selected": true,
"text": "<p>Wordpress can be a resource hog if you don't use caching. W3 Total Cache could help you a lot with MySQL, O... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100479",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I have a website with 6000 posts and it is extremely slow.
Sometimes I get this error in my browser:
```
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Error: 503 Service Temporarily Unavailable
```... | Wordpress can be a resource hog if you don't use caching. W3 Total Cache could help you a lot with MySQL, Object and Page Caching. You should also install PHP-APC and use it with the plugin. It can do wonders. |
100,484 | <p>(1) I used the code given on answer to <a href="https://wordpress.stackexchange.com/questions/46547/how-to-use-logout-function-on-custom-menu-link/46549#46549">How to use logout function on custom menu link?</a>
to programmatically add a menu element to <code>wp_nav_menu_objects</code> (Say "Animals"). I give it an ... | [
{
"answer_id": 100496,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 1,
"selected": false,
"text": "<p>you code may be look like this</p>\n\n<pre><code> add_filter( 'wp_nav_menu_objects', 'ravs_add_menu... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33200/"
] | (1) I used the code given on answer to [How to use logout function on custom menu link?](https://wordpress.stackexchange.com/questions/46547/how-to-use-logout-function-on-custom-menu-link/46549#46549)
to programmatically add a menu element to `wp_nav_menu_objects` (Say "Animals"). I give it an id, say 1000.
(2) Simila... | The WordPress functions changed since the answers here in 2014.
As of today (Version 4.6.1) this code will create a main menu named "My Menu" , main item and sub item.
To run code just paste and saves in your functions.php file in your [child theme](https://codex.wordpress.org/Child_Themes).
```
$menu_id = wp_create... |
100,487 | <p>I want the main WordPress post editor to appear below some of my meta boxes (generated by Advanced Custom Fields).</p>
<p>I know there are the <code>add_meta_box()</code> and <code>remove_meta_box()</code> functions, however it'd be really awesome if I could just modify the editor meta box priority without having t... | [
{
"answer_id": 100495,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>The editor is <a href=\"http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/edit-form-advanced.php#L3... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100487",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29/"
] | I want the main WordPress post editor to appear below some of my meta boxes (generated by Advanced Custom Fields).
I know there are the `add_meta_box()` and `remove_meta_box()` functions, however it'd be really awesome if I could just modify the editor meta box priority without having to remove and add it again.
Any ... | To answer my own question, I'll first explain why @s\_ha\_dum's answer doesn't work for me.
I'm using Advanced Custom Fields to add the extra meta boxes, the ones I need to appear above the WordPress editor.
@s\_ha\_dum pointed out that the WordPress editor is [hardcoded within the template](http://core.trac.wordpres... |
100,492 | <p>I'm trying to add an if statement on the sidebars that are displays in POSTS. I want posts to show a specific sidebar if it's in category x and display a different sidebar if it's not in category x.</p>
<p>To do this, i'm trying to use the following code:</p>
<pre><code><?php if ( in_category( 'featured-listing... | [
{
"answer_id": 100494,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p><code>get_sidebar()</code> accepts a parameter <code>$name</code>. Then will look for a file <code>sidebar-{$name}.ph... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26686/"
] | I'm trying to add an if statement on the sidebars that are displays in POSTS. I want posts to show a specific sidebar if it's in category x and display a different sidebar if it's not in category x.
To do this, i'm trying to use the following code:
```
<?php if ( in_category( 'featured-listing' ) || ( in_category( 'l... | `get_sidebar()` accepts a parameter `$name`. Then will look for a file `sidebar-{$name}.php`.
So what you can do is:
```
get_sidebar( get_post_type() ); // search for sidebar-post.php or sidebar-page.php
```
or:
```
if ( in_category( array( 'featured-listing', 'listing-post' ) ) )
get_sidebar( 'listing' ); // ... |
100,507 | <p>Ok, maybe i'm thinking too difficult, but I have 2 stylesheets with the same name. One is from the parent theme folder, and one from the child theme folder.</p>
<p>I want to enqueue the style from the child theme folder AFTER the parent theme style has loaded, so I can overrule some classes.</p>
<p>This is the enq... | [
{
"answer_id": 100494,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p><code>get_sidebar()</code> accepts a parameter <code>$name</code>. Then will look for a file <code>sidebar-{$name}.ph... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33143/"
] | Ok, maybe i'm thinking too difficult, but I have 2 stylesheets with the same name. One is from the parent theme folder, and one from the child theme folder.
I want to enqueue the style from the child theme folder AFTER the parent theme style has loaded, so I can overrule some classes.
This is the enqueue script from ... | `get_sidebar()` accepts a parameter `$name`. Then will look for a file `sidebar-{$name}.php`.
So what you can do is:
```
get_sidebar( get_post_type() ); // search for sidebar-post.php or sidebar-page.php
```
or:
```
if ( in_category( array( 'featured-listing', 'listing-post' ) ) )
get_sidebar( 'listing' ); // ... |
100,515 | <p>My site has a static landing page with buttons to go to Cait's content or Shannons's content. Each author's page will feature their own posts, as well as a section with their social media streams. It is vital that these two author's content is kept separate.
Currently, I'm using conditional tags in the header to tak... | [
{
"answer_id": 100514,
"author": "stellarcowboy",
"author_id": 33207,
"author_profile": "https://wordpress.stackexchange.com/users/33207",
"pm_score": 1,
"selected": false,
"text": "<p>Use an RSS feed widget and grab the RSS feed of the SE site. In the case of this site: <a href=\"https:... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100515",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | My site has a static landing page with buttons to go to Cait's content or Shannons's content. Each author's page will feature their own posts, as well as a section with their social media streams. It is vital that these two author's content is kept separate.
Currently, I'm using conditional tags in the header to take c... | Use an RSS feed widget and grab the RSS feed of the SE site. In the case of this site: <https://wordpress.stackexchange.com/feeds/> |
100,517 | <p>I want to add a button (or rather, a link formatted to look like a button) in the utilities area somewhere above the main navigation menu of a WordPress-based business site (that is, not in the body of a post or page). The purpose of the link is to enable the website visitors to download the company's annual report ... | [
{
"answer_id": 100570,
"author": "Elisha Terada",
"author_id": 33229,
"author_profile": "https://wordpress.stackexchange.com/users/33229",
"pm_score": 0,
"selected": false,
"text": "<p>Does your theme allows you to display a custom content above the menu area? Some themes give you a inpu... | 2013/05/23 | [
"https://wordpress.stackexchange.com/questions/100517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31921/"
] | I want to add a button (or rather, a link formatted to look like a button) in the utilities area somewhere above the main navigation menu of a WordPress-based business site (that is, not in the body of a post or page). The purpose of the link is to enable the website visitors to download the company's annual report to ... | The pdf is itself an attachment post so in wordpress template hierarchy we can create a template named pdf.php Then you can write following code in it which force download the pdf file.
```
<?php
if (have_posts()) :
the_post();
$pdf_title = $post->post_title;
$pdf_src = get_attached_file($post->ID );
$bytes = fil... |
100,549 | <p>Following scenario: I'm building a theme framework which I want to reuse in various themes of mine. In this framework there is a collection of many shortcodes. For exemplary illustration of my problem, let's say one of these shortcodes fetches the recent posts ([recent_posts]) and displays them. </p>
<p>Now, maybe ... | [
{
"answer_id": 100558,
"author": "Elisha Terada",
"author_id": 33229,
"author_profile": "https://wordpress.stackexchange.com/users/33229",
"pm_score": 0,
"selected": false,
"text": "<p>I develop and utilize shortcodes too, and I found passing options as attributes works well. For example... | 2013/05/24 | [
"https://wordpress.stackexchange.com/questions/100549",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5328/"
] | Following scenario: I'm building a theme framework which I want to reuse in various themes of mine. In this framework there is a collection of many shortcodes. For exemplary illustration of my problem, let's say one of these shortcodes fetches the recent posts ([recent\_posts]) and displays them.
Now, maybe I want so... | The first problem you didn’t even mention is: you are putting shortcodes into a theme. [Shortcodes are pure plugin territory](https://wordpress.stackexchange.com/questions/73031/where-to-put-my-code-plugin-or-functions-php), because they are changing post content and must survive a theme switch.
Once you fixed that an... |