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 |
|---|---|---|---|---|---|---|
100,566 | <p>What is the easiest method to make all my articles accessible only to registered users?</p>
<p>My homepage contains titles and excerpts but I want to allow access to the full content only to registered users.</p>
<p>I remember there was an admin setting for that but I cannot find it.</p>
<p>Maybe Im wrong. Any id... | [
{
"answer_id": 100567,
"author": "Elisha Terada",
"author_id": 33229,
"author_profile": "https://wordpress.stackexchange.com/users/33229",
"pm_score": 1,
"selected": false,
"text": "<p>I recommend a plugin like <a href=\"http://wordpress.org/plugins/user-access-manager/\" rel=\"nofollow\... | 2013/05/24 | [
"https://wordpress.stackexchange.com/questions/100566",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16266/"
] | What is the easiest method to make all my articles accessible only to registered users?
My homepage contains titles and excerpts but I want to allow access to the full content only to registered users.
I remember there was an admin setting for that but I cannot find it.
Maybe Im wrong. Any ideas?
Thanks. | You could hook into `template_redirect`, check if it is a singular page (post, page, custom post type) and force a log in:
```
add_action( 'template_redirect', 'login_to_see_content' );
function login_to_see_content()
{
if ( is_singular() && ! is_user_logged_in() )
auth_redirect(); // does nothing for log... |
100,588 | <p>I am using <code>wp_cron</code> to auto grab posts from a remote website and save them in my wp db.</p>
<p><strong>NOTICE! I am executing my code from my plugin, not from my template functions.php or somewhere else. I have my own validation of grabbed content to prevent malicious code etc. so turning off security v... | [
{
"answer_id": 100592,
"author": "Derfder",
"author_id": 17368,
"author_profile": "https://wordpress.stackexchange.com/users/17368",
"pm_score": 1,
"selected": false,
"text": "<p><strong>WARNING !!!</strong></p>\n\n<p><strong>Always make validation of the data you are saving into the dat... | 2013/05/24 | [
"https://wordpress.stackexchange.com/questions/100588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I am using `wp_cron` to auto grab posts from a remote website and save them in my wp db.
**NOTICE! I am executing my code from my plugin, not from my template functions.php or somewhere else. I have my own validation of grabbed content to prevent malicious code etc. so turning off security validation in wordpress is n... | Instead of manually removing the safety filters like this, you should simply set the correct user for these processes to be running as.
When you are logged in and running a process manually, you are *logged in* and thus you have your credentials being used, and your permissions being used. I'm betting you're an admini... |
100,607 | <p>I'm wanting to list child pages of my current page in the sidebar of theme. However my sidebar (left side) is before the loop in the template and the post->ID won't return anything if it's before the loop.</p>
<p>My current code:</p>
<pre><code><?php
wp_list_pages('title_li=&child_of='.$post->ID);
?&g... | [
{
"answer_id": 100608,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>try to make code like</p>\n\n<pre><code>global $post;\nvar_dump($post);//test values in $post\nwp_list... | 2013/05/24 | [
"https://wordpress.stackexchange.com/questions/100607",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20003/"
] | I'm wanting to list child pages of my current page in the sidebar of theme. However my sidebar (left side) is before the loop in the template and the post->ID won't return anything if it's before the loop.
My current code:
```
<?php
wp_list_pages('title_li=&child_of='.$post->ID);
?>
```
I've read something about... | >
> ... the post->ID won't return anything if it's before the loop
>
>
>
Generally speaking, this is false. The `$post` variable is set well before the Loop starts in your theme, for most pages. The main query "primes" that variable to the first post in the Loop. That said, depending on this variable outside the L... |
100,647 | <p>I'd like to create a role group where users can edit pages and submit them for approval before they are displayed on the website. I've used the following roles (shown below) but they don't allow me to approve page edits. Is it possible to create a role where a user can edit pages and then have the edits be approved ... | [
{
"answer_id": 100642,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I understand the worry but there is no realistic way to predict what changes will be made in Core in the fut... | 2013/05/24 | [
"https://wordpress.stackexchange.com/questions/100647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18814/"
] | I'd like to create a role group where users can edit pages and submit them for approval before they are displayed on the website. I've used the following roles (shown below) but they don't allow me to approve page edits. Is it possible to create a role where a user can edit pages and then have the edits be approved by ... | In your specific case, I don't think the answer is a technical one (see my comment on the question for more details).
For everyone else, the answer to **"How can I easily verify a core or plugin update has not broken anything?"** *is* automated testing. That's the whole purpose of automated testing, because it's unrea... |
100,654 | <p>On my website, I have a custom post type ("foto's"). It contains photo albums which are fetched from Facebook with Facebook Photo Fetcher (plugin). This works great. Unfortunately, this plugin does not allow for pagination. On pages that contain a lot of images this can cause problems (verrrrryyy long load times), s... | [
{
"answer_id": 100642,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I understand the worry but there is no realistic way to predict what changes will be made in Core in the fut... | 2013/05/24 | [
"https://wordpress.stackexchange.com/questions/100654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16574/"
] | On my website, I have a custom post type ("foto's"). It contains photo albums which are fetched from Facebook with Facebook Photo Fetcher (plugin). This works great. Unfortunately, this plugin does not allow for pagination. On pages that contain a lot of images this can cause problems (verrrrryyy long load times), such... | In your specific case, I don't think the answer is a technical one (see my comment on the question for more details).
For everyone else, the answer to **"How can I easily verify a core or plugin update has not broken anything?"** *is* automated testing. That's the whole purpose of automated testing, because it's unrea... |
100,659 | <p>I have a site that I'm making for a quarterly print magazine. I'm making all of the articles from all issues into Wordpress posts.</p>
<p>Every Article/Post belongs to an Issue and every Issue belongs to a Volume (Standard magazine stuff).</p>
<p>Instead of using Categories to represent a hierarchical relationship... | [
{
"answer_id": 100662,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 3,
"selected": true,
"text": "<p>There are a lot of ways you can solve this issue. What I'd do if it were me is to <strong>make \"issue\... | 2013/05/24 | [
"https://wordpress.stackexchange.com/questions/100659",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9575/"
] | I have a site that I'm making for a quarterly print magazine. I'm making all of the articles from all issues into Wordpress posts.
Every Article/Post belongs to an Issue and every Issue belongs to a Volume (Standard magazine stuff).
Instead of using Categories to represent a hierarchical relationship between Volume -... | There are a lot of ways you can solve this issue. What I'd do if it were me is to **make "issue" its own taxonomy**.
If issue is its own taxonomy, then the terms can be unique (and things are much less cluttered). An article will then belong to a volume, and also an issue. The trick is to create a hierarchy in the rew... |
100,701 | <p>I was investigating the cause of hyperlinks breaking on a friend's website. She copies over her content from email and pastes it in the Wordpress editor. In a few articles, the content between the a tags has wbr in it and that seems to break the hyperlinks. You can find it on <a href="http://chandni.org/information-... | [
{
"answer_id": 100667,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>You can <a href=\"http://codex.wordpress.org/Stepping_Into_Templates\" rel=\"nofollow\">read this</a>. I think y... | 2013/05/25 | [
"https://wordpress.stackexchange.com/questions/100701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16933/"
] | I was investigating the cause of hyperlinks breaking on a friend's website. She copies over her content from email and pastes it in the Wordpress editor. In a few articles, the content between the a tags has wbr in it and that seems to break the hyperlinks. You can find it on <http://chandni.org/information-about-award... | Have you take a look at Options Page Add-on for Advanced Custom Field?
<http://www.advancedcustomfields.com/add-ons/options-page/>
I created an option page for my client once where they enter promotion content once in that options page, and display that same information elsewhere via widget, shortcode, and PHP functio... |
100,707 | <p>I have deep hierarchical taxonomy and I want to have all parent term assigned when I select a child term. I need it for category structure on a online listing/classified site.</p>
<p><strong>CPT name:</strong> <code>product</code></p>
<p><strong>Taxonomy Name:</strong> <code>product_cat</code></p>
| [
{
"answer_id": 100708,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 5,
"selected": true,
"text": "<p>Hooking into <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/save_post\" rel=\"noreferrer\"><code... | 2013/05/25 | [
"https://wordpress.stackexchange.com/questions/100707",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | I have deep hierarchical taxonomy and I want to have all parent term assigned when I select a child term. I need it for category structure on a online listing/classified site.
**CPT name:** `product`
**Taxonomy Name:** `product_cat` | Hooking into [`save_post`](http://codex.wordpress.org/Plugin_API/Action_Reference/save_post) action.
```
add_action('save_post', 'assign_parent_terms', 10, 2);
function assign_parent_terms($post_id, $post){
if($post->post_type != 'product')
return $post_id;
// get all assigned terms
$terms = ... |
100,709 | <p><code>wp_register_script()</code> (see <a href="http://codex.wordpress.org/Function_Reference/wp_register_script" rel="noreferrer">codex</a>) allows you to specify dependencies: scripts that must be loaded before the one being registered is loaded (if it is loaded).</p>
<p>But suppose the script is a third-party o... | [
{
"answer_id": 100713,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>There is no designated way to change details of registered script/style dependency after the registration. Your opt... | 2013/05/25 | [
"https://wordpress.stackexchange.com/questions/100709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9364/"
] | `wp_register_script()` (see [codex](http://codex.wordpress.org/Function_Reference/wp_register_script)) allows you to specify dependencies: scripts that must be loaded before the one being registered is loaded (if it is loaded).
But suppose the script is a third-party one (WordPress or another plug-in) so that you are ... | Digging through <https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/class.wp-dependencies.php> all registered scripts are stored in the global `$wp_scripts`.
You can access them directly through that, but I prefer to use the API when it exists. In this case, `$wp_scripts->query()` returns a particular regi... |
100,719 | <p>I think this should be relatively easy, but somehow I cannot figure out how to do this.
essentially there's a preexisting plugin that does this:</p>
<pre><code>add_action('widgets_init', create_function('', 'register_widget("Foo");'));
if ( ! class_exists( 'Foo' ) ) {
class Foo extends WP_Widget {
/*constru... | [
{
"answer_id": 100713,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>There is no designated way to change details of registered script/style dependency after the registration. Your opt... | 2013/05/25 | [
"https://wordpress.stackexchange.com/questions/100719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26009/"
] | I think this should be relatively easy, but somehow I cannot figure out how to do this.
essentially there's a preexisting plugin that does this:
```
add_action('widgets_init', create_function('', 'register_widget("Foo");'));
if ( ! class_exists( 'Foo' ) ) {
class Foo extends WP_Widget {
/*constructs etc*/
}}
... | Digging through <https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/class.wp-dependencies.php> all registered scripts are stored in the global `$wp_scripts`.
You can access them directly through that, but I prefer to use the API when it exists. In this case, `$wp_scripts->query()` returns a particular regi... |
100,726 | <p>I'm trying to figure out the best way to add custom menu attributes without using a plugin. I have a site using a custom theme and need to make sure this is setup at theme activation vs needing to setup a plugin as well.</p>
<p>Is there a function I can plug into for this?</p>
| [
{
"answer_id": 100727,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>Filter <code>nav_menu_link_attributes</code>:</p>\n\n<pre><code>add_filter( 'nav_menu_link_attributes', 'wpse_100726_e... | 2013/05/25 | [
"https://wordpress.stackexchange.com/questions/100726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25283/"
] | I'm trying to figure out the best way to add custom menu attributes without using a plugin. I have a site using a custom theme and need to make sure this is setup at theme activation vs needing to setup a plugin as well.
Is there a function I can plug into for this? | Filter `nav_menu_link_attributes`:
```
add_filter( 'nav_menu_link_attributes', 'wpse_100726_extra_atts', 10, 3 );
function wpse_100726_extra_atts( $atts, $item, $args )
{
// inspect $item, then …
$atts['custom'] = 'some value';
return $atts;
}
```
This works with WordPress < 3.6:
```
add_filter( 'walke... |
100,749 | <p>I've asked this question already on the WordPress forum, but it sank like a stone, which isn't at all unusual.</p>
<p>I've set up a general Articles page with multiple loops, in order to display the first three articles from any category within the custom post type "Articles." These are all hard-coded into the temp... | [
{
"answer_id": 100741,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Use <code>get_post_custom_keys()</code>:</p>\n\n<pre><code>$fields = get_post_custom_keys( get_the_ID() );\n</code></... | 2013/05/25 | [
"https://wordpress.stackexchange.com/questions/100749",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33293/"
] | I've asked this question already on the WordPress forum, but it sank like a stone, which isn't at all unusual.
I've set up a general Articles page with multiple loops, in order to display the first three articles from any category within the custom post type "Articles." These are all hard-coded into the template, like... | I assume that you are talking about post meta-- data stored in the `$wpdb->postmeta` table when you talk about "meta data fields". [The data in that table is associated with particular posts, of whatever type. It is not in any way keyed directly to the post type itself.](http://codex.wordpress.org/Database_Description#... |
100,767 | <p>I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar.</p>
<p>I started this way but something's not ok:</p>
<pre><code> $category = get_the_category($post->ID);
$current_cat = $category[0]... | [
{
"answer_id": 100769,
"author": "Devoted",
"author_id": 33191,
"author_profile": "https://wordpress.stackexchange.com/users/33191",
"pm_score": 0,
"selected": false,
"text": "<p>Try this way:</p>\n\n<pre><code>global $post;\n$category = get_the_category($post->ID); \n$current_cat = $... | 2013/05/26 | [
"https://wordpress.stackexchange.com/questions/100767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22826/"
] | I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar.
I started this way but something's not ok:
```
$category = get_the_category($post->ID);
$current_cat = $category[0]->cat_name; //This will ... | Try this
```
// Get categories
$categories = wp_get_post_terms( get_the_ID(), 'category');
// Check if there are any categories
if( ! empty( $categories ) ) :
// Get all posts within current category, but exclude current post
$category_posts = new WP_Query( arr... |
100,780 | <p>I'm facing a really weird problem with my wordpress/server.</p>
<p>Sometimes when I add media (images) to a new post, and then try to submit this post, instead of my website I got the information in browser:</p>
<pre><code>connection rejected by server
</code></pre>
<p>I contacted my hosting provider to solve thi... | [
{
"answer_id": 100889,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n <p>I contacted my hosting provider to solve this problem and they claim\n that my wordpress is ... | 2013/05/26 | [
"https://wordpress.stackexchange.com/questions/100780",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15834/"
] | I'm facing a really weird problem with my wordpress/server.
Sometimes when I add media (images) to a new post, and then try to submit this post, instead of my website I got the information in browser:
```
connection rejected by server
```
I contacted my hosting provider to solve this problem and they claim that my ... | >
> I contacted my hosting provider to solve this problem and they claim
> that my wordpress is generating too many simultaneous connections to
> server...
>
>
>
The only times I've seen hosts put limits on the number of MySQL connections is when the host is free or very cheap or incompetent.
Is it free hosting... |
100,781 | <p>I'm using a <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu" rel="nofollow">WordPress Menu</a> to create a navigation structured like this:</p>
<ul>
<li>Home</li>
<li>About</li>
<li>Contact
<ul>
<li>Sub Page</li>
</ul></li>
</ul>
<p>Using this code from <a href="http://wordpress.org/support/topi... | [
{
"answer_id": 100785,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>I would lean very much towards a custom walker for this but I think I've managed to make it work using part o... | 2013/05/26 | [
"https://wordpress.stackexchange.com/questions/100781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13142/"
] | I'm using a [WordPress Menu](http://codex.wordpress.org/Function_Reference/wp_nav_menu) to create a navigation structured like this:
* Home
* About
* Contact
+ Sub Page
Using this code from [kuroi's response here](http://wordpress.org/support/topic/adding-a-class-to-first-and-last-menu-items?replies=6#post-1643645) ... | I would lean very much towards a custom walker for this but I think I've managed to make it work using part of that code and some of my own.
```
function add_position_classes_wpse_100781($classes, $item, $args) {
static $fl;
if (0 == $item->menu_item_parent) {
$fl = (empty($fl)) ? 'first' : 'middle';
$clas... |
100,794 | <p>I wrote a plugin <a href="http://wordpress.org/plugins/premium-posts/" rel="nofollow">Premium Posts</a> that registers a custom taxonomy called <strong>sms_premium_posts</strong> and adds a column to the post list table in the WordPress administration area.</p>
<p>In that custom column, if a post has been marked <s... | [
{
"answer_id": 100796,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>Use a <code>tax_query</code> with a <code>NOT IN</code> operator.</p>\n<pre><code>$args = array(\n 'post_typ... | 2013/05/26 | [
"https://wordpress.stackexchange.com/questions/100794",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5750/"
] | I wrote a plugin [Premium Posts](http://wordpress.org/plugins/premium-posts/) that registers a custom taxonomy called **sms\_premium\_posts** and adds a column to the post list table in the WordPress administration area.
In that custom column, if a post has been marked **Premium**, the term **Premium** links to a filt... | Use a `tax_query` with a `NOT IN` operator.
```
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'sms_premium_posts',
'field' => 'slug',
'terms' => 'Premium',
'operator' => 'NOT IN'
)
)
);
$query = new WP_Query( $args );
```
Now, to make that work... |
100,804 | <p>Is it possible to add specific classes to posts/pages in a query in increments of 2?</p>
<p>For example</p>
<ul>
<li>Post 1</li>
<li>Post 2</li>
<li>Post 3 (add custom class)</li>
<li>Post 4 (add custom class)</li>
<li>Post 5</li>
<li>Post 6</li>
<li>Post 7 (add custom class)</li>
<li>Post 8 (add custom class)</li... | [
{
"answer_id": 100807,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>Filter <code>post_class</code>, use a static internal counter in the filter callback:</p>\n\n<pre><code>add_filter( 'p... | 2013/05/26 | [
"https://wordpress.stackexchange.com/questions/100804",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33310/"
] | Is it possible to add specific classes to posts/pages in a query in increments of 2?
For example
* Post 1
* Post 2
* Post 3 (add custom class)
* Post 4 (add custom class)
* Post 5
* Post 6
* Post 7 (add custom class)
* Post 8 (add custom class)
* Post 9
I don't mind using jQuery if needs be. | Filter `post_class`, use a static internal counter in the filter callback:
```
add_filter( 'post_class', 'wpse_100804_post_class' );
function wpse_100804_post_class( $classes )
{
static $counter = 0;
$counter += 1;
switch ( $counter )
{
case 4:
$counter = 0;
case 3:
... |
100,825 | <p>Ok I am trying to make a page the list user meta.</p>
<p><a href="http://pastebin.com/rw1t7Mgp" rel="nofollow">http://pastebin.com/rw1t7Mgp</a></p>
<p>The part I am stuck on is </p>
<p><code>$our_children = get_user_meta ($user_id,"our_children");</code></p>
<p>it is a meta field with an array in it.</p>
<p><co... | [
{
"answer_id": 100826,
"author": "Andrew Bartel",
"author_id": 17879,
"author_profile": "https://wordpress.stackexchange.com/users/17879",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress stores arrays in the database as serialized data. Once you have retrieved it, you can use ph... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33326/"
] | Ok I am trying to make a page the list user meta.
<http://pastebin.com/rw1t7Mgp>
The part I am stuck on is
`$our_children = get_user_meta ($user_id,"our_children");`
it is a meta field with an array in it.
`a:1:{i:0;a:2:{s:4:"Name";s:6:"Elisha";s:3:"Age";s:2:"13";}}`
How do I display the data in that array?
`//... | You have a few PHP issues preventing output-
1. it appears your foreach is commented out with `//`.
2. you do `foreach( $our_children as $children )`, but then you use `$our_children` instead of `$children` inside the foreach.
3. `$children->Age` is for accessing an object's property, but what you have here is an arra... |
100,834 | <p>I have a custom post type and the content looks something like this:</p>
<pre><code><h3>Description</h3>
The Production Assistant works closely with the production team to ensure that our games ship on time and at our very high standards. You will be a part of an international team and gain valuable in... | [
{
"answer_id": 100836,
"author": "Subharanjan",
"author_id": 13615,
"author_profile": "https://wordpress.stackexchange.com/users/13615",
"pm_score": 2,
"selected": false,
"text": "<p>Try with this by pasting these code inside functions.php file under your current theme.</p>\n\n<pre><code... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100834",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I have a custom post type and the content looks something like this:
```
<h3>Description</h3>
The Production Assistant works closely with the production team to ensure that our games ship on time and at our very high standards. You will be a part of an international team and gain valuable insight into game developmen... | There's a discussion on [WP Support Forum](https://wordpress.org/support/topic/remove-content-within-the-header-tags-in-the-excerpt) that was related to your question. The [pastebin](http://pastebin.com/XMJNtH6A) constains the function stated in the [other answer](https://wordpress.stackexchange.com/a/100836/17305).
I... |
100,838 | <p>I am trying to fetch and insert images outside the wordpress environment to a custom post via PHP.</p>
<p>How to move/upload that image to wordpress upload directory year date folder format just like wordpress do and set that image to featured image against the custom post?</p>
<p>Also to upload image to custom po... | [
{
"answer_id": 100848,
"author": "Simon",
"author_id": 10889,
"author_profile": "https://wordpress.stackexchange.com/users/10889",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps I am misunderstanding, but why would you want to do that outside of the WordPress environment? Replicat... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30847/"
] | I am trying to fetch and insert images outside the wordpress environment to a custom post via PHP.
How to move/upload that image to wordpress upload directory year date folder format just like wordpress do and set that image to featured image against the custom post?
Also to upload image to custom post gallery?
Belo... | Can't this simply be done with [media\_sideload\_image()](http://codex.wordpress.org/Function_Reference/media_sideload_image) ?
Seems pretty simple. Only catch is if you aren't on admin area, you must include some libraries from within WordPress includes:
```
// only need these if performing outside of admin environm... |
100,855 | <p>i'm new in wordpress so please suggest me.
i'm selling ring, earings, chains, ect.
ring, earings "catogry"
and ring-1, ring=2 product.
so i want to show on shop page my catogry and on click catogry my products will show</p>
| [
{
"answer_id": 100848,
"author": "Simon",
"author_id": 10889,
"author_profile": "https://wordpress.stackexchange.com/users/10889",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps I am misunderstanding, but why would you want to do that outside of the WordPress environment? Replicat... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33335/"
] | i'm new in wordpress so please suggest me.
i'm selling ring, earings, chains, ect.
ring, earings "catogry"
and ring-1, ring=2 product.
so i want to show on shop page my catogry and on click catogry my products will show | Can't this simply be done with [media\_sideload\_image()](http://codex.wordpress.org/Function_Reference/media_sideload_image) ?
Seems pretty simple. Only catch is if you aren't on admin area, you must include some libraries from within WordPress includes:
```
// only need these if performing outside of admin environm... |
100,867 | <p>I created a plugin that activate my theme programmatically. I want to set default permalink using programming. It does't seems to work with custom post types. it works well with default custom post type.</p>
<p>I tried it on admin_footer hook with 9999 priority but not helped.</p>
<p>The code i used is:</p>
<pre>... | [
{
"answer_id": 100909,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>do something like this:</p>\n\n<pre><code>function setup_permalinks_by_default() {\n global $wp_... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33338/"
] | I created a plugin that activate my theme programmatically. I want to set default permalink using programming. It does't seems to work with custom post types. it works well with default custom post type.
I tried it on admin\_footer hook with 9999 priority but not helped.
The code i used is:
```
add_action('admin_foo... | Try to do something like this.
```
<?php
/*
Plugin Name: My Custom Plugin
Plugin URI:
Description:
Author:
Version: 1.0
Author URI:
*/
/* Runs when plugin is activated */
register_activation_hook(__FILE__, 'mcp_install');
/* Runs on plugin deactivation*/
register_deactivation_hook( __FILE__, 'mcp_remove' );
... |
100,868 | <p>I am working in a new project using WordPress. I have created some Custom Posts and now I have to relate some custom posts like categories.</p>
<p>I created a custom dropdown menu inside the custom posts. The dropdown displays the title of the customs post but I don´t know how to save them. </p>
<p>Here is my code... | [
{
"answer_id": 100870,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>one thing before I start: using query_posts in this context is simply bad bad bad.\nas for the rest here is ... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32788/"
] | I am working in a new project using WordPress. I have created some Custom Posts and now I have to relate some custom posts like categories.
I created a custom dropdown menu inside the custom posts. The dropdown displays the title of the customs post but I don´t know how to save them.
Here is my code:
```
/* add cus... | I solved the problem with this code by creating again de meta box:
```
// Add the Meta Box
function add_custom_meta_box() {
add_meta_box(
'custom_meta_box', // $id
'Product Requirements', // $title
'show_custom_meta_box', // $callback
'produktkrav', // $page
'normal', // $co... |
100,880 | <p>I need to sum custom field values of a custom post type with a particular taxonomy ONLY.</p>
<p>For example...</p>
<ul>
<li>Custom Post Type: Computers</li>
<li>Taxonomy: Laptops</li>
<li>Custom Field: Quantity</li>
</ul>
<p>How can I get the quantity value of "laptop" "computers" only?
I have been using the foll... | [
{
"answer_id": 100870,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>one thing before I start: using query_posts in this context is simply bad bad bad.\nas for the rest here is ... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32982/"
] | I need to sum custom field values of a custom post type with a particular taxonomy ONLY.
For example...
* Custom Post Type: Computers
* Taxonomy: Laptops
* Custom Field: Quantity
How can I get the quantity value of "laptop" "computers" only?
I have been using the following to sum custom fields of ALL taxonomies... c... | I solved the problem with this code by creating again de meta box:
```
// Add the Meta Box
function add_custom_meta_box() {
add_meta_box(
'custom_meta_box', // $id
'Product Requirements', // $title
'show_custom_meta_box', // $callback
'produktkrav', // $page
'normal', // $co... |
100,914 | <p>I want the featured image of a post to display not only in the blog list view, but also inside the post (when i press "Read More..."). How do i do that? </p>
<p>I pasted this</p>
<pre><code>if ( has_post_thumbnail() ) {
the_post_thumbnail('full');
}
</code></pre>
<p>in single.php just before the_post();. It lo... | [
{
"answer_id": 100916,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>There should be a file in your theme called <code>content-single.php</code> (if it's not there, look instead fo... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33351/"
] | I want the featured image of a post to display not only in the blog list view, but also inside the post (when i press "Read More..."). How do i do that?
I pasted this
```
if ( has_post_thumbnail() ) {
the_post_thumbnail('full');
}
```
in single.php just before the\_post();. It looks like this:
```
while (have_... | @PatJ's answer affords the most control over the placement of the image but involves editing the theme, which may or may not be wise, or possible, depending on the circumstance, so an alternative is to add a filter to `the_content`.
```
function add_thumb_wpse_100914($content) {
// check that we are on a 'single' ... |
100,929 | <p>I have a client with a private Wordpress blog - that is to say, you need to log in to read it.</p>
<p>We are using Counterize to keep track of visits to the site and to find the most popular pages.</p>
<p>But now he wants to know which users are logging in, and perhaps how often they are logging in to read this bl... | [
{
"answer_id": 100930,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p>A basic user login tracker is pretty trivial to implement.</p>\n\n<pre><code>function track_user_login_wpse_... | 2013/05/27 | [
"https://wordpress.stackexchange.com/questions/100929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3058/"
] | I have a client with a private Wordpress blog - that is to say, you need to log in to read it.
We are using Counterize to keep track of visits to the site and to find the most popular pages.
But now he wants to know which users are logging in, and perhaps how often they are logging in to read this blog.
I checked to... | A basic user login tracker is pretty trivial to implement.
```
function track_user_login_wpse_100929($id,$user) {
$tracking = get_user_meta($user->ID,'tracking_key_name',true);
$tracking[] = time();
update_user_meta($user->ID,'tracking_key_name',$tracking);
}
add_action('wp_login','track_user_login_wpse_100929'... |
100,948 | <p>I am using the <strong>content-video.php</strong> include to show the latest video post on my homepage. The include only shows the video from the post and not the rest of the content, which works well.</p>
<p>My problem is, if I add any content (eg - text, another link, etc) after the link to the video in the post,... | [
{
"answer_id": 100950,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>If you don’t <em>know</em> what the content is, use a regular expression to test if there is an URL.</p>\n\n<p>Sample... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/100948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33358/"
] | I am using the **content-video.php** include to show the latest video post on my homepage. The include only shows the video from the post and not the rest of the content, which works well.
My problem is, if I add any content (eg - text, another link, etc) after the link to the video in the post, it breaks my video emb... | If you don’t *know* what the content is, use a regular expression to test if there is an URL.
Sample code:
```
$content = get_the_content();
$pattern = '~([^"\'])?(https?://.*\.(flv|aac|mp4|mov|m4a|f4a|ogg|oga|mp3))([^"\'\?])?~i';
if ( preg_match( $pattern, $content, $matches ) )
{
$parsedUrl = parse_url( $matc... |
100,961 | <p>I am creating a Wordpress plugin which create pages (with <code>get_header()</code>, <code>get_footer()</code> and <code>get_sidebar()</code>) for searching through an API.</p>
<p>Of course, I have defined some rules for URL rewriting like this:</p>
<pre><code>function init() {
global $wp_rewrite;
add_rewr... | [
{
"answer_id": 100964,
"author": "Core",
"author_id": 27917,
"author_profile": "https://wordpress.stackexchange.com/users/27917",
"pm_score": 0,
"selected": false,
"text": "<p>I found the code.</p>\n\n<pre><code>modify_permalinks('/%postname%/','','');\nfunction modify_permalinks($permal... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/100961",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33370/"
] | I am creating a Wordpress plugin which create pages (with `get_header()`, `get_footer()` and `get_sidebar()`) for searching through an API.
Of course, I have defined some rules for URL rewriting like this:
```
function init() {
global $wp_rewrite;
add_rewrite_rule('my_plugin/(.+)/results?', 'index.php?my_plug... | Whenever I create a plugin that needs permalinks enabled i check on the plugin activation and if its not set i display a message for the user:
```
// Add Check if permalinks are set on plugin activation
register_activation_hook( __FILE__, 'is_permalink_activate' );
function is_permalink_activate() {
//add notice i... |
100,973 | <p>I've created a custom filtering facility for a front end search, which also includes a specific user group.</p>
<p>To add the function to the search I have used </p>
<pre><code>add_filter('pre_get_posts','my_filter_the_search',10,1);
function my_filter_the_search($query){
$post_type = filter_input(INPUT_GET,... | [
{
"answer_id": 100975,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>Just do a <code>var_dump( $query );</code> inside your callback to see the objects properties. One of the property... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/100973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26814/"
] | I've created a custom filtering facility for a front end search, which also includes a specific user group.
To add the function to the search I have used
```
add_filter('pre_get_posts','my_filter_the_search',10,1);
function my_filter_the_search($query){
$post_type = filter_input(INPUT_GET, 'post_type', FILTER_... | Only hook the function if its not the backend.
```
if( !is_admin() ){
add_filter('pre_get_posts','my_filter_the_search',10,1);
}
``` |
100,980 | <p>I'm using the plugin "Fancybox for Wordpress" in WP 3.5.1. On small screens, I want to disable the fancybox-script. So, at top of header-file, I include a check for user agent, and sets global variable <code>$is_mobile</code> <code>true</code> or <code>false</code>. This works.</p>
<p>However, depending on this, I ... | [
{
"answer_id": 100985,
"author": "user33379",
"author_id": 33379,
"author_profile": "https://wordpress.stackexchange.com/users/33379",
"pm_score": -1,
"selected": false,
"text": "<p>Directly under that script try:</p>\n\n<p>$is_mobile = is_mobile();</p>\n"
},
{
"answer_id": 10098... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/100980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33378/"
] | I'm using the plugin "Fancybox for Wordpress" in WP 3.5.1. On small screens, I want to disable the fancybox-script. So, at top of header-file, I include a check for user agent, and sets global variable `$is_mobile` `true` or `false`. This works.
However, depending on this, I would like to add something like this to `f... | You could have a try with [`wp_is_mobile()`](http://codex.wordpress.org/Function_Reference/wp_is_mobile):
```
if ( wp_is_mobile() ) {
remove_action( 'wp_print_scripts', 'mfbfw_load' );
remove_action( 'wp_print_styles', 'mfbfw_css' );
remove_action( 'wp_head', 'mfbfw_init' );
}
```
You should also check with ta... |
100,990 | <p>Trying to include the post title in my excerpt readmore links. I've read the codex on this, but my theme files are much more complicated so I could use a bit of expert help...</p>
<p>Extract from functions.php: ** Edited to show more code.........</p>
<pre><code>function theme_get_content($args = array()) {
$more... | [
{
"answer_id": 101000,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 2,
"selected": true,
"text": "<p>If the following code is in-fact the code that is controlling your read more link then you perhaps the following ... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/100990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22537/"
] | Trying to include the post title in my excerpt readmore links. I've read the codex on this, but my theme files are much more complicated so I could use a bit of expert help...
Extract from functions.php: \*\* Edited to show more code.........
```
function theme_get_content($args = array()) {
$more_tag = theme_get_ar... | If the following code is in-fact the code that is controlling your read more link then you perhaps the following may work;
```
if ($show_more_tag) {
global $post;
$excerpt = $excerpt . ' <a class="more-link" href="' . $perma_link . '">' . get_the_title($post->ID) . ' </a>';
}
```
I've declared `global $post;... |
100,992 | <p>I am trying to show the profile fields (like AIM, Jibber) outside the loop. I managed to do that with</p>
<pre><code><?php
global $post;
$author_id=$post->post_author;
?>
<?php
$field='aim';
the_author_meta( $field, $author_id );
?>
</code></pre>
<p>But now, I can't put an image beside it if such a... | [
{
"answer_id": 101000,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 2,
"selected": true,
"text": "<p>If the following code is in-fact the code that is controlling your read more link then you perhaps the following ... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/100992",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | I am trying to show the profile fields (like AIM, Jibber) outside the loop. I managed to do that with
```
<?php
global $post;
$author_id=$post->post_author;
?>
<?php
$field='aim';
the_author_meta( $field, $author_id );
?>
```
But now, I can't put an image beside it if such a field exists. This works inside the loop... | If the following code is in-fact the code that is controlling your read more link then you perhaps the following may work;
```
if ($show_more_tag) {
global $post;
$excerpt = $excerpt . ' <a class="more-link" href="' . $perma_link . '">' . get_the_title($post->ID) . ' </a>';
}
```
I've declared `global $post;... |
101,003 | <p>I am creating several jQuery scripts to help validate forms before they are submitted. I have read that it is best to always separate jQuery scripts into a separate file so that you can load the script with <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script"><code>wp_enqeue_script</code></a>.<... | [
{
"answer_id": 101006,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>you could still put the script in a seperate js-file, but separate from the rest of your script(-fi... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/101003",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | I am creating several jQuery scripts to help validate forms before they are submitted. I have read that it is best to always separate jQuery scripts into a separate file so that you can load the script with [`wp_enqeue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script).
However, if I am doing so... | You can target a specific page using [`is_page()`](http://codex.wordpress.org/Function_Reference/is_page) when you are enqueueing your JS file.
```
function my_scripts_method() {
if( is_page('your page title') ){
wp_enqueue_script( 'your-js-script' );
}
}
add_action( 'wp_enqueue_scripts', 'my_scripts_me... |
101,005 | <p>I want to use a time tag with the datetime attribute in it... I tried this in <strong>functions.php</strong>:</p>
<pre><code><time class="time" datetime='. the_date('d-m-Y') . '>%3$s '.get_the_time( $d, $post ).'</time>'
</code></pre>
<p>But instead of putting it in the <code>time tag</code>, it output... | [
{
"answer_id": 101008,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>General WordPress rule:</p>\n\n<p>when a function starts with <code>get</code>, it will return the value. If i... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/101005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | I want to use a time tag with the datetime attribute in it... I tried this in **functions.php**:
```
<time class="time" datetime='. the_date('d-m-Y') . '>%3$s '.get_the_time( $d, $post ).'</time>'
```
But instead of putting it in the `time tag`, it outputs the date in the content itself, which is very weird... How c... | General WordPress rule:
when a function starts with `get`, it will return the value. If it starts with `the`, it echoes the value.
Here, you need [`get_the_date('d-m-Y')`](http://codex.wordpress.org/Function_Reference/get_the_date) instead of `the_date('d-m-Y')`. |
101,043 | <p>My team has inherited a large WordPress Networks install. Updates need to be run and we need to communicate this to our editors and administrators. My system admin has asked me for a list of URLs and email address matched to those URLs. We plan to contact them site-by-site to manage a system wide upgrade. </p>
<p>W... | [
{
"answer_id": 101866,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>There's <a href=\"https://codex.wordpress.org/Function_Reference/get_users\" rel=\"nofollow\"><code>get_users()... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/101043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33401/"
] | My team has inherited a large WordPress Networks install. Updates need to be run and we need to communicate this to our editors and administrators. My system admin has asked me for a list of URLs and email address matched to those URLs. We plan to contact them site-by-site to manage a system wide upgrade.
What would ... | This should do the trick. Read along with the comments for some explanation.
```
// get users with specified roles -- this can go in functions
function get_users_with_role( $roles ) {
global $wpdb;
if ( ! is_array( $roles ) )
$roles = array_walk( explode( ",", $roles ), 'trim' );
$sql = '
S... |
101,049 | <pre><code> <?php
if ( has_post_thumbnail()) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
echo '<a href="' . $large_image_url[0] . '" >';
the_post_thumbnail('medium');
echo '</a>';
}
?>
</code></pre>
<p>This code adds a big image to the thumbnai... | [
{
"answer_id": 101056,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Check the Codex. <a href=\"http://codex.wordpress.org/Function_Reference/the_post_thumbnail\" rel=\"nofollow... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/101049",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27243/"
] | ```
<?php
if ( has_post_thumbnail()) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
echo '<a href="' . $large_image_url[0] . '" >';
the_post_thumbnail('medium');
echo '</a>';
}
?>
```
This code adds a big image to the thumbnail image. What can I do add title to '... | Check the Codex. [`the_post_thumbnail`](http://codex.wordpress.org/Function_Reference/the_post_thumbnail) accepts two parameters, the second of which is `$attr`-- "attributes".
```
the_post_thumbnail('full',array('title'=>'yay! a title!'));
```
The Codex entry for [`the_post_thumbnail`](http://codex.wordpress.org/Fu... |
101,055 | <p>I'm trying to get all posts from a particular custom post type using the following code:</p>
<pre><code>$auctions = get_posts(array('post_type' => 'auction'));
print_r($auctions);
echo '<select>';
foreach ($auctions as $auction) {
echo '<option value="' . $auction->ID . '">' . $auction->pos... | [
{
"answer_id": 101058,
"author": "stellarcowboy",
"author_id": 33207,
"author_profile": "https://wordpress.stackexchange.com/users/33207",
"pm_score": 1,
"selected": false,
"text": "<p>Perhaps because <code>get_posts</code> returns an object, you need to setup post data per <a href=\"htt... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/101055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33049/"
] | I'm trying to get all posts from a particular custom post type using the following code:
```
$auctions = get_posts(array('post_type' => 'auction'));
print_r($auctions);
echo '<select>';
foreach ($auctions as $auction) {
echo '<option value="' . $auction->ID . '">' . $auction->post_title . '</option>';
}
echo '</se... | You can use `wp_query()` for this to work
```
$args = array(
'post_type' => 'auction',
'posts_per_page' => -1
);
$query = new WP_Query($args);
if ($query->have_posts()):
echo '<select>';
while ($query->have_posts()): $query->the_post();
echo '<option value="' . get_the_ID() . '... |
101,061 | <p>My goal is to use human_time_diff only when the post was added on the current day. When it wasn't, I would like to revert to the traditional timestamp (the second code). I'm unsure how this would be achieved and need some help. I have provided the two codes I would be combining below.</p>
<p>The code for grabbin... | [
{
"answer_id": 101065,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>You need to express your condition in code. You are interested in comparing to current day, which can be expressed ... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/101061",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | My goal is to use human\_time\_diff only when the post was added on the current day. When it wasn't, I would like to revert to the traditional timestamp (the second code). I'm unsure how this would be achieved and need some help. I have provided the two codes I would be combining below.
The code for grabbing the diffe... | You can get the post's creation date/time and compare it to the current date/time.
```
global $post;
$now = time(); // Current time in seconds since Epoch
$post_created = strtotime( $post->post_date ); // post's creation date in seconds since Epoch, so we're comparing apples to apples
$one_day_in_seconds = 24*60*60;
... |
101,085 | <p>I am trying to create the ability for the end user to add quotes (testimonials) as posts. So far, so good. I have enabled the 'quote' post-format in my theme. So the ability exists to enter said testimonials, and I have even figured out how to show some random quotes in the sidebar. The next obvious step is to have ... | [
{
"answer_id": 101065,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>You need to express your condition in code. You are interested in comparing to current day, which can be expressed ... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33419/"
] | I am trying to create the ability for the end user to add quotes (testimonials) as posts. So far, so good. I have enabled the 'quote' post-format in my theme. So the ability exists to enter said testimonials, and I have even figured out how to show some random quotes in the sidebar. The next obvious step is to have a "... | You can get the post's creation date/time and compare it to the current date/time.
```
global $post;
$now = time(); // Current time in seconds since Epoch
$post_created = strtotime( $post->post_date ); // post's creation date in seconds since Epoch, so we're comparing apples to apples
$one_day_in_seconds = 24*60*60;
... |
101,092 | <p>I recently changed my theme from one custom theme to another custom theme.</p>
<p>There were previously pages that used template files (i.e., "Blog" page uses Blog template) and now that I've changed themes the pages are not redirecting as usual.</p>
<p>I tried importing the old data and then each page was created... | [
{
"answer_id": 101093,
"author": "Elisha Terada",
"author_id": 33229,
"author_profile": "https://wordpress.stackexchange.com/users/33229",
"pm_score": 0,
"selected": false,
"text": "<p>Try resetting the permalink by clicking \"Save Changes\" in Settings > Permalinks in the admin page.</p... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33421/"
] | I recently changed my theme from one custom theme to another custom theme.
There were previously pages that used template files (i.e., "Blog" page uses Blog template) and now that I've changed themes the pages are not redirecting as usual.
I tried importing the old data and then each page was created twice (i.e., Blo... | If you're getting
```
Index of /blog
Apache Server Port 80
```
instead of a `404` page, you might be having a folder called `blog` in on your server. Try deleting or renaming that folder if you're not using it.
EDIT:
Here is a related question: [WP Page and Subdirectory with same name](https://wordpress.stackexcha... |
101,094 | <p>How can you get the category ID of "category-name" from a nice URL (e.g. <a href="http://www.example.com/category/category-name/" rel="nofollow">http://www.example.com/category/category-name/</a>)?</p>
<p>I need to retrieve the category ID from a URL of wordpress because this function will be used in wp_nav_menu() ... | [
{
"answer_id": 101095,
"author": "acsmith",
"author_id": 31960,
"author_profile": "https://wordpress.stackexchange.com/users/31960",
"pm_score": 0,
"selected": false,
"text": "<p>You will want a couple of steps:</p>\n\n<ol>\n<li><a href=\"http://codex.wordpress.org/Function_Reference/get... | 2013/05/28 | [
"https://wordpress.stackexchange.com/questions/101094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | How can you get the category ID of "category-name" from a nice URL (e.g. <http://www.example.com/category/category-name/>)?
I need to retrieve the category ID from a URL of wordpress because this function will be used in wp\_nav\_menu() since the design of the site is to have a dropdown of latest post under the catego... | Try this,
```
$cat = get_category_by_path('http://www.example.com/category/category-name/')
```
Reference <http://codex.wordpress.org/Function_Reference/get_category_by_path> |
101,096 | <p>the code I am using below will show the last 5 post in whatever category I choose, but I was wondering, How can I get it so that the first post shows different from the other 4?</p>
<p>I want the first post to show the thumbnail and the title under it and the rest to show titles. I found a code on a recent post on <... | [
{
"answer_id": 101097,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p>The code you show wraps your first post in a <code><div class='first-post'>...</div></code> element... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32447/"
] | the code I am using below will show the last 5 post in whatever category I choose, but I was wondering, How can I get it so that the first post shows different from the other 4?
I want the first post to show the thumbnail and the title under it and the rest to show titles. I found a code on a recent post on [here](htt... | The code you posted will only make difference in adding `<div class="first-post"></div>` for the first post, so it still displays same information for all posts.
Try this instead:
```
<?php
$queryObject = new Wp_Query( array(
'showposts' => 5,
'post_type' => array('post'),
'category_name' => videos,
... |
101,109 | <p>the bigger question is:
How to have a beta (test) site and production, and switch between them so easily that a user can do it.</p>
<p>I <strong>wrote a script</strong> that does the move. Here's what the script does:</p>
<pre><code>1. saves the target wp-config DB settings
2. dumps source_DB, with --add-drop-tabl... | [
{
"answer_id": 101140,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>You cannot just do a plain text string replacement on database dump - that breaks any serialized data, that contain... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101109",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5923/"
] | the bigger question is:
How to have a beta (test) site and production, and switch between them so easily that a user can do it.
I **wrote a script** that does the move. Here's what the script does:
```
1. saves the target wp-config DB settings
2. dumps source_DB, with --add-drop-table --add-drop-database
3. replaces... | There's a set of tutorials on how to deploy WordPress (source and DB) using Capistrano.
[Part 1](http://theme.fm/2011/08/tutorial-deploying-wordpress-with-capistrano-2082/)
| [Part 2](http://theme.fm/2011/09/deploying-wordpress-with-capistrano-part-2-staging-servers-tagging-database-security-2213/)
| [Part 3](http:/... |
101,115 | <p>I am creating a responsive WordPress website with a mobile-first approach.</p>
<p>When my client uploads an image for a blog post, I would like WordPress to then generate smaller versions of the image (with a smaller file size!) which then get served to smaller screen sizes?</p>
<p>Even if the user has to upload s... | [
{
"answer_id": 101117,
"author": "v123shine",
"author_id": 27378,
"author_profile": "https://wordpress.stackexchange.com/users/27378",
"pm_score": 0,
"selected": false,
"text": "<p>The easiest way is using <strong>css</strong></p>\n\n<p>I use the following code to my site.</p>\n\n<pre><c... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24587/"
] | I am creating a responsive WordPress website with a mobile-first approach.
When my client uploads an image for a blog post, I would like WordPress to then generate smaller versions of the image (with a smaller file size!) which then get served to smaller screen sizes?
Even if the user has to upload several versions o... | add\_image\_size does change the actual size of the image file.
What I hava tried:
```
function odevice_image_sizes() {
add_image_size( 'iphone-size', 300, 100, true );//OF course the dimensions are not correct...
add_image_size( 'tablet-size', 600, 300, true );
}
function show_odevice_at_img_select($sizes) ... |
101,133 | <p>I have a question about the wp_mail() function. Right now I'm having the following button to send e-mail with:</p>
<pre><code>echo '<input type="submit" name="send_button" value="verzenden" id="'.$post_id.'" class="send_post">';
</code></pre>
<p>which triggers a jQuery request:</p>
<pre><code>jQuery(documen... | [
{
"answer_id": 101138,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>What am i doing wrong here?</p>\n</blockquote>\n\n<p>Many, many things, not all performance r... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101133",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33436/"
] | I have a question about the wp\_mail() function. Right now I'm having the following button to send e-mail with:
```
echo '<input type="submit" name="send_button" value="verzenden" id="'.$post_id.'" class="send_post">';
```
which triggers a jQuery request:
```
jQuery(document).ready(function() {
jQuery(".send_post"... | >
> What am i doing wrong here?
>
>
>
Many, many things, not all performance related. Lets begin with the critical parts, then conclude on your performance issues and what can be done to mitigate and help
AJAX API
========
Firstly, you're not using the AJAX API, and reinventing the wheel. It's quite simple:
JS:... |
101,165 | <p>I am allowing user's to upload their images, so to show their uploaded images i am using<code><?php echo $options_images['image_bg'];?></code> <b>which outputs this</b>:<code>http://www.mydomain.com/myfolder/wp-content/uploads/2013/05/deleteme.png</code>. So now my image is displayed properly.
Now i want to al... | [
{
"answer_id": 101138,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>What am i doing wrong here?</p>\n</blockquote>\n\n<p>Many, many things, not all performance r... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101165",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20941/"
] | I am allowing user's to upload their images, so to show their uploaded images i am using`<?php echo $options_images['image_bg'];?>` **which outputs this**:`http://www.mydomain.com/myfolder/wp-content/uploads/2013/05/deleteme.png`. So now my image is displayed properly.
Now i want to allow my users **to delete** that im... | >
> What am i doing wrong here?
>
>
>
Many, many things, not all performance related. Lets begin with the critical parts, then conclude on your performance issues and what can be done to mitigate and help
AJAX API
========
Firstly, you're not using the AJAX API, and reinventing the wheel. It's quite simple:
JS:... |
101,166 | <p>I have a simple function that automatically formats the whole post after publishing/updating.</p>
<p>It's hooked on: </p>
<pre><code>add_action('save_post', 'myFunction');
</code></pre>
<p>I would like to format every post, that I already have in database. I know I can open every post and click on update to call ... | [
{
"answer_id": 101187,
"author": "iyrin",
"author_id": 33393,
"author_profile": "https://wordpress.stackexchange.com/users/33393",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, this is possible. Something like this should affect all posts that are currently published. Literally run ... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33454/"
] | I have a simple function that automatically formats the whole post after publishing/updating.
It's hooked on:
```
add_action('save_post', 'myFunction');
```
I would like to format every post, that I already have in database. I know I can open every post and click on update to call the "save\_post" hook on myFuncti... | Yes, this is possible. Something like this should affect all posts that are currently published. Literally run this once and then disable it by commenting out the add\_action or you will have a bunch of unwanted queries to the database.
Running once: With this code placed in your functions.php, the function will run ... |
101,170 | <p>I'm using the save_post action to save some meta data in a custom post type:</p>
<pre><code>function my_save_post($post_id) {
// is autosave?
if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// verify nonce
if ( !wp_verify_nonce( $_POST['metabox_nonce'], base... | [
{
"answer_id": 101178,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>You could use the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data\" rel=\"nofo... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101170",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33049/"
] | I'm using the save\_post action to save some meta data in a custom post type:
```
function my_save_post($post_id) {
// is autosave?
if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// verify nonce
if ( !wp_verify_nonce( $_POST['metabox_nonce'], basename(__FILE__) )) {
... | You could use the [`wp_insert_post_data`](http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data) filter instead, which gives you direct access to the post's data.
```
function wpa_insert_post( $data , $postarr ){
//do something with $data['post_parent']
return $data;
}
add_filter( 'wp_ins... |
101,200 | <p>I removed the tabs from the WP editor using </p>
<pre><code>wp_editor('', 'some-id', array('quicktags' => false) );
</code></pre>
<p>But sometimes when the page loads the TinyMCE field loads with the Text tab selected:</p>
<p><img src="https://i.stack.imgur.com/gfB8r.png" alt=""></p>
<p>Rather than the HTML t... | [
{
"answer_id": 101178,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>You could use the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data\" rel=\"nofo... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25372/"
] | I removed the tabs from the WP editor using
```
wp_editor('', 'some-id', array('quicktags' => false) );
```
But sometimes when the page loads the TinyMCE field loads with the Text tab selected:

Rather than the HTML tab:

Is there a... | You could use the [`wp_insert_post_data`](http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data) filter instead, which gives you direct access to the post's data.
```
function wpa_insert_post( $data , $postarr ){
//do something with $data['post_parent']
return $data;
}
add_filter( 'wp_ins... |
101,213 | <p>I'm trying to figure out how to get to a is_child() equivalent; I'd like to be able to target the parent page and it's children. How can this be achieved?</p>
<p>My pseudo-code is...</p>
<pre><code>if (is_page('pagename') || is_child('pagename')) {...}
</code></pre>
<p>...however, the is_child() doesn't seem to w... | [
{
"answer_id": 101216,
"author": "iyrin",
"author_id": 33393,
"author_profile": "https://wordpress.stackexchange.com/users/33393",
"pm_score": 1,
"selected": true,
"text": "<p>To check for a specific parent ID use <code>$post->post_parent==\"123\"</code> and replace \"123\" with the p... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15360/"
] | I'm trying to figure out how to get to a is\_child() equivalent; I'd like to be able to target the parent page and it's children. How can this be achieved?
My pseudo-code is...
```
if (is_page('pagename') || is_child('pagename')) {...}
```
...however, the is\_child() doesn't seem to work. I would like it to return ... | To check for a specific parent ID use `$post->post_parent=="123"` and replace "123" with the parent ID of your choice.
I learned how to do this by using the Widget Logic plugin. From the [Widget Logic notes](http://wordpress.org/plugins/widget-logic/other_notes/):
`global $post; return (is_page('pagename') || ($post-... |
101,217 | <p>With a multi-user blog, how can I add a <em>posted by Some Author</em> line, or something similar, at the top of each post, as in <a href="http://blog.stackexchange.com/">this blog</a>? I assumed this should be something very basic, and there should be a setting for it, but I can't seem to find it anywhere.</p>
| [
{
"answer_id": 101220,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Short answer, but it sounds like what you want is <a href=\"http://codex.wordpress.org/Function_Reference/th... | 2013/05/29 | [
"https://wordpress.stackexchange.com/questions/101217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33461/"
] | With a multi-user blog, how can I add a *posted by Some Author* line, or something similar, at the top of each post, as in [this blog](http://blog.stackexchange.com/)? I assumed this should be something very basic, and there should be a setting for it, but I can't seem to find it anywhere. | A plug-in might use `the_content` filter to append / prepend this, but if you're a theme author or otherwise are able to edit the the theme templates directly.
In this case you want to edit your theme's `single.php`. (You can always check which template file is being used by a particular page using this answer: <https... |
101,230 | <p>I am in process of writing a plugin that has front-end shortcodes that display a user's information/data. If the user is not logged in, I need to redirect to a front-end login page/form. What would be the best practice here? My plugin creates the pages that I use as well as add the shortcodes to those pages. So,... | [
{
"answer_id": 101231,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 2,
"selected": true,
"text": "<p>Not sure about the best practices, but I have a few custom login-sensitive pages which simply display a mess... | 2013/05/30 | [
"https://wordpress.stackexchange.com/questions/101230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30695/"
] | I am in process of writing a plugin that has front-end shortcodes that display a user's information/data. If the user is not logged in, I need to redirect to a front-end login page/form. What would be the best practice here? My plugin creates the pages that I use as well as add the shortcodes to those pages. So, if the... | Not sure about the best practices, but I have a few custom login-sensitive pages which simply display a message if user is not logged and is trying to view the page directly:
```
$logged_in = is_user_logged_in();
if($logged_in) {
?>
<article id="post">
<?php the_content(); ?>
</article>
<?php
} else {
_e(... |
101,238 | <p>I need to remove a function from the parent theme and replace it within the child theme.</p>
<p>The function is called print_meta($meta_box). The function is not pluggable and it located in a random file, not the functions.php file. </p>
<p>The function adds options to a metabox that shows in a page or post. I nee... | [
{
"answer_id": 101240,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Is this even possible?</p>\n</blockquote>\n\n<p>If your description is correct and ...</p>\n... | 2013/05/30 | [
"https://wordpress.stackexchange.com/questions/101238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16641/"
] | I need to remove a function from the parent theme and replace it within the child theme.
The function is called print\_meta($meta\_box). The function is not pluggable and it located in a random file, not the functions.php file.
The function adds options to a metabox that shows in a page or post. I need to add more o... | >
> Is this even possible?
>
>
>
If your description is correct and ...
1. The function is not pluggable, by which I assume you mean not
wrapped in a `if (!function_exists())` condition and
2. The function is not a callback for an action or a filter and
3. The function is not in a theme file that gets automatical... |
101,268 | <p>I need to show all subcategories using</p>
<pre><code>$product_category = wp_get_post_terms( $post->ID, 'product_cat' );
</code></pre>
<p>actually I use:</p>
<pre><code><?php
global $post;
$terms = get_the_terms( $post->ID, 'product_cat', 'hide_empty=0' );
foreach ( $terms as $term ){
$category_i... | [
{
"answer_id": 101273,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>Try something like this:</p>\n\n<h3>by ID</h3>\n\n<pre><code>function woocommerce_subcats_from_paren... | 2013/05/30 | [
"https://wordpress.stackexchange.com/questions/101268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33492/"
] | I need to show all subcategories using
```
$product_category = wp_get_post_terms( $post->ID, 'product_cat' );
```
actually I use:
```
<?php
global $post;
$terms = get_the_terms( $post->ID, 'product_cat', 'hide_empty=0' );
foreach ( $terms as $term ){
$category_id = $term->term_id;
$category_name = $term... | Try something like this:
### by ID
```
function woocommerce_subcats_from_parentcat_by_ID($parent_cat_ID) {
$args = array(
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 0,
'parent' => $parent_cat_ID,
'taxonomy' => 'product_cat'
);
$subcats = get_categories(... |
101,279 | <p>For example, I want Sidebar A to display <strong>nothing but one</strong> text widget and Sidebar B to display <strong>anything but</strong> text widgets. How can I do that?</p>
<p>Thanks.</p>
| [
{
"answer_id": 101273,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>Try something like this:</p>\n\n<h3>by ID</h3>\n\n<pre><code>function woocommerce_subcats_from_paren... | 2013/05/30 | [
"https://wordpress.stackexchange.com/questions/101279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33497/"
] | For example, I want Sidebar A to display **nothing but one** text widget and Sidebar B to display **anything but** text widgets. How can I do that?
Thanks. | Try something like this:
### by ID
```
function woocommerce_subcats_from_parentcat_by_ID($parent_cat_ID) {
$args = array(
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 0,
'parent' => $parent_cat_ID,
'taxonomy' => 'product_cat'
);
$subcats = get_categories(... |
101,296 | <p>When I run a simple php file called test.php (placed in the root of the wp installation) that contains something like that:</p>
<pre><code><?php echo date('H:i:s'); ?>
</code></pre>
<p>The result is right: <code>15:30:00</code> and the timezone is set also correctly to Europe/Prague which is UTC+2 time</p>
... | [
{
"answer_id": 101313,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress uses GMT. The only way to get around that is to <a href=\"http://php.net/manual/en/function.date... | 2013/05/30 | [
"https://wordpress.stackexchange.com/questions/101296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | When I run a simple php file called test.php (placed in the root of the wp installation) that contains something like that:
```
<?php echo date('H:i:s'); ?>
```
The result is right: `15:30:00` and the timezone is set also correctly to Europe/Prague which is UTC+2 time
However, if I place the same line within my e.g... | WordPress uses GMT. The only way to get around that is to [declare a new timezone](http://php.net/manual/en/function.date-default-timezone-set.php) after the header to use for your own purposes. Kind of a pain.
Also see this answer: [How to get WordPress Time Zone setting?](https://wordpress.stackexchange.com/question... |
101,301 | <p>I've this pages structure:</p>
<ul>
<li><p>TOP PAGE</p>
<ul>
<li>SUB PAGE 1
<ul>
<li>SUB SUB PAGE 1</li>
</ul></li>
<li>SUB PAGE 2</li>
</ul>
<p>[etc]</p></li>
</ul>
<p>Is it possible to display on each sub page a link to come back to the top level page? And how?</p>
| [
{
"answer_id": 101302,
"author": "sabreuse",
"author_id": 2140,
"author_profile": "https://wordpress.stackexchange.com/users/2140",
"pm_score": 1,
"selected": false,
"text": "<p>You can get the post ID of the parent page with <code>$post->post_parent</code>; at that point, it's just a... | 2013/05/30 | [
"https://wordpress.stackexchange.com/questions/101301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33504/"
] | I've this pages structure:
* TOP PAGE
+ SUB PAGE 1
- SUB SUB PAGE 1
+ SUB PAGE 2[etc]
Is it possible to display on each sub page a link to come back to the top level page? And how? | Here's a way to get the top page url:
```
$top_page_url = get_permalink( array_slice( get_ancestors( get_the_ID(), 'page' ) , -1 ) );
```
where `get_ancestors()` returns an array containing all the parents (ID) of the given page. You can read more about it in the Codex [here](http://codex.wordpress.org/Function_Refe... |
101,345 | <p>I am looking for a way to output all page IDs from the following menu: </p>
<pre><code><?php wp_list_pages('depth=1&exclude='3,5,11')); ?>
</code></pre>
<p>Only top level pages needed, therefore the 'depth=1'.</p>
<p>Any help appreciated.</p>
| [
{
"answer_id": 101346,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p><code>wp_list_pages()</code> is for formatted markup. Use <code>get_pages()</code> and <code>wp_list_pluck()</code>:</... | 2013/05/30 | [
"https://wordpress.stackexchange.com/questions/101345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33520/"
] | I am looking for a way to output all page IDs from the following menu:
```
<?php wp_list_pages('depth=1&exclude='3,5,11')); ?>
```
Only top level pages needed, therefore the 'depth=1'.
Any help appreciated. | `wp_list_pages()` is for formatted markup. Use `get_pages()` and `wp_list_pluck()`:
```
$pages = get_pages(
array (
'parent' => 0, // replaces 'depth' => 1,
'exclude' => '3,5,11'
)
);
$ids = wp_list_pluck( $pages, 'ID' );
```
`$ids` holds an array of page IDs now. |
101,408 | <p>I'm a bit despaired because I cannot figure out how to do what I need (and I worked with WP since a lot of time ..)</p>
<p>Basically, I need to show my artistic work.
Each work is a post, or a page or a custom types (I still don't know which fits the best)
I have 3 categories of work and I won't have more.</p>
<p>... | [
{
"answer_id": 101409,
"author": "kruti",
"author_id": 32919,
"author_profile": "https://wordpress.stackexchange.com/users/32919",
"pm_score": 0,
"selected": false,
"text": "<p>Change your permalink and set to this</p>\n\n<pre><code> %postname%/\n</code></pre>\n\n<p>Its change your ur... | 2013/05/31 | [
"https://wordpress.stackexchange.com/questions/101408",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33543/"
] | I'm a bit despaired because I cannot figure out how to do what I need (and I worked with WP since a lot of time ..)
Basically, I need to show my artistic work.
Each work is a post, or a page or a custom types (I still don't know which fits the best)
I have 3 categories of work and I won't have more.
I have a blog on ... | This is fairly straightforward with a custom post type and custom taxonomy.
First, [register a custom taxonomy](http://codex.wordpress.org/Function_Reference/register_taxonomy) `worktype`, with rewrite parameter set to `works`:
```
'rewrite' => array( 'slug' => 'works' )
```
Next, [register a custom post type](http... |
101,417 | <p>My enqueue scripts are never called I can't figure out why. All my paths are correct and I'm assuming the code is correct</p>
<p><strong>Functions.php</strong></p>
<pre><code>function tim_enqueue_default_scripts() {
if (ENVIRONMENT == 'dev') {
$globaljs = 'global.js';
$globalcss = 'global.css';... | [
{
"answer_id": 101418,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 0,
"selected": false,
"text": "<p>Try <code>wp_register_script()</code> and <code>wp_register_style()</code> first\n<a href=\"http://codex.w... | 2013/05/31 | [
"https://wordpress.stackexchange.com/questions/101417",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33551/"
] | My enqueue scripts are never called I can't figure out why. All my paths are correct and I'm assuming the code is correct
**Functions.php**
```
function tim_enqueue_default_scripts() {
if (ENVIRONMENT == 'dev') {
$globaljs = 'global.js';
$globalcss = 'global.css';
}
else {
$globalj... | Be sure about the parameters wp\_enqueue\_style and wp\_enqueue\_script uses.(The parameters are not same for both )
```
wp_enqueue_style( $handle, $src, $deps, $ver, $media );
```
you are giving false,false,true for dependency,version and media which is a blunder mistake.If you are not sure about them, you can avoi... |
101,444 | <p>I have places stored as posts in WP's posts table.</p>
<p>I am doing some geo-locating using Geo Data Store (<a href="http://wordpress.org/plugins/geo-data-store/" rel="nofollow">http://wordpress.org/plugins/geo-data-store/</a>). This is working great for me, as I can currently get results from any radius I choose ... | [
{
"answer_id": 101445,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>All of the real work here is being done by <code>$geoDataStore->getPostIDsOfInRange</code>. That is where ... | 2013/05/31 | [
"https://wordpress.stackexchange.com/questions/101444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26833/"
] | I have places stored as posts in WP's posts table.
I am doing some geo-locating using Geo Data Store (<http://wordpress.org/plugins/geo-data-store/>). This is working great for me, as I can currently get results from any radius I choose from a starting point (a city converted to coordinates).
I was previously using a... | All of the real work here is being done by `$geoDataStore->getPostIDsOfInRange`. That is where the search is done and that is what isn't returning the results you want.
`WP_Query` just pulls the specified post `ID`s. There is no reason you should have to abandon that part of the code, though you may want to add `'orde... |
101,452 | <p>I have a standard wordpress installation with no plugins residing in /var/www/blog on my root server. It uses an Apache2, mod_rewrite, mod_ssl and that is configured just fine and works perfectly for anything but Wordpress.</p>
<p>My .htaccess is:</p>
<pre><code><IfModule mod_rewrite.c>
RewriteEngine On
Rewr... | [
{
"answer_id": 101445,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>All of the real work here is being done by <code>$geoDataStore->getPostIDsOfInRange</code>. That is where ... | 2013/05/31 | [
"https://wordpress.stackexchange.com/questions/101452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33565/"
] | I have a standard wordpress installation with no plugins residing in /var/www/blog on my root server. It uses an Apache2, mod\_rewrite, mod\_ssl and that is configured just fine and works perfectly for anything but Wordpress.
My .htaccess is:
```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteCond %... | All of the real work here is being done by `$geoDataStore->getPostIDsOfInRange`. That is where the search is done and that is what isn't returning the results you want.
`WP_Query` just pulls the specified post `ID`s. There is no reason you should have to abandon that part of the code, though you may want to add `'orde... |
101,488 | <p>My requirements are bit different I was able to hide email and website field with filter but what I want to know is there a way to make comment text un-required when I am giving comment without comment text area filled its giving me error that comment is required please guide me how i can make comment text unrequire... | [
{
"answer_id": 101489,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>You can circumvent the check for empty comments easily by adding the uploaded image as HTML to the comment text:</p>\n... | 2013/06/01 | [
"https://wordpress.stackexchange.com/questions/101488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33582/"
] | My requirements are bit different I was able to hide email and website field with filter but what I want to know is there a way to make comment text un-required when I am giving comment without comment text area filled its giving me error that comment is required please guide me how i can make comment text unrequired.
... | You can circumvent the check for empty comments easily by adding the uploaded image as HTML to the comment text:
```
add_action( 'pre_comment_on_post', 'allow_empty_comment_text' );
function allow_empty_comment_text( $text = '' )
{
if ( ! isset ( $_POST['comment'] ) or '' === trim( $_POST['comment'] ) )
{
... |
101,492 | <p>I need to make Wordpress use another database (not the one specified in wp-config site-wide) on the "Comments" admin backend. I then must be able to edit, approve, delete etc. comments as usual.
The database server I am going to connect to has been setup to accept external connections.</p>
<p>I have a couple of ide... | [
{
"answer_id": 101489,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>You can circumvent the check for empty comments easily by adding the uploaded image as HTML to the comment text:</p>\n... | 2013/06/01 | [
"https://wordpress.stackexchange.com/questions/101492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31910/"
] | I need to make Wordpress use another database (not the one specified in wp-config site-wide) on the "Comments" admin backend. I then must be able to edit, approve, delete etc. comments as usual.
The database server I am going to connect to has been setup to accept external connections.
I have a couple of ideas how to ... | You can circumvent the check for empty comments easily by adding the uploaded image as HTML to the comment text:
```
add_action( 'pre_comment_on_post', 'allow_empty_comment_text' );
function allow_empty_comment_text( $text = '' )
{
if ( ! isset ( $_POST['comment'] ) or '' === trim( $_POST['comment'] ) )
{
... |
101,498 | <p><a href="http://wordpress.org/plugins/freshdesk/">I am developing a free plugin</a> for connection a external support system to WordPress to be able to authenticate users on WordPress. </p>
<p>For this, currently from the external system, the user is sent to WordPress's login page with this at the end </p>
<pre><c... | [
{
"answer_id": 101500,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://queryposts.com/function/wp_redirect/\" rel=\"noreferrer\"><code>wp_redirect()</code></a> performs ... | 2013/06/01 | [
"https://wordpress.stackexchange.com/questions/101498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18389/"
] | [I am developing a free plugin](http://wordpress.org/plugins/freshdesk/) for connection a external support system to WordPress to be able to authenticate users on WordPress.
For this, currently from the external system, the user is sent to WordPress's login page with this at the end
```
?action=freshdesk-remote-log... | As @Rarst explains, shortcodes normally run too late for you to redirect from inside one. They usually run on the `the_content` hook which is well after content is sent to the browser. If you need to redirect based on the presence of a shortcode you need to check for that shortcode before any content leaves the server.... |
101,508 | <p>I really like the idea to switch themes for mobile devices and am using jetpack for several feature on my website, So I thought, why not use it for mobile devices as well. Jetpack comes packed with a feature that switches themes for mobile devices, but it is only possible to use their theme and adjust some things li... | [
{
"answer_id": 102356,
"author": "jeherve",
"author_id": 27574,
"author_profile": "https://wordpress.stackexchange.com/users/27574",
"pm_score": 3,
"selected": true,
"text": "<p>I see 3 ways to edit Jetpack Mobile theme:</p>\n\n<p><strong>1. Use Jetpack's Custom CSS module</strong></p>\n... | 2013/06/01 | [
"https://wordpress.stackexchange.com/questions/101508",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27247/"
] | I really like the idea to switch themes for mobile devices and am using jetpack for several feature on my website, So I thought, why not use it for mobile devices as well. Jetpack comes packed with a feature that switches themes for mobile devices, but it is only possible to use their theme and adjust some things like ... | I see 3 ways to edit Jetpack Mobile theme:
**1. Use Jetpack's Custom CSS module**
Jetpack includes a module named "Custom CSS" that allows you to add your own custom CSS without having to edit your theme stylesheet. The custom CSS editor (under Appearance > Edit CSS) also includes an option to include this custom CSS... |
101,522 | <p>I have 5000 posts on my website, which I have uploaded from a <code>CSV</code> file. This all went well and the website is fast on the back-end and frankly on any other page. There is one exception: if I click on a post, it takes 8 to 9 seconds to open a post, which is very disturbing.</p>
<p>I am using <em>year/mo... | [
{
"answer_id": 102356,
"author": "jeherve",
"author_id": 27574,
"author_profile": "https://wordpress.stackexchange.com/users/27574",
"pm_score": 3,
"selected": true,
"text": "<p>I see 3 ways to edit Jetpack Mobile theme:</p>\n\n<p><strong>1. Use Jetpack's Custom CSS module</strong></p>\n... | 2013/06/01 | [
"https://wordpress.stackexchange.com/questions/101522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | I have 5000 posts on my website, which I have uploaded from a `CSV` file. This all went well and the website is fast on the back-end and frankly on any other page. There is one exception: if I click on a post, it takes 8 to 9 seconds to open a post, which is very disturbing.
I am using *year/month/year/post-name* as t... | I see 3 ways to edit Jetpack Mobile theme:
**1. Use Jetpack's Custom CSS module**
Jetpack includes a module named "Custom CSS" that allows you to add your own custom CSS without having to edit your theme stylesheet. The custom CSS editor (under Appearance > Edit CSS) also includes an option to include this custom CSS... |
101,526 | <p><strong>The setup:</strong><br>
I have two Wordpress installations. One in the root of the Server and one in a subdirectory, every installation has it's own database. The subdirectory installation is connected with a subdomain.</p>
<p><strong>The problem:</strong><br>
In the subdirectory installation, no images sho... | [
{
"answer_id": 102356,
"author": "jeherve",
"author_id": 27574,
"author_profile": "https://wordpress.stackexchange.com/users/27574",
"pm_score": 3,
"selected": true,
"text": "<p>I see 3 ways to edit Jetpack Mobile theme:</p>\n\n<p><strong>1. Use Jetpack's Custom CSS module</strong></p>\n... | 2013/06/01 | [
"https://wordpress.stackexchange.com/questions/101526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12580/"
] | **The setup:**
I have two Wordpress installations. One in the root of the Server and one in a subdirectory, every installation has it's own database. The subdirectory installation is connected with a subdomain.
**The problem:**
In the subdirectory installation, no images show up - even in the admin menu. I check... | I see 3 ways to edit Jetpack Mobile theme:
**1. Use Jetpack's Custom CSS module**
Jetpack includes a module named "Custom CSS" that allows you to add your own custom CSS without having to edit your theme stylesheet. The custom CSS editor (under Appearance > Edit CSS) also includes an option to include this custom CSS... |
101,533 | <p>I have function to upload images inside my settings API ,it uploads images as expected but the problem comes when user chooses to upload <b>non-image file</b> to stop users from uploading other files (non-image files) i am using <code>wp_die('No image found');</code> an that leads to dreaded
<b>500 Internal Server E... | [
{
"answer_id": 101536,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 3,
"selected": true,
"text": "<p>Use <code>die($msg);</code> to do what you're trying to do. <a href=\"http://codex.wordpress.org/Function_Ref... | 2013/06/01 | [
"https://wordpress.stackexchange.com/questions/101533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20941/"
] | I have function to upload images inside my settings API ,it uploads images as expected but the problem comes when user chooses to upload **non-image file** to stop users from uploading other files (non-image files) i am using `wp_die('No image found');` an that leads to dreaded
**500 Internal Server Error** message dis... | Use `die($msg);` to do what you're trying to do. [wp\_die()](http://codex.wordpress.org/Function_Reference/wp_die) returns an HTTP error code and passes your message to the error page, and the default code is 500 (internal server error) if you don't set the return code in the args. |
101,540 | <p>Context: For a site's images used in a particular section, each post relies on a base name put into meta data, which then is used with automatic extensions to generate large images, gallery thumbnail images, and an index page thumbnail as well.</p>
<p>For example, if Example_Name is the base name, then:<br>
<code>E... | [
{
"answer_id": 101554,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>In this line...</p>\n\n<pre><code>if ( file_exists( echo $upload_dir['baseurl'] . '/' . echo get_post_meta($... | 2013/06/01 | [
"https://wordpress.stackexchange.com/questions/101540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14751/"
] | Context: For a site's images used in a particular section, each post relies on a base name put into meta data, which then is used with automatic extensions to generate large images, gallery thumbnail images, and an index page thumbnail as well.
For example, if Example\_Name is the base name, then:
`Example_Name_2-L... | You can't use a *file url* in `file_exists()` like this:
```
file_exists( "http://example.com/wp-content/uploads/Example_Name_2_SM.jpg" );
```
You should rather use an *absolute file path*, for example:
```
file_exists( "/absolute/path/to/wp-content/uploads/Example_Name_2_SM.jpg" );
```
Then you should try
```
$... |
101,570 | <p>I am trying to add a functionality to the default wordpress feed. The problem is i managed to do this modifying the rss feed php file. The problem number two that i have in mind is when wp gets an update also that file will be updated and my code will disappear.</p>
<p>So i am looking to for a way to insert my code... | [
{
"answer_id": 106357,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 0,
"selected": false,
"text": "<p>There is probably not a way to change that, but if you post this as an \"issue\" at Woo's github: <a hre... | 2013/06/02 | [
"https://wordpress.stackexchange.com/questions/101570",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2215/"
] | I am trying to add a functionality to the default wordpress feed. The problem is i managed to do this modifying the rss feed php file. The problem number two that i have in mind is when wp gets an update also that file will be updated and my code will disappear.
So i am looking to for a way to insert my code as a filt... | Type Alt + 124 for the vertical pipe symbol instead of changing language |
101,578 | <p>I have created a <a href="http://goo.gl/kQXyT" rel="nofollow">Facebook App</a> to upload photos to facebook from image url with help of some tutorials. It needs an image url and description. I want to put a button "Upload to Facebook" below every "Image" type posts in wordpress. </p>
<p>App Main Part to upload imag... | [
{
"answer_id": 101609,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>There is no built-in way to extract an image/image-src from the post body. If the images are attachments you ... | 2013/06/02 | [
"https://wordpress.stackexchange.com/questions/101578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29577/"
] | I have created a [Facebook App](http://goo.gl/kQXyT) to upload photos to facebook from image url with help of some tutorials. It needs an image url and description. I want to put a button "Upload to Facebook" below every "Image" type posts in wordpress.
App Main Part to upload images -
```
<?php
if(isset($_POST["so... | There is no built-in way to extract an image/image-src from the post body. If the images are attachments you can do it with `get_children` or `WP_Query`, and `wp_get_attachment_image_src`.
```
function get_image_src_from_content_101578($content) {
global $post;
$args = array(
'post_parent' => $post->ID,
);
... |
101,585 | <p>I've inherited a Wordpress site. Have a ton of PHP experience but only moderate Wordpress experience.</p>
<p>Currently the URL: <a href="http://iridescentlearning.org/technovation" rel="nofollow">http://iridescentlearning.org/technovation</a></p>
<p>Redirects to another page. My client wants that redirection cha... | [
{
"answer_id": 101588,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 0,
"selected": false,
"text": "<p>Like any other PHP site, it can happen anywhere in the code or the server config. It's also possible t... | 2013/06/02 | [
"https://wordpress.stackexchange.com/questions/101585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33514/"
] | I've inherited a Wordpress site. Have a ton of PHP experience but only moderate Wordpress experience.
Currently the URL: <http://iridescentlearning.org/technovation>
Redirects to another page. My client wants that redirection changed. But I can't figure out where that redirection is happening.
The .htaccess file has... | If the page `http://iridescentlearning.org/technovation/` doesn't actually exist in that location and returns a 404, WordPress will attempt to find a matching page of the same name and redirect to that URL via the [`redirect_canonical()`](http://codex.wordpress.org/Function_Reference/redirect_canonical) function. Look ... |
101,586 | <p>I don't know if this is possible, I've searched around but came up short. Basically, I need that the current user who is commenting to see his comments slightly different than the rest.</p>
<p>I'm doing this for admins/moderators, but the thing is that all users see the highlighted comments made by admin/mod, where... | [
{
"answer_id": 101594,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>First, if you look at the comment classes, you will notice a class called <code>byuser</code>. That class is... | 2013/06/02 | [
"https://wordpress.stackexchange.com/questions/101586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33622/"
] | I don't know if this is possible, I've searched around but came up short. Basically, I need that the current user who is commenting to see his comments slightly different than the rest.
I'm doing this for admins/moderators, but the thing is that all users see the highlighted comments made by admin/mod, where here I ju... | assumes that your theme is using `comment_class()`;
example (to be added to functions.php of your theme):
```
add_filter( 'comment_class', 'comment_class_logged_in_user' );
function comment_class_logged_in_user( $classes ) {
global $comment;
if ( $comment->user_id > 0 && is_user_logged_in() ) {
globa... |
101,606 | <p>I'm working on new project and I want to let users have access to create pages on the site. To prevent users from "spamming" a lot of pages, I'd like to set a daily upload limit for each user. I've posted the code I'm using below but I'm not able to cancel the page upload because the event is being fired after a pag... | [
{
"answer_id": 101594,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>First, if you look at the comment classes, you will notice a class called <code>byuser</code>. That class is... | 2013/06/02 | [
"https://wordpress.stackexchange.com/questions/101606",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18814/"
] | I'm working on new project and I want to let users have access to create pages on the site. To prevent users from "spamming" a lot of pages, I'd like to set a daily upload limit for each user. I've posted the code I'm using below but I'm not able to cancel the page upload because the event is being fired after a page h... | assumes that your theme is using `comment_class()`;
example (to be added to functions.php of your theme):
```
add_filter( 'comment_class', 'comment_class_logged_in_user' );
function comment_class_logged_in_user( $classes ) {
global $comment;
if ( $comment->user_id > 0 && is_user_logged_in() ) {
globa... |
101,615 | <p>I'm not sure how to word my search terms for this problem.</p>
<p>I've created a site in WP.
So, let's assume the URL is <code>http://example.org</code></p>
<p>The 'Contact' page would be <code>http://example.org/contact</code>, for example.</p>
<p>I want to also have a blog on this site.
The blog would reside at... | [
{
"answer_id": 101594,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>First, if you look at the comment classes, you will notice a class called <code>byuser</code>. That class is... | 2013/06/02 | [
"https://wordpress.stackexchange.com/questions/101615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12481/"
] | I'm not sure how to word my search terms for this problem.
I've created a site in WP.
So, let's assume the URL is `http://example.org`
The 'Contact' page would be `http://example.org/contact`, for example.
I want to also have a blog on this site.
The blog would reside at `http://example.org/blog`
I have created a p... | assumes that your theme is using `comment_class()`;
example (to be added to functions.php of your theme):
```
add_filter( 'comment_class', 'comment_class_logged_in_user' );
function comment_class_logged_in_user( $classes ) {
global $comment;
if ( $comment->user_id > 0 && is_user_logged_in() ) {
globa... |
101,633 | <p>This is what I'm using to output my post navigation:</p>
<pre><code><?php if (is_single() ) { ?>
<nav class="post-navigation">
<h1 class="visuallyhidden">Post Navigation</h1>
<ul>
<li class="prev"><?php previous_post_link('%link', '%title', 'in_same_cat'); ?>... | [
{
"answer_id": 102596,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>you code may be look like</p>\n\n<pre><code><?php if (is_single() ) { ?>\n<nav class=\"post-n... | 2013/06/02 | [
"https://wordpress.stackexchange.com/questions/101633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13142/"
] | This is what I'm using to output my post navigation:
```
<?php if (is_single() ) { ?>
<nav class="post-navigation">
<h1 class="visuallyhidden">Post Navigation</h1>
<ul>
<li class="prev"><?php previous_post_link('%link', '%title', 'in_same_cat'); ?></li>
<li class="next"><?php next_post_link('%l... | As @Ravs mentions the third parameter in `next_post_link()`/`previous_post_link()` should be a boolean value indicating whether to restrict the link to a post in the same category. By default this is false. If set to true, it will choose the next (or previous) post which is in the same category as the current post. Thi... |
101,637 | <p>I have spent many time looking for a solution to my issue, but in vain. Your help is invaluable.</p>
<p>I am creating a simplified badge system. The goal is to increment the number of badges for a user if he performs some things on the website. For example, for each post published, I give a user one badge.</p>
<p>... | [
{
"answer_id": 101655,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>You're probably running into a problem with <code>$current_user->id</code> being deprecated since ... | 2013/06/02 | [
"https://wordpress.stackexchange.com/questions/101637",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | I have spent many time looking for a solution to my issue, but in vain. Your help is invaluable.
I am creating a simplified badge system. The goal is to increment the number of badges for a user if he performs some things on the website. For example, for each post published, I give a user one badge.
To do so, I opted... | You're probably running into a problem with `$current_user->id` being deprecated since WordPress 2.1. Specifically, I get this notice in the error log:
**Notice**: WP\_User->id was called with an argument that is deprecated since version 2.1! Use WP\_User->ID instead. in /xxx/xxx/public\_html/wordpress/wp-includes/fun... |
101,649 | <p>I'm having a lot of trouble finding an aswer to this. This is what happens to my permalink structure currently:</p>
<ul>
<li><p>When I open the page, filtering all posts for a category, the url is:
<code>myblog.com/category/</code></p></li>
<li><p>When I open the page filtering all posts for a sub-category the url
... | [
{
"answer_id": 101655,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>You're probably running into a problem with <code>$current_user->id</code> being deprecated since ... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33628/"
] | I'm having a lot of trouble finding an aswer to this. This is what happens to my permalink structure currently:
* When I open the page, filtering all posts for a category, the url is:
`myblog.com/category/`
* When I open the page filtering all posts for a sub-category the url
is: `myblog.com/parent-category/child-cate... | You're probably running into a problem with `$current_user->id` being deprecated since WordPress 2.1. Specifically, I get this notice in the error log:
**Notice**: WP\_User->id was called with an argument that is deprecated since version 2.1! Use WP\_User->ID instead. in /xxx/xxx/public\_html/wordpress/wp-includes/fun... |
101,651 | <p>I'm trying to set a wordpress static HTML front page, which doesn't seem trivial.</p>
<p>I tried three approaches:</p>
<p>1) add a index.html, and rename index.php to blog.php. Change the permalink into custom: <code>/blog.php?p=%postid%</code>. However for handling categories, the generated link is <code>/blog.ph... | [
{
"answer_id": 101655,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>You're probably running into a problem with <code>$current_user->id</code> being deprecated since ... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101651",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33647/"
] | I'm trying to set a wordpress static HTML front page, which doesn't seem trivial.
I tried three approaches:
1) add a index.html, and rename index.php to blog.php. Change the permalink into custom: `/blog.php?p=%postid%`. However for handling categories, the generated link is `/blog.php?p=cat=3`.
2) add a index.html,... | You're probably running into a problem with `$current_user->id` being deprecated since WordPress 2.1. Specifically, I get this notice in the error log:
**Notice**: WP\_User->id was called with an argument that is deprecated since version 2.1! Use WP\_User->ID instead. in /xxx/xxx/public\_html/wordpress/wp-includes/fun... |
101,683 | <p>I am writing this code in page.php for removing the sidebar in one page</p>
<pre><code><?php if (is_page('x')) : ?>
<?php else : ?>
<?php get_sidebar(); ?>
<?php endif; ?>
</code></pre>
<p>... where <code>"x"</code> is the ID of that page.</p>
<p>but I am having a bit of trouble though the... | [
{
"answer_id": 101655,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>You're probably running into a problem with <code>$current_user->id</code> being deprecated since ... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33663/"
] | I am writing this code in page.php for removing the sidebar in one page
```
<?php if (is_page('x')) : ?>
<?php else : ?>
<?php get_sidebar(); ?>
<?php endif; ?>
```
... where `"x"` is the ID of that page.
but I am having a bit of trouble though the forum which is the page in question does not stretch across the who... | You're probably running into a problem with `$current_user->id` being deprecated since WordPress 2.1. Specifically, I get this notice in the error log:
**Notice**: WP\_User->id was called with an argument that is deprecated since version 2.1! Use WP\_User->ID instead. in /xxx/xxx/public\_html/wordpress/wp-includes/fun... |
101,694 | <p>I need to display an avatar in the post info position which i have written the code for but i only want to display it on the most recent post on the home page and not a specific post as this will change when a new post id published.</p>
<p>Couldn't find a conditional tag which handles this.</p>
<p>I'm using the co... | [
{
"answer_id": 101699,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>Within an ordinary WordPress Loop, the following would identify the first post in the Loop, which would be th... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29218/"
] | I need to display an avatar in the post info position which i have written the code for but i only want to display it on the most recent post on the home page and not a specific post as this will change when a new post id published.
Couldn't find a conditional tag which handles this.
I'm using the code in a custom fu... | Within an ordinary WordPress Loop, the following would identify the first post in the Loop, which would be the latest if posts are ordered by date descending.
```
global $wp_query; // might not be necessary; depends on context
if (is_paged() && 0 === $wp_query->current_post) {
echo 'first-post';
}
```
I don't know... |
101,711 | <p>First, let me start off by saying I'm very new to WordPress. I've only ever done basic themes before, this is my first big project.</p>
<p>I'm working on a design that has two sidebars on every page. Each sidebar displays the most recent post from two categories. These posts have Featured Images associated with the... | [
{
"answer_id": 101712,
"author": "Pieter",
"author_id": 20277,
"author_profile": "https://wordpress.stackexchange.com/users/20277",
"pm_score": 3,
"selected": true,
"text": "<p>The $id variable isn't defined. Add this just before the conditional statement:</p>\n\n<pre><code>$id = get_the... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101711",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24566/"
] | First, let me start off by saying I'm very new to WordPress. I've only ever done basic themes before, this is my first big project.
I'm working on a design that has two sidebars on every page. Each sidebar displays the most recent post from two categories. These posts have Featured Images associated with them. I want ... | The $id variable isn't defined. Add this just before the conditional statement:
```
$id = get_the_ID();
``` |
101,713 | <p>I have some elements showing on the home page that I do not want to display in the Theme Customizer preview window. Is there a simple check in PHP that I can use for that ?</p>
<p>For example:</p>
<pre><code><img class="background" src="<?php echo $background ?>" <?php if(is_wpThemeCustomizer()) echo '... | [
{
"answer_id": 101715,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>Check for global variable <code>$wp_customize</code>:</p>\n\n<pre><code>if ( empty ( $GLOBALS['wp_customize'] ) ) \n{\... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101713",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16975/"
] | I have some elements showing on the home page that I do not want to display in the Theme Customizer preview window. Is there a simple check in PHP that I can use for that ?
For example:
```
<img class="background" src="<?php echo $background ?>" <?php if(is_wpThemeCustomizer()) echo 'style="display:none"' ?>/>
```
... | Check for global variable `$wp_customize`:
```
if ( empty ( $GLOBALS['wp_customize'] ) )
{
// show something
}
```
**Update:** in WordPress 4.0, you can use [`is_customize_preview()`](https://core.trac.wordpress.org/changeset/28999). |
101,716 | <p>I would like to create a page (let's name it "Facebook") where i will display only the posts that has the custom field: "Facebook" and specifically the custom field value: "Yes".</p>
<p>P.S. 1. I would like to include the theme's header, slider, footer, sidebars etc.
2. I use Advanced Custom Fields plugin</p>
... | [
{
"answer_id": 101719,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 1,
"selected": false,
"text": "<p>You're going to need to learn how to <a href=\"http://codex.wordpress.org/Theme_Development#Custom_Page_Te... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101716",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25490/"
] | I would like to create a page (let's name it "Facebook") where i will display only the posts that has the custom field: "Facebook" and specifically the custom field value: "Yes".
P.S. 1. I would like to include the theme's header, slider, footer, sidebars etc.
2. I use Advanced Custom Fields plugin
```
<?php get_hea... | Duplicate your `page.php` template, name the duplicate `page-facebook.php`, give it a template name:
```
/*
Template Name: My Facebook Meta Key Page
*/
```
More information here: <http://codex.wordpress.org/Page_Templates>
To get the right posts with `get_posts` use something like this:
```
<?php
$args = array(
... |
101,728 | <p>I have created a custom post type (screen shot below), and would like to change the order of columns. Is it possible to move the "tags" column before the "date" column?</p>
<p>Screen shot: </p>
<p><img src="https://i.stack.imgur.com/eGJls.png" alt="Screen shot"></p>
| [
{
"answer_id": 114651,
"author": "Asped",
"author_id": 37612,
"author_profile": "https://wordpress.stackexchange.com/users/37612",
"pm_score": 5,
"selected": true,
"text": "<p>Yes this is possible. I have changed this for the default post type, but this is also possible for a custom one.... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33679/"
] | I have created a custom post type (screen shot below), and would like to change the order of columns. Is it possible to move the "tags" column before the "date" column?
Screen shot:
 | Yes this is possible. I have changed this for the default post type, but this is also possible for a custom one.
First check the codex:
<http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column>
```
function your_columns_head($defaults) {
$new = array();
$tags = $defaults['tags'];... |
101,744 | <p>What does it mean by a screen? I've had a look in the codex and don't understand (I'm a newbie). Thanks.</p>
| [
{
"answer_id": 101746,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>I know now. It retrieves the current settings page you are on. So for example, if you're on the the theme options... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | What does it mean by a screen? I've had a look in the codex and don't understand (I'm a newbie). Thanks. | `$current_screen` is a global variable in admin screens. It holds the result of `WP_Screen::get( $hook_name )->set_current_screen();`.
`WP_Screen` is a class, `get()` is a static method that returns a real object – an instance of `WP_Screen` with some predefined properties:
```
$screen->base = $base;
$screen->a... |
101,761 | <p>What is the best way to add new custom blog settings to the Wordpress general settings (or some other settings page for that matter), such that these settings are available to the theme to use?</p>
<p>For example I would like simple settings like the Twitter URL and Facebook Page URL to be configurable, rather than... | [
{
"answer_id": 101762,
"author": "jbx",
"author_id": 21333,
"author_profile": "https://wordpress.stackexchange.com/users/21333",
"pm_score": 0,
"selected": false,
"text": "<p>OK, I was evidently looking at the wrong place. The <a href=\"http://codex.wordpress.org/Settings_API\" rel=\"nof... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101761",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21333/"
] | What is the best way to add new custom blog settings to the Wordpress general settings (or some other settings page for that matter), such that these settings are available to the theme to use?
For example I would like simple settings like the Twitter URL and Facebook Page URL to be configurable, rather than hardcoded... | Here is part of a class I wrote for client recently:
```
if ( is_admin() )
RevenueCalculatorAdminSettings::init();
/**
* Call this class with:
*
* RevenueCalculatorAdminSettings->init();
*
* or
*
* RevenueCalculatorAdminSettings->init( 'text_domain' );
*
*/
class RevenueCalculatorAdminSettings ... |
101,766 | <p>My wordpress video blog have several categories. Lets say the category can belong to several genres e.g actions,horror,mystery and another category belong to actions,horror,romance</p>
<p>How do I group categories into genres? Cause in the most basic structure, we group posts into category.
Now i want group categor... | [
{
"answer_id": 102073,
"author": "sanchothefat",
"author_id": 1733,
"author_profile": "https://wordpress.stackexchange.com/users/1733",
"pm_score": 2,
"selected": false,
"text": "<p>I would suggest using Scribu's Posts 2 Posts plugin.</p>\n\n<p>It allows you to map posts to other posts a... | 2013/06/03 | [
"https://wordpress.stackexchange.com/questions/101766",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17971/"
] | My wordpress video blog have several categories. Lets say the category can belong to several genres e.g actions,horror,mystery and another category belong to actions,horror,romance
How do I group categories into genres? Cause in the most basic structure, we group posts into category.
Now i want group categories into g... | It sounds to me like genre should be its own taxonomy. Then posts get assigned to both categories and genres. If you do it this way, here's what you need to do to get everything working:
First, [register the taxonomy `genre`](http://codex.wordpress.org/Function_Reference/register_taxonomy).
Next, *assuming you're usi... |
101,776 | <p>I have categories and sub -categories with same name.. but I want to show only the categories which is on the top level and not in the sub categories</p>
<pre><code>$qry=query_posts( array(
'post_status' => 'publish',
'post_type' => 'custom_post',
'author' => '12;,
'showposts' => 9,
... | [
{
"answer_id": 101778,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>try this</p>\n\n<pre><code>while($qry->have_posts()){\n $qry->the_post;\n foreach((get_the_categ... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101776",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29259/"
] | I have categories and sub -categories with same name.. but I want to show only the categories which is on the top level and not in the sub categories
```
$qry=query_posts( array(
'post_status' => 'publish',
'post_type' => 'custom_post',
'author' => '12;,
'showposts' => 9,
'tax_query' => array(
... | See [Taxonomy Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters) documentation - there is `include_children` parameter, which you can set to `false` in your taxonomy query. |
101,793 | <p>I have a custom post type "custom_author" which is selected when making a new post using a metabox dropdown with field key "chosen_author".</p>
<p>This is what my wp_postmeta looks like:</p>
<p><img src="https://i.stack.imgur.com/ImnXv.png" alt="enter image description here"></p>
<p>Where 13088 is the blog post t... | [
{
"answer_id": 101798,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<h2>The problem</h2>\n\n<p>It looks like you are saving the data as:</p>\n\n<pre><code>$a = array( \"13112\" );... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24367/"
] | I have a custom post type "custom\_author" which is selected when making a new post using a metabox dropdown with field key "chosen\_author".
This is what my wp\_postmeta looks like:

Where 13088 is the blog post that has "author" 13112 assigned to ... | Fixed by using
get\_posts($args) instead of new WP\_Query($args);
No idea why... |
101,809 | <p>I have managed to make my own custom comment rating system - that was working fine until now. I got an idea: why not add star rating to individual comments? I thought it would be easy as I have already added a custom rating field in comment - through filter that is ..</p>
<pre><code>add_action( 'comment_form_logged... | [
{
"answer_id": 101831,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>You could add a metabox to your comment. For this you can use some hooks such as preprocess_comment() and commen... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101809",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33582/"
] | I have managed to make my own custom comment rating system - that was working fine until now. I got an idea: why not add star rating to individual comments? I thought it would be easy as I have already added a custom rating field in comment - through filter that is ..
```
add_action( 'comment_form_logged_in_after', 'a... | This is almost entirely an HTML and/or Javascript question. You just need to make proper forms and have some PHP to process it.
```
function additional_fields ($below) {
global $comment;
$ratsec = '<form action="'.get_permalink().'" method="get" class="comment-form-rating">';
$ratsec .= '<input type="hidden" n... |
101,816 | <p>I'm working on a website that can display 3D molecules (.mol) using the JavaScript-based viewer from JSmol (<a href="http://sourceforge.net/projects/jsmol/" rel="nofollow">http://sourceforge.net/projects/jsmol/</a>). With the "Upload File Type Settings" plug-in files with .mol extension can be uploaded as "Featured ... | [
{
"answer_id": 101819,
"author": "Marc Dingena",
"author_id": 28660,
"author_profile": "https://wordpress.stackexchange.com/users/28660",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe something like this? It saves the URL to the post's thumbnail (if set) in variable <code>$src</cod... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33715/"
] | I'm working on a website that can display 3D molecules (.mol) using the JavaScript-based viewer from JSmol (<http://sourceforge.net/projects/jsmol/>). With the "Upload File Type Settings" plug-in files with .mol extension can be uploaded as "Featured Image".
I managed to customize my single.php template with the JSmol... | ```
$post_thumbnail_id = get_post_thumbnail_id();
$thumb = get_post($post_thumbnail_id);
var_dump($thumb);
```
Look at the `post_mime_type` in the `$thumb` object.
Reference
---------
<http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail>
<http://codex.wordpress.org/Function_Reference/get_post> |
101,823 | <p>I have the following front-page template made: </p>
<p><img src="https://i.stack.imgur.com/VP1G6.png" alt="enter image description here"></p>
<p>In place of those large <a href="http://www.lipsum.com/" rel="noreferrer">Lorem Ipsum</a> blocks, I need to show an "excerpt" from a specific page to fill that box (a ce... | [
{
"answer_id": 101825,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>If you're in the loop do this:</p>\n\n<pre><code><?php\n$my_excerpt = get_the_excerpt();\nif ( $my_excerp... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101823",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33717/"
] | I have the following front-page template made:

In place of those large [Lorem Ipsum](http://www.lipsum.com/) blocks, I need to show an "excerpt" from a specific page to fill that box (a certain number of characters).
How do I get a pages content i... | ```
<?php
// would echo post 7's content up until the <!--more--> tag
$post_7 = get_post(7);
$excerpt = $post_7->post_excerpt;
echo $excerpt;
// would get post 12's entire content after which you
// can manipulate it with your own trimming preferences
$post_12 = get_post(12);
$trim_me = $post_12->post_content;
my_t... |
101,829 | <p>I've tried plugins like "WP Mail SMTP" "WP SMTP" "Easy WP SMTP" "WP SMTP Config" noone is compatible with WPMU</p>
| [
{
"answer_id": 101843,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand the question correctly, you're having trouble with SMTP settings in a Multisite environment; sp... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29072/"
] | I've tried plugins like "WP Mail SMTP" "WP SMTP" "Easy WP SMTP" "WP SMTP Config" noone is compatible with WPMU | If I understand the question correctly, you're having trouble with SMTP settings in a Multisite environment; specifically, your SMTP settings are not propagating throughout your sites from the root site.
It's possible that you need to configure the SMTP settings for every site individually, even if you've network acti... |
101,853 | <p>I am successfully using get_current_screen(); to get the post_type to decide whether to manipulate a meta box or not.</p>
<p>I also need to use it in:</p>
<pre><code>add_action('admin_menu', 'infographicMetaBox');
function infographicMetaBox() {
// ...
$screen = get_current_screen();
if('post' != $scr... | [
{
"answer_id": 101843,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand the question correctly, you're having trouble with SMTP settings in a Multisite environment; sp... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24367/"
] | I am successfully using get\_current\_screen(); to get the post\_type to decide whether to manipulate a meta box or not.
I also need to use it in:
```
add_action('admin_menu', 'infographicMetaBox');
function infographicMetaBox() {
// ...
$screen = get_current_screen();
if('post' != $screen->post_type)
... | If I understand the question correctly, you're having trouble with SMTP settings in a Multisite environment; specifically, your SMTP settings are not propagating throughout your sites from the root site.
It's possible that you need to configure the SMTP settings for every site individually, even if you've network acti... |
101,854 | <p>Is there a way to only display <code><?php the_post_thumbnail( $size, $attr ); ?></code> if it is larger/smaller than specified dimensions?</p>
| [
{
"answer_id": 101843,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand the question correctly, you're having trouble with SMTP settings in a Multisite environment; sp... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | Is there a way to only display `<?php the_post_thumbnail( $size, $attr ); ?>` if it is larger/smaller than specified dimensions? | If I understand the question correctly, you're having trouble with SMTP settings in a Multisite environment; specifically, your SMTP settings are not propagating throughout your sites from the root site.
It's possible that you need to configure the SMTP settings for every site individually, even if you've network acti... |
101,874 | <p>I'm having trouble finding out how to accomplish this - I want to display a cropped version of an image in the post. So when it's uploaded, it would automatically be displayed cropped. Is there any way to do that? For example, <a href="http://kineticcreative.co/1.jpg" rel="nofollow">this would be the original image ... | [
{
"answer_id": 101843,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand the question correctly, you're having trouble with SMTP settings in a Multisite environment; sp... | 2013/06/04 | [
"https://wordpress.stackexchange.com/questions/101874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19059/"
] | I'm having trouble finding out how to accomplish this - I want to display a cropped version of an image in the post. So when it's uploaded, it would automatically be displayed cropped. Is there any way to do that? For example, [this would be the original image uploaded](http://kineticcreative.co/1.jpg) and [this is wha... | If I understand the question correctly, you're having trouble with SMTP settings in a Multisite environment; specifically, your SMTP settings are not propagating throughout your sites from the root site.
It's possible that you need to configure the SMTP settings for every site individually, even if you've network acti... |
101,914 | <p>I'm currently working on an ecommerce website and I met an problem.
My client want a page e-boutique with all the product categories displayed, followed by three promoted products and a button "show all".</p>
<p>This "Show all" button is supposed to show all the product that the store contains with the default wooc... | [
{
"answer_id": 102993,
"author": "HamzStramGram",
"author_id": 33749,
"author_profile": "https://wordpress.stackexchange.com/users/33749",
"pm_score": 4,
"selected": true,
"text": "<p>I didn't entirely resolved my problem. My client changed his mind and didn't want the sorting anymore. <... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33749/"
] | I'm currently working on an ecommerce website and I met an problem.
My client want a page e-boutique with all the product categories displayed, followed by three promoted products and a button "show all".
This "Show all" button is supposed to show all the product that the store contains with the default woocommerce so... | I didn't entirely resolved my problem. My client changed his mind and didn't want the sorting anymore.
But concerning the paging, I managed to have it working by adding a new arg in my query, here is the code that made it worked for me :
```
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
... |
101,917 | <p>I want to display the last say 6 pieces of work from my portfolio. So i have written this query</p>
<pre><code><?php $the_query = new WP_Query array( 'category_name' => 'portfolio', 'showposts=6' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php the_post_t... | [
{
"answer_id": 102993,
"author": "HamzStramGram",
"author_id": 33749,
"author_profile": "https://wordpress.stackexchange.com/users/33749",
"pm_score": 4,
"selected": true,
"text": "<p>I didn't entirely resolved my problem. My client changed his mind and didn't want the sorting anymore. <... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101917",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23874/"
] | I want to display the last say 6 pieces of work from my portfolio. So i have written this query
```
<?php $the_query = new WP_Query array( 'category_name' => 'portfolio', 'showposts=6' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php the_post_thumbnail(); ?>
<?php endwhile;?>
``... | I didn't entirely resolved my problem. My client changed his mind and didn't want the sorting anymore.
But concerning the paging, I managed to have it working by adding a new arg in my query, here is the code that made it worked for me :
```
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
... |