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 |
|---|---|---|---|---|---|---|
123,698 | <p>I'm trying to find a way to display related posts that are in a subcategory of a specific parent category based upon the subcategory of the current post. The current post may be assigned to multiple parent categories, but I only want to display related posts of one of the parent category's subcategories. </p>
<p>So... | [
{
"answer_id": 124034,
"author": "Sean Henderson",
"author_id": 40807,
"author_profile": "https://wordpress.stackexchange.com/users/40807",
"pm_score": 0,
"selected": false,
"text": "<p>So here's what I came up with. I don't think that this is the ideal way to code this, but it is doing ... | 2013/11/18 | [
"https://wordpress.stackexchange.com/questions/123698",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40807/"
] | I'm trying to find a way to display related posts that are in a subcategory of a specific parent category based upon the subcategory of the current post. The current post may be assigned to multiple parent categories, but I only want to display related posts of one of the parent category's subcategories.
So for examp... | There is indeed a much simpler way to do this.
First, to get the child category, just check the value of each category's parent. If it's a top-level category, the parent will be 0. So the child category will pass the test `if( 0 != $category->parent )`:
```
$categories = get_the_category();
foreach( $categories as $c... |
123,720 | <p>Right now i am developing a plugin for one of my client according to their need. But I want the plugin hold all the functionality itself including the custom template. I mean my plugin holds the custom template but i don't know that if the template display on the admin post/page section. </p>
<p>Is it possible to d... | [
{
"answer_id": 124034,
"author": "Sean Henderson",
"author_id": 40807,
"author_profile": "https://wordpress.stackexchange.com/users/40807",
"pm_score": 0,
"selected": false,
"text": "<p>So here's what I came up with. I don't think that this is the ideal way to code this, but it is doing ... | 2013/11/19 | [
"https://wordpress.stackexchange.com/questions/123720",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13331/"
] | Right now i am developing a plugin for one of my client according to their need. But I want the plugin hold all the functionality itself including the custom template. I mean my plugin holds the custom template but i don't know that if the template display on the admin post/page section.
Is it possible to display cus... | There is indeed a much simpler way to do this.
First, to get the child category, just check the value of each category's parent. If it's a top-level category, the parent will be 0. So the child category will pass the test `if( 0 != $category->parent )`:
```
$categories = get_the_category();
foreach( $categories as $c... |
123,732 | <p>I'm writing a plugin that checks and collects data from WP - including info about installed plugins.</p>
<p>I can get most of the data I require using <code>get_plugins()</code> - however, I'd also like to check for the latest repository hosted version of each plugin - but I can't seem to find an API method for thi... | [
{
"answer_id": 123737,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>There is not quite <em>simple</em> way to do it, since WP check for plugin updates by submitting all their data in ... | 2013/11/19 | [
"https://wordpress.stackexchange.com/questions/123732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7968/"
] | I'm writing a plugin that checks and collects data from WP - including info about installed plugins.
I can get most of the data I require using `get_plugins()` - however, I'd also like to check for the latest repository hosted version of each plugin - but I can't seem to find an API method for this.
Sorry, I've got n... | Ok - here is a method - thanks to @Rarst for pointing me in the right direction.
Include the require file if the plugins\_api function is not found:
```
if ( ! function_exists( 'plugins_api' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
}
```
Then, prepare a query to pass to plugins\... |
123,750 | <p>I have a WordPress Multi Site installation and several blogs. On the frontpage (domain.com) I have a login form and when the user is logged in, it shows two links at the moment (Admin Panel and Log out). But I also want to include a link that goes to the current blog site of the user, eg: blog.domain.com.</p>
<pre>... | [
{
"answer_id": 123754,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 0,
"selected": false,
"text": "<p>The \"<code>current blog</code>\" in WPMU terms means the blog that is actually shown in the moment. In other ... | 2013/11/19 | [
"https://wordpress.stackexchange.com/questions/123750",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40495/"
] | I have a WordPress Multi Site installation and several blogs. On the frontpage (domain.com) I have a login form and when the user is logged in, it shows two links at the moment (Admin Panel and Log out). But I also want to include a link that goes to the current blog site of the user, eg: blog.domain.com.
```
<li clas... | try use this function,,
```
function get_primary_blog_url($id=null) {
// is there a user to check?
global $current_user;
$user_id = (null != $id ) ? $id : $current_user->ID;
if ( isset( $user_id ) ) {
// Get the blogs of this user
$user_blogs = get_blogs_of_user( $user_id );
// Get the URL of the... |
123,751 | <p>In the past when I created a news post, the featured image was automatically assigned to the post when I uploaded an image in the post.</p>
<p>But now, that doesn't work anymore :(
The only thing that changed was that I installed certain plugins for testing and deactivated them afterwards.</p>
<p>First I found out... | [
{
"answer_id": 123754,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 0,
"selected": false,
"text": "<p>The \"<code>current blog</code>\" in WPMU terms means the blog that is actually shown in the moment. In other ... | 2013/11/19 | [
"https://wordpress.stackexchange.com/questions/123751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42874/"
] | In the past when I created a news post, the featured image was automatically assigned to the post when I uploaded an image in the post.
But now, that doesn't work anymore :(
The only thing that changed was that I installed certain plugins for testing and deactivated them afterwards.
First I found out that I didn't ad... | try use this function,,
```
function get_primary_blog_url($id=null) {
// is there a user to check?
global $current_user;
$user_id = (null != $id ) ? $id : $current_user->ID;
if ( isset( $user_id ) ) {
// Get the blogs of this user
$user_blogs = get_blogs_of_user( $user_id );
// Get the URL of the... |
123,757 | <p>I've made a video custom post type and on the edit page I've placed a meta box where I display a shortcode associated to the post, to make it easier for the user.</p>
<p>However, I wish the shortcode and/or the box to be visible on the edit post page only and not on the new post page, where it's not yet relevant - ... | [
{
"answer_id": 123758,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": 2,
"selected": true,
"text": "<p>Check the post status using get_post_status( $ID ) and then display the html code according to the status. ( i.e )... | 2013/11/19 | [
"https://wordpress.stackexchange.com/questions/123757",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37651/"
] | I've made a video custom post type and on the edit page I've placed a meta box where I display a shortcode associated to the post, to make it easier for the user.
However, I wish the shortcode and/or the box to be visible on the edit post page only and not on the new post page, where it's not yet relevant - what am I ... | Check the post status using get\_post\_status( $ID ) and then display the html code according to the status. ( i.e ) You could simply use if else condition in your php template file to display different content based on the post status. I think new posts have auto-draft status. [get\_post\_status](http://codex.wordpres... |
123,822 | <p>The following code from <a href="https://gist.github.com/mikejolley/1600117" rel="nofollow noreferrer">github</a> will add "- [max price]" to all variable products displayed in product archives.</p>
<p>I am wondering how I could also remove the "From" text inside the same filter.</p>
<pre><code>add_filter('woocomm... | [
{
"answer_id": 123823,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 3,
"selected": true,
"text": "<p>Go with commenting out this line:</p>\n\n<pre><code> if ( !$product->min_variation_price || $prod... | 2013/11/19 | [
"https://wordpress.stackexchange.com/questions/123822",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42934/"
] | The following code from [github](https://gist.github.com/mikejolley/1600117) will add "- [max price]" to all variable products displayed in product archives.
I am wondering how I could also remove the "From" text inside the same filter.
```
add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2... | Go with commenting out this line:
```
if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) $price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>';
```
and this won't be added to the price output. |
123,826 | <p>I'm building a plugin that picks a random post from the database and delivers the result dynamically to the user. For certain aspects I need to know the post ID that's been randomly selected. Session data would work perfectly for this if it weren't for website caching.
When a site is cached, the post that is suppos... | [
{
"answer_id": 123823,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 3,
"selected": true,
"text": "<p>Go with commenting out this line:</p>\n\n<pre><code> if ( !$product->min_variation_price || $prod... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123826",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31714/"
] | I'm building a plugin that picks a random post from the database and delivers the result dynamically to the user. For certain aspects I need to know the post ID that's been randomly selected. Session data would work perfectly for this if it weren't for website caching.
When a site is cached, the post that is supposed ... | Go with commenting out this line:
```
if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) $price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>';
```
and this won't be added to the price output. |
123,831 | <p>I am using the code below to sort by name based on taxonomy and then list the posts within each taxonomy.</p>
<p>First query works ok for alphabetical listing of taxonomies.</p>
<p>The problem i am having is that the posts inside each taxonomy are not listed in alphabetical order. Any ideas?</p>
<pre><code><ul... | [
{
"answer_id": 123845,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 2,
"selected": true,
"text": "<p>Posts are not sorted alphabetically, because you don't tell WordPress to sort them in such way. By def... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123831",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am using the code below to sort by name based on taxonomy and then list the posts within each taxonomy.
First query works ok for alphabetical listing of taxonomies.
The problem i am having is that the posts inside each taxonomy are not listed in alphabetical order. Any ideas?
```
<ul style="margin: 10px 25px 45px ... | Posts are not sorted alphabetically, because you don't tell WordPress to sort them in such way. By default they will be sorted by date in descendant order (newest first).
What you should do, is change your `WP_Query` args by adding `order` and `orderby`, so it should look like this:
```
$args = array(
'post_type'... |
123,843 | <p>I have this function in my <code>functions.php</code></p>
<pre><code><?php
if ( !wp_next_scheduled('re-post2') ) {
wp_schedule_event( time(), 'hourly', 'rep-post2' );
}
function repostads() {
global $wpdb;
$querystr = "
UPDATE $wpdb->posts
INNER JOIN $wpdb->repost
ON $wpdb->posts.... | [
{
"answer_id": 123844,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>And what do you think it should do?</p>\n\n<p>Either you posted here only part of your code or it can... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123843",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41223/"
] | I have this function in my `functions.php`
```
<?php
if ( !wp_next_scheduled('re-post2') ) {
wp_schedule_event( time(), 'hourly', 'rep-post2' );
}
function repostads() {
global $wpdb;
$querystr = "
UPDATE $wpdb->posts
INNER JOIN $wpdb->repost
ON $wpdb->posts.ID = $wpdb->repost.post_id
AND $w... | And what do you think it should do?
Either you posted here only part of your code or it can't do anything that makes sense. The only thing this function does is assigning a value to a variable. This SQL query is never executed, because you don't execute it anywhere in your code.
I guess you want to do something like ... |
123,850 | <p>I have added custom "folder" named Srpski to my permalink structure as you can see in .htaccess file below. So in WP Dashboard > Settings > Permalinks my custom permalink structure looks like this: </p>
<pre>http://webdizajntest.com/poljoprivredni-fakultet/<b>Srpski</b>/%postname%/</pre>
<p>This i working great wh... | [
{
"answer_id": 123844,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>And what do you think it should do?</p>\n\n<p>Either you posted here only part of your code or it can... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38585/"
] | I have added custom "folder" named Srpski to my permalink structure as you can see in .htaccess file below. So in WP Dashboard > Settings > Permalinks my custom permalink structure looks like this:
```
http://webdizajntest.com/poljoprivredni-fakultet/**Srpski**/%postname%/
```
This i working great when i add new pos... | And what do you think it should do?
Either you posted here only part of your code or it can't do anything that makes sense. The only thing this function does is assigning a value to a variable. This SQL query is never executed, because you don't execute it anywhere in your code.
I guess you want to do something like ... |
123,852 | <p>I'm trying to clone a wordpress blog that i have on a internet web server on my local machine. I performed the following steps.</p>
<ol>
<li>Backed up and Restored Mysql DB on localbox</li>
<li>Copied all filesystem files on local box</li>
<li>Changed <code>wp-config.php</code> to reflect local box settings</li>
<l... | [
{
"answer_id": 123844,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>And what do you think it should do?</p>\n\n<p>Either you posted here only part of your code or it can... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23510/"
] | I'm trying to clone a wordpress blog that i have on a internet web server on my local machine. I performed the following steps.
1. Backed up and Restored Mysql DB on localbox
2. Copied all filesystem files on local box
3. Changed `wp-config.php` to reflect local box settings
4. Changed `wp_options` table. Set `wp_opti... | And what do you think it should do?
Either you posted here only part of your code or it can't do anything that makes sense. The only thing this function does is assigning a value to a variable. This SQL query is never executed, because you don't execute it anywhere in your code.
I guess you want to do something like ... |
123,877 | <p>I was trying to get a solution for something that I am trying to accomplish.
I am using the wordpress native and simple gallery to show images in a page called: "gallery"
so far - very simple. it works fine and I have a gallery page with thumbnails.</p>
<p>Now, I would like to show 8 latest photo thumbnails in my h... | [
{
"answer_id": 123896,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>Displaying images from your galleries is going to be labor intensive. \"Galleries\" are saved as shortcodes i... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | I was trying to get a solution for something that I am trying to accomplish.
I am using the wordpress native and simple gallery to show images in a page called: "gallery"
so far - very simple. it works fine and I have a gallery page with thumbnails.
Now, I would like to show 8 latest photo thumbnails in my homepage.
n... | Displaying images from your galleries is going to be labor intensive. "Galleries" are saved as shortcodes in the post body so you would need to:
1. Query your database for posts containing a gallery shortcode
2. Process the post content of the result set to extract the ids of the
gallery images
3. And then use those i... |
123,892 | <p>I'm working on a theme with some options to change the design. For the options I am using the Theme customizer. With the theme customizer there are many option types like color, upload, image upload, background image and header image.
I am adding the background image control with this code:</p>
<pre><code>function ... | [
{
"answer_id": 143002,
"author": "davidcondrey",
"author_id": 45362,
"author_profile": "https://wordpress.stackexchange.com/users/45362",
"pm_score": 2,
"selected": false,
"text": "<p>Here's some code I use which places a control in the Title's and Taglines section to add a logo image..<... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123892",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9186/"
] | I'm working on a theme with some options to change the design. For the options I am using the Theme customizer. With the theme customizer there are many option types like color, upload, image upload, background image and header image.
I am adding the background image control with this code:
```
function tcx_register_t... | Here's some code I use which places a control in the Title's and Taglines section to add a logo image..
```
$wp_customize->add_setting( 'theme_logo' );
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,'theme_logo',array(
'label' => 'Logo',
'section' => 'tit... |
123,900 | <p>I'm using a custom function to create a shortcode that displays the latest blog post on the home page of a template. But I'm trying to NOT have it display any images.</p>
<p>I know I can use the Advanced Excerpt plugin to have it remove images, but the issue is that it will also remove images from the index.php fee... | [
{
"answer_id": 123915,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>If you read the <a href=\"http://codex.wordpress.org/Function_Reference/get_the_excerpt\" rel=\"nofollow\"... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16613/"
] | I'm using a custom function to create a shortcode that displays the latest blog post on the home page of a template. But I'm trying to NOT have it display any images.
I know I can use the Advanced Excerpt plugin to have it remove images, but the issue is that it will also remove images from the index.php feed which I ... | Ok, so I did more digging and testing and I found by using `strip_tags()` basically removes any formatting within `get_the_excerpt()`.
Here's my updated code:
```
function my_recent_news()
{
global $post;
$html = "";
$my_query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 4
)... |
123,902 | <p>I'm working on a plugin derived from this <a href="http://www.wpexplorer.com/how-to-ban-a-wordpress-user/" rel="nofollow noreferrer">tutorial</a>. So far, the plugin adds a checkbox on a user's profile edit page where admins can ban the user.</p>
<p><img src="https://i.stack.imgur.com/scFl6.jpg" alt="checkbox"></p>... | [
{
"answer_id": 123903,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>Use <code>wp_logout()</code>. It calls <code>wp_clear_auth_cookie()</code> and invalidates the current log-in informat... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | I'm working on a plugin derived from this [tutorial](http://www.wpexplorer.com/how-to-ban-a-wordpress-user/). So far, the plugin adds a checkbox on a user's profile edit page where admins can ban the user.

If checked, the user will receive a message upon logging in:
!... | Use `wp_logout()`. It calls `wp_clear_auth_cookie()` and invalidates the current log-in information immediately.
Sample code, not tested:
```
add_action( 'init', 'log_out_banned_user' );
function log_out_banned_user() {
if ( ! is_user_logged_in() )
return;
$user = wp_get_current_user();
if ( ! ... |
123,938 | <p>I realize modifying the core files is frowned against but I strongly believe that the WP core SHOULD NOT rely on external links. In my situation, I'm behind the Great Chinese Firewall, the gravatar sites are blocked. This causes a lag in my page load times. I have a patch in place but I'd like to remove it from my i... | [
{
"answer_id": 123944,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p>You can simply disable gravatars in <code>Settings</code> > <code>Discussion</code> > <code>Avatar Display</code>.<... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123938",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36977/"
] | I realize modifying the core files is frowned against but I strongly believe that the WP core SHOULD NOT rely on external links. In my situation, I'm behind the Great Chinese Firewall, the gravatar sites are blocked. This causes a lag in my page load times. I have a patch in place but I'd like to remove it from my inst... | I still think Rarst's answer is better and that there is no need to remove Gravatar links in the core WordPress files, but ...
The files you are looking for are:
```
/wp-admin/credits.php
/wp-admin/options-discussion.php
/wp-content/plugins/akismet/akismet.js
/wp-includes/pluggable.php
/wp-includes/post-template.php
... |
123,952 | <p>I am wanting to show the current taxonomy product category title in the single product page.</p>
<p>The code below works, but returns all product categories. I need some help singling out the current category.</p>
<pre><code><?php
global $post;
$args = array( 'taxonomy' => 'product_cat',);
$term... | [
{
"answer_id": 123958,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p>In most themes I know this is standard, but yours might differ. Below code is from the <a href=\"ht... | 2013/11/20 | [
"https://wordpress.stackexchange.com/questions/123952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6070/"
] | I am wanting to show the current taxonomy product category title in the single product page.
The code below works, but returns all product categories. I need some help singling out the current category.
```
<?php
global $post;
$args = array( 'taxonomy' => 'product_cat',);
$terms = wp_get_post_terms($post... | In most themes I know this is standard, but yours might differ. Below code is from the [`meta.php`](https://github.com/woothemes/woocommerce/blob/release-2-0-20/templates/single-product/meta.php) file, which is responsible for showing the meta data - categories, tags - in woocommerce.
**Code:**
```
<?php
... |
123,982 | <h2>The scenario:</h2>
<p>This question relates to Wordpress theme development on a local environment via <a href="http://www.mamp.info" rel="nofollow noreferrer">MAMP</a>.</p>
<p>In order to enable mobile device testing via <a href="http://xip.io" rel="nofollow noreferrer">xip.io</a>, I have modified my local Wordpres... | [
{
"answer_id": 123997,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>My quick guess (that code is rather nightmarish to follow) would be that you need to define <code>WP_CONTENT_URL</c... | 2013/11/21 | [
"https://wordpress.stackexchange.com/questions/123982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42984/"
] | The scenario:
-------------
This question relates to Wordpress theme development on a local environment via [MAMP](http://www.mamp.info).
In order to enable mobile device testing via [xip.io](http://xip.io), I have modified my local Wordpress `wp-config.php` file with the following:
```
require_once('b5f-browsers.ph... | Found the solution... the problem was due to placement of the conditional statement in the `wp-config.php` file.
It needed to be inserted *before* the `require_once(ABSPATH . 'wp-settings.php');` line near the bottom of the default config file, otherwise the constants are already defined and cannot be redefined.
So ... |
124,005 | <p>On one of my custom posts edit page I have a button that triggers the media popup onclick, with: <code>wp.media.editor.open();</code> and while it brings up the media manager I'm not sure if that's the proper way to do it. Is it? </p>
<p>But real question is about something else. How do I attach event listeners to ... | [
{
"answer_id": 125084,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 5,
"selected": true,
"text": "<p>You can use several event handlers.</p>\n\n<pre><code>frame.on('open',function() {\n // Do something\n}... | 2013/11/21 | [
"https://wordpress.stackexchange.com/questions/124005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/421/"
] | On one of my custom posts edit page I have a button that triggers the media popup onclick, with: `wp.media.editor.open();` and while it brings up the media manager I'm not sure if that's the proper way to do it. Is it?
But real question is about something else. How do I attach event listeners to various events that m... | You can use several event handlers.
```
frame.on('open',function() {
// Do something
});
frame.on('close',function() {
// Do something
});
frame.on('select',function() {
// Do something
});
```
Where `frame` is a reference to `wp.media()`
```
frame = wp.media();
frame.on('select',function() {
// ... |
124,009 | <p>Am new to WordPress, when I upload any image, WordPress automatic crops into its own sizes which I have not mention in the media section (Settings » Media).</p>
<p>Settings which I saved in media is:<br/>
<img src="https://i.stack.imgur.com/6Gl0k.jpg" alt="Setting which i saved in media."></p>
<p>And when I ... | [
{
"answer_id": 124010,
"author": "Gerald Schneider",
"author_id": 11355,
"author_profile": "https://wordpress.stackexchange.com/users/11355",
"pm_score": 2,
"selected": false,
"text": "<p>Plugins and Themes can define their own thumbnail sizes. WordPress will convert all newly uploaded i... | 2013/11/21 | [
"https://wordpress.stackexchange.com/questions/124009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42997/"
] | Am new to WordPress, when I upload any image, WordPress automatic crops into its own sizes which I have not mention in the media section (Settings » Media).
Settings which I saved in media is:

And when I check in the directory it crop automati... | WordPress by default is designed to generate 3 types of cropping of any uploaded images (Media):
* Thumbnail (typically 150px × 150px)
* Medium (typically 300px × 300px)
* Large (typically 1024px × 1024px)
It's to ensure site speed with different sizes where necessary. So, with uploading the Original image there woul... |
124,030 | <p>I need to find out the number of times a term/tag or category is used in a post in WordPress. I wrote the below SQL query.</p>
<pre><code>SELECT t.name , count(*)FROM wp_terms t
JOIN wp_term_taxonomy tt ON tt.term_taxonomy_id = t.term_id
JOIN wp_term_relationships tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
JOI... | [
{
"answer_id": 124032,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 0,
"selected": false,
"text": "<p>If the taxonomy is only attached to one post type, you can just use the <code>term_taxonomy.count</code> ... | 2013/11/21 | [
"https://wordpress.stackexchange.com/questions/124030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43005/"
] | I need to find out the number of times a term/tag or category is used in a post in WordPress. I wrote the below SQL query.
```
SELECT t.name , count(*)FROM wp_terms t
JOIN wp_term_taxonomy tt ON tt.term_taxonomy_id = t.term_id
JOIN wp_term_relationships tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
JOIN wp_posts p O... | `Wp_Query` should be able to do this for you. Pass it the appropriate parameters, including a `tax_query`, and check `found_posts`.
```
$p = new WP_Query(
array(
'post_type' => 'custcpt', // your CPT
'tax_query' => array(
array(
'taxonomy' => 'custtax', // your tax
'field' => 'id',
... |
124,037 | <p>Trying to figure out how I can output my posts based on category title (a–z) and secondly, the title of the posts within the category:</p>
<p>A CATEGORY<br>
– A post beginning with a<br>
– Because I want to be output second<br>
– Come on, and output me already<br></p>
<p>B CATEGORY<br>
– Another post beginning wit... | [
{
"answer_id": 125638,
"author": "user564285",
"author_id": 18958,
"author_profile": "https://wordpress.stackexchange.com/users/18958",
"pm_score": -1,
"selected": false,
"text": "<p>You can use <code>orderby</code> parameter for a new <code>wp_query</code> instance:</p>\n\n<pre><code>$q... | 2013/11/21 | [
"https://wordpress.stackexchange.com/questions/124037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2830/"
] | Trying to figure out how I can output my posts based on category title (a–z) and secondly, the title of the posts within the category:
A CATEGORY
– A post beginning with a
– Because I want to be output second
– Come on, and output me already
B CATEGORY
– Another post beginning with a
– Bother, can't ... | To get them broken down by Category, you need to loop through the list of categories and then query on each category:
```
$categories = get_categories( array ('orderby' => 'name', 'order' => 'asc' ) );
foreach ($categories as $category) {
echo "Category is: $category->name <br/>";
$catPosts = new WP_Query( ar... |
124,039 | <p>In my custom plugin, I have a custom post type and have a custom meta box for it. I have few fields in it, one of it is a check box. I want this check box to be checked by default when I go for a <code>add new post</code> and then proceed with the selection of the user ie checked/not checked.</p>
<p>I am adding the... | [
{
"answer_id": 124042,
"author": "Joey Yax",
"author_id": 6148,
"author_profile": "https://wordpress.stackexchange.com/users/6148",
"pm_score": 1,
"selected": false,
"text": "<p>If the post is new the value of <code>get_post_meta( $post->ID, 'coupon_status' )</code> will be <code>null... | 2013/11/21 | [
"https://wordpress.stackexchange.com/questions/124039",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37890/"
] | In my custom plugin, I have a custom post type and have a custom meta box for it. I have few fields in it, one of it is a check box. I want this check box to be checked by default when I go for a `add new post` and then proceed with the selection of the user ie checked/not checked.
I am adding the related codes ie: fo... | `save_post` being called multiple times is expected behavior, but because of how it’s used, you may not always want your code to execute until the user actually clicks on the save button. Like you have mentioned above regarding your requirement.
So you can check the current page ( i.e `post-new.php` ) in the wp-admin ... |
124,074 | <p>I am trying to hide the Alignment radio buttons for images uploaded to the post content area, but can't figure out how to add a custom CSS or JS file to the Image Editor dialog.</p>
<p>I've successfully added a filter to the tiny_mce_before_init action hook to remove alignment buttons from the TinyMCE text editor, ... | [
{
"answer_id": 126053,
"author": "BenFreke",
"author_id": 32803,
"author_profile": "https://wordpress.stackexchange.com/users/32803",
"pm_score": -1,
"selected": false,
"text": "<p>The function you're looking for, to add CSS to the MCE editor is called <a href=\"http://codex.wordpress.or... | 2013/11/21 | [
"https://wordpress.stackexchange.com/questions/124074",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42963/"
] | I am trying to hide the Alignment radio buttons for images uploaded to the post content area, but can't figure out how to add a custom CSS or JS file to the Image Editor dialog.
I've successfully added a filter to the tiny\_mce\_before\_init action hook to remove alignment buttons from the TinyMCE text editor, but am ... | Looking at it in detail it seems that you can't alter the image editor just in some details. The only thing you can do is to replace the image editor with a slightly modified copy. I'll explain shortly how this can be done.
>
> **But before that a word of warning. The Image Editor is currently (2/2014) worked on, so ... |
124,100 | <p>First the code:</p>
<pre><code>function itsme_better_editions( $query ) {
if ( $query->is_category() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post' ) );
// Get current tax query
$tax_query = $query->get( 'tax_query' );
$tax_query['rel... | [
{
"answer_id": 124404,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>AFAIK <code>$query->get</code> for main query works only with public query vars, i.e. vars that can be trig... | 2013/11/22 | [
"https://wordpress.stackexchange.com/questions/124100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | First the code:
```
function itsme_better_editions( $query ) {
if ( $query->is_category() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post' ) );
// Get current tax query
$tax_query = $query->get( 'tax_query' );
$tax_query['relation'] = 'OR';
$tax_quer... | AFAIK `$query->get` for main query works only with public query vars, i.e. vars that can be triggered via url, but nothing prevents to directly access directly to `tax_query` property of query, but notice that it is an object, instance of [`WP_Tax_Query`](http://phpdoc.wordpress.org/branches/3.6/WordPress/Taxonomy/WP_T... |
124,104 | <p>I have a WordPress network with multiple sites using the same theme. Now I need to edit part of a certain <code>PageTemplate.php</code> to display different things based on the <code>blog id</code>.</p>
<p>Example:</p>
<p><em>If blog ID 1, run this:</em></p>
<pre><code><a href="<?php if(get_post_meta($post-... | [
{
"answer_id": 124106,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 3,
"selected": false,
"text": "<p>You can do it like this:</p>\n\n<pre><code><?php\n $blog_id = get_current_blog_id();\n if ( 1 == $blog_... | 2013/11/22 | [
"https://wordpress.stackexchange.com/questions/124104",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25552/"
] | I have a WordPress network with multiple sites using the same theme. Now I need to edit part of a certain `PageTemplate.php` to display different things based on the `blog id`.
Example:
*If blog ID 1, run this:*
```
<a href="<?php if(get_post_meta($post->ID, 'videoembed_videopopup', true)): ?><?php echo get_post_met... | You can do it like this:
```
<?php
$blog_id = get_current_blog_id();
if ( 1 == $blog_id ) {
?>
<!-- Your FIRST code block here -->
<?php } else { ?>
<!-- Your SECOND code block here -->
<?php } ?>
```
---
Here's the whole prettified version of the code you can use (totally UNTESTED, but should work unless... |
124,120 | <p>I'm following the instructions from <a href="http://codex.wordpress.org/remove_node#Remove_the_WordPress_Logo_from_the_Toolbar" rel="nofollow">this page to remove the adminbar wordpress logo</a> and cannot quite understand why this is not working in a plugin I have created.</p>
<pre><code>// Hide top left WordPress... | [
{
"answer_id": 124126,
"author": "Charles",
"author_id": 15605,
"author_profile": "https://wordpress.stackexchange.com/users/15605",
"pm_score": 3,
"selected": true,
"text": "<p>This one does the job for us, we use WP3.7.1.<br /></p>\n\n<pre><code>function no_wp_logo_admin_bar_remove() {... | 2013/11/22 | [
"https://wordpress.stackexchange.com/questions/124120",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12589/"
] | I'm following the instructions from [this page to remove the adminbar wordpress logo](http://codex.wordpress.org/remove_node#Remove_the_WordPress_Logo_from_the_Toolbar) and cannot quite understand why this is not working in a plugin I have created.
```
// Hide top left WordPress logo
add_action( 'admin_bar_menu', 're... | This one does the job for us, we use WP3.7.1.
```
function no_wp_logo_admin_bar_remove() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'no_wp_logo_admin_bar_remove', 0);
``` |
124,150 | <p>I currently have a custom post type called 'events'. I created this from a tutorial here <a href="http://tatiyants.com/how-to-use-wordpress-custom-post-types-to-add-events-to-your-site/" rel="nofollow">http://tatiyants.com/how-to-use-wordpress-custom-post-types-to-add-events-to-your-site/</a>. I want to query the da... | [
{
"answer_id": 124151,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>This will query / show all future <code>posts</code> - standard WP Query surrounded by 2 filters, 1 to add ... | 2013/11/22 | [
"https://wordpress.stackexchange.com/questions/124150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43041/"
] | I currently have a custom post type called 'events'. I created this from a tutorial here <http://tatiyants.com/how-to-use-wordpress-custom-post-types-to-add-events-to-your-site/>. I want to query the date to only show the posts with dates coming up and not ones on the past. `$event_date >= time`
However in the tutoria... | You want to query for posts with `event_date` in the future but you have saved (or so it seems from a comment), your dates as:
```
date("F", $unixtime)." ".date("d", $unixtime).", ".date("Y", $unixtime);
```
That is "textual month name" + "numeric day" + "numeric year". There is no way to query/sort that format so t... |
124,155 | <p>I run wordpress on nginx + php-fpm in a subfolder <code>abc</code>. I want to upload images into a <a href="http://wordpress.org/plugins/nextgen-gallery/" rel="nofollow">NextgenGallery</a> and the ajax-based uploader yields this:</p>
<pre><code>POST 404 for http://example.com/abc/index.php/photocrati_ajax
</code></... | [
{
"answer_id": 124151,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>This will query / show all future <code>posts</code> - standard WP Query surrounded by 2 filters, 1 to add ... | 2013/11/22 | [
"https://wordpress.stackexchange.com/questions/124155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1373/"
] | I run wordpress on nginx + php-fpm in a subfolder `abc`. I want to upload images into a [NextgenGallery](http://wordpress.org/plugins/nextgen-gallery/) and the ajax-based uploader yields this:
```
POST 404 for http://example.com/abc/index.php/photocrati_ajax
```
Obviously the rewrite in the `nginx.conf` does not wor... | You want to query for posts with `event_date` in the future but you have saved (or so it seems from a comment), your dates as:
```
date("F", $unixtime)." ".date("d", $unixtime).", ".date("Y", $unixtime);
```
That is "textual month name" + "numeric day" + "numeric year". There is no way to query/sort that format so t... |
124,161 | <p>I am working with BuddyPress 1.7. I need to add a text field under under the activity/update text area and capture that data when an update is posted. Any help to help to get me started would be much appreciated.</p>
<p>I see the <code>post-form.php</code> file that contains the HTML form elements but how can my ... | [
{
"answer_id": 124151,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>This will query / show all future <code>posts</code> - standard WP Query surrounded by 2 filters, 1 to add ... | 2013/11/22 | [
"https://wordpress.stackexchange.com/questions/124161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43044/"
] | I am working with BuddyPress 1.7. I need to add a text field under under the activity/update text area and capture that data when an update is posted. Any help to help to get me started would be much appreciated.
I see the `post-form.php` file that contains the HTML form elements but how can my text box be added using... | You want to query for posts with `event_date` in the future but you have saved (or so it seems from a comment), your dates as:
```
date("F", $unixtime)." ".date("d", $unixtime).", ".date("Y", $unixtime);
```
That is "textual month name" + "numeric day" + "numeric year". There is no way to query/sort that format so t... |
124,179 | <p>I have a wordpress theme that I am modifying the look and feel by making a child theme.</p>
<p>The parent theme I am using uses the redux framework.</p>
<p>Im a bit new to using filters and hooks, but I want to add/modify a section on the options page.</p>
<p>I found a function to add sections through the child t... | [
{
"answer_id": 128283,
"author": "Dovy",
"author_id": 44585,
"author_profile": "https://wordpress.stackexchange.com/users/44585",
"pm_score": 3,
"selected": false,
"text": "<p>I'm the lead dev for Redux Framework. This is because you use the same function name. You must change the <code>... | 2013/11/22 | [
"https://wordpress.stackexchange.com/questions/124179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35203/"
] | I have a wordpress theme that I am modifying the look and feel by making a child theme.
The parent theme I am using uses the redux framework.
Im a bit new to using filters and hooks, but I want to add/modify a section on the options page.
I found a function to add sections through the child theme but I don't know ho... | I'm the lead dev for Redux Framework. This is because you use the same function name. You must change the `add_another_section` name to something less common. Otherwise you'll always get an error. That's unfortunately a limitation of PHP. One name per function per instance. |
124,198 | <p>I'm using the following code, placed in the functions.php of my theme, to hide certain categories used to organise posts and populate sliders from the posts themselves and their category listings:</p>
<pre><code>function the_category_filter($thelist,$separator=' ') {
// list the IDs of the categories to exclude
$... | [
{
"answer_id": 124199,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>Just don't apply the filter if <a href=\"http://codex.wordpress.org/Function_Reference/is_admin\" rel=\"nofollow\"... | 2013/11/22 | [
"https://wordpress.stackexchange.com/questions/124198",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29435/"
] | I'm using the following code, placed in the functions.php of my theme, to hide certain categories used to organise posts and populate sliders from the posts themselves and their category listings:
```
function the_category_filter($thelist,$separator=' ') {
// list the IDs of the categories to exclude
$exclude = arra... | Just don't apply the filter if [`is_admin()`](http://codex.wordpress.org/Function_Reference/is_admin).
Unrelated- you should also take a look at [`add_filter`](http://codex.wordpress.org/Function_Reference/add_filter), your arguments are not correct. |
124,233 | <p>I want to:</p>
<ul>
<li>Control the name of the Posts post type, like I can with custom post types</li>
<li>Set an archive page for posts e.g. example.com/posts, like with custom post types</li>
<li>Control the archive slug, like I can for custom post types</li>
</ul>
<p>But I can't. I can create a new post type a... | [
{
"answer_id": 124243,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": true,
"text": "<p>You can use the globals <code>$menu</code>, <code>$submenu</code> and <code>$wp_post_types</code> fo... | 2013/11/23 | [
"https://wordpress.stackexchange.com/questions/124233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8698/"
] | I want to:
* Control the name of the Posts post type, like I can with custom post types
* Set an archive page for posts e.g. example.com/posts, like with custom post types
* Control the archive slug, like I can for custom post types
But I can't. I can create a new post type and `unregister_post_type('posts')`. Wait f... | You can use the globals `$menu`, `$submenu` and `$wp_post_types` for renaming.
**Code:**
```
function wpse124233_alter_builtin_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = __( 'YourName' );
$submenu['edit.php'][5][0] = __( 'YourName' );
$submenu['edit.ph... |
124,236 | <p>I am trying to add a shortcode from a plugin to my custom metabox. I have read it isn't the done thing but in this case i do need it to work. The client might not add a video but might add an image into it or something is so need to make sure it can still work for standard content.</p>
<p>The issue I am having is t... | [
{
"answer_id": 124237,
"author": "Andrei Surdu",
"author_id": 31111,
"author_profile": "https://wordpress.stackexchange.com/users/31111",
"pm_score": 0,
"selected": false,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/do_shortcode\" rel=\"nofollow\"><code>do_sho... | 2013/11/23 | [
"https://wordpress.stackexchange.com/questions/124236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36308/"
] | I am trying to add a shortcode from a plugin to my custom metabox. I have read it isn't the done thing but in this case i do need it to work. The client might not add a video but might add an image into it or something is so need to make sure it can still work for standard content.
The issue I am having is that it is ... | I noticed that your are using `get_the_content()`, but it will return unfiltered content.
The shortcodes are generated via the `the_content` filter with priority `11`.
So if you want
* only the shortcodes generated, try:
```
'content' => do_shortcode( get_the_content() )
```
* to filter it through `the_content` f... |
124,241 | <p>Many of my Wordpress Blog(<a href="http://subinsb.com/" rel="nofollow">http://subinsb.com/</a>) posts have code snippets which is wrapped in <strong>blockquote</strong> elements. I need to highlight these code snippets. I tried using <strong>GeSHi</strong>, <strong>Prettify Code Syntax</strong>, <strong>CodeColorer<... | [
{
"answer_id": 124247,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 2,
"selected": false,
"text": "<p>First of all you should use the standard <code>pre</code> and <code>code</code> elements instead of blockq... | 2013/11/23 | [
"https://wordpress.stackexchange.com/questions/124241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41326/"
] | Many of my Wordpress Blog(<http://subinsb.com/>) posts have code snippets which is wrapped in **blockquote** elements. I need to highlight these code snippets. I tried using **GeSHi**, **Prettify Code Syntax**, **CodeColorer** but none of them works for **blockquote** elements. Is there any plugin that supports code hi... | First of all you should use the standard `pre` and `code` elements instead of blockquotes. But if have too many to change them, there might be a workaround.
If you only use blockquotes for code, then you can use a bit of jQuery to convert those to `pre` tags, but make sure to do that before Prettify is loaded.
I don... |
124,258 | <p>I am trying to figure out how to assign a seperate stylesheet for different pages? I wan't to use the same stylesheet for my front page, and page template and a different stylesheet for my blog and it's related pages.</p>
<p>My theme only consists of a front page, a page template and a blog. So I would somehow need... | [
{
"answer_id": 124260,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>What you are looking for are the <a href=\"http://codex.wordpress.org/Conditional_Tags\" rel=\"nofollow\">co... | 2013/11/23 | [
"https://wordpress.stackexchange.com/questions/124258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | I am trying to figure out how to assign a seperate stylesheet for different pages? I wan't to use the same stylesheet for my front page, and page template and a different stylesheet for my blog and it's related pages.
My theme only consists of a front page, a page template and a blog. So I would somehow need to figure... | The correct method is to *enqueue* the stylesheets, via callback hooked into `wp_enqueue_scripts`. You can add the contextual conditionals inside the callback:
```
function wpse124258_enqueue_scripts() {
if ( ! is_admin() ) {
// Conditionally enqueue
if ( is_front_page() ) {
// Fron... |
124,277 | <p>I'm searching, unsuccessfully unfortunately, for a ThickBox replacement used in Media Uploader.</p>
<p>Any search fails on how to leverage Media Uploader and nothing about a script used for modal windows.</p>
<p>Can somebody help me? Is there a way to use the same modal as Media Uploader is using, but to put custo... | [
{
"answer_id": 124260,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>What you are looking for are the <a href=\"http://codex.wordpress.org/Conditional_Tags\" rel=\"nofollow\">co... | 2013/11/24 | [
"https://wordpress.stackexchange.com/questions/124277",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38695/"
] | I'm searching, unsuccessfully unfortunately, for a ThickBox replacement used in Media Uploader.
Any search fails on how to leverage Media Uploader and nothing about a script used for modal windows.
Can somebody help me? Is there a way to use the same modal as Media Uploader is using, but to put custom content in it l... | The correct method is to *enqueue* the stylesheets, via callback hooked into `wp_enqueue_scripts`. You can add the contextual conditionals inside the callback:
```
function wpse124258_enqueue_scripts() {
if ( ! is_admin() ) {
// Conditionally enqueue
if ( is_front_page() ) {
// Fron... |
124,296 | <p>Hi & thanks in advance to those who could help me sot out he below:</p>
<ul>
<li>I have customized my home page, using tpl-home.php to show the authors (eg users...) of the most recent posts - nothing specific yet...-.</li>
<li>I have customs fields (using ACF) and customs taxonomies, among which the 'member' ta... | [
{
"answer_id": 124301,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 1,
"selected": false,
"text": "<p>From reading your question, I assume the following things.</p>\n\n<ul>\n<li>Your post(s) are related to a... | 2013/11/24 | [
"https://wordpress.stackexchange.com/questions/124296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42951/"
] | Hi & thanks in advance to those who could help me sot out he below:
* I have customized my home page, using tpl-home.php to show the authors (eg users...) of the most recent posts - nothing specific yet...-.
* I have customs fields (using ACF) and customs taxonomies, among which the 'member' taxonomy.
Some members can... | From reading your question, I assume the following things.
* Your post(s) are related to an author (user)
* Your post(s) are related to a term in the Custom Taxonomy "members", which would have the same slug as a users nicename/username/something.
First, may I recommend losing the 'Members' taxonomy, as Users already... |
124,303 | <p>How do you set the <code>posts_per_page</code> query setting so that a different number of posts are displayed on the first of the paginated pages (of home, archive, search, etc.) and the rest of them?</p>
<p>For example, say I'd like to display 10 posts on the first of the paginated pages of category archives, and... | [
{
"answer_id": 124426,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 4,
"selected": true,
"text": "<h2>Case #1: Simple Offset</h2>\n\n<p>You want to 'offset' posts of a category archive by 'n', i.e. you simply don... | 2013/11/24 | [
"https://wordpress.stackexchange.com/questions/124303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | How do you set the `posts_per_page` query setting so that a different number of posts are displayed on the first of the paginated pages (of home, archive, search, etc.) and the rest of them?
For example, say I'd like to display 10 posts on the first of the paginated pages of category archives, and 15 on the rest of th... | Case #1: Simple Offset
----------------------
You want to 'offset' posts of a category archive by 'n', i.e. you simply don't want to show the first/latest 'n' posts in an archive.
That is, (considering the `posts_per_page` setting in *WP Dashboard > Settings > Reading* is set to 10) you want posts 11 to 20 to be show... |
124,304 | <p>I want to change the default comment form title_reply, label_submit ... just on my CPT without affecting the default comment form but I can't get it to work without affecting the default ones.</p>
<p><strong>First</strong> I don't want to output the comment form if CPT and user isn't logged in, I'm doing this with ... | [
{
"answer_id": 124426,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 4,
"selected": true,
"text": "<h2>Case #1: Simple Offset</h2>\n\n<p>You want to 'offset' posts of a category archive by 'n', i.e. you simply don... | 2013/11/24 | [
"https://wordpress.stackexchange.com/questions/124304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12572/"
] | I want to change the default comment form title\_reply, label\_submit ... just on my CPT without affecting the default comment form but I can't get it to work without affecting the default ones.
**First** I don't want to output the comment form if CPT and user isn't logged in, I'm doing this with this code:
```
// D... | Case #1: Simple Offset
----------------------
You want to 'offset' posts of a category archive by 'n', i.e. you simply don't want to show the first/latest 'n' posts in an archive.
That is, (considering the `posts_per_page` setting in *WP Dashboard > Settings > Reading* is set to 10) you want posts 11 to 20 to be show... |
124,312 | <p><strong>Use case (example):</strong> Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query.</p>
<p>I don't want the 5 featured posts, i.e. the first 5 posts tagged 'highlights', to appear among the latest pos... | [
{
"answer_id": 124426,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 4,
"selected": true,
"text": "<h2>Case #1: Simple Offset</h2>\n\n<p>You want to 'offset' posts of a category archive by 'n', i.e. you simply don... | 2013/11/24 | [
"https://wordpress.stackexchange.com/questions/124312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | **Use case (example):** Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query.
I don't want the 5 featured posts, i.e. the first 5 posts tagged 'highlights', to appear among the latest posts.
To put it another ... | Case #1: Simple Offset
----------------------
You want to 'offset' posts of a category archive by 'n', i.e. you simply don't want to show the first/latest 'n' posts in an archive.
That is, (considering the `posts_per_page` setting in *WP Dashboard > Settings > Reading* is set to 10) you want posts 11 to 20 to be show... |
124,330 | <p>I was wondering : You are an administrator : when you re-order the layout of your meta-box, in a page, or in a post, this layout is saved with your user profil : for example you drag the category box before the publish box...</p>
<p>Is it possible to save this layout for other users (editors, authors..) ?</p>
<p>I... | [
{
"answer_id": 124337,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>This is a rough outline but something like this should work:</p>\n\n<ol>\n<li>Assume there is a some \"maste... | 2013/11/24 | [
"https://wordpress.stackexchange.com/questions/124330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43023/"
] | I was wondering : You are an administrator : when you re-order the layout of your meta-box, in a page, or in a post, this layout is saved with your user profil : for example you drag the category box before the publish box...
Is it possible to save this layout for other users (editors, authors..) ?
Is it possible to ... | This is a rough outline but something like this should work:
1. Assume there is a some "master" user with a known user ID-- your
administrator or a user created for this purpose.
2. When meta boxes are displayed, [user settings are checked](http://core.trac.wordpress.org/browser/tags/3.7.1/src/wp-admin/includes/templa... |
124,342 | <p>I am developing a custom WP plugin for a client and I wish to make sure that the client does not install it on any other domain other than the one specified. If the client tries to install the plugin on other domains, it should throw out an exception and plugin should get deactivated or self destruct. </p>
<p>How ... | [
{
"answer_id": 124343,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>You could use a combination of the file content and the domain to create a unique hash.</p>\n\n<p>Example:</p>\n\n<pre... | 2013/11/25 | [
"https://wordpress.stackexchange.com/questions/124342",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34472/"
] | I am developing a custom WP plugin for a client and I wish to make sure that the client does not install it on any other domain other than the one specified. If the client tries to install the plugin on other domains, it should throw out an exception and plugin should get deactivated or self destruct.
How can I make ... | You could use a combination of the file content and the domain to create a unique hash.
Example:
```
$md5 = md5( file_get_contents( __FILE__ ) . $_SERVER['HTTP_HOST'] );
if ( 'be5d38f32a5d4a897e6c878f0c2f1b14' !== $md5 )
deactivate_plugins( plugin_basename( __FILE__ ) );
```
Additionally, you could check each w... |
124,348 | <p>How should I write <code>if</code> condition to display specific code only when I enter this page:</p>
<pre><code>/wordpress/wp-admin/post-new.php?post_type=slideshow
</code></pre>
<p>This is what i was trying to get ;) Thanks to Krzysiek!</p>
<pre><code>function plu_admin_enqueue($hook) {
$screen = get_current... | [
{
"answer_id": 124353,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>I would use <a href=\"http://codex.wordpress.org/Function_Reference/get_current_screen\" rel=\"nofollo... | 2013/11/25 | [
"https://wordpress.stackexchange.com/questions/124348",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40492/"
] | How should I write `if` condition to display specific code only when I enter this page:
```
/wordpress/wp-admin/post-new.php?post_type=slideshow
```
This is what i was trying to get ;) Thanks to Krzysiek!
```
function plu_admin_enqueue($hook) {
$screen = get_current_screen();
if ( 'post.php' == $hook && $screen-... | I would use [`get_current_screen();`](http://codex.wordpress.org/Function_Reference/get_current_screen) to do this. It returns a [WP\_Screen](http://codex.wordpress.org/Class_Reference/WP_Screen) object.
You should remember that this function will return NULL if it's called before `admin_init` action.
In your case it... |
124,352 | <p>I have added a new column to 'wp_bp_groups_members' table it's called 'relationship'. Now I want to get data from that column. I have to pass user_id and group_id to get that data.</p>
| [
{
"answer_id": 124437,
"author": "Sasindu H",
"author_id": 43108,
"author_profile": "https://wordpress.stackexchange.com/users/43108",
"pm_score": 0,
"selected": false,
"text": "<p>Creating a new function in bp-groups-template.php file.</p>\n\n<pre><code>function get_relationship($group_... | 2013/11/25 | [
"https://wordpress.stackexchange.com/questions/124352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43108/"
] | I have added a new column to 'wp\_bp\_groups\_members' table it's called 'relationship'. Now I want to get data from that column. I have to pass user\_id and group\_id to get that data. | Simpler solution:
```
function get_relationship($group_id,$user_id) {
global $wpdb;
$relationships = $wpdb->get_col("SELECT relationship FROM wp_bp_groups_members WHERE group_id = $group_id AND user_id = $user_id");
if ( !empty( $relationships ) ) {
foreach ( $relationships as $relationship ) {
... |
124,373 | <p>I have a problem and I don't know how to solve it. I tried some solutions but I failed since I am not good programer.
I also tried to find a solution, but there is no similar question asked.
So... here is the problem.</p>
<p>I have a custom post type called "Arrangements", and one of the custom fields associated wi... | [
{
"answer_id": 124437,
"author": "Sasindu H",
"author_id": 43108,
"author_profile": "https://wordpress.stackexchange.com/users/43108",
"pm_score": 0,
"selected": false,
"text": "<p>Creating a new function in bp-groups-template.php file.</p>\n\n<pre><code>function get_relationship($group_... | 2013/11/25 | [
"https://wordpress.stackexchange.com/questions/124373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37464/"
] | I have a problem and I don't know how to solve it. I tried some solutions but I failed since I am not good programer.
I also tried to find a solution, but there is no similar question asked.
So... here is the problem.
I have a custom post type called "Arrangements", and one of the custom fields associated with that CP... | Simpler solution:
```
function get_relationship($group_id,$user_id) {
global $wpdb;
$relationships = $wpdb->get_col("SELECT relationship FROM wp_bp_groups_members WHERE group_id = $group_id AND user_id = $user_id");
if ( !empty( $relationships ) ) {
foreach ( $relationships as $relationship ) {
... |
124,422 | <p>This is proving to be a challenge.</p>
<p>I'm trying to make the excerpt a required field, but only when editing/saving a post in a custom post type.</p>
<p>The following code makes the excerpt a required field for all posts, but doesn't take into account for narrowing its affect to a single custom post type.</p>
... | [
{
"answer_id": 124427,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 4,
"selected": true,
"text": "<p>The code adds a filter to <code>wp_insert_post_data</code>:</p>\n\n<pre><code>add_filter('wp_insert_post_da... | 2013/11/25 | [
"https://wordpress.stackexchange.com/questions/124422",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25430/"
] | This is proving to be a challenge.
I'm trying to make the excerpt a required field, but only when editing/saving a post in a custom post type.
The following code makes the excerpt a required field for all posts, but doesn't take into account for narrowing its affect to a single custom post type.
```
function mandato... | The code adds a filter to `wp_insert_post_data`:
```
add_filter('wp_insert_post_data', 'mandatory_excerpt');
```
And here's the callback:
```
function mandatory_excerpt($data) {
$excerpt = $data['post_excerpt'];
if (empty($excerpt)) {
if ($data['post_status'] === 'publish') {
add_filter('redirect_pos... |
124,446 | <p>In general a function that hooks into the <code>found_posts</code> filter looks like this:</p>
<pre><code>add_filter( 'found_posts', 'adjust_offset_pagination', 10, 2 );
function adjust_offset_pagination( $found_posts, $query ) {
$offset = 10;
if ( $query->is_posts_page ) {
return( $found_posts... | [
{
"answer_id": 124453,
"author": "Twifty",
"author_id": 36977,
"author_profile": "https://wordpress.stackexchange.com/users/36977",
"pm_score": 0,
"selected": false,
"text": "<p>Due to the nature of PHP's variable handling, they are all interchangable. I would guess that <code>$found_pos... | 2013/11/25 | [
"https://wordpress.stackexchange.com/questions/124446",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | In general a function that hooks into the `found_posts` filter looks like this:
```
add_filter( 'found_posts', 'adjust_offset_pagination', 10, 2 );
function adjust_offset_pagination( $found_posts, $query ) {
$offset = 10;
if ( $query->is_posts_page ) {
return( $found_posts - $offset );
}
}
```
... | Almost all integers in WordPress are treated as strings.
If you try to `var_dump($post->ID);` inside a loop you notice also post id is a string.
Normally this is not a problem because of PHP auto type casting feature.
This can be a problem, when you do strict comparison, like `1 === $post->ID` or `in_array(1, $ids, ... |
124,459 | <p>I'm try to get the output of this post type to order by the staff name alphabetically and I can't seem to figure out if needs to be within the beginning <code>array()</code> or if I been do something within the <code>foreach()</code> loop.</p>
<p>Here's my constructed loop:</p>
<pre><code> <?php
$mypost = arra... | [
{
"answer_id": 124453,
"author": "Twifty",
"author_id": 36977,
"author_profile": "https://wordpress.stackexchange.com/users/36977",
"pm_score": 0,
"selected": false,
"text": "<p>Due to the nature of PHP's variable handling, they are all interchangable. I would guess that <code>$found_pos... | 2013/11/25 | [
"https://wordpress.stackexchange.com/questions/124459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16613/"
] | I'm try to get the output of this post type to order by the staff name alphabetically and I can't seem to figure out if needs to be within the beginning `array()` or if I been do something within the `foreach()` loop.
Here's my constructed loop:
```
<?php
$mypost = array('post_type' => 'staff', 'posts_per_page' => ... | Almost all integers in WordPress are treated as strings.
If you try to `var_dump($post->ID);` inside a loop you notice also post id is a string.
Normally this is not a problem because of PHP auto type casting feature.
This can be a problem, when you do strict comparison, like `1 === $post->ID` or `in_array(1, $ids, ... |
124,473 | <p>I use <a href="/questions/tagged/disqus" class="post-tag" title="show questions tagged 'disqus'" rel="tag">disqus</a> to handle comments on my blog.</p>
<p>I also like to have pingbacks from various posts back and forth to each other (and from outside sources.</p>
<p>However, I noticed today that while the... | [
{
"answer_id": 156647,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>The plugin you mentioned is only a single function so it shouldn't be too heavy on your setup. It uses the <co... | 2013/11/25 | [
"https://wordpress.stackexchange.com/questions/124473",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5173/"
] | I use [disqus](/questions/tagged/disqus "show questions tagged 'disqus'") to handle comments on my blog.
I also like to have pingbacks from various posts back and forth to each other (and from outside sources.
However, I noticed today that while the comment count at the bottom of a post will show the total number of ... | The plugin you mentioned is only a single function so it shouldn't be too heavy on your setup. It uses the `comments_template` filter to inject the *pingbacks*/*trackbacks* list into your page.
But the plugin is using an extra manual SQL query and the template is constructed by hand,
so there's a room for improvements... |
124,490 | <p>hi i'm using the Categories widget show hierarchy. I leave the space for title because I don't need to show any title. but it then displays on the website as "Categories". how can I remove that?</p>
| [
{
"answer_id": 124500,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>There is a filter you can use to do this. (Kruti has even found it, but instead of using it, he modifi... | 2013/11/26 | [
"https://wordpress.stackexchange.com/questions/124490",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40999/"
] | hi i'm using the Categories widget show hierarchy. I leave the space for title because I don't need to show any title. but it then displays on the website as "Categories". how can I remove that? | There is a filter you can use to do this. (Kruti has even found it, but instead of using it, he modified core files...)
```
$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);
```
So what you really need to do, is to add this to yo... |
124,499 | <p>Is it possible to perform an action only if the theme is deleted (not deactivated) from the theme directory ?</p>
<p>For example, I want to remove the theme settings from database after the theme is removed. So I want to run this when the theme is deleted:</p>
<pre><code>delete_option( 'mysettings' );
</code></pre... | [
{
"answer_id": 124529,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>It is very complex to know which option was generated by your theme settings.</p>\n\n<p>But if you fol... | 2013/11/26 | [
"https://wordpress.stackexchange.com/questions/124499",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38318/"
] | Is it possible to perform an action only if the theme is deleted (not deactivated) from the theme directory ?
For example, I want to remove the theme settings from database after the theme is removed. So I want to run this when the theme is deleted:
```
delete_option( 'mysettings' );
``` | As the other answers seem to imply, there is no built-in way to do this. There is no theme uninstall API similar to [that for plugins](http://codex.wordpress.org/Function_Reference/register_uninstall_hook). There is actually [a long-standing ticket](https://core.trac.wordpress.org/ticket/14955) to get this feature adde... |
124,532 | <p>As a network admin in multisite configuration, I have the option to enable or disable the user registration \ site registration. is there any way i can enable the user registration on s single sub site , not on all sites.</p>
<p>In my WP setup, I have a main blog which is managed by me and I dont want user to regis... | [
{
"answer_id": 124540,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 3,
"selected": true,
"text": "<p>The multisite setup allows you to enable and disable user registration at the network level but if you ... | 2013/11/26 | [
"https://wordpress.stackexchange.com/questions/124532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43173/"
] | As a network admin in multisite configuration, I have the option to enable or disable the user registration \ site registration. is there any way i can enable the user registration on s single sub site , not on all sites.
In my WP setup, I have a main blog which is managed by me and I dont want user to register here. ... | The multisite setup allows you to enable and disable user registration at the network level but if you see the database it store the value in the **`wp_options`** tables for each site.
So we can try the below and see if this work.
Use the below code in the **`functions.php`** file.
```
function wpse_enable_user_regi... |
124,533 | <p>I am trying to filter a CPT by an array of post ids using pre_get_post filter within my plugin. Everything works fine when there are post that match the ids, but when there are no post that match the ids I am getting all the post within the CPT that I am trying to filter in return. What I need id there are not post ... | [
{
"answer_id": 124540,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 3,
"selected": true,
"text": "<p>The multisite setup allows you to enable and disable user registration at the network level but if you ... | 2013/11/26 | [
"https://wordpress.stackexchange.com/questions/124533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38434/"
] | I am trying to filter a CPT by an array of post ids using pre\_get\_post filter within my plugin. Everything works fine when there are post that match the ids, but when there are no post that match the ids I am getting all the post within the CPT that I am trying to filter in return. What I need id there are not post i... | The multisite setup allows you to enable and disable user registration at the network level but if you see the database it store the value in the **`wp_options`** tables for each site.
So we can try the below and see if this work.
Use the below code in the **`functions.php`** file.
```
function wpse_enable_user_regi... |
124,542 | <p>So far in my wordpress installation I have a complete wordpress search page that I can call by going to:</p>
<p><code>/?s=mysearchstring</code></p>
<p>And this searches through wordpress pages containing the "<code>mysearchstring</code>" string.</p>
<p>So I have created a new page "Custom Search" (<code>/custom-... | [
{
"answer_id": 124548,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>A <code>GET</code> string will work just like in any other PHP application but you cannot use a <a href=\"ht... | 2013/11/26 | [
"https://wordpress.stackexchange.com/questions/124542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28403/"
] | So far in my wordpress installation I have a complete wordpress search page that I can call by going to:
`/?s=mysearchstring`
And this searches through wordpress pages containing the "`mysearchstring`" string.
So I have created a new page "Custom Search" (`/custom-search/`) and assigned a template file `custom-searc... | Problem is that `'s'` param is a standard query param of WordPress, when you use the url `/custom-search?s=mysearchstring` your are saying to WordPress to retrieve the page `'custom-search'` that contain the string `'mysearchstring'` and this bring a 404.
You have **2** possibilities:
1. use another query string name... |
124,574 | <p>I have a site whose navigation disappears on category pages for posts in the ‘post’ post type, but not for posts in any of my custom post types. The ‘post’ post type and post of the custom post types use the same template file for theirs archives and headers – no differences. The menu is using the wp_nav_menu functi... | [
{
"answer_id": 124593,
"author": "Zach Russell",
"author_id": 30778,
"author_profile": "https://wordpress.stackexchange.com/users/30778",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried using the <code>wp_nav_menu()</code> function? here is the <a href=\"http://codex.wordpre... | 2013/11/26 | [
"https://wordpress.stackexchange.com/questions/124574",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8903/"
] | I have a site whose navigation disappears on category pages for posts in the ‘post’ post type, but not for posts in any of my custom post types. The ‘post’ post type and post of the custom post types use the same template file for theirs archives and headers – no differences. The menu is using the wp\_nav\_menu functio... | I know this is an old question but seems that is still unresolved. As @Milo said you may have an incorrect `pre_get_posts` implementation.
Most people do this like this (example):
```
add_filter( 'pre_get_posts', 'query_post_type' );
function query_post_type( $query ) {
if ( is_category() ) {
$post_type ... |
124,576 | <p>I was recently created a custom application for wordpress. So while doing so in my file manager (I use the one provided by godaddy(my webhost)), I moved all the files from the [DOCUMENT_ROOT] ... the webroot /public_html/ page to a seperate folder (that was 3 days ago)... 3 days later. When I moved them back, my wor... | [
{
"answer_id": 124579,
"author": "Sherman B.",
"author_id": 35996,
"author_profile": "https://wordpress.stackexchange.com/users/35996",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress still thinks it's being hosted in the sub-directory \"/wordpress\" instead of the root directory... | 2013/11/26 | [
"https://wordpress.stackexchange.com/questions/124576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43186/"
] | I was recently created a custom application for wordpress. So while doing so in my file manager (I use the one provided by godaddy(my webhost)), I moved all the files from the [DOCUMENT\_ROOT] ... the webroot /public\_html/ page to a seperate folder (that was 3 days ago)... 3 days later. When I moved them back, my word... | If you cannot login, use FTP or the file manager to edit `wp-config.php` and `define` [`WP_HOME` and `WP_SITEURL`,](http://codex.wordpress.org/Changing_The_Site_URL#Edit_wp-config.php).
```
define( 'WP_SITEURL', 'http://www.security-shell.com ');
define( 'WP_HOME', 'http://www.security-shell.com ' );
```
When you ... |
124,600 | <p>I am calling a javascript file from my wordpress plugin code using:</p>
<pre><code>add_action('init','gallery_sugar_js_init');
function gallery_sugar_js_init() {
wp_enqueue_script( 'gallery_sugar_js', plugins_url( '/js/gallery_sugar.js', __FILE__ ));
}
</code></pre>
<p>But in source code for WordPress... | [
{
"answer_id": 124601,
"author": "Pepe",
"author_id": 43190,
"author_profile": "https://wordpress.stackexchange.com/users/43190",
"pm_score": 2,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>add_action('init','gallery_sugar_js_init');\n\nfunction gallery_sugar_js_init() {\n ... | 2013/11/26 | [
"https://wordpress.stackexchange.com/questions/124600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15712/"
] | I am calling a javascript file from my wordpress plugin code using:
```
add_action('init','gallery_sugar_js_init');
function gallery_sugar_js_init() {
wp_enqueue_script( 'gallery_sugar_js', plugins_url( '/js/gallery_sugar.js', __FILE__ ));
}
```
But in source code for WordPress I'm seeing this (my javas... | Try this:
```
add_action('init','gallery_sugar_js_init');
function gallery_sugar_js_init() {
wp_enqueue_script( 'gallery_sugar_js', plugins_url( '/js/gallery_sugar.js', __FILE__ ), array( 'jquery' ) );
}
```
Check [Function Reference](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Parameters) for... |
124,610 | <p>I have installed Jetpack and now my custom post types feature a meta-box that says "Sharing: Show sharing buttons" with a checkbox. This is unnecessary for this custom post type and I would like to remove it altogether (not just hide it via screen options).</p>
<p>I tried adding</p>
<pre><code>add_action( 'init', ... | [
{
"answer_id": 124635,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": true,
"text": "<p>you can try this</p>\n\n<pre><code>if (is_admin()){\n function my_remove_meta_boxes() {\n global $typenow... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124610",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27115/"
] | I have installed Jetpack and now my custom post types feature a meta-box that says "Sharing: Show sharing buttons" with a checkbox. This is unnecessary for this custom post type and I would like to remove it altogether (not just hide it via screen options).
I tried adding
```
add_action( 'init', array( $this, 'my_rem... | you can try this
```
if (is_admin()){
function my_remove_meta_boxes() {
global $typenow;
if( 'YOUR_CUSTOM_POST_TYPE' == $typenow ) {
remove_meta_box('sharing_meta', 'YOUR_CUSTOM_POST_TYPE', 'high');
}
}
add_action( 'admin_menu', 'my_remove_meta_boxes' );
}
```
Which removes the metabox regist... |
124,611 | <p>Any good ideas on how to <em>disable</em> the post content editor? I don't want to hide it, remove it, or remove the page.</p>
<p>The goal is to allow users with few permissions to view the edit screen so they can read the content, but not be able to make changes to the content. (I also need to figure out how to di... | [
{
"answer_id": 124649,
"author": "wordpresrox",
"author_id": 28855,
"author_profile": "https://wordpress.stackexchange.com/users/28855",
"pm_score": -1,
"selected": false,
"text": "<p>you can remove the <code><?php edit_post_link(); ?></code> code in your single.php or post php to ... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3293/"
] | Any good ideas on how to *disable* the post content editor? I don't want to hide it, remove it, or remove the page.
The goal is to allow users with few permissions to view the edit screen so they can read the content, but not be able to make changes to the content. (I also need to figure out how to disable other eleme... | I think the best way is remove it and then print the content out of any textarea, but just as html:
```
add_action('load-post.php', 'read_only_content');
function read_only_content() {
if ( ! current_user_can('manage_options') ) { // change the cap with the wanted one
$scr = get_current_screen();
remove_pos... |
124,613 | <p>I had this code running fine forever. Some days ago it just started outputting nothing (just the <code><ul></ul></code>). No errors in logs:</p>
<pre><code><ul style="margin-left:0">
<?php query_posts('tag=pp&showposts=4'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_p... | [
{
"answer_id": 124615,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You should not be using <code>query_posts</code> at all.</p>\n\n<blockquote>\n <p>It should be noted that u... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23296/"
] | I had this code running fine forever. Some days ago it just started outputting nothing (just the `<ul></ul>`). No errors in logs:
```
<ul style="margin-left:0">
<?php query_posts('tag=pp&showposts=4'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_pe... | Turns out it was a problem of the plugin "The Events Calendar":
*<http://wordpress.org/support/topic/tags-conflict>* |
124,619 | <p>I need to add the "All Categories" item to the default WP categories widget.</p>
<p>I can see that there's a filter that I can hook into in the core (line 485 default-widgets.php).</p>
<pre><code>wp_list_categories(apply_filters('widget_categories_args', $cat_args));
</code></pre>
<p>I've written the following f... | [
{
"answer_id": 124624,
"author": "GusRuss89",
"author_id": 18322,
"author_profile": "https://wordpress.stackexchange.com/users/18322",
"pm_score": 1,
"selected": false,
"text": "<p>Sorry, I was just hooking into the wrong filter. My <code>add_filter</code> should have hooked into <code>w... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18322/"
] | I need to add the "All Categories" item to the default WP categories widget.
I can see that there's a filter that I can hook into in the core (line 485 default-widgets.php).
```
wp_list_categories(apply_filters('widget_categories_args', $cat_args));
```
I've written the following function, but I must have somethin... | Sorry, I was just hooking into the wrong filter. My `add_filter` should have hooked into `widget_categories_args` not `widget_categories_dropdown_args`. |
124,637 | <p>I am in a terrible fix. I have been locked out of Site Admin and the solutions offered by the plug-in team in their documentation aren't working. I've tried both methods using Webmatrix. I have to launch my site on Friday and I don't know what to do.</p>
<p>This is what they suggested:</p>
<p>How do I reset the p... | [
{
"answer_id": 124917,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 2,
"selected": false,
"text": "<p>First, rename the folder <code>wp-content/plugins/wordpress-https</code> to <code>wp-content/plugins/wordpre... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124637",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43199/"
] | I am in a terrible fix. I have been locked out of Site Admin and the solutions offered by the plug-in team in their documentation aren't working. I've tried both methods using Webmatrix. I have to launch my site on Friday and I don't know what to do.
This is what they suggested:
How do I reset the plugin's settings? ... | First, rename the folder `wp-content/plugins/wordpress-https` to `wp-content/plugins/wordpress-https-OFF` so that WordPress can't find it to run it.
Second, add the following lines to your wp-config.php file, replacing the domain name with your domain name:
```
define( 'WP_SITEURL', 'http://example.com/' );
define( '... |
124,641 | <p>I have a problem in a <a href="http://wordpress.org/plugins/customer-area" rel="nofollow">plugin of mine</a> which uses post meta to store ownership of a post. Basically, my issue is that the <code>WP_Meta_Query</code> class generates one JOIN per meta_query query. I don't understand why we cannot us the same JOIN f... | [
{
"answer_id": 124648,
"author": "Vincent Mimoun-Prat",
"author_id": 32343,
"author_profile": "https://wordpress.stackexchange.com/users/32343",
"pm_score": 2,
"selected": true,
"text": "<p>In case I am right about that possible optimisation, I have opened a ticket on Trac and submitted ... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32343/"
] | I have a problem in a [plugin of mine](http://wordpress.org/plugins/customer-area) which uses post meta to store ownership of a post. Basically, my issue is that the `WP_Meta_Query` class generates one JOIN per meta\_query query. I don't understand why we cannot us the same JOIN for **all** queries.
Of course, when u... | In case I am right about that possible optimisation, I have opened a ticket on Trac and submitted a patch: <http://core.trac.wordpress.org/ticket/26281>
My plugin's page query time goes from 10+ seconds to 20ms... I hope there are no edge cases. |
124,652 | <p>I am trying to enqueue a js file in functions.php but its not working. Following is my code</p>
<pre><code> add_action('init','shopswing');
function shopswing(){
if(!is_admin()){
wp_register_script('swing',get_stylsheet_directory_uri(). '/js/swing.js',array('jquery'));
wp_enqueue_script('swin... | [
{
"answer_id": 124651,
"author": "saifur",
"author_id": 31689,
"author_profile": "https://wordpress.stackexchange.com/users/31689",
"pm_score": 2,
"selected": true,
"text": "<p>Before import database_backup.sql. You have to replace server url with your local url in sql. for example: you ... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33028/"
] | I am trying to enqueue a js file in functions.php but its not working. Following is my code
```
add_action('init','shopswing');
function shopswing(){
if(!is_admin()){
wp_register_script('swing',get_stylsheet_directory_uri(). '/js/swing.js',array('jquery'));
wp_enqueue_script('swing');
}
}
... | Before import database\_backup.sql. You have to replace server url with your local url in sql. for example: you took backup from abc.com , and your local url is localhost/abc .then open database\_backup.sql and find and replace abc.com with localhost/abc. Save and import now. |
124,655 | <p>I previously had a WordpressMU install, but this is deprecated and I'm trying to find my way around multisite.</p>
<p>I need to programatically create a new user account for a particular site. <a href="http://codex.wordpress.org/Function_Reference/wp_insert_user" rel="nofollow">wp_insert_user</a> looks like it does... | [
{
"answer_id": 124660,
"author": "artfulrobot",
"author_id": 40420,
"author_profile": "https://wordpress.stackexchange.com/users/40420",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming you have Wordpress Multisite, with sites: <code>example.com</code>, <code>foo.example.com</code>... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40420/"
] | I previously had a WordpressMU install, but this is deprecated and I'm trying to find my way around multisite.
I need to programatically create a new user account for a particular site. [wp\_insert\_user](http://codex.wordpress.org/Function_Reference/wp_insert_user) looks like it does everything except say which site ... | You can use the **add\_user\_to\_blog** function after creating the user.
```
$userid = 1;
$blogid = 5;
$role = 'administrator';
add_user_to_blog( $blogid, $userid, $role );
``` |
124,658 | <p>I'm trying to create a theme which when activated, sets up a primary navigation, adds the homepage to it and then enables it in the correct location.</p>
<p>Here's what I've got so far:</p>
<pre><code>register_nav_menu('Primary', 'Primary Navigation');
$primary_nav_menu_id = wp_create_nav_menu('Primary');
wp_upd... | [
{
"answer_id": 124709,
"author": "Chittaranjan",
"author_id": 43031,
"author_profile": "https://wordpress.stackexchange.com/users/43031",
"pm_score": 2,
"selected": false,
"text": "<p>You need to first collect the menu locations, then set the primary menu location with the menu id.</p>\n... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124658",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37430/"
] | I'm trying to create a theme which when activated, sets up a primary navigation, adds the homepage to it and then enables it in the correct location.
Here's what I've got so far:
```
register_nav_menu('Primary', 'Primary Navigation');
$primary_nav_menu_id = wp_create_nav_menu('Primary');
wp_update_nav_menu_item($pr... | You need to first collect the menu locations, then set the primary menu location with the menu id.
```
// Set the menu to primary menu location
$locations = get_theme_mod( 'nav_menu_locations' );
$locations['primary'] = $primary_nav_menu_id;
set_theme_mod ( 'nav_menu_locations', $locations );
```
Here I assume 'prim... |
124,666 | <p>As it's fairly well known, it is possible to schedule Posts in Wordpress for publishing.</p>
<p>Also Attachments are actually Posts (in the more internal, technical meaning).</p>
<p>So the question that bothers me right now is: Is it possible to schedule attachments as well? Like for example that a Photo-Gallery g... | [
{
"answer_id": 124670,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Create the complete gallery at once, use a custom shortcode handler for it.</p>\n\n<p>In your shortcode handler, just... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/178/"
] | As it's fairly well known, it is possible to schedule Posts in Wordpress for publishing.
Also Attachments are actually Posts (in the more internal, technical meaning).
So the question that bothers me right now is: Is it possible to schedule attachments as well? Like for example that a Photo-Gallery grows over time? | My idea is that you can setup a post date for the attachments. This can be done using `attachment_fields_to_edit` to show the UI (is possible use the `touch_time` internal function).
After that, you can filter all the attachments query to show only the attachments with a past or current date.
So
```
add_action('load... |
124,683 | <p>I have a question about restricting access to page templates for blog editors who may create new pages in the future. During my buildout, I had to create specific templates to add custom features for specific pages (i.e. FAQs pulls from a CPT in a separate loop, but allows the editor to add an intro paragraph using ... | [
{
"answer_id": 124716,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 0,
"selected": false,
"text": "<p>I think <a href=\"http://codex.wordpress.org/Function_Reference/remove_post_type_support\" rel=\"nofollow\"><... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32629/"
] | I have a question about restricting access to page templates for blog editors who may create new pages in the future. During my buildout, I had to create specific templates to add custom features for specific pages (i.e. FAQs pulls from a CPT in a separate loop, but allows the editor to add an intro paragraph using the... | Here is a solution to remove that [metabox](https://codex.wordpress.org/Function_Reference/remove_meta_box) from the edit page - this solution also assumes that the editors don't have access to edit themes.
```
add_action( 'admin_menu', 'restrict_access' );
function restrict_access() {
if(!current_user_can('edit_them... |
124,697 | <p>How do I limit the username field upon registration to <code>A-Z</code> and <code>0-9</code> for single site? So no spaces, hyphens, underscores, dots etc.</p>
| [
{
"answer_id": 124699,
"author": "Moaz Ateeq",
"author_id": 35021,
"author_profile": "https://wordpress.stackexchange.com/users/35021",
"pm_score": 1,
"selected": false,
"text": "<p>Use this regular expression </p>\n\n<blockquote>\n <p>/^[a-z0-9]{3,16}$/</p>\n</blockquote>\n\n<p>(3,16) ... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | How do I limit the username field upon registration to `A-Z` and `0-9` for single site? So no spaces, hyphens, underscores, dots etc. | Using the regex posted by **Moaz** (and adding capitals), we will need to hook into the `registration_errors` filter:
```
// Restrict username registration to alphanumerics
add_filter('registration_errors', 'limit_username_alphanumerics', 10, 3);
function limit_username_alphanumerics ($errors, $name) {
if ( ! preg_m... |
124,719 | <p>I have the query_post on my codes. This will display the popular post of all time.
But I want to dispaly the popular post in past 24 hours. How do I do that? </p>
<pre><code><?php query_posts('orderby=comment_count&order=DESC&paged=' . get_query_var('paged'));?>
</code></pre>
<p>I have seen many answ... | [
{
"answer_id": 124699,
"author": "Moaz Ateeq",
"author_id": 35021,
"author_profile": "https://wordpress.stackexchange.com/users/35021",
"pm_score": 1,
"selected": false,
"text": "<p>Use this regular expression </p>\n\n<blockquote>\n <p>/^[a-z0-9]{3,16}$/</p>\n</blockquote>\n\n<p>(3,16) ... | 2013/11/27 | [
"https://wordpress.stackexchange.com/questions/124719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41176/"
] | I have the query\_post on my codes. This will display the popular post of all time.
But I want to dispaly the popular post in past 24 hours. How do I do that?
```
<?php query_posts('orderby=comment_count&order=DESC&paged=' . get_query_var('paged'));?>
```
I have seen many answer here related to this topic, But not ... | Using the regex posted by **Moaz** (and adding capitals), we will need to hook into the `registration_errors` filter:
```
// Restrict username registration to alphanumerics
add_filter('registration_errors', 'limit_username_alphanumerics', 10, 3);
function limit_username_alphanumerics ($errors, $name) {
if ( ! preg_m... |
124,761 | <p>I have a multisite Wordpress setup (3.5.1, I cannot risk updating) on which I am querying some posts after having switched to the correct blog.</p>
<p>I have a query_posts function with the following parameters:</p>
<pre><code>$posts = query_posts('posts_per_page=5&paged=1&post_status=publish&orderby=d... | [
{
"answer_id": 124699,
"author": "Moaz Ateeq",
"author_id": 35021,
"author_profile": "https://wordpress.stackexchange.com/users/35021",
"pm_score": 1,
"selected": false,
"text": "<p>Use this regular expression </p>\n\n<blockquote>\n <p>/^[a-z0-9]{3,16}$/</p>\n</blockquote>\n\n<p>(3,16) ... | 2013/11/28 | [
"https://wordpress.stackexchange.com/questions/124761",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43253/"
] | I have a multisite Wordpress setup (3.5.1, I cannot risk updating) on which I am querying some posts after having switched to the correct blog.
I have a query\_posts function with the following parameters:
```
$posts = query_posts('posts_per_page=5&paged=1&post_status=publish&orderby=date&order=desc');
```
from thi... | Using the regex posted by **Moaz** (and adding capitals), we will need to hook into the `registration_errors` filter:
```
// Restrict username registration to alphanumerics
add_filter('registration_errors', 'limit_username_alphanumerics', 10, 3);
function limit_username_alphanumerics ($errors, $name) {
if ( ! preg_m... |
124,770 | <p>I read the documentation of the codex but i can't order the get_categories() result just like parent,childrens.</p>
<p>I have these kind of categories' three:</p>
<pre><code>-Events
- Music
- Culture
- Workshop
- Tourism
-Sport
-Football
-Rugby
-Tennis
</code></pre>
<p>I want the outpu... | [
{
"answer_id": 124895,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>I don't have a setup like you, so let's try something. I'm giving the code, you better try and give me... | 2013/11/28 | [
"https://wordpress.stackexchange.com/questions/124770",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43258/"
] | I read the documentation of the codex but i can't order the get\_categories() result just like parent,childrens.
I have these kind of categories' three:
```
-Events
- Music
- Culture
- Workshop
- Tourism
-Sport
-Football
-Rugby
-Tennis
```
I want the output to be:
```
Events, Music
```... | **Firstly**, [`$product->get_categories()`](http://docs.woothemes.com/wc-apidocs/source-class-WC_Product.html#1008) won't work because it's a woocommerce function, that basically is just a wrapper for [`get_the_term_list`](http://codex.wordpress.org/Function_Reference/get_the_term_list), which has no sorting parameter.... |
124,778 | <p>I think this is a fairly simple question and im sorry if it is but how would I add a <code><div></code> to each individual category within this code:</p>
<pre><code> <?php
$taxonomy = 'category';
// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fi... | [
{
"answer_id": 124780,
"author": "Ryan S",
"author_id": 23956,
"author_profile": "https://wordpress.stackexchange.com/users/23956",
"pm_score": 0,
"selected": false,
"text": "<p>Use this approach instead</p>\n\n<pre><code> $terms = get_terms( $taxonomy );\n $count = count($terms);\n if (... | 2013/11/28 | [
"https://wordpress.stackexchange.com/questions/124778",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43041/"
] | I think this is a fairly simple question and im sorry if it is but how would I add a `<div>` to each individual category within this code:
```
<?php
$taxonomy = 'category';
// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// separator betw... | My suggestion.
```
$categories = get_the_category();
$output = '';
if($categories) {
$output = "<ul>";
foreach($categories as $category) {
$output .= '<li><div class="btn-standard"><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $categor... |
124,785 | <p>I have a huge number of posts and the pagination with no limits eats my server CPU and ram so I need a function to limit the number of posts for all <code>query_posts</code> on my site and I need this function to work in the admin area too if possible, any suggestions??</p>
<pre><code>function limit_posts {
$args ... | [
{
"answer_id": 124780,
"author": "Ryan S",
"author_id": 23956,
"author_profile": "https://wordpress.stackexchange.com/users/23956",
"pm_score": 0,
"selected": false,
"text": "<p>Use this approach instead</p>\n\n<pre><code> $terms = get_terms( $taxonomy );\n $count = count($terms);\n if (... | 2013/11/28 | [
"https://wordpress.stackexchange.com/questions/124785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25104/"
] | I have a huge number of posts and the pagination with no limits eats my server CPU and ram so I need a function to limit the number of posts for all `query_posts` on my site and I need this function to work in the admin area too if possible, any suggestions??
```
function limit_posts {
$args = array(
'posts_per_pa... | My suggestion.
```
$categories = get_the_category();
$output = '';
if($categories) {
$output = "<ul>";
foreach($categories as $category) {
$output .= '<li><div class="btn-standard"><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $categor... |
124,789 | <p>A very simple question may be, but I'm struggling. In theme development, I worked with <code>get_template_part()</code> many times, and I understand its basics. But when I's developing a plugin, I wondered using it showing me some errors:</p>
<blockquote>
<p><strong>Notice: Use of undefined constant STYLESHEETPAT... | [
{
"answer_id": 124794,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_template_part\"><code>get_template_part</code></a... | 2013/11/28 | [
"https://wordpress.stackexchange.com/questions/124789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | A very simple question may be, but I'm struggling. In theme development, I worked with `get_template_part()` many times, and I understand its basics. But when I's developing a plugin, I wondered using it showing me some errors:
>
> **Notice: Use of undefined constant STYLESHEETPATH** - assumed 'STYLESHEETPATH' in `..... | [`get_template_part`](http://codex.wordpress.org/Function_Reference/get_template_part) is a *theme* function. You can't load plugin files with that function. Take a look at the source and you will notice the work is done by [`locate_template`](http://core.trac.wordpress.org/browser/tags/3.7.1/src/wp-includes/general-te... |
124,800 | <ul>
<li>I have an existing asp based blog where all posts contain a post id in their URL (<code>template_permalink.asp?id=123</code>).</li>
<li>I have a blank WordPress blog. I will have to recreate all of my posts manually, because the feed from my existing blog doesn't contain the original images (it just has a CDAT... | [
{
"answer_id": 124794,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_template_part\"><code>get_template_part</code></a... | 2013/11/28 | [
"https://wordpress.stackexchange.com/questions/124800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43270/"
] | * I have an existing asp based blog where all posts contain a post id in their URL (`template_permalink.asp?id=123`).
* I have a blank WordPress blog. I will have to recreate all of my posts manually, because the feed from my existing blog doesn't contain the original images (it just has a CDATA block) so I can't impor... | [`get_template_part`](http://codex.wordpress.org/Function_Reference/get_template_part) is a *theme* function. You can't load plugin files with that function. Take a look at the source and you will notice the work is done by [`locate_template`](http://core.trac.wordpress.org/browser/tags/3.7.1/src/wp-includes/general-te... |
124,803 | <p>How do you prevent WordPress from localizing a company name when using the localization functions?</p>
<p>In the following snippet will "Company Name" be translated?</p>
<pre><code><?php printf(__('Here is some text about %s', 'my_theme'), 'Company Name'); ?>
</code></pre>
<p>Is it best practice to not tran... | [
{
"answer_id": 124808,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>In your example, the company name will not be translated. However, you should at least make it possible to write the ... | 2013/11/28 | [
"https://wordpress.stackexchange.com/questions/124803",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11804/"
] | How do you prevent WordPress from localizing a company name when using the localization functions?
In the following snippet will "Company Name" be translated?
```
<?php printf(__('Here is some text about %s', 'my_theme'), 'Company Name'); ?>
```
Is it best practice to not translate a company name and the name of in... | In your example, the company name will not be translated. However, you should at least make it possible to write the name in the native alphabet. Latin letters look really odd in some other alphabets.
There is also a legal issue: in some countries it is not allowed to use capital letters for anything but some reserved... |
124,868 | <p>I have a CPT that gets its data by reading from an external server. The external server is the master of the data and my plugin stores a replication without an ability to update the master, therefor the ability to edit the content will just confuse the user, might even make him think that the master will be updated ... | [
{
"answer_id": 124893,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You can replace the editor with a read-only meta box.</p>\n\n<pre><code>// use the action to create a place ... | 2013/11/29 | [
"https://wordpress.stackexchange.com/questions/124868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23970/"
] | I have a CPT that gets its data by reading from an external server. The external server is the master of the data and my plugin stores a replication without an ability to update the master, therefor the ability to edit the content will just confuse the user, might even make him think that the master will be updated by ... | I did something similar recently for a simple email log (for diagnosing some problems). I don't have time to dissect the code, but hopefully it'll be clear enough for you.
It creates a CPT for storing data that can be viewed in the admin (only), and allows the user to view and delete each post. NB: delete, not trash -... |
124,874 | <p>I am trying to replicate the same style as seen in this picture displaying the latest posts. I am aware as to how to recreate it using a WP Loop and having the content sizes all the same. What I want to do is have it so it varies the sizing based on a fixed template. So the layout would be constant but the posts wou... | [
{
"answer_id": 124893,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You can replace the editor with a read-only meta box.</p>\n\n<pre><code>// use the action to create a place ... | 2013/11/29 | [
"https://wordpress.stackexchange.com/questions/124874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43041/"
] | I am trying to replicate the same style as seen in this picture displaying the latest posts. I am aware as to how to recreate it using a WP Loop and having the content sizes all the same. What I want to do is have it so it varies the sizing based on a fixed template. So the layout would be constant but the posts would ... | I did something similar recently for a simple email log (for diagnosing some problems). I don't have time to dissect the code, but hopefully it'll be clear enough for you.
It creates a CPT for storing data that can be viewed in the admin (only), and allows the user to view and delete each post. NB: delete, not trash -... |
124,875 | <p>I have a custom post type for the user profile page. My client wants all users to update their profile at least once a month, so we want their profile (custom post) to be automatically set to draft after 30 days. They will then receive an email asking them to update the post. The post needs to be set to draft again ... | [
{
"answer_id": 124891,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Don't use <code>global $post</code>. Everything you need should be passed into the function in the <code>$da... | 2013/11/29 | [
"https://wordpress.stackexchange.com/questions/124875",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36987/"
] | I have a custom post type for the user profile page. My client wants all users to update their profile at least once a month, so we want their profile (custom post) to be automatically set to draft after 30 days. They will then receive an email asking them to update the post. The post needs to be set to draft again 30 ... | Don't use `global $post`. Everything you need should be passed into the function in the `$data` and `$postarr` parameters.
Secondly, you have to `return` the `$data` in all cases. What you are doing now is effectively erasing data for everything but your `profile` post type.
You need to reorganize a bit:
```
funct... |
124,902 | <p>I'm looking to port a site into Wordpress that contains not just an About page, but an entire About section with various pages highlighting particular details about the company. Each of these pages vary in terms of layout and content but none are what could be described as being amendable to a custom post type. This... | [
{
"answer_id": 124891,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Don't use <code>global $post</code>. Everything you need should be passed into the function in the <code>$da... | 2013/11/29 | [
"https://wordpress.stackexchange.com/questions/124902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42811/"
] | I'm looking to port a site into Wordpress that contains not just an About page, but an entire About section with various pages highlighting particular details about the company. Each of these pages vary in terms of layout and content but none are what could be described as being amendable to a custom post type. This is... | Don't use `global $post`. Everything you need should be passed into the function in the `$data` and `$postarr` parameters.
Secondly, you have to `return` the `$data` in all cases. What you are doing now is effectively erasing data for everything but your `profile` post type.
You need to reorganize a bit:
```
funct... |
124,908 | <p>I tried fixing this for 5 days and my head is burning now. I bought a theme from GorilaThemes and the developer doesn't get back to me on the forum either, so Im pretty much by myself now. can you guys please help?</p>
<p>There is a page where it lists cars with with the below query</p>
<pre><code>$query = new WP... | [
{
"answer_id": 124930,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 0,
"selected": false,
"text": "<p>The last line of code and your explanation, indicates that <em>year</em> may be stored as an index i... | 2013/11/29 | [
"https://wordpress.stackexchange.com/questions/124908",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42723/"
] | I tried fixing this for 5 days and my head is burning now. I bought a theme from GorilaThemes and the developer doesn't get back to me on the forum either, so Im pretty much by myself now. can you guys please help?
There is a page where it lists cars with with the below query
```
$query = new WP_Query(array(
... | This did the trick. I had to use '\_year"
```
<?php $query = new WP_Query(array(
'post_type' => array('gtcd','user_listing'),
'posts_per_page' => '999',
'meta_key' => '_year',
'orderby' => 'meta_value',
'order' => 'ASC'
));
``` |
124,913 | <p>I am using this function to display the date and title of my latest posts on my dashboard. </p>
<p>However for some of the posts the date is not being displayed at all - I have a feeling this might be the posts which I subsequently hit the "update" button but i am not sure.. any ideas why this happens?</p>
<pre><c... | [
{
"answer_id": 124914,
"author": "Pippin",
"author_id": 2418,
"author_profile": "https://wordpress.stackexchange.com/users/2418",
"pm_score": 3,
"selected": true,
"text": "<p>Replace the_date() with the_time() and it should work fine.</p>\n\n<p>the_date() only displays the date for posts... | 2013/11/29 | [
"https://wordpress.stackexchange.com/questions/124913",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am using this function to display the date and title of my latest posts on my dashboard.
However for some of the posts the date is not being displayed at all - I have a feeling this might be the posts which I subsequently hit the "update" button but i am not sure.. any ideas why this happens?
```
function wps_rece... | Replace the\_date() with the\_time() and it should work fine.
the\_date() only displays the date for posts that are on different days. If two posts are published on the same day, only the first one's date will be displayed. |
124,949 | <p>I want to change the default number of posts shown for my mobile site. Here is my theme's loop </p>
<pre><code> <?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'mobile-content' ); ?>
<?php en... | [
{
"answer_id": 124953,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 4,
"selected": true,
"text": "<p><em>Firstly</em>, you need to detect mobile devices, probably the easiest and a built in possibility... | 2013/11/30 | [
"https://wordpress.stackexchange.com/questions/124949",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23717/"
] | I want to change the default number of posts shown for my mobile site. Here is my theme's loop
```
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'mobile-content' ); ?>
<?php endwhile; ?>
```
I have 25 posts sho... | *Firstly*, you need to detect mobile devices, probably the easiest and a built in possibility is [`wp_is_mobile`](http://codex.wordpress.org/Function_Reference/wp_is_mobile). It is simpler then other solutions that are available, but works reasonably well. It can be altered, if necessary, take a look at this [question]... |
124,950 | <p>I am trying to write a code for my custom plugin where need to include a template page. I have tried in few ways but it redirects me to 404. After this i also added code for template redirect but no results. Somebody please notice me where I am doing wrong ?</p>
<p>Few example of my code snippet:</p>
<pre><code>ad... | [
{
"answer_id": 124971,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Your <code>portfolio_newpage_template</code> function does not result in a 404 when I try it, but it is not ... | 2013/11/30 | [
"https://wordpress.stackexchange.com/questions/124950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32673/"
] | I am trying to write a code for my custom plugin where need to include a template page. I have tried in few ways but it redirects me to 404. After this i also added code for template redirect but no results. Somebody please notice me where I am doing wrong ?
Few example of my code snippet:
```
add_filter( 'template_i... | Your `portfolio_newpage_template` function does not result in a 404 when I try it, but it is not going to work either. [`locate_template`](http://codex.wordpress.org/Function_Reference/locate_template) will ***always*** load from theme directories, so it will never find your plugin file. You can [see that in the source... |
124,959 | <p>Is it possible to include jQuery UI as a whole instead of:</p>
<pre><code>wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-effects-core');
// a lot of other jquery ui imports....
</code></pre>
<p>I've searched in the codex and was able to find the full list of included scripts, but could not find a w... | [
{
"answer_id": 124968,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p>If you take a look at <a href=\"http://core.trac.wordpress.org/browser/branches/3.7/src/wp-includes/script-loader.p... | 2013/11/30 | [
"https://wordpress.stackexchange.com/questions/124959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43342/"
] | Is it possible to include jQuery UI as a whole instead of:
```
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-effects-core');
// a lot of other jquery ui imports....
```
I've searched in the codex and was able to find the full list of included scripts, but could not find a way to include the full jQu... | If you take a look at [registrations in source](http://core.trac.wordpress.org/browser/branches/3.7/src/wp-includes/script-loader.php#L146) there is no alias to load all of jQuery UI in bulk available and WP core itself uses pieces as dependencies individually.
You could create and use such alias yourself (registered ... |
124,977 | <p>The multi language plugin qtranslate works for custom post types but there is no capability to translate media information like title, description, captions for images.</p>
<p>I am using the following code (WP v3.7.1) in order to adding support for custom taxonomies translation:</p>
<pre><code>add_action('admin_i... | [
{
"answer_id": 131949,
"author": "Rcalleja",
"author_id": 45920,
"author_profile": "https://wordpress.stackexchange.com/users/45920",
"pm_score": 0,
"selected": false,
"text": "<p>You can download the plugin with the fix from GitHub.</p>\n\n<ul>\n<li><a href=\"https://github.com/rafaelca... | 2013/11/30 | [
"https://wordpress.stackexchange.com/questions/124977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31606/"
] | The multi language plugin qtranslate works for custom post types but there is no capability to translate media information like title, description, captions for images.
I am using the following code (WP v3.7.1) in order to adding support for custom taxonomies translation:
```
add_action('admin_init', 'qtranslate_edit... | Good question .
Well.. After reading Rcalleja answer ..
You can use the plugin provided , but there is really no need for it, nor for code hacking or php juggling ..
All you have to do is to use the quicktags in the attachments fields :
```
[:en]English Description[:fr]French description[:de]German description
```
... |
124,993 | <p>I am looking for help on understanding how child themes and parent themes <code>functions.php</code> work.</p>
<p>I know with CSS, the cascade overrides CSS declared earlier in the style sheet. It is my understanding that the <code>functions.php</code> does not operate the same way. I understand that both <code>fu... | [
{
"answer_id": 131949,
"author": "Rcalleja",
"author_id": 45920,
"author_profile": "https://wordpress.stackexchange.com/users/45920",
"pm_score": 0,
"selected": false,
"text": "<p>You can download the plugin with the fix from GitHub.</p>\n\n<ul>\n<li><a href=\"https://github.com/rafaelca... | 2013/11/30 | [
"https://wordpress.stackexchange.com/questions/124993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43351/"
] | I am looking for help on understanding how child themes and parent themes `functions.php` work.
I know with CSS, the cascade overrides CSS declared earlier in the style sheet. It is my understanding that the `functions.php` does not operate the same way. I understand that both `functions.php` are loaded.
What happens... | Good question .
Well.. After reading Rcalleja answer ..
You can use the plugin provided , but there is really no need for it, nor for code hacking or php juggling ..
All you have to do is to use the quicktags in the attachments fields :
```
[:en]English Description[:fr]French description[:de]German description
```
... |
125,023 | <p>I am trying to modify a plugin and in which i require to update a value in wp_options which has multiple values . </p>
<p>My <code>option_name</code> is <code>ws_mem_options</code></p>
<p>and the </p>
<p><code>option_value</code> has values such as in format </p>
<pre><code>s:20:"pro_sp_email_subject";s:36:"Than... | [
{
"answer_id": 125030,
"author": "Ali Hashemi",
"author_id": 39225,
"author_profile": "https://wordpress.stackexchange.com/users/39225",
"pm_score": 0,
"selected": false,
"text": "<p>If you have access to run SQL queries, you can select the <code>option_value</code> you want to change an... | 2013/12/01 | [
"https://wordpress.stackexchange.com/questions/125023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41094/"
] | I am trying to modify a plugin and in which i require to update a value in wp\_options which has multiple values .
My `option_name` is `ws_mem_options`
and the
`option_value` has values such as in format
```
s:20:"pro_sp_email_subject";s:36:"Thank You! (instructions for access)";s:20:"mem_email_message";s:309:"T... | What you are looking at is serialized data-- possibly multiple bits of serialized data as @Rarst noted. The [Options API](http://codex.wordpress.org/Options_API) will serialize and unserialize automatically so all you need to do is:
```
$data = get_option('optionkey');
// $data will be unserialized into whatever data ... |
125,048 | <p>I would like to add extra markup to a comment made by the site admin/post author. Is there a check for this and how would I add it to my code below?</p>
<p>Basically, if the comment is from the post author I would like to add HTML next to their name (Author or Admin).</p>
<p>Thanks</p>
<pre><code> <... | [
{
"answer_id": 125030,
"author": "Ali Hashemi",
"author_id": 39225,
"author_profile": "https://wordpress.stackexchange.com/users/39225",
"pm_score": 0,
"selected": false,
"text": "<p>If you have access to run SQL queries, you can select the <code>option_value</code> you want to change an... | 2013/12/01 | [
"https://wordpress.stackexchange.com/questions/125048",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43368/"
] | I would like to add extra markup to a comment made by the site admin/post author. Is there a check for this and how would I add it to my code below?
Basically, if the comment is from the post author I would like to add HTML next to their name (Author or Admin).
Thanks
```
<div class="comment-meta comment... | What you are looking at is serialized data-- possibly multiple bits of serialized data as @Rarst noted. The [Options API](http://codex.wordpress.org/Options_API) will serialize and unserialize automatically so all you need to do is:
```
$data = get_option('optionkey');
// $data will be unserialized into whatever data ... |
125,054 | <p>I'm trying to install Thesis on <a href="http://aspirecode.com" rel="nofollow">my blog</a>, and I'm having an issue that's caused by the theme that's currently active, which is <a href="http://themes.okaythemes.com/docs/structure/" rel="nofollow">Structure by Okay Themes</a>. </p>
<p>This theme created a static hom... | [
{
"answer_id": 125061,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>It sounds like the theme is hanging when you try to disable it. </p>\n\n<p>Physically remove the theme. Logi... | 2013/12/01 | [
"https://wordpress.stackexchange.com/questions/125054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43371/"
] | I'm trying to install Thesis on [my blog](http://aspirecode.com), and I'm having an issue that's caused by the theme that's currently active, which is [Structure by Okay Themes](http://themes.okaythemes.com/docs/structure/).
This theme created a static home page when I installed it, but not in [the way recommended by... | It sounds like the theme is hanging when you try to disable it.
Physically remove the theme. Login over FTP and delete or rename the theme directory. If that doesn't work this will take a lot of debugging. WordPress will notice that the active theme is gone/broken and load a default theme.
---
***I tell you the fol... |
125,067 | <p>Trying to figure out why this won't work for me. I'm simply trying to run a loop of all posts and pages, and tag them as post and page in a array. But the <code>is_single()</code> conditional is not working, all posts show up as pages. And if I remove the <code>is_page()</code> it'll just give me <code>null</code></... | [
{
"answer_id": 125069,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p><code>is_single()</code> and <code>is_page()</code> operate on the global <code>$wp_query</code>, and won't work i... | 2013/12/01 | [
"https://wordpress.stackexchange.com/questions/125067",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2830/"
] | Trying to figure out why this won't work for me. I'm simply trying to run a loop of all posts and pages, and tag them as post and page in a array. But the `is_single()` conditional is not working, all posts show up as pages. And if I remove the `is_page()` it'll just give me `null`
```
$data = array();
$args = array(
... | `is_single()` and `is_page()` refer to the main query and as far as I know are not altered to match the individual posts in a Loop. They refer to the *type of page* not to the individual posts. Try and you should see what I mean:
```
$data = array();
$args = array(
'posts_per_page' => '-1',
'post_type' => arra... |
125,078 | <p>I am trying to include a template from plugin which required to display some of my custom information's. I wrote function to insert a page and included the template. It's working for me but once i created the page it automatically displaying in navbar menu list(currently using thwentythirteen theme).</p>
<p>So actu... | [
{
"answer_id": 125095,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>I do not completely understand what you are doing, but I get the feeling that you have greatly over-complica... | 2013/12/01 | [
"https://wordpress.stackexchange.com/questions/125078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32673/"
] | I am trying to include a template from plugin which required to display some of my custom information's. I wrote function to insert a page and included the template. It's working for me but once i created the page it automatically displaying in navbar menu list(currently using thwentythirteen theme).
So actually i don... | I do not completely understand what you are doing, but I get the feeling that you have greatly over-complicate this. You don't have to create a "Page" at all to load a custom template. You can hook to `template_include` and simply include a plugin file with much less effort than you are currently going through.
For ex... |
125,082 | <p>As above, for example this is the blog page url:</p>
<p><code>http://192.168.1.100/wordpress/?page_id=30</code></p>
<p>Let assume that I don't know the exact ID of blog page and I want to write <code>if</code> condition for this page.</p>
| [
{
"answer_id": 125083,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 3,
"selected": true,
"text": "<p>You can get the blog page id using this:</p>\n\n<pre><code>get_option('page_for_posts');\n</code></p... | 2013/12/01 | [
"https://wordpress.stackexchange.com/questions/125082",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40492/"
] | As above, for example this is the blog page url:
`http://192.168.1.100/wordpress/?page_id=30`
Let assume that I don't know the exact ID of blog page and I want to write `if` condition for this page. | You can get the blog page id using this:
```
get_option('page_for_posts');
``` |
125,098 | <p>Is there a way to redirect users returning to the site who are already logged in? Assuming something like:</p>
<pre><code>function returning_redirect()
{
//code here
}
add_action('auth_cookie_valid', 'returning_redirect');
</code></pre>
<p>But I can't seem to get any variation of that to work. Thanks!</p>
| [
{
"answer_id": 125099,
"author": "Ryan Koehler",
"author_id": 20787,
"author_profile": "https://wordpress.stackexchange.com/users/20787",
"pm_score": 1,
"selected": false,
"text": "<pre><code>function redirect_user() { \n if ( is_user_logged_in() ) {\n wp_redirect( 'h... | 2013/12/02 | [
"https://wordpress.stackexchange.com/questions/125098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43386/"
] | Is there a way to redirect users returning to the site who are already logged in? Assuming something like:
```
function returning_redirect()
{
//code here
}
add_action('auth_cookie_valid', 'returning_redirect');
```
But I can't seem to get any variation of that to work. Thanks! | ```
function redirect_user() {
if ( is_user_logged_in() ) {
wp_redirect( 'http://yoursite.com/page/' );
exit;
}
}
add_action( 'init', 'redirect_user' );
```
This will redirect the user to the page of your choice if they are logged in. It might be necessary to add a conditiona... |
125,158 | <p>What is the correct way to write a conditional statement?</p>
<pre><code> <?php if is_tag( 'Premium' ){
<a href="<?php the_permalink(); ?>" class="info"> Subscribe</a>
}else {
<a href="<?php the_permalink();... | [
{
"answer_id": 125099,
"author": "Ryan Koehler",
"author_id": 20787,
"author_profile": "https://wordpress.stackexchange.com/users/20787",
"pm_score": 1,
"selected": false,
"text": "<pre><code>function redirect_user() { \n if ( is_user_logged_in() ) {\n wp_redirect( 'h... | 2013/12/02 | [
"https://wordpress.stackexchange.com/questions/125158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37664/"
] | What is the correct way to write a conditional statement?
```
<?php if is_tag( 'Premium' ){
<a href="<?php the_permalink(); ?>" class="info"> Subscribe</a>
}else {
<a href="<?php the_permalink(); ?>" class="info">Read More</a>
... | ```
function redirect_user() {
if ( is_user_logged_in() ) {
wp_redirect( 'http://yoursite.com/page/' );
exit;
}
}
add_action( 'init', 'redirect_user' );
```
This will redirect the user to the page of your choice if they are logged in. It might be necessary to add a conditiona... |
125,163 | <p>I want to change the wording in the Default thumbnail metabox to 'Set default thumbnail' instead of 'Set featured image'. How can I do this?</p>
| [
{
"answer_id": 125166,
"author": "Ryan Koehler",
"author_id": 20787,
"author_profile": "https://wordpress.stackexchange.com/users/20787",
"pm_score": 1,
"selected": false,
"text": "<p>Use <a href=\"http://core.trac.wordpress.org/browser/branches/3.7/src/wp-includes/media.php#L1932http://... | 2013/12/02 | [
"https://wordpress.stackexchange.com/questions/125163",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I want to change the wording in the Default thumbnail metabox to 'Set default thumbnail' instead of 'Set featured image'. How can I do this? | This is usually what I go with:
```
/** Use "Featured Image" Box As A Custom Box **/
function customposttype_image_box() {
remove_meta_box('postimagediv', 'page', 'side');
add_meta_box('postimagediv', __('Set Dat Image'), 'post_thumbnail_meta_box', 'page', 'side');
}
add_action('do_meta_boxes', 'custompost... |
125,171 | <p>Several of my pages have some "posts" of custom post types as child posts. On these pages I want to list all of the child posts. Therefore I have this code:</p>
<pre><code><?php
$page_id = get_queried_object_id();
function subpage_peek($parent_id) {
// reset the query, just to be sure
wp_reset_postdata()... | [
{
"answer_id": 125173,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>I think you're confusing <code>WP_Query</code> with taxonomy arguments. <code>WP_Query</code> doesn't have a <code... | 2013/12/02 | [
"https://wordpress.stackexchange.com/questions/125171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34790/"
] | Several of my pages have some "posts" of custom post types as child posts. On these pages I want to list all of the child posts. Therefore I have this code:
```
<?php
$page_id = get_queried_object_id();
function subpage_peek($parent_id) {
// reset the query, just to be sure
wp_reset_postdata();
//query sub... | My final solution:
```
<?php
/**
Modified function from wp types with capability of choosing post_status
Originally located here: plugins/types/embedded/functions.php lines 319-342
*/
function mod_wpcf_pr_post_get_has($post_id, $post_type_q = null, $post_status) {
$post_type = get_post_type($post_id);
$ha... |