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 |
|---|---|---|---|---|---|---|
62,926 | <p>Is it possible to not use the loop for the base URL of a custom post type.</p>
<p>So for instance if my custom post type is 'directory'.</p>
<p>I don't want <a href="http://www.mysite.com/directory/" rel="nofollow">http://www.mysite.com/directory/</a> to land at the loop page, I want to make a custom page template... | [
{
"answer_id": 62929,
"author": "MZAweb",
"author_id": 5223,
"author_profile": "https://wordpress.stackexchange.com/users/5223",
"pm_score": 0,
"selected": false,
"text": "<p>save_post is called multiple times while you edit a post (autosave). That's a common gotcha, but it'd be cool if ... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62926",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29582/"
] | Is it possible to not use the loop for the base URL of a custom post type.
So for instance if my custom post type is 'directory'.
I don't want <http://www.mysite.com/directory/> to land at the loop page, I want to make a custom page template that will serve a customised layout for proceeding into areas of the custom ... | I had something similar going on when I tried to use the `wp_editor()` function while inside a custom metabox. It was wanting to save multiple times.
Take a look at this.
```
// SAVE Metabox for admin response
add_action('post_updated', 'display_jwl_wp_etickets_response_meta_box_save');
function display_jwl_wp_eticke... |
62,941 | <p>I have the settings so only one post (which is by default the most recent) displays with index.php</p>
<p>my current working code</p>
<pre><code><?php if (have_posts()) : while (have_posts()) : the_post(); ?>
</code></pre>
<p>How could I change to code to display a random post from any category/date?</p>
<... | [
{
"answer_id": 62943,
"author": "OriginalEXE",
"author_id": 16710,
"author_profile": "https://wordpress.stackexchange.com/users/16710",
"pm_score": -1,
"selected": false,
"text": "<p>Try posting this code above your current code:</p>\n\n<pre><code><?php query_posts(array('orderby' =&g... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19574/"
] | I have the settings so only one post (which is by default the most recent) displays with index.php
my current working code
```
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
```
How could I change to code to display a random post from any category/date?
It just needs to be one post if that makes a... | Place the following code in your theme functions.php file.
```
function one_random_post_on_home_page( $query )
{
if ( ! ( $query->is_home() && $query->is_main_query() ) )
return;
$query->set( 'orderby ', 'rand' );
$query->set( 'posts_per_page', 1 );
}
add_action( 'pre_get_posts', 'one_random_pos... |
62,954 | <p>How can I link to the posts page that has been set in Settings > Reading?</p>
<p>This is for a premium theme so it can't just be the page's permalink.</p>
| [
{
"answer_id": 62955,
"author": "Warwick",
"author_id": 19554,
"author_profile": "https://wordpress.stackexchange.com/users/19554",
"pm_score": 4,
"selected": true,
"text": "<p>WordPress Does it like this this.</p>\n\n<pre><code>echo get_permalink( get_option( 'page_for_posts' ) );\n</co... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62954",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14895/"
] | How can I link to the posts page that has been set in Settings > Reading?
This is for a premium theme so it can't just be the page's permalink. | WordPress Does it like this this.
```
echo get_permalink( get_option( 'page_for_posts' ) );
``` |
62,963 | <p>I'm developing a Multisute plugin that is supposed to setup sites using a specific template, including setting up several static pages and menu items, as well as a "Blog" category for blog posts.</p>
<p>The category is created fine, and has one post in it, and I've figured out how to setup the menu link to the blog... | [
{
"answer_id": 63630,
"author": "sanchothefat",
"author_id": 1733,
"author_profile": "https://wordpress.stackexchange.com/users/1733",
"pm_score": 1,
"selected": false,
"text": "<p>Try a slightly different approach editing the options in the options table for the new sites rather than fl... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62963",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19654/"
] | I'm developing a Multisute plugin that is supposed to setup sites using a specific template, including setting up several static pages and menu items, as well as a "Blog" category for blog posts.
The category is created fine, and has one post in it, and I've figured out how to setup the menu link to the blog category ... | I found that the reason `flush_rewrite_rules();` wasn't working was because `switch_to_blog` doesn't re-initialize some of the properties of `$wp_rewrite` (not to mention other parts of WP), so `flush_rewrite_rules` was still generating some of the rules based on the permalink structure of the current blog (which is no... |
62,967 | <p>I am trying to activate second plugin automatically while activating first plugin.</p>
<pre><code>register_activation_hook(__FILE__, 'example_activation' );
function example_activation() {
include_once(ABSPATH .'/wp-admin/includes/plugin.php');
activate_plugin('hello.php');
}
</code></pre>
<p>Its not... | [
{
"answer_id": 62974,
"author": "mltsy",
"author_id": 19654,
"author_profile": "https://wordpress.stackexchange.com/users/19654",
"pm_score": 2,
"selected": false,
"text": "<p>Here is someone explaining why it wasn't working for him, and how he had to copy the activate_plugin method and ... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1372/"
] | I am trying to activate second plugin automatically while activating first plugin.
```
register_activation_hook(__FILE__, 'example_activation' );
function example_activation() {
include_once(ABSPATH .'/wp-admin/includes/plugin.php');
activate_plugin('hello.php');
}
```
Its not working inside register... | For full explanation of what's happening see [this post](http://www.stephenharris.info/2012/deactivate-other-plug-ins-on-deactivation/) (this is for deactivating plug-ins, but the problem is the same).
**A brief explanation:** Plug-ins are essentially activated by adding them to the array of active pug-ins stored in ... |
62,979 | <p>I'm programming a plugin in Wordpress and want to access some database functions with in my theme with the do_action feature. First I just included $fdb-> get_finaboo_footer(1); on my page for example but he couldnt find the object. I added global $fdb; Then it worked. But I dont want to globalize on every php file ... | [
{
"answer_id": 62980,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>I recommend to add a static method to access the plugin instance.</p>\n\n<p>Example, taken from <a href=\"https://wordp... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62979",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19661/"
] | I'm programming a plugin in Wordpress and want to access some database functions with in my theme with the do\_action feature. First I just included $fdb-> get\_finaboo\_footer(1); on my page for example but he couldnt find the object. I added global $fdb; Then it worked. But I dont want to globalize on every php file ... | I recommend to add a static method to access the plugin instance.
Example, taken from [this answer](https://wordpress.stackexchange.com/a/61440/73):
```
class My_Plugin
{
private $var = 'foo';
protected static $instance = NULL;
public static function get_instance()
{
// create an object
... |
62,984 | <p>I have setup in admin to have 5 comments per post display, which is what I want, and newest at the top. </p>
<p>But the problem is when a 6th comment is made it is the only one displayed and you can read the previous comments which will display 5.</p>
<p>What I would like it to do is always display 5 comments, whe... | [
{
"answer_id": 63052,
"author": "Sean Berg",
"author_id": 16139,
"author_profile": "https://wordpress.stackexchange.com/users/16139",
"pm_score": 1,
"selected": false,
"text": "<p>Try adding the following code to your comments.php template file (where you want the \"next page\" / \"prev ... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62984",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7125/"
] | I have setup in admin to have 5 comments per post display, which is what I want, and newest at the top.
But the problem is when a 6th comment is made it is the only one displayed and you can read the previous comments which will display 5.
What I would like it to do is always display 5 comments, when 6th is made the... | Ended up solving this with the following code:
```
<ol class="commentlist">
<?php $comments = array_reverse($comments, true); ?>
<?php
/* Loop through and list the comments. Tell wp_list_comments()
* to use twentyten_comment() to format the comments.
... |
62,985 | <p>Is it possible to remove all references to 'edit' or 'add' from a particular post type on its post list display screen in admin?</p>
<p>So basically what I need is that for this post type, all roles defined, whatever they are, can only view a list of these posts, and not do anything with them except trash them. So ... | [
{
"answer_id": 64160,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": true,
"text": "<p>For say the 'moomin' post type, when defining the custom post type specify its 'capability_type' as 'moomin'.<... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62985",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | Is it possible to remove all references to 'edit' or 'add' from a particular post type on its post list display screen in admin?
So basically what I need is that for this post type, all roles defined, whatever they are, can only view a list of these posts, and not do anything with them except trash them. So that means... | For say the 'moomin' post type, when defining the custom post type specify its 'capability\_type' as 'moomin'.
This will give you the 'capabilities' edit\_moomin' etc which you can then remove from individual roles, e.g.:
```
global $wp_roles;
// remove capability edit_moomin from role editor
$wp_roles->remove_cap( '... |
62,989 | <p>I want to make a php class that gets an option from the wp database (which is an array of options) and be able to call this class with the name of the option and the class to return the options value.</p>
<p>Does anyone know how would I go about doing this?</p>
<p>EDIT:
I have tried the following code</p>
<pre><c... | [
{
"answer_id": 62992,
"author": "Tribalpixel",
"author_id": 11987,
"author_profile": "https://wordpress.stackexchange.com/users/11987",
"pm_score": 0,
"selected": false,
"text": "<p>look at <a href=\"http://codex.wordpress.org/Options_API\" rel=\"nofollow\">Options API</a> in wordpress c... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62989",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16859/"
] | I want to make a php class that gets an option from the wp database (which is an array of options) and be able to call this class with the name of the option and the class to return the options value.
Does anyone know how would I go about doing this?
EDIT:
I have tried the following code
```
class N_Options {
f... | If you have [registered your option](http://queryposts.com/function/add_option/ "add_option()") without setting the fourth parameter `$autoload` to `no` your calls to `get_option` will not trigger any extra database call because all aotoload options are stored in the cache when the site is loaded.
To test it add …
``... |
62,993 | <p>I am trying to create a multi-select category list in a theme options page and everything shows up but when i save the options only the last option from the multi-select box that is selected gets saved to the database.</p>
<p>Does someone know what I'm doing wrong perhaps?</p>
<p>Here's bits and pieces of the code... | [
{
"answer_id": 62992,
"author": "Tribalpixel",
"author_id": 11987,
"author_profile": "https://wordpress.stackexchange.com/users/11987",
"pm_score": 0,
"selected": false,
"text": "<p>look at <a href=\"http://codex.wordpress.org/Options_API\" rel=\"nofollow\">Options API</a> in wordpress c... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/62993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19667/"
] | I am trying to create a multi-select category list in a theme options page and everything shows up but when i save the options only the last option from the multi-select box that is selected gets saved to the database.
Does someone know what I'm doing wrong perhaps?
Here's bits and pieces of the code I'm currently us... | If you have [registered your option](http://queryposts.com/function/add_option/ "add_option()") without setting the fourth parameter `$autoload` to `no` your calls to `get_option` will not trigger any extra database call because all aotoload options are stored in the cache when the site is loaded.
To test it add …
``... |
63,000 | <p>I use this codes in my functions.php to track post views.</p>
<pre><code>/* Functions to track Post Views*/
function getPostViews($postID){
$count_key = 'post_views';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_k... | [
{
"answer_id": 62992,
"author": "Tribalpixel",
"author_id": 11987,
"author_profile": "https://wordpress.stackexchange.com/users/11987",
"pm_score": 0,
"selected": false,
"text": "<p>look at <a href=\"http://codex.wordpress.org/Options_API\" rel=\"nofollow\">Options API</a> in wordpress c... | 2012/08/24 | [
"https://wordpress.stackexchange.com/questions/63000",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18025/"
] | I use this codes in my functions.php to track post views.
```
/* Functions to track Post Views*/
function getPostViews($postID){
$count_key = 'post_views';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
... | If you have [registered your option](http://queryposts.com/function/add_option/ "add_option()") without setting the fourth parameter `$autoload` to `no` your calls to `get_option` will not trigger any extra database call because all aotoload options are stored in the cache when the site is loaded.
To test it add …
``... |
63,018 | <p>How can i get the name of a page's parent?<br>
I can only get it's id.</p>
<pre><code> $page = get_queried_object();
$pageparent = $page->post_parent;
</code></pre>
| [
{
"answer_id": 63023,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": true,
"text": "<p>Once you've got the id of a post or page, use <code>get_the_title($id)</code> to get the page title (which is what I as... | 2012/08/25 | [
"https://wordpress.stackexchange.com/questions/63018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18592/"
] | How can i get the name of a page's parent?
I can only get it's id.
```
$page = get_queried_object();
$pageparent = $page->post_parent;
``` | Once you've got the id of a post or page, use `get_the_title($id)` to get the page title (which is what I assume you mean by name)
[Codex Reference](http://codex.wordpress.org/Function_Reference/get_the_title) |
63,038 | <p>I want 3 post with one loop iteration, so I'm using <code>the_post()</code> to achieve this: (html removed)</p>
<pre><code><?php while ( have_posts() ) : the_post();
the_title();
the_post();
the_title();
the_post();
the_title();
endwhile; ?>
</code></pre>
<p>The problem starts, if numbe... | [
{
"answer_id": 63040,
"author": "smogg",
"author_id": 15476,
"author_profile": "https://wordpress.stackexchange.com/users/15476",
"pm_score": -1,
"selected": false,
"text": "<p>After posting this question, I've had the \"eureka\" moment and achieved it (probably the ugly way) by surround... | 2012/08/25 | [
"https://wordpress.stackexchange.com/questions/63038",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15476/"
] | I want 3 post with one loop iteration, so I'm using `the_post()` to achieve this: (html removed)
```
<?php while ( have_posts() ) : the_post();
the_title();
the_post();
the_title();
the_post();
the_title();
endwhile; ?>
```
The problem starts, if number of posts is not divisible by 3. For examp... | Ultimately, this question is **off-topic**, because the solution has nothing to do with WordPress. Outputting posts in a grid pattern is an **HTML/CSS** issue, and the best-practice solutions don't involve putting every three posts inside a separate containing `<div>`. Even so, you can do what you want to do, using PHP... |
63,043 | <p>I using custom $wp_query for most of my archive pages like, taxonomy,index,category and author page. Everything working fine, except one weird thing - the author template page pagination failed to work. The pagination stop to work on page 2 it direct to the 404 page. Pagination on other archive page, works perfectl... | [
{
"answer_id": 63047,
"author": "smogg",
"author_id": 15476,
"author_profile": "https://wordpress.stackexchange.com/users/15476",
"pm_score": 0,
"selected": false,
"text": "<p>Try changing your page slug. If I remember correctly, it cannot be the same as custom post type.</p>\n\n<p>@edit... | 2012/08/25 | [
"https://wordpress.stackexchange.com/questions/63043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14728/"
] | I using custom $wp\_query for most of my archive pages like, taxonomy,index,category and author page. Everything working fine, except one weird thing - the author template page pagination failed to work. The pagination stop to work on page 2 it direct to the 404 page. Pagination on other archive page, works perfectly.
... | You have a couple of issues here, the main one being that your query sets posts per page to two, but the number of pages available has no relationship to your custom query. If your "Blog pages show at most" under Reading settings is set to 10, and an author only has <= 10 posts, there is no second page.
The other issu... |
63,054 | <p><a href="http://queryposts.com/function/comments_number/" rel="nofollow"><code>comments_number()</code></a> is quite useful: It takes the result of <a href="http://queryposts.com/function/get_comments_number/" rel="nofollow"><code>get_comments_number()</code></a> and prepares the output with some localization magic.... | [
{
"answer_id": 63055,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Since WordPress 4.0, you can use the function <code>get_comments_number_text()</code>. See ticket <a href=\"https://co... | 2012/08/25 | [
"https://wordpress.stackexchange.com/questions/63054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73/"
] | [`comments_number()`](http://queryposts.com/function/comments_number/) is quite useful: It takes the result of [`get_comments_number()`](http://queryposts.com/function/get_comments_number/) and prepares the output with some localization magic. Unfortunately, it prints the result out when it is done, it doesn’t offer an... | Easiest way:
```
ob_start();
comments_number();
$data = ob_get_clean();
```
$data will contain the text. |
63,057 | <p>I was wondering which is the correct method to do this and which action hook should i use. </p>
<p>I have custom login/register pages so if the user try to go to a forbidden page and its not logged in i will redirect him to a login page.</p>
<p>Currently on my functions.php i got the following:</p>
<pre><code>/*
... | [
{
"answer_id": 63175,
"author": "Puneet Sahalot",
"author_id": 19731,
"author_profile": "https://wordpress.stackexchange.com/users/19731",
"pm_score": 1,
"selected": false,
"text": "<p>The posts/pages which you want to hide from non logged in users can be published as \"Private\" and it ... | 2012/08/25 | [
"https://wordpress.stackexchange.com/questions/63057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4130/"
] | I was wondering which is the correct method to do this and which action hook should i use.
I have custom login/register pages so if the user try to go to a forbidden page and its not logged in i will redirect him to a login page.
Currently on my functions.php i got the following:
```
/*
* Restrict non logged user... | I couldnt find a better method other than:
```
/*
* Restrict non logged users to certain pages
*/
add_action('template_redirect','my_non_logged_redirect');
function my_non_logged_redirect()
{
if ((is_page('mi-perfil') || is_page('agregar-empresa')) && !is_user_logged_in() )
{
wp_redirect( home_url(... |
63,060 | <p>I have a website with many authors and posts.
I need to create a list of all authors and for each one display his latest post (not posts, <strong>only one post</strong>).</p>
<p>This better explains what I need:</p>
<pre><code><ul>
<li>
<h2>name of the author</h2>
<a ... | [
{
"answer_id": 63175,
"author": "Puneet Sahalot",
"author_id": 19731,
"author_profile": "https://wordpress.stackexchange.com/users/19731",
"pm_score": 1,
"selected": false,
"text": "<p>The posts/pages which you want to hide from non logged in users can be published as \"Private\" and it ... | 2012/08/25 | [
"https://wordpress.stackexchange.com/questions/63060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | I have a website with many authors and posts.
I need to create a list of all authors and for each one display his latest post (not posts, **only one post**).
This better explains what I need:
```
<ul>
<li>
<h2>name of the author</h2>
<a href="his latest post"> Title of his latest post </a>
</l... | I couldnt find a better method other than:
```
/*
* Restrict non logged users to certain pages
*/
add_action('template_redirect','my_non_logged_redirect');
function my_non_logged_redirect()
{
if ((is_page('mi-perfil') || is_page('agregar-empresa')) && !is_user_logged_in() )
{
wp_redirect( home_url(... |
63,084 | <p>I created a plugin with a new table (<code>wp_soundcloud</code>) and I need to retrieve the data from that new table along with the post data.</p>
<p>Here is my query:</p>
<pre><code> $querystr = "
SELECT $wpdb->posts.*,
FROM $wpdb->posts
LEFT JOIN $wpdb->soundcloud ON($wpdb->posts.ID = $... | [
{
"answer_id": 63097,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<h2>Always escape/prepare your data</h2>\n\n<p>Don't leave it open to injections:</p>\n\n<pre><code>global $wpdb;\n$all... | 2012/08/26 | [
"https://wordpress.stackexchange.com/questions/63084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19691/"
] | I created a plugin with a new table (`wp_soundcloud`) and I need to retrieve the data from that new table along with the post data.
Here is my query:
```
$querystr = "
SELECT $wpdb->posts.*,
FROM $wpdb->posts
LEFT JOIN $wpdb->soundcloud ON($wpdb->posts.ID = $wpdb->soundcloud.idpost)
WHERE $wpdb->po... | Always escape/prepare your data
-------------------------------
Don't leave it open to injections:
```
global $wpdb;
$all_posts = $wpdb->get_results( $wpdb->prepare(
"
SELECT %s.*
FROM %s
LEFT JOIN %s ON(%s = %s)
WHERE %s = 'soundcloud'
AND %s = '%s'
"
,$wp... |
63,092 | <p>This should be very easy, however for some reason I can't find a working snippet anywhere on the web..
I basically need to display one latest post from 6 categories (can be changed to 7,8, etc etc)
using one loop.
this should be the output: (just a demonstration)</p>
<pre><code><div class=box>
<h2>nam... | [
{
"answer_id": 63115,
"author": "Sanc",
"author_id": 19711,
"author_profile": "https://wordpress.stackexchange.com/users/19711",
"pm_score": 1,
"selected": false,
"text": "<p>What about in_category() function? You can build a conditional for those categories and then use a $var to show j... | 2012/08/26 | [
"https://wordpress.stackexchange.com/questions/63092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | This should be very easy, however for some reason I can't find a working snippet anywhere on the web..
I basically need to display one latest post from 6 categories (can be changed to 7,8, etc etc)
using one loop.
this should be the output: (just a demonstration)
```
<div class=box>
<h2>name of category 1</h2>
<a ... | What about in\_category() function? You can build a conditional for those categories and then use a $var to show just one post, filtering previously those cats on the query. It would be something like that:
```
<?php query_posts( 'posts_per_page=-1&cat=1,2,3,4,5,6' ); $var = 0; ?>
<?php if ( have_posts() ) : while ( ... |
63,098 | <p>I want my pages to not have comments enabled by default, only my posts. Is this possible?</p>
| [
{
"answer_id": 63103,
"author": "Damien",
"author_id": 17132,
"author_profile": "https://wordpress.stackexchange.com/users/17132",
"pm_score": -1,
"selected": false,
"text": "<p>You probably just need to show the widget for Discussion. </p>\n\n<p><img src=\"https://i.stack.imgur.com/kMY... | 2012/08/26 | [
"https://wordpress.stackexchange.com/questions/63098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/313/"
] | I want my pages to not have comments enabled by default, only my posts. Is this possible? | The Front-End Solution:
=======================
Trick your templates
--------------------
You could *fake* that comments are open for specific post types. The following code works for all templates, that wrap the comment form (or whatever comment related code/UI elements) inside a conditional [`comments_open()`](http... |
63,099 | <p>I just found my '.htaccess' file has the same lines of code repeated twice as below, maybe some plugins changed it, is it incorrect? Should I remove the repeated one? Thanks!!</p>
<pre><code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} ... | [
{
"answer_id": 63103,
"author": "Damien",
"author_id": 17132,
"author_profile": "https://wordpress.stackexchange.com/users/17132",
"pm_score": -1,
"selected": false,
"text": "<p>You probably just need to show the widget for Discussion. </p>\n\n<p><img src=\"https://i.stack.imgur.com/kMY... | 2012/08/26 | [
"https://wordpress.stackexchange.com/questions/63099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18252/"
] | I just found my '.htaccess' file has the same lines of code repeated twice as below, maybe some plugins changed it, is it incorrect? Should I remove the repeated one? Thanks!!
```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{RE... | The Front-End Solution:
=======================
Trick your templates
--------------------
You could *fake* that comments are open for specific post types. The following code works for all templates, that wrap the comment form (or whatever comment related code/UI elements) inside a conditional [`comments_open()`](http... |
63,150 | <p>When I post a PHP code snippet into a wordpress post it will convert</p>
<p><code><?PHP</code> into <code><!--?PHP</code></p>
<p>To avoid this I must replace <code><?PHP</code> with <code>&lt;?PHP</code></p>
<p>I am asking if there is a setting or easy method to avoid this? If not I am thinking of m... | [
{
"answer_id": 63151,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 1,
"selected": false,
"text": "<p>PHP is filtered out of the WordPress post editor as a security feature. There are some plugins that let you put t... | 2012/08/26 | [
"https://wordpress.stackexchange.com/questions/63150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8668/"
] | When I post a PHP code snippet into a wordpress post it will convert
`<?PHP` into `<!--?PHP`
To avoid this I must replace `<?PHP` with `<?PHP`
I am asking if there is a setting or easy method to avoid this? If not I am thinking of maybe writing a PHP function that will search the content filed and replace `<?PHP`... | Here is my only idea so far
```
function strip_php($content) {
return str_ireplace("<?PHP", "<?PHP", $content );
}
add_filter('content_save_pre','strip_php');
``` |
63,153 | <p>I recently installed WordPress on my own server, which uses non-port 80 Apache service. I could view posts but the tinymce editor constantly broke. More specifically, all menu items in visual editor did not appear and if there were any text, they were all invisible until I highlighted them.</p>
<p>After numerous re... | [
{
"answer_id": 63172,
"author": "Puneet Sahalot",
"author_id": 19731,
"author_profile": "https://wordpress.stackexchange.com/users/19731",
"pm_score": 3,
"selected": true,
"text": "<p>I had exactly same issue with Visual Editor but my site was working on port 80. \nThis is what I did : \... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63153",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19727/"
] | I recently installed WordPress on my own server, which uses non-port 80 Apache service. I could view posts but the tinymce editor constantly broke. More specifically, all menu items in visual editor did not appear and if there were any text, they were all invisible until I highlighted them.
After numerous research, so... | I had exactly same issue with Visual Editor but my site was working on port 80.
This is what I did :
Edited wp-config.php and added the following :
```
define( 'CONCATENATE_SCRIPTS', false );
```
and everything worked fine.
Additionally you can check if `wp-includes/js/tinymce/wp-tinymce.js.gz` file exists or no... |
63,161 | <p>I'm trying to come to an accurate decision here about safe ajax requests from a template.</p>
<p>The thing about AJAX that always scares me is that the called script location is public:</p>
<pre><code>http://www.mydomain.com/wp-content/themes/mytheme/inc/myscript.php
</code></pre>
<p>I just don't feel comfortable... | [
{
"answer_id": 63162,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 0,
"selected": false,
"text": "<p>Yes don't use that script and use the secure one WordPress provides for you.</p>\n\n<p><code>wp-admin/admin-ajax.p... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9295/"
] | I'm trying to come to an accurate decision here about safe ajax requests from a template.
The thing about AJAX that always scares me is that the called script location is public:
```
http://www.mydomain.com/wp-content/themes/mytheme/inc/myscript.php
```
I just don't feel comfortable with that kind of public knowled... | Security through obscurity isn't a good pattern to follow. You have to have a URL to make XHR or JSONP calls. Anyone who knows anything about searching the DOM using developer tools, Firebug, etc... can easily find your remote script URL. To me, this is the wrong question to ask.
The more relevant question to securit... |
63,183 | <p>I created a custom theme (style.css in the dashboard)</p>
<pre><code>/*
Theme Name: Client customisations
Description: Child theme for the client Website
Author: Me
Author URI: http://example.com/about/
Template: aries
Version: 1.0.0
*/
@import url("../aries/style.css");
h2{
co... | [
{
"answer_id": 63207,
"author": "Casebash",
"author_id": 313,
"author_profile": "https://wordpress.stackexchange.com/users/313",
"pm_score": 2,
"selected": false,
"text": "<p>I simply had to replace <code>get_template_directory_uri()</code> with <code>get_stylesheet_directory_uri()</code... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/313/"
] | I created a custom theme (style.css in the dashboard)
```
/*
Theme Name: Client customisations
Description: Child theme for the client Website
Author: Me
Author URI: http://example.com/about/
Template: aries
Version: 1.0.0
*/
@import url("../aries/style.css");
h2{
color: #4E8B4E !... | I simply had to replace `get_template_directory_uri()` with `get_stylesheet_directory_uri()` in the parent template. I tried enqueing the css first, as I didn't want to modify the parent, but I couldn't get it working. |
63,188 | <p>I have <strong>HTML5 Template</strong> with 5 pages. I am converting it to a <strong>WordPress Theme</strong>.</p>
<p>I have a contact page. This page includes 'forms.js' script to send contact form data to 'MailHandler.php' file.</p>
<p>Inside the 'forms.js' script there is a variable I want to change, </p>
<pre... | [
{
"answer_id": 63199,
"author": "amit",
"author_id": 17968,
"author_profile": "https://wordpress.stackexchange.com/users/17968",
"pm_score": 0,
"selected": false,
"text": "<p>If the code itself is small, then I think you should call it inside theme file, as shown here in the below exampl... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63188",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19683/"
] | I have **HTML5 Template** with 5 pages. I am converting it to a **WordPress Theme**.
I have a contact page. This page includes 'forms.js' script to send contact form data to 'MailHandler.php' file.
Inside the 'forms.js' script there is a variable I want to change,
```
mailHandlerURL:'bat/MailHandler.php'
```
How ... | If you want to send the url of the website, or other server side calculated values, to JavaScript you can use `wp_localize_script` ([Codex Page](http://codex.wordpress.org/Function_Reference/wp_localize_script)). This function creates an object, with the values you've passed.
As the documentation states, you've got to... |
63,198 | <p>i want to get the user avatar URL to use it as background URL style for a div. i tried to use the following but it does not return anything when i view the code it appears like that.</p>
<pre><code>background: url()
</code></pre>
<p>i used this function.</p>
<pre><code>function get_avatar_url($get_avatar){
preg_m... | [
{
"answer_id": 63199,
"author": "amit",
"author_id": 17968,
"author_profile": "https://wordpress.stackexchange.com/users/17968",
"pm_score": 0,
"selected": false,
"text": "<p>If the code itself is small, then I think you should call it inside theme file, as shown here in the below exampl... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63198",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19738/"
] | i want to get the user avatar URL to use it as background URL style for a div. i tried to use the following but it does not return anything when i view the code it appears like that.
```
background: url()
```
i used this function.
```
function get_avatar_url($get_avatar){
preg_match("/src='(.*?)'/i", $get_avatar, $... | If you want to send the url of the website, or other server side calculated values, to JavaScript you can use `wp_localize_script` ([Codex Page](http://codex.wordpress.org/Function_Reference/wp_localize_script)). This function creates an object, with the values you've passed.
As the documentation states, you've got to... |
63,202 | <p>I am trying to create a sub-menu under a Custom Post Type I have named Portfolios.</p>
<p>When I change <code>add_submenu_page()</code> to <code>add_options_page()</code>, it correctly shows a new link under the Settings menu, but it doesn't show under the Portfolios menu.</p>
<p>What am I doing wrong?</p>
<p>Bel... | [
{
"answer_id": 76182,
"author": "NightHawk",
"author_id": 14656,
"author_profile": "https://wordpress.stackexchange.com/users/14656",
"pm_score": 5,
"selected": false,
"text": "<p><a href=\"https://developer.wordpress.org/reference/functions/add_options_page/\" rel=\"noreferrer\"><code>a... | 2012/08/22 | [
"https://wordpress.stackexchange.com/questions/63202",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19636/"
] | I am trying to create a sub-menu under a Custom Post Type I have named Portfolios.
When I change `add_submenu_page()` to `add_options_page()`, it correctly shows a new link under the Settings menu, but it doesn't show under the Portfolios menu.
What am I doing wrong?
Below is my code snippet;
```
add_action( 'admin... | [`add_options_page()`](https://developer.wordpress.org/reference/functions/add_options_page/) automatically adds it underneath settings, however [`add_submenu_page()`](https://developer.wordpress.org/reference/functions/add_submenu_page/) gives you control as to where you want it to show up.
Try something like this:
... |
63,222 | <p>I have created a shortcode via the Shortcode API that does something like this:</p>
<pre><code>[accordion_item numero="01" primeiro="true"]Item 01[/accordion_item]
[accordion_conteudo]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed quis nisi eget eros ultrices vestibulum in sit amet nunc.
Cras varius ... | [
{
"answer_id": 97984,
"author": "nocommit",
"author_id": 32273,
"author_profile": "https://wordpress.stackexchange.com/users/32273",
"pm_score": 3,
"selected": true,
"text": "<p>I have just spent 24 hours attempting the same implementation, but with a more elaborate styled preview of res... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9781/"
] | I have created a shortcode via the Shortcode API that does something like this:
```
[accordion_item numero="01" primeiro="true"]Item 01[/accordion_item]
[accordion_conteudo]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed quis nisi eget eros ultrices vestibulum in sit amet nunc.
Cras varius pellentesque t... | I have just spent 24 hours attempting the same implementation, but with a more elaborate styled preview of results. Basically like a layout builder using shortcodes.
Wish I would have found [this post](http://www.garyc40.com/2010/03/how-to-make-shortcodes-user-friendly/) earlier cause it lays the groundwork for the fi... |
63,226 | <p>I have this part of code:</p>
<pre><code>return '<img class="myimage '.$text_color.' '.$horizontal.$slide_fitscreen.'" src="'.$image.'" alt="" '.$slide_desc.' />';
</code></pre>
<p>What I want to do is to return also a php shortcode but not inside the <strong>img</strong> element, because my shortcode genera... | [
{
"answer_id": 63240,
"author": "Brent",
"author_id": 10972,
"author_profile": "https://wordpress.stackexchange.com/users/10972",
"pm_score": 2,
"selected": true,
"text": "<p>This behavior is being caused most likely because something in the shortcode function that is causing unstable be... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12572/"
] | I have this part of code:
```
return '<img class="myimage '.$text_color.' '.$horizontal.$slide_fitscreen.'" src="'.$image.'" alt="" '.$slide_desc.' />';
```
What I want to do is to return also a php shortcode but not inside the **img** element, because my shortcode generates a **a** element so I need to return it af... | This behavior is being caused most likely because something in the shortcode function that is causing unstable behavior. I recently just had the same issue with something I was working on.
From the WordPress Codex for ["Add ShortCode"](http://codex.wordpress.org/Function_Reference/add_shortcode) there's a note tucked... |
63,237 | <p>Thanks to a variety of posts on here I've managed to put together a front end submission form. After about 24 hours of tweaking I've finally got everything working including a redirect to a 'success' page after submission, but I have no idea what to do with the nonce.</p>
<p>Here is the form page: <a href="http://p... | [
{
"answer_id": 103209,
"author": "drzaus",
"author_id": 13122,
"author_profile": "https://wordpress.stackexchange.com/users/13122",
"pm_score": -1,
"selected": false,
"text": "<p>Starting with this page: <a href=\"http://codex.wordpress.org/WordPress_Nonces\" rel=\"nofollow\">http://code... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63237",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19753/"
] | Thanks to a variety of posts on here I've managed to put together a front end submission form. After about 24 hours of tweaking I've finally got everything working including a redirect to a 'success' page after submission, but I have no idea what to do with the nonce.
Here is the form page: <http://pastebin.com/YWyXL3... | Use the following code inside just before tag on your front end code.
```
wp_nonce_field('name_of_your_action', 'name_of_your_nonce_field');
```
The above code will generate two hidden inputs inside your form tag. Now you can verify your nonce in the backend where you will process your form. Use the following code t... |
63,247 | <p>I’ve put the class for 'logged_in_as' into another container to display the content in another column:</p>
<pre><code> <div id="content-form">
<?php
$fields = array(
'author' => '<div class="right_col"><p class="comment-form-author">
... | [
{
"answer_id": 64846,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": true,
"text": "<p>You don't change the ordering, essentially. If you need to reposition things on the page, you should use CSS. That's... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63247",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19005/"
] | I’ve put the class for 'logged\_in\_as' into another container to display the content in another column:
```
<div id="content-form">
<?php
$fields = array(
'author' => '<div class="right_col"><p class="comment-form-author">
<input id="author" name="autho... | You don't change the ordering, essentially. If you need to reposition things on the page, you should use CSS. That's what it's for.
The submit button is in a P with a class of form-submit. You can use that to move it around with CSS. |
63,250 | <p>I am trying to do an email subscriber form and I would like to implement my own solution. I do not want to spend hours trying to figure out which Plugins is the best. Spending more times to install it in the template. And then realize that I can't easily send back a confirmation email to the subscriber... All I want... | [
{
"answer_id": 63253,
"author": "Jo_pinkish",
"author_id": 19753,
"author_profile": "https://wordpress.stackexchange.com/users/19753",
"pm_score": 0,
"selected": false,
"text": "<p>You could display the form on your WP site using an iframe and then the user would get confirmation without... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19757/"
] | I am trying to do an email subscriber form and I would like to implement my own solution. I do not want to spend hours trying to figure out which Plugins is the best. Spending more times to install it in the template. And then realize that I can't easily send back a confirmation email to the subscriber... All I want is... | The core of Wordpress will not touch your .htaccess file outside the comments.
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
```
Plugins such as WP Sup... |
63,252 | <p>I need to build a "export as .csv" functionality into my plugin. Problem is: i get the header already sent warning, because by the time my "export" function is called, Wordpress has already started rendering.</p>
<p>The way i set it up is via a small form in the Settings screen, which action attribute points to a f... | [
{
"answer_id": 63257,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": true,
"text": "<p>The start of what you're doing wrong can be explained by this quote:</p>\n\n<blockquote>\n <p>which action attribut... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63252",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82/"
] | I need to build a "export as .csv" functionality into my plugin. Problem is: i get the header already sent warning, because by the time my "export" function is called, Wordpress has already started rendering.
The way i set it up is via a small form in the Settings screen, which action attribute points to a file (downl... | The start of what you're doing wrong can be explained by this quote:
>
> which action attribute points to a file (download.csv.php) in my
> plugin folder, that should not be shown, just prompt a file download
> dialog for the csv dump.
>
>
>
and this code:
```
$core = $_POST['download'].'wp-load.php';
if(isset... |
63,260 | <p>What's the code for adding a widget area between my blog posts? Specifically I want to put one widget area inbetween after the first 3 posts of my blog?</p>
| [
{
"answer_id": 63257,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": true,
"text": "<p>The start of what you're doing wrong can be explained by this quote:</p>\n\n<blockquote>\n <p>which action attribut... | 2012/08/27 | [
"https://wordpress.stackexchange.com/questions/63260",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19758/"
] | What's the code for adding a widget area between my blog posts? Specifically I want to put one widget area inbetween after the first 3 posts of my blog? | The start of what you're doing wrong can be explained by this quote:
>
> which action attribute points to a file (download.csv.php) in my
> plugin folder, that should not be shown, just prompt a file download
> dialog for the csv dump.
>
>
>
and this code:
```
$core = $_POST['download'].'wp-load.php';
if(isset... |
63,267 | <p>As the title implies, I'm trying to set each new page under X parent to a specific page template. Either through a function/plugin/code </p>
<p>eg: if I make a 'swiss cheese' page, that is a children of the 'chesses' page, wp will automatically assign it the 'cheese' page template</p>
| [
{
"answer_id": 63268,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": false,
"text": "<p>On the admin side, you could update the meta data for the page-post_type programmatically:</p>\n\n<pre><code>global... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63267",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19108/"
] | As the title implies, I'm trying to set each new page under X parent to a specific page template. Either through a function/plugin/code
eg: if I make a 'swiss cheese' page, that is a children of the 'chesses' page, wp will automatically assign it the 'cheese' page template | On the admin side, you could update the meta data for the page-post\_type programmatically:
```
global $post;
if (
'swiss_cheese' === $post->post_parent
AND is_admin()
)
update_post_meta( $post->ID, '_wp_page_template', 'some_template.php' );
```
On the visitor facing side, you can simply jump into tem... |
63,316 | <p>Whenever a user presses on a comments author it redirects the user to the site which was enetered by user. I just want to add the target="_blank" element. where I can modify this?</p>
<p>In file i see only this: get_comment_author_link()</p>
| [
{
"answer_id": 63324,
"author": "Joshua Abenazer",
"author_id": 10251,
"author_profile": "https://wordpress.stackexchange.com/users/10251",
"pm_score": 2,
"selected": false,
"text": "<p>You would have to use the <code>get_comment_author_link</code> filter for this in the following manner... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63316",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7552/"
] | Whenever a user presses on a comments author it redirects the user to the site which was enetered by user. I just want to add the target="\_blank" element. where I can modify this?
In file i see only this: get\_comment\_author\_link() | You would have to use the `get_comment_author_link` filter for this in the following manner.
```
add_filter( "get_comment_author_link", "wpse_63316_modifiy_comment_author_anchor" );
function wpse_63316_modifiy_comment_author_anchor( $author_link ){
return str_replace( "<a", "<a target='_blank'", $author_link );
}
... |
63,323 | <p>This is the code I am using:</p>
<pre><code><?php echo str_replace( home_url(), '', get_permalink($post->ID) ); ?>
</code></pre>
<p>What it does is output the permalink as a relative URL i.e. only the slug. For instance, if the permalink is <code>http://example.com/2012/01/post-title/</code>, the relative... | [
{
"answer_id": 63332,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 5,
"selected": true,
"text": "<p>Use <code>$_SERVER['REQUEST_URI']</code> instead of <code>get_permalink()</code> to grab the current URL. <cod... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63323",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | This is the code I am using:
```
<?php echo str_replace( home_url(), '', get_permalink($post->ID) ); ?>
```
What it does is output the permalink as a relative URL i.e. only the slug. For instance, if the permalink is `http://example.com/2012/01/post-title/`, the relative URL output by the code would look like `/2012... | Use `$_SERVER['REQUEST_URI']` instead of `get_permalink()` to grab the current URL. `get_permalink` will give you the full address of the current post, not the address of the URL visited.
e.g. for example.com/test/page `echo $_SERVER['REQUEST_URI'];` prints `/test/page`
Note that this doesn't include the hashtag, as ... |
63,334 | <p>In a post, I have this text:</p>
<pre><code>[bhours shortcode="test" title="test"]
</code></pre>
<p>But the "title" attribute appears to be ignored. Here's a var_dump of the $atts attribute array</p>
<pre><code>array(1) {
["shortcode"]=>
string(4) "test"
}
</code></pre>
<p>Here's the PHP code:</p>
<pre><... | [
{
"answer_id": 63342,
"author": "Foxinni",
"author_id": 17011,
"author_profile": "https://wordpress.stackexchange.com/users/17011",
"pm_score": 1,
"selected": false,
"text": "<p>It appears that you are not extracting your $atts correctly or at all for that matter.</p>\n\n<p>Use the corre... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7332/"
] | In a post, I have this text:
```
[bhours shortcode="test" title="test"]
```
But the "title" attribute appears to be ignored. Here's a var\_dump of the $atts attribute array
```
array(1) {
["shortcode"]=>
string(4) "test"
}
```
Here's the PHP code:
```
function bhour_shortcode_handler($atts){
global $post... | I figured out the problem.
I had a function that was stripping the title attribute from the HTML, but couldn't differentiate between a shortcode and an HTML tag.
So, I converted over from regex to DOMDocument.
<https://stackoverflow.com/questions/15252770/php-preg-replace-match-html-attribute> |
63,343 | <p>I am trying to use categories to provide the structure for my site. I will create sections on my site called England, Wales, Scotland and Ireland . These will be categories. My posts will use custom post types - Video, Guide, Event, Clubs etc.</p>
<p>So, if I create a post called 'Trouble down south' using the 'Vid... | [
{
"answer_id": 63448,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You have to filter <code>'post_type_link'</code> to create the appropriate permalink. See <a href=\"https://wordpress.s... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18487/"
] | I am trying to use categories to provide the structure for my site. I will create sections on my site called England, Wales, Scotland and Ireland . These will be categories. My posts will use custom post types - Video, Guide, Event, Clubs etc.
So, if I create a post called 'Trouble down south' using the 'Video' CPT, a... | You have to filter `'post_type_link'` to create the appropriate permalink. See [this answer](https://wordpress.stackexchange.com/a/44596/73) for a similar example.
The following code works:
```
add_action( 'init', array ( 'WPSE_63343', 'init' ) );
class WPSE_63343
{
protected $post_type = 'video';
public st... |
63,345 | <p>Can anyone suggest the best way to go about adding a 'mega menu' to my wordpress navigation without using a plugin?</p>
<p>The content in the mega menu itself does not need to be editable via the CMS HOWEVER does need to be active when the user hovers over a certain li in the main navigation.</p>
<p>I've looked on... | [
{
"answer_id": 63351,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 0,
"selected": false,
"text": "<p>If you don't want to use a plugin, you can use the HTML version of <a href=\"http://www.designchemical.com/lab/jq... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13998/"
] | Can anyone suggest the best way to go about adding a 'mega menu' to my wordpress navigation without using a plugin?
The content in the mega menu itself does not need to be editable via the CMS HOWEVER does need to be active when the user hovers over a certain li in the main navigation.
I've looked on Google but every... | I’ll just point out how you can insert the HTML of your mega dropdown menu, then it’s up to you to style and animate it.
Dig around in `wp-includes/nav-menu-template.php` to find different useful filters for modifying navigation menus created in the admin area. I chose for the `walker_nav_menu_start_el` filter which g... |
63,350 | <p>For some categories on my site there's introduction text that needs formatting (so using the category description isn't an option) and placing at the top of <code>categories.php</code>.</p>
<p>I've added a post ID to the category description field thinking I could then use <code>get_post()</code> to load the releva... | [
{
"answer_id": 63449,
"author": "v3nt",
"author_id": 3978,
"author_profile": "https://wordpress.stackexchange.com/users/3978",
"pm_score": 0,
"selected": false,
"text": "<p>used this in the end but still not sure why get_post wouldn't work</p>\n\n<pre><code> $secintro_args =array(... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63350",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | For some categories on my site there's introduction text that needs formatting (so using the category description isn't an option) and placing at the top of `categories.php`.
I've added a post ID to the category description field thinking I could then use `get_post()` to load the relevant post's content then list all ... | You're using an old version of WordPress. Upgrade to 3.5 and you will no longer see that error.
Here's the function declaration for `get_post` in WP 3.4:
```
function &get_post(&$post, $output = OBJECT, $filter = 'raw')
```
Notice the ampersand in front of `$post`? That would mean the value is passed by reference. ... |
63,358 | <p>How can I output ONLY the post content (ie the text entered into the wysiwyg) and nothing else? i just need this for the posts in a specific category, so if i could call like say, </p>
<pre><code><?php get_template_part( 'venue_content', 'single' ); ?>
</code></pre>
<p>it would be ideal.</p>
| [
{
"answer_id": 63360,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": true,
"text": "<p>Assuming you are in the loop, or otherwise know (or know how to get) the <code>$post</code> object:</p>\n\n<... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63358",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19794/"
] | How can I output ONLY the post content (ie the text entered into the wysiwyg) and nothing else? i just need this for the posts in a specific category, so if i could call like say,
```
<?php get_template_part( 'venue_content', 'single' ); ?>
```
it would be ideal. | Assuming you are in the loop, or otherwise know (or know how to get) the `$post` object:
```
function wpse63358_get_post_content() {
global $post;
return $post->post_content;
}
```
If you want the *formatted* post content, replace this:
```
return $post->post_content;
```
...with this:
```
return apply_f... |
63,384 | <p>I wrote a plugin that creates a custom post type with custom fields. To prevent users from entering incorrect information, how can I validate the data?</p>
<p>I assumed that the save_post hook function would process field validation, but I can't seem to find a straight forward way that displays errors back to the u... | [
{
"answer_id": 63389,
"author": "Ian Dunn",
"author_id": 3898,
"author_profile": "https://wordpress.stackexchange.com/users/3898",
"pm_score": 4,
"selected": true,
"text": "<p>You're on the right track. I test the fields in the <code>save_post</code> callback, and then use <a href=\"htt... | 2012/08/28 | [
"https://wordpress.stackexchange.com/questions/63384",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7332/"
] | I wrote a plugin that creates a custom post type with custom fields. To prevent users from entering incorrect information, how can I validate the data?
I assumed that the save\_post hook function would process field validation, but I can't seem to find a straight forward way that displays errors back to the user.
Is ... | You're on the right track. I test the fields in the `save_post` callback, and then use [admin notices](http://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices) to display errors to the user when a field fails validation. They show up just in a highlighted box at the top of the page, just like any errors/me... |
63,418 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://wordpress.stackexchange.com/questions/4028/how-to-add-custom-form-fields-to-the-user-profile-page">How To Add Custom Form Fields To The User Profile Page?</a> </p>
</blockquote>
<p>I'm current removing some user fields with the following ... | [
{
"answer_id": 63425,
"author": "Upeksha",
"author_id": 19683,
"author_profile": "https://wordpress.stackexchange.com/users/19683",
"pm_score": 1,
"selected": false,
"text": "<p>The following function is from WordPress 3.4.1 default installation source file 'user.php' starting at line 14... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63418",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8945/"
] | >
> **Possible Duplicate:**
>
> [How To Add Custom Form Fields To The User Profile Page?](https://wordpress.stackexchange.com/questions/4028/how-to-add-custom-form-fields-to-the-user-profile-page)
>
>
>
I'm current removing some user fields with the following code in the functions.php file:
```
function adjus... | ```
unset($contactmethods['googleplus']);
```
Is what I needed to add to my above code. |
63,424 | <p>I edited my loop in archives.php in order to work with pagination and with the Category Post List Widget. I basically pieced it all together from random code and ideas and am now so far from the default post query that I'm having trouble getting back to square one. The reason I need to get back to square one is that... | [
{
"answer_id": 63481,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 4,
"selected": true,
"text": "<p>First, for layout and CSS styling, I would recommend creating <em>template files</em> for the contexts you w... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63424",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16856/"
] | I edited my loop in archives.php in order to work with pagination and with the Category Post List Widget. I basically pieced it all together from random code and ideas and am now so far from the default post query that I'm having trouble getting back to square one. The reason I need to get back to square one is that I ... | First, for layout and CSS styling, I would recommend creating *template files* for the contexts you want to customize; i.e. create a `category.php` and a `tag.php` for the category and tag index archive pages, respectively. In either case, copy `archive.php` (or, if it doesn't exist, copy `index.php`), and rename the c... |
63,436 | <p>I'm using Wordpress version 2.6.2 and now it shows in the page that </p>
<pre><code>Deprecated: Assigning the return value of new by reference is deprecated in /home/np14388/domains/<sitename>/public_html/wp-settings.php on line 472
</code></pre>
<p>etc. Is it safe to update from this version to the newest o... | [
{
"answer_id": 63542,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>Probably.</p>\n\n<p>Just do the following before updating:</p>\n\n<ol>\n<li>Do a direct SQL backup of the da... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63436",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5932/"
] | I'm using Wordpress version 2.6.2 and now it shows in the page that
```
Deprecated: Assigning the return value of new by reference is deprecated in /home/np14388/domains/<sitename>/public_html/wp-settings.php on line 472
```
etc. Is it safe to update from this version to the newest one, or should I update in certai... | Probably.
Just do the following before updating:
1. Do a direct SQL backup of the database
2. Export your site content
3. Disable all Plugins
4. Switch to the default Theme
Then update to the latest version. If anything goes wrong, just restore from your backups, and try an iterative update. |
63,467 | <p>How can I hide or disable this <code>«</code> sign in front of <code>previous_post_link</code>?
I can't find it anywhere - it only shows up on the generated page.</p>
<p>This is the code I am using: </p>
<pre><code> <?php
$nextPost = get_next_post();
$nextthumbnail = get_the_post_thumbnail($... | [
{
"answer_id": 63469,
"author": "Joseph Leedy",
"author_id": 8554,
"author_profile": "https://wordpress.stackexchange.com/users/8554",
"pm_score": 1,
"selected": false,
"text": "<p>Just copy your <code>next_post_link</code>:</p>\n\n<pre><code> <?php previous_post_link( '%link', '' . $... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17376/"
] | How can I hide or disable this `«` sign in front of `previous_post_link`?
I can't find it anywhere - it only shows up on the generated page.
This is the code I am using:
```
<?php
$nextPost = get_next_post();
$nextthumbnail = get_the_post_thumbnail($nextPost->ID);
next_post_link('%link','... | Just copy your `next_post_link`:
```
<?php previous_post_link( '%link', '' . $prevthumbnail . '' ); ?>
```
Per the [codex page](http://codex.wordpress.org/Function_Reference/previous_post_link), the first parameter specifies what will we be shown (thanks Chip!) |
63,478 | <p>Is there a <code>save_post</code> hook for custom post types?</p>
<p>Example: <code>save_my_post_type</code></p>
<p>I know there is <code>publish_my_post_type</code> but I'm looking for a save hook.</p>
| [
{
"answer_id": 63480,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 6,
"selected": true,
"text": "<p>the hook is the same <code>save_post</code> just make sure its your post type ex:</p>\n\n<pre><code>add_actio... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | Is there a `save_post` hook for custom post types?
Example: `save_my_post_type`
I know there is `publish_my_post_type` but I'm looking for a save hook. | the hook is the same `save_post` just make sure its your post type ex:
```
add_action('save_post','save_post_callback');
function save_post_callback($post_id){
global $post;
if ($post->post_type != 'MY_CUSTOM_POST_TYPE_NAME'){
return;
}
//if you get here then it's your post type so do your thi... |
63,491 | <p>I have this template I purchased and I'm trying to customize.</p>
<p>I added a new taxonomy category called location and I'm trying to replace the default categories being loaded in the theme with my new taxonomy categories.</p>
<p>here's the current code and where it loads the categories:</p>
<pre><code> $cats_a... | [
{
"answer_id": 63495,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>Use :</p>\n\n<pre><code>$terms = get_terms( 'location', 'hide_empty=0' );\nif(is_wp_error($terms)){\n // e... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19831/"
] | I have this template I purchased and I'm trying to customize.
I added a new taxonomy category called location and I'm trying to replace the default categories being loaded in the theme with my new taxonomy categories.
here's the current code and where it loads the categories:
```
$cats_array = get_categories('hide_... | I wasn't able to fix the issue in the end, but instead of using the theme options file to dynamically select the category I want, I used an override code to directly (statically) select the category I wanted |
63,503 | <p>I'm making an admin page for my plugin and I'd like to make a text link designed like the form button of admin pages. </p>
<p>I tried this but didn't work well.</p>
<pre><code><a href="" cless="button-primary" style="line-height: 2em; border-color: #298CBA; font-weight: bold; color: white; background: #21759B u... | [
{
"answer_id": 63667,
"author": "Teno",
"author_id": 19360,
"author_profile": "https://wordpress.stackexchange.com/users/19360",
"pm_score": 0,
"selected": false,
"text": "<p>This worked,</p>\n\n<pre><code><?php \n$pageslug = 'the-plugin-option-page-slug';\n?>\n <form method=... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63503",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19360/"
] | I'm making an admin page for my plugin and I'd like to make a text link designed like the form button of admin pages.
I tried this but didn't work well.
```
<a href="" cless="button-primary" style="line-height: 2em; border-color: #298CBA; font-weight: bold; color: white; background: #21759B url(../images/button-grad... | You can style a link as a button with the `button` css class:
```
<a href="#" class="button">I am a button</a>
```
You can modify a button with the primary styling by adding `button-primary`:
```
<a href="#" class="button button-primary">I am the primary button</a>
``` |
63,505 | <p>I have facebook Like Button and I use Wordpress 3.4.1.
I notice if I make "like" on URL like <a href="http://example.com/" rel="nofollow">http://example.com/</a>{post_type}/{post_slug}/ facebook knows about copy of this page on URL <a href="http://example.com/" rel="nofollow">http://example.com/</a>?{post_type}={po... | [
{
"answer_id": 63667,
"author": "Teno",
"author_id": 19360,
"author_profile": "https://wordpress.stackexchange.com/users/19360",
"pm_score": 0,
"selected": false,
"text": "<p>This worked,</p>\n\n<pre><code><?php \n$pageslug = 'the-plugin-option-page-slug';\n?>\n <form method=... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19838/"
] | I have facebook Like Button and I use Wordpress 3.4.1.
I notice if I make "like" on URL like <http://example.com/>{post\_type}/{post\_slug}/ facebook knows about copy of this page on URL <http://example.com/>?{post\_type}={post\_slug}. I see that Like Button is on and off on these pages simultaneously. And I don't und... | You can style a link as a button with the `button` css class:
```
<a href="#" class="button">I am a button</a>
```
You can modify a button with the primary styling by adding `button-primary`:
```
<a href="#" class="button button-primary">I am the primary button</a>
``` |
63,551 | <p>I am currently working with ZURB's Foundation Framework. It's a terrific framework and my project is coming along a lot nicer and quicker than it would have beforehand. Foundation comes with CSS/Javascript that can be called upon within your design. One of these key features is their Tabs system. Now, what I current... | [
{
"answer_id": 63756,
"author": "Jen",
"author_id": 13810,
"author_profile": "https://wordpress.stackexchange.com/users/13810",
"pm_score": 0,
"selected": false,
"text": "<p>Forget about the custom code built above (though I'm glad you like it!) and just use the vanilla WP nav menus.</p>... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19566/"
] | I am currently working with ZURB's Foundation Framework. It's a terrific framework and my project is coming along a lot nicer and quicker than it would have beforehand. Foundation comes with CSS/Javascript that can be called upon within your design. One of these key features is their Tabs system. Now, what I currently ... | you can write a custom class to extend Walker\_Nav\_Menu in your functions.php, in this class you can change all the markup
the more simple is to copy all the class from /wp-includes/nav-menu-template.php and modify what you want
```
class Walker_Nav_Foundation extends Walker_Nav_Menu {
function start_lvl() // to... |
63,558 | <p>I'm extremely new to WP. I want to add an extra field to the Post interface and show the content on a template. I don't want to show the content of the Post, but just the content in the extra field. </p>
<p>Basically what I'm trying to achieve is design a Customer Testimonial page on my website where I show the ful... | [
{
"answer_id": 63601,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 1,
"selected": false,
"text": "<p><strong>You can use a custom field eaisly then call into the template</strong><br>\n<em>(the image shows custom f... | 2012/08/29 | [
"https://wordpress.stackexchange.com/questions/63558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19705/"
] | I'm extremely new to WP. I want to add an extra field to the Post interface and show the content on a template. I don't want to show the content of the Post, but just the content in the extra field.
Basically what I'm trying to achieve is design a Customer Testimonial page on my website where I show the full testimon... | **You can use a custom field eaisly then call into the template**
*(the image shows custom field <-- my installation is in hebrew but would look the same and apears under the editor)*

Then you can get the value of the field like so...
**Inside... |
63,563 | <p>I struggled with this all day, and now am here... </p>
<p>I have a contact form generated by including a php. Presently, I have this code in my theme's index.php to include it:</p>
<pre><code>if ( is_page('contact') ) {
include("../contact.php");
}
</code></pre>
<p>which renders and functions as expected: <a ... | [
{
"answer_id": 63596,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 1,
"selected": false,
"text": "<p>I can confirm that Password Protected pages still work as normal in 3.4.1.</p>\n\n<p>The password protect form doe... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19852/"
] | I struggled with this all day, and now am here...
I have a contact form generated by including a php. Presently, I have this code in my theme's index.php to include it:
```
if ( is_page('contact') ) {
include("../contact.php");
}
```
which renders and functions as expected: <http://www.derekbeck.com/1775/conta... | I can confirm that Password Protected pages still work as normal in 3.4.1.
The password protect form does submit the password to `/wp-login.php?action=postpass` where that file deals with authentication. Upon successful or failed login the file will redirect you back to the page the user was on.
One thing to be aware... |
63,591 | <p>Can anyone help?</p>
<p>I'm trying to show a default placeholder image on my posts when the user hasn't uploaded an image.</p>
<p>I have the below code BUT i need to rewrite it so that the link isn't applied to the placeholder image - only the uploaded image.</p>
<p>Unfortunately my PHP isn't great at all so woul... | [
{
"answer_id": 63590,
"author": "D.W.",
"author_id": 16448,
"author_profile": "https://wordpress.stackexchange.com/users/16448",
"pm_score": 0,
"selected": false,
"text": "<p>Step 1. Disable all plugins. See if you can still reproduce this problem. If you can, proceed to step 2. Comm... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63591",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13998/"
] | Can anyone help?
I'm trying to show a default placeholder image on my posts when the user hasn't uploaded an image.
I have the below code BUT i need to rewrite it so that the link isn't applied to the placeholder image - only the uploaded image.
Unfortunately my PHP isn't great at all so would appreciate some help..... | Short answer: No, WordPress doesn't care about pastebin in particular and doesn't do any sort of filtering like you're describing.
Long answer: Your host is doing it.
Step 1: Ask your host if they have mod\_security enabled and what their filtering rules are.
Step 2: Try pasting the same link via a comment or someth... |
63,599 | <p>I do have a custom post type with the following setup:</p>
<pre><code>$supports = array(
'title'
, 'editor'
, 'thumbnail'
, 'revisions'
, 'page-attributes'
);
$args = array(
'hierarchical' => true
, 'supports' => $supports
[...]
);
register_post_type('myType', $args);
</code></pre>... | [
{
"answer_id": 63620,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 3,
"selected": false,
"text": "<p>See the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters\">codex... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19822/"
] | I do have a custom post type with the following setup:
```
$supports = array(
'title'
, 'editor'
, 'thumbnail'
, 'revisions'
, 'page-attributes'
);
$args = array(
'hierarchical' => true
, 'supports' => $supports
[...]
);
register_post_type('myType', $args);
```
I would like to show all po... | As far as I can tell, there is no work-around to this at the database level. This is a problem I run into somewhat often, which is the case you need to turn an list with structure references into an an ordered array with children elements appearing immediately after their parents. This can be accomplished in PHP, but w... |
63,600 | <p>I am trying to get the user ID during registration and automatically add that ID to my custom table. I am using the WP-Members plugin for registration.</p>
<p>Is it possible to get user ID on the fly while registering and add that ID to another custom table with WP-Members plugin.</p>
<p>Or I could use a custom re... | [
{
"answer_id": 63604,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 4,
"selected": true,
"text": "<p>Please take a look at <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/user_register\" rel=\"norefe... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9821/"
] | I am trying to get the user ID during registration and automatically add that ID to my custom table. I am using the WP-Members plugin for registration.
Is it possible to get user ID on the fly while registering and add that ID to another custom table with WP-Members plugin.
Or I could use a custom registration page i... | Please take a look at [user\_register hook](http://codex.wordpress.org/Plugin_API/Action_Reference/user_register)
This is fired when a new user is registered and conveniently passes you the user ID of the new user.
```
function function_name( $user_id )
{
/* do what you want to do with ID here */
}
add_ac... |
63,611 | <p>I really need your help with a feature I have never worked with so far.</p>
<p>I have a custom-post-type named <code>wr_event</code>. And I created this custom <code>WP_Query</code> to retrieve all posts for this post-type that are "younger" than yesterday. Fairly simple and this works like a charm.</p>
<pre><code... | [
{
"answer_id": 63827,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>Try this: </p>\n\n<p>First add this functions to your theme's functions.php</p>\n\n<pre><code>//this will cal... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I really need your help with a feature I have never worked with so far.
I have a custom-post-type named `wr_event`. And I created this custom `WP_Query` to retrieve all posts for this post-type that are "younger" than yesterday. Fairly simple and this works like a charm.
```
function event_list_iCal() {
$yesterd... | This is entirely based on [Event Organiser](http://wordpress.org/extend/plugins/event-organiser/) (a plug-in I've developed). The code is lifted almost straight from the source but with alterations. As such I've not tested the code as given.
### Step 1: Create a feed
This is simple:
```
add_action('init','wpse63611_... |
63,612 | <p>I have a local development server with WordPress installed (my desktop Linux Mint 12 box). I'd like to use multi-site WordPress to manage my different client projects through one install, but I have a couple of important questions before I commit to this set-up.</p>
<p>1) Is it possible to import a database backup ... | [
{
"answer_id": 63827,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>Try this: </p>\n\n<p>First add this functions to your theme's functions.php</p>\n\n<pre><code>//this will cal... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63612",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10789/"
] | I have a local development server with WordPress installed (my desktop Linux Mint 12 box). I'd like to use multi-site WordPress to manage my different client projects through one install, but I have a couple of important questions before I commit to this set-up.
1) Is it possible to import a database backup (created f... | This is entirely based on [Event Organiser](http://wordpress.org/extend/plugins/event-organiser/) (a plug-in I've developed). The code is lifted almost straight from the source but with alterations. As such I've not tested the code as given.
### Step 1: Create a feed
This is simple:
```
add_action('init','wpse63611_... |
63,625 | <p>I feel like I'm extremely close on this one but the query keeps on showing up empty. Basically, I'm trying to query the custom values between two dates. Records should be returned if the start date is less than the current date <em>and</em> the end date is greater than or equal to the current date:</p>
<pre><code>$... | [
{
"answer_id": 63633,
"author": "sanchothefat",
"author_id": 1733,
"author_profile": "https://wordpress.stackexchange.com/users/1733",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried specifying the 'type' of data for the meta_query? I'm assuming you're using timestamps becau... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63625",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6875/"
] | I feel like I'm extremely close on this one but the query keeps on showing up empty. Basically, I'm trying to query the custom values between two dates. Records should be returned if the start date is less than the current date *and* the end date is greater than or equal to the current date:
```
$args = array(
'ta... | **Update - it may be supported in a meta\_query. I need more information - see below.**
~~You can't do it using a meta\_query, it's not supported.~~
**Do you have data in meta\_data fields?** - WordPress queries will exclude posts where any of the orderby (or meta\_query) fields is missing. WordPress adds a join con... |
63,635 | <p>I have this in my <code>functions.php</code></p>
<pre><code>add_theme_support( 'post-thumbnails' );
</code></pre>
<p>This means all my post-types (normal posts and custom-post-types) have post-thumbnails enabled.</p>
<p>Is it possible to just enable them inside a custom-post-type and not on normal posts?</p>
| [
{
"answer_id": 63638,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 0,
"selected": false,
"text": "<p>If you specify a \"supports\" argument when registering the Custom Post type, you can leave out \"thumbnai... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63635",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I have this in my `functions.php`
```
add_theme_support( 'post-thumbnails' );
```
This means all my post-types (normal posts and custom-post-types) have post-thumbnails enabled.
Is it possible to just enable them inside a custom-post-type and not on normal posts? | Use [`remove_post_type_support`](http://codex.wordpress.org/Function_Reference/remove_post_type_support) to disable features for specific post types.
```
add_action( 'init', 'wpa63635_init' );
function wpa63635_init() {
remove_post_type_support( 'post', 'thumbnail' );
}
``` |
63,643 | <p>I'm using WP 3.4.1 with German language files and started using the <a href="http://www.harriswebsolutions.co.uk/event-organiser/" rel="nofollow">Event Organiser plugin</a>.
This plugins already comes with some German language files, but I'm not 100% happy with it due to following reasons:</p>
<ul>
<li>Some typos</... | [
{
"answer_id": 63644,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>As with every <em>»bug«</em> you find (typos in language files are bugs too): </p>\n\n<ul>\n<li>Contact the develop... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63643",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19880/"
] | I'm using WP 3.4.1 with German language files and started using the [Event Organiser plugin](http://www.harriswebsolutions.co.uk/event-organiser/).
This plugins already comes with some German language files, but I'm not 100% happy with it due to following reasons:
* Some typos
* Mixture of informal (Du) and formal (Si... | Put your language files to a place where they are not overwritten. Then change the path to your custom language files on `'load_textdomain_mofile'`.
Pseudo-code, you have to change the path and the text domain:
```
add_filter( 'load_textdomain_mofile', 'wpse_63643_custom_eo_lang', 10, 2 );
function wpse_63643_custom... |
63,668 | <p>Has anyone used <a href="http://php.net/manual/en/language.oop5.autoload.php">autoloading</a> and/or PHP namespaces within a plugin or theme?</p>
<p>Thoughts on using them? Any harm? Pitfalls?</p>
<p><em>Note: namespaces are PHP 5.3+ only. Assume, for this question, that you know you'll be dealing with servers tha... | [
{
"answer_id": 63982,
"author": "Daniel Chatfield",
"author_id": 6210,
"author_profile": "https://wordpress.stackexchange.com/users/6210",
"pm_score": 2,
"selected": false,
"text": "<p>I use autoloading (as my plugin has loads of classes - partly because it includes Twig), never had an i... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6035/"
] | Has anyone used [autoloading](http://php.net/manual/en/language.oop5.autoload.php) and/or PHP namespaces within a plugin or theme?
Thoughts on using them? Any harm? Pitfalls?
*Note: namespaces are PHP 5.3+ only. Assume, for this question, that you know you'll be dealing with servers that you know have PHP 5.3 or grea... | Okay, I've had two big projects where I've been in control of the server enough to namespace and rely on autoloading.
First up. Autoloading is awesome. Not worrying about requires is a relatively good thing.
Here's a loader I've been using on a few projects. Checks to make sure the class is in the current namespace f... |
63,678 | <p>I've built a test site for a client using a theme purchased from Template Monster. I can't seem to find out why the link is broken on this page. and the Template Monster support has extremely poor.</p>
<p><a href="http://trustlabor.com/riverstonesalonspa/portfolio/" rel="nofollow">http://trustlabor.com/riverstonesa... | [
{
"answer_id": 63982,
"author": "Daniel Chatfield",
"author_id": 6210,
"author_profile": "https://wordpress.stackexchange.com/users/6210",
"pm_score": 2,
"selected": false,
"text": "<p>I use autoloading (as my plugin has loads of classes - partly because it includes Twig), never had an i... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19895/"
] | I've built a test site for a client using a theme purchased from Template Monster. I can't seem to find out why the link is broken on this page. and the Template Monster support has extremely poor.
<http://trustlabor.com/riverstonesalonspa/portfolio/>
I renamed the stock theme "Portfolio" page to "Staff Bios" If I ch... | Okay, I've had two big projects where I've been in control of the server enough to namespace and rely on autoloading.
First up. Autoloading is awesome. Not worrying about requires is a relatively good thing.
Here's a loader I've been using on a few projects. Checks to make sure the class is in the current namespace f... |
63,681 | <p>I have template-clientlist.php now I search on wordpress doc but can find a function on how to check if page used template-clientlist.php</p>
<pre><code>template-clientlist.php
<?php
/*
Template Name: Page Of Posts
*/
?>
</code></pre>
<p>Is there function that exist or custom function to check if page used ... | [
{
"answer_id": 63719,
"author": "Joshua Abenazer",
"author_id": 10251,
"author_profile": "https://wordpress.stackexchange.com/users/10251",
"pm_score": 2,
"selected": true,
"text": "<p>You can give this a try.</p>\n\n<pre><code>$template_name = get_post_meta( get_the_ID(), '_wp_page_temp... | 2012/08/30 | [
"https://wordpress.stackexchange.com/questions/63681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/420/"
] | I have template-clientlist.php now I search on wordpress doc but can find a function on how to check if page used template-clientlist.php
```
template-clientlist.php
<?php
/*
Template Name: Page Of Posts
*/
?>
```
Is there function that exist or custom function to check if page used the custom template? | You can give this a try.
```
$template_name = get_post_meta( get_the_ID(), '_wp_page_template', true );
``` |
63,689 | <p>I created a category and call it "Blog". Then I created some posts and assign "Blog" as category for the posts. So I'm trying to go to previous/next into the same category and doesn't work. Here is my code:</p>
<pre><code><nav id="nav-single">
<span class="nav-previous"><?php previous_post_link('... | [
{
"answer_id": 63696,
"author": "Upeksha",
"author_id": 19683,
"author_profile": "https://wordpress.stackexchange.com/users/19683",
"pm_score": 2,
"selected": true,
"text": "<p>This is the default in WordPress Twenty Eleven Theme</p>\n\n<pre><code><nav id=\"nav-single\">\n &... | 2012/08/31 | [
"https://wordpress.stackexchange.com/questions/63689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16412/"
] | I created a category and call it "Blog". Then I created some posts and assign "Blog" as category for the posts. So I'm trying to go to previous/next into the same category and doesn't work. Here is my code:
```
<nav id="nav-single">
<span class="nav-previous"><?php previous_post_link('%link', __('<span class="meta... | This is the default in WordPress Twenty Eleven Theme
```
<nav id="nav-single">
<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
<span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">←</span> Previous', 'twentyeleven' ) ); ?></spa... |
63,692 | <p>I've a filter attached, that allows modifying an array:</p>
<pre><code>$data = apply_filters( 'wpse_example_filter', $data );
</code></pre>
<p>The problem is, that the data can be a single or multidimensional array:</p>
<pre><code>// single:
'SINGLE' => array(
// some data
)
// multidimensional:
'MULTI' =&... | [
{
"answer_id": 63695,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>This is what I've found so far.</p>\n\n<p>The <strong>trick</strong> is, that I'm using a non existent 2<sup>nd</su... | 2012/08/31 | [
"https://wordpress.stackexchange.com/questions/63692",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | I've a filter attached, that allows modifying an array:
```
$data = apply_filters( 'wpse_example_filter', $data );
```
The problem is, that the data can be a single or multidimensional array:
```
// single:
'SINGLE' => array(
// some data
)
// multidimensional:
'MULTI' => array(
0 => array(
// som... | While your answer is very interesting and I like it, I still want to post another proposal, just let you have another choice :)
IMHO, if the data contains only simple fields, like:
```
array(
'name' => 'my name',
'address' => 'my address',
'phone' => '01234',
);
```
then you can use the code below:
```... |
63,699 | <p>I want to insert hundreds of categories, structured hierarchically.
Any suggestions on how I could do it in a batch mode?
Thanks.</p>
| [
{
"answer_id": 63706,
"author": "gArn",
"author_id": 10629,
"author_profile": "https://wordpress.stackexchange.com/users/10629",
"pm_score": 0,
"selected": false,
"text": "<p>Would this do the trick?</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/category-import/\" rel=\"nofollo... | 2012/08/31 | [
"https://wordpress.stackexchange.com/questions/63699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16266/"
] | I want to insert hundreds of categories, structured hierarchically.
Any suggestions on how I could do it in a batch mode?
Thanks. | This is main function of the import process.
```
function menu_recursive_output( $branch_objet, $parent_id, $level ) {
// JUST FOR COUNTING ITEMS
static $counter = 1;
if ( $level ) {
// CHECK IF ITEM EXISTS ALREADY
// IF SO, THIS WILL RETURN ARRAY CONTAINING ID OF EXISTING ITEM
$created_cat = term_exis... |
63,707 | <p>As our users regularly upload ~6MB images to use on the website (and aren't too familiar with how to resize them first), WordPress stores the originals as well as resizing them to several different sizes.</p>
<p>I'd like a function or plugin that takes the uploaded image, resizes it down to something more manageabl... | [
{
"answer_id": 69287,
"author": "Paul Phillips",
"author_id": 13527,
"author_profile": "https://wordpress.stackexchange.com/users/13527",
"pm_score": 5,
"selected": true,
"text": "<p>Add this to the functions.php file in the theme folder. It replaces the original image with the large ima... | 2012/08/31 | [
"https://wordpress.stackexchange.com/questions/63707",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112/"
] | As our users regularly upload ~6MB images to use on the website (and aren't too familiar with how to resize them first), WordPress stores the originals as well as resizing them to several different sizes.
I'd like a function or plugin that takes the uploaded image, resizes it down to something more manageable and then... | Add this to the functions.php file in the theme folder. It replaces the original image with the large image set in settings. You might want to setup a new image format and use that as the new original size though.
```
function replace_uploaded_image($image_data) {
// if there is no large image : return
if (!is... |
63,714 | <p>I would like to have <strong>two different sized featured images</strong> on my homepage. I currently have all featured images set to 280x200. I would like to have SOME posts on the home page display a larger 620x200 image and others the 280x200. I'm not sure how to accomplish this. I realize I can specify a cus... | [
{
"answer_id": 63717,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": -1,
"selected": false,
"text": "<p>A featured image is saved as an attachment ID, you can use the <code>get_post_thumbnail</code> function as a... | 2012/08/31 | [
"https://wordpress.stackexchange.com/questions/63714",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19905/"
] | I would like to have **two different sized featured images** on my homepage. I currently have all featured images set to 280x200. I would like to have SOME posts on the home page display a larger 620x200 image and others the 280x200. I'm not sure how to accomplish this. I realize I can specify a custom image size in my... | With `get_post_thumbnail()` you have the ability to insert a featured image in your theme.
`the_post_thumbnail( $size, $attr );` holds to parameter 1. The size of your image and the ID.
If you would like to have 2 image sizes of featured images on your home page you could do it like this:
```
if(is_front_page(){ // ... |
63,748 | <p>I want to add a class to the 'Read more' link. Actually I have this:</p>
<pre><code><?php the_content( 'Read more...' ); ?>
</code></pre>
<p>Which outputs:</p>
<pre><code><a href="...?p=14#more-14" class="more-link">Read more…</a>
</code></pre>
<p>How can I add a class (using PHP) to the link, ... | [
{
"answer_id": 63754,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": -1,
"selected": false,
"text": "<p>Wordpress has a explenation in the codex regarding the read more... </p>\n\n<p>You can find it here: </p>\n\n<... | 2012/08/31 | [
"https://wordpress.stackexchange.com/questions/63748",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16533/"
] | I want to add a class to the 'Read more' link. Actually I have this:
```
<?php the_content( 'Read more...' ); ?>
```
Which outputs:
```
<a href="...?p=14#more-14" class="more-link">Read more…</a>
```
How can I add a class (using PHP) to the link, so it outputs:
```
<a href="...?p=14#more-14" class="more-link my_... | What (exactly) happens
----------------------
When calling `the_content()` inside your template, you are able to call it without any parameters. This means, that the function already has the defaults of `null` for both arguments: The "more" link text and the boolean switch that allows you to strip teaser content befor... |
63,752 | <p>Let's say I have a custom post type (e.g. <code>product</code>) and a custom taxonomy (e.g. <code>prod_cat</code>).<br>
What I need to do is to get all my custom taxonomy terms associated with an object of my custom post type.<br>
Here is how I do it inside the loop. </p>
<pre><code>$terms = wp_get_object_terms(ge... | [
{
"answer_id": 63754,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": -1,
"selected": false,
"text": "<p>Wordpress has a explenation in the codex regarding the read more... </p>\n\n<p>You can find it here: </p>\n\n<... | 2012/08/31 | [
"https://wordpress.stackexchange.com/questions/63752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7410/"
] | Let's say I have a custom post type (e.g. `product`) and a custom taxonomy (e.g. `prod_cat`).
What I need to do is to get all my custom taxonomy terms associated with an object of my custom post type.
Here is how I do it inside the loop.
```
$terms = wp_get_object_terms(get_the_ID(),'prod_cat', array('fields'=>... | What (exactly) happens
----------------------
When calling `the_content()` inside your template, you are able to call it without any parameters. This means, that the function already has the defaults of `null` for both arguments: The "more" link text and the boolean switch that allows you to strip teaser content befor... |
63,773 | <p>I am trying to target a specific category from a custom taxonomy. This is for WooCommerce.</p>
<p>So, the custom taxonomy is called "product_cat" and the category itself is called "adult-dvds".</p>
<p>This is what I tried; however, it didn't work (nothing shows up between the comment tags):</p>
<pre><code> <... | [
{
"answer_id": 63792,
"author": "rizqyhi",
"author_id": 16596,
"author_profile": "https://wordpress.stackexchange.com/users/16596",
"pm_score": 0,
"selected": false,
"text": "<p>Are your custom taxonomy's slug is <code>product-cat</code>? The <a href=\"http://codex.wordpress.org/Function... | 2012/09/01 | [
"https://wordpress.stackexchange.com/questions/63773",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I am trying to target a specific category from a custom taxonomy. This is for WooCommerce.
So, the custom taxonomy is called "product\_cat" and the category itself is called "adult-dvds".
This is what I tried; however, it didn't work (nothing shows up between the comment tags):
```
<!-- Custom Fields -->
<?p... | I ended up using this bit of code and it worked:
```
<?php if (has_term('adult-dvds','product_cat')) { ?>
<p>blah blah blah</p>
<?php } ?>
``` |
63,787 | <p>i would like to know the proper way to do this</p>
<pre><code>$dynValue=5;//loop this many times
//start of my loop
for ($num=1; $num <= $dynValue; $num++){
//note the incremented number ($num) in the call back
add_action('add_meta_boxes', 'mpc_meta_box_'.$num.');
//below is where im having the problem
// i am... | [
{
"answer_id": 63792,
"author": "rizqyhi",
"author_id": 16596,
"author_profile": "https://wordpress.stackexchange.com/users/16596",
"pm_score": 0,
"selected": false,
"text": "<p>Are your custom taxonomy's slug is <code>product-cat</code>? The <a href=\"http://codex.wordpress.org/Function... | 2012/09/01 | [
"https://wordpress.stackexchange.com/questions/63787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18928/"
] | i would like to know the proper way to do this
```
$dynValue=5;//loop this many times
//start of my loop
for ($num=1; $num <= $dynValue; $num++){
//note the incremented number ($num) in the call back
add_action('add_meta_boxes', 'mpc_meta_box_'.$num.');
//below is where im having the problem
// i am trying to increm... | I ended up using this bit of code and it worked:
```
<?php if (has_term('adult-dvds','product_cat')) { ?>
<p>blah blah blah</p>
<?php } ?>
``` |
63,833 | <p>I'm using this in my search.php template …</p>
<pre><code><div class="pagination">
<?php echo get_pagination_links(); ?>
</div>
</code></pre>
<p>And this is the function …</p>
<pre><code>function get_pagination_links() {
global $wp_query;
$big = 999999999;
return paginate_links(... | [
{
"answer_id": 63838,
"author": "Craig Pearson",
"author_id": 17295,
"author_profile": "https://wordpress.stackexchange.com/users/17295",
"pm_score": 0,
"selected": false,
"text": "<p>Although this isn't a solution using your exact code perhaps you can try using <a href=\"http://www.krie... | 2012/09/01 | [
"https://wordpress.stackexchange.com/questions/63833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I'm using this in my search.php template …
```
<div class="pagination">
<?php echo get_pagination_links(); ?>
</div>
```
And this is the function …
```
function get_pagination_links() {
global $wp_query;
$big = 999999999;
return paginate_links( array(
'base' => str_replace( $big, '%#%', esc... | I'm fairly certain this is answered elsewhere, but I'll add it here again.
I believe your issue lies here:
```
'current' => max( 1, get_query_var('paged') ),
```
Try this instead:
```
global $wp_query;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
```
...then:
``... |
63,843 | <p>I've never transferred a website before let alone a database. I believe I backed up the database to an .sql file and I haven't deactivated the old host yet in case I need to do it again.</p>
<p>My main question is now that I'm on a host with cPanel should I use the automatic "WP Install" and then upload the databas... | [
{
"answer_id": 63838,
"author": "Craig Pearson",
"author_id": 17295,
"author_profile": "https://wordpress.stackexchange.com/users/17295",
"pm_score": 0,
"selected": false,
"text": "<p>Although this isn't a solution using your exact code perhaps you can try using <a href=\"http://www.krie... | 2012/09/01 | [
"https://wordpress.stackexchange.com/questions/63843",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17954/"
] | I've never transferred a website before let alone a database. I believe I backed up the database to an .sql file and I haven't deactivated the old host yet in case I need to do it again.
My main question is now that I'm on a host with cPanel should I use the automatic "WP Install" and then upload the database somehow ... | I'm fairly certain this is answered elsewhere, but I'll add it here again.
I believe your issue lies here:
```
'current' => max( 1, get_query_var('paged') ),
```
Try this instead:
```
global $wp_query;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
```
...then:
``... |
63,891 | <p>I know how to create wp menus using the functions.php and diaplay it in my sote wherever the menu is required (e.g top menu, footer menu)
I even know how to style it using custom CSS.</p>
<p>I would like to know if it's possible to add HTML elements to a dynamic custom menu.
for example:
I want to build a menu when... | [
{
"answer_id": 63873,
"author": "Darshan Thanki",
"author_id": 18711,
"author_profile": "https://wordpress.stackexchange.com/users/18711",
"pm_score": 1,
"selected": false,
"text": "<p>JW player for wordpress is a good plugin for all your needs. Download it from <a href=\"http://wordpres... | 2012/09/02 | [
"https://wordpress.stackexchange.com/questions/63891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | I know how to create wp menus using the functions.php and diaplay it in my sote wherever the menu is required (e.g top menu, footer menu)
I even know how to style it using custom CSS.
I would like to know if it's possible to add HTML elements to a dynamic custom menu.
for example:
I want to build a menu when each **li... | JW player for wordpress is a good plugin for all your needs. Download it from [wordpress.org](http://wordpress.org/extend/plugins/jw-player-plugin-for-wordpress/) |
63,910 | <p>How can I allow a user to have the option of choosing the number of posts to display per page? I'd like to have it similar to how <a href="https://wordpress.stackexchange.com/questions">it's done on this site</a>: 15, 30, 50 per page (see the bottom of the page to the right of the pagination).</p>
| [
{
"answer_id": 65351,
"author": "Hignesh Hirani",
"author_id": 20161,
"author_profile": "https://wordpress.stackexchange.com/users/20161",
"pm_score": 0,
"selected": false,
"text": "<p>@simon</p>\n\n<p>One such hack is available check this out, <a href=\"http://wordpress.org/extend/plugi... | 2012/09/02 | [
"https://wordpress.stackexchange.com/questions/63910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19975/"
] | How can I allow a user to have the option of choosing the number of posts to display per page? I'd like to have it similar to how [it's done on this site](https://wordpress.stackexchange.com/questions): 15, 30, 50 per page (see the bottom of the page to the right of the pagination). | This is may not be the best solution, but it works. Following code needs to be added in functions.php.
```
add_filter('query_vars', 'parameter_queryvars' ); // Let WP accept the query argument we will use
function parameter_queryvars( $qvars )
{
$qvars[] = 'posts_per_page';
return $qvars;
}
add_action( 'pre_g... |
63,923 | <p>I'm building a simple widget which will allow the user to select a post among a list of posts.<br>
For some reason, when I select an option, I believe it actually gets selected but the option doesn't remain in the select field. </p>
<p>I think my error is at the following line but I don't manage to fix it. Maybe c... | [
{
"answer_id": 63952,
"author": "WPler",
"author_id": 16431,
"author_profile": "https://wordpress.stackexchange.com/users/16431",
"pm_score": 1,
"selected": false,
"text": "<p>Use get_the_ID() instead of the_ID(). the_ID() will echo'ed the ID of posting:</p>\n\n<pre><code><option valu... | 2012/09/02 | [
"https://wordpress.stackexchange.com/questions/63923",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7131/"
] | I'm building a simple widget which will allow the user to select a post among a list of posts.
For some reason, when I select an option, I believe it actually gets selected but the option doesn't remain in the select field.
I think my error is at the following line but I don't manage to fix it. Maybe calling the\_... | Use get\_the\_ID() instead of the\_ID(). the\_ID() will echo'ed the ID of posting:
```
<option value="<? the_ID(); ?>" <?php selected(get_the_ID(), $instance['post_to_display']); ?>><?php the_title(); ?></option>
``` |
63,925 | <p>An example file:
<a href="http://twentyeleven.korkmaz.biz/files/2012/09/example.docx" rel="nofollow">http://twentyeleven.korkmaz.biz/files/2012/09/example.docx</a></p>
<p>and here is same file but direct url without ms-files.php:
<a href="http://twentyeleven.korkmaz.biz/wp-content/blogs.dir/3/files/2012/09/example.... | [
{
"answer_id": 64754,
"author": "Bendoh",
"author_id": 8907,
"author_profile": "https://wordpress.stackexchange.com/users/8907",
"pm_score": 2,
"selected": false,
"text": "<p>The resulting file is identical regardless of the link that you use. I downloaded the file via each link and comp... | 2012/09/02 | [
"https://wordpress.stackexchange.com/questions/63925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1372/"
] | An example file:
<http://twentyeleven.korkmaz.biz/files/2012/09/example.docx>
and here is same file but direct url without ms-files.php:
<http://twentyeleven.korkmaz.biz/wp-content/blogs.dir/3/files/2012/09/example.docx>
Its same file. Just first one is getting call with ms-files.php. Problem is
first file is not wor... | Only fix for 3.4.2 involves hacking a core file. The issue is already corrected in the upcoming version 3.5.
Edit wp-includes/functions.php. Around line 1810, you'll find this:
```
'doc|docx' => 'application/msword',
```
Change that to this:
```
'doc' => 'application/msword',
```
The docx file extension is actua... |
63,953 | <p>I have a custom post type 'events', to which I have associated a custom taxonomy 'calendar'. The calendar has 12 fixed terms, for each month of the year ( 'august', 'october', 'november, etc.).</p>
<p>I'm in the process to make the archive page for the 'events' post type. I was thinking to display 12 different list... | [
{
"answer_id": 63967,
"author": "Jan Beck",
"author_id": 18760,
"author_profile": "https://wordpress.stackexchange.com/users/18760",
"pm_score": 1,
"selected": false,
"text": "<p>I can not come up with any reason why you wouldn't want to query the database 12 times if what you need is 12... | 2012/09/03 | [
"https://wordpress.stackexchange.com/questions/63953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8421/"
] | I have a custom post type 'events', to which I have associated a custom taxonomy 'calendar'. The calendar has 12 fixed terms, for each month of the year ( 'august', 'october', 'november, etc.).
I'm in the process to make the archive page for the 'events' post type. I was thinking to display 12 different lists of max 1... | Don't use `query_posts()`. Don't modify the main loop query from within the template.
You *may* be able to get a single query to provide what you need (e.g. by filtering `pre_get_posts` and `groupby`), but more than likely, you will need to iterate 12 custom loops using `WP_Query()`. Perhaps something like this:
```
... |
63,968 | <p>I am having a rather difficult time adding a script to the 3.4 Theme Customizer (i.e., customize.php). If I want, I can deregister jquery and add it from googleapi as follows:</p>
<pre><code>wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.mi... | [
{
"answer_id": 64094,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>Okay, I figured it out. Instead of \"init\" or \"wp_enqueue_scripts\", etc. I had to use \"customize_controls_prin... | 2012/09/03 | [
"https://wordpress.stackexchange.com/questions/63968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am having a rather difficult time adding a script to the 3.4 Theme Customizer (i.e., customize.php). If I want, I can deregister jquery and add it from googleapi as follows:
```
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js');
wp_enqu... | Okay, I figured it out. Instead of "init" or "wp\_enqueue\_scripts", etc. I had to use "customize\_controls\_print\_footer\_scripts" as such:
```
add_action( 'customize_controls_print_footer_scripts', 'bp_admin_scripts' );
```
If you want the script in the header then you use: "customize\_controls\_print\_scripts"
... |
63,980 | <p>We can <a href="https://wordpress.stackexchange.com/a/57702/10691">use the <code>post_gallery</code> filter</a> to modify/replace the default WordPress gallery template (AKA output code) to suit our needs. But this doesn't seem to affect the markup in RSS feeds.</p>
<p>No matter what I do, the markup for gallery im... | [
{
"answer_id": 64022,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 1,
"selected": false,
"text": "<p>Based on Otto's suggestions, I modified my function as such (see below), and it worked!</p>\n\n<pre><code>// Cu... | 2012/09/03 | [
"https://wordpress.stackexchange.com/questions/63980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | We can [use the `post_gallery` filter](https://wordpress.stackexchange.com/a/57702/10691) to modify/replace the default WordPress gallery template (AKA output code) to suit our needs. But this doesn't seem to affect the markup in RSS feeds.
No matter what I do, the markup for gallery images in my RSS feed is simply li... | Without knowing what your post\_gallery filter function does, there's no way to give a proper answer.
However, if you are using the post\_gallery filter, and returning new markup, then yes, it will be used in feeds too. The code you mention commenting out happens after the post\_gallery filter, and won't get executed ... |
64,050 | <p>I've recently heard someone say WordPress does send data about your blog to back home. Is that true? and if so what data is that or where in the code can I see what's exchanged?</p>
| [
{
"answer_id": 64052,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 4,
"selected": false,
"text": "<p>WordPress sends version data back to .org when using the .org API (installing/searching/updating) to my kno... | 2012/09/04 | [
"https://wordpress.stackexchange.com/questions/64050",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7898/"
] | I've recently heard someone say WordPress does send data about your blog to back home. Is that true? and if so what data is that or where in the code can I see what's exchanged? | Yes, it does. See [Ticket #16778 wordpress is leaking user/blog information during wp\_version\_check()](http://core.trac.wordpress.org/ticket/16778). All the details are in `/wp-includes/update.php`:
```
if ( is_multisite( ) ) {
$user_count = get_user_count( );
$num_blogs = get_blog_count( );
$wp_install ... |
64,058 | <p>Someone knows how to show 'all tags' insteads of the 'most used tags' in edit post of administration panel?
This should give the ability to select with a single click tags that are not yet used!</p>
<p>Here is a screenshot of what I mean: <a href="http://www.meliusabundare.com/show-all-tags.jpg" rel="nofollow">scre... | [
{
"answer_id": 64112,
"author": "binfalse",
"author_id": 20047,
"author_profile": "https://wordpress.stackexchange.com/users/20047",
"pm_score": -1,
"selected": false,
"text": "<p>Go to your WordPress installation and open <code>wp-admin/admin-ajax.php</code>. Search for a line that look... | 2012/09/04 | [
"https://wordpress.stackexchange.com/questions/64058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20032/"
] | Someone knows how to show 'all tags' insteads of the 'most used tags' in edit post of administration panel?
This should give the ability to select with a single click tags that are not yet used!
Here is a screenshot of what I mean: [screenshot](http://www.meliusabundare.com/show-all-tags.jpg)
Thank you very much.
Ok... | Never modify Wordpress core files!
Use your template's functions.php. You can check examples here:
<https://wordpress.stackexchange.com/a/198778/69451> |
64,095 | <p>I have this line …</p>
<pre><code><div class="permalink"><?php the_permalink(); ?></div>
</code></pre>
<p>and the result on my page looks like this …</p>
<pre><code>http://mysite.com/whatever/post-or-so
</code></pre>
<p>I guess it could also look like this …</p>
<pre><code>http://www.mysite.co... | [
{
"answer_id": 64097,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>use <a href=\"https://codex.wordpress.org/Function_Reference/get_permalink\" rel=\"nofollow\"><code>get_permalink</c... | 2012/09/04 | [
"https://wordpress.stackexchange.com/questions/64095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I have this line …
```
<div class="permalink"><?php the_permalink(); ?></div>
```
and the result on my page looks like this …
```
http://mysite.com/whatever/post-or-so
```
I guess it could also look like this …
```
http://www.mysite.com/whatever/post-or-so
```
However I'd like to have just `mysite.com/whatever... | use [`get_permalink`](https://codex.wordpress.org/Function_Reference/get_permalink) instead of `the_permalink` and manipulate it however you'd like via php. |
64,098 | <p>I want to get the users of role academic and student. I have tried using the code below (passing an array of roles, but all users are being displayed, so clearly it's not working.</p>
<pre><code>$roles=array('academic','student');
$args =array('role'=>$roles);
$users=get_users( $args );
foreach ($users as $use... | [
{
"answer_id": 64108,
"author": "Tomas Buteler",
"author_id": 5552,
"author_profile": "https://wordpress.stackexchange.com/users/5552",
"pm_score": 3,
"selected": true,
"text": "<p>I don't think it's possible to do it with the get_users function. From what the <a href=\"http://codex.word... | 2012/09/04 | [
"https://wordpress.stackexchange.com/questions/64098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14739/"
] | I want to get the users of role academic and student. I have tried using the code below (passing an array of roles, but all users are being displayed, so clearly it's not working.
```
$roles=array('academic','student');
$args =array('role'=>$roles);
$users=get_users( $args );
foreach ($users as $user) {
echo '<li... | I don't think it's possible to do it with the get\_users function. From what the [Codex](http://codex.wordpress.org/Function_Reference/get_users) implies, you cannot pass arrays to the role argument. But it should be fairly easy to code your way out of that limitation.
Try this:
```
function filter_two_roles($user) {... |
64,115 | <p>essentially I need to be able to add a class to a post when it show in the list (say index.php) so when in the back end you can say oneCol, twoCol, threeCol and it will then output this within the loop post class.</p>
<p>This is to enable a tighter control of the layout. using this line of code for the output?</p>
... | [
{
"answer_id": 64117,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/post_class#Add_Classes_By_Filters\" rel=\"nofollow\... | 2012/09/04 | [
"https://wordpress.stackexchange.com/questions/64115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16532/"
] | essentially I need to be able to add a class to a post when it show in the list (say index.php) so when in the back end you can say oneCol, twoCol, threeCol and it will then output this within the loop post class.
This is to enable a tighter control of the layout. using this line of code for the output?
```
<div id="... | >
> ### Note -
>
>
> I recommend using the hook suggested by *@Chip Bennett* in another answer
>
>
> **Here's the modified version of that filter -**
>
>
>
> ```
> function wpse_filter_post_class( $classes ) {
> $my_post_class = get_post_meta($post->ID, "your_meta_name");
>
> if( $my_post_class != '' ... |
64,121 | <p>I am trying to change placement of Price from top to beside the Add to Cart button and want to wrap Price and Add to cart button (form) both with one div.</p>
<p>I dont know either it is bad way or correct way but somehow I managed to change placement but now getting trouble to wrap both with </p>
<p>Here what I a... | [
{
"answer_id": 64126,
"author": "pixelngrain",
"author_id": 9821,
"author_profile": "https://wordpress.stackexchange.com/users/9821",
"pm_score": 2,
"selected": false,
"text": "<p>Okay I solved this but don't know it is right way or wrong way. Hope you expert will give some better guidel... | 2012/09/04 | [
"https://wordpress.stackexchange.com/questions/64121",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9821/"
] | I am trying to change placement of Price from top to beside the Add to Cart button and want to wrap Price and Add to cart button (form) both with one div.
I dont know either it is bad way or correct way but somehow I managed to change placement but now getting trouble to wrap both with
Here what I am doing
```
//fi... | Okay I solved this but don't know it is right way or wrong way. Hope you expert will give some better guideline.
What I did just added two function into my add\_action function and use those as a wrapper.
```
// adding and re arranging placement
function q2a_product_summary() {
function wrapstart () {
e... |
64,165 | <p>So I am making a news website about the future, 2112 to be specific (hello, critics). I wanted to display a post's date to be from 2112. But when I try to do this from the admin panel, it 'schedules' the post. I really want to publish the post in this century. Any help, people?</p>
| [
{
"answer_id": 64168,
"author": "Ipstenu",
"author_id": 7886,
"author_profile": "https://wordpress.stackexchange.com/users/7886",
"pm_score": 2,
"selected": false,
"text": "<p>What about making a taxonomy for 'future year' and then assign it as 2112 in your posts?</p>\n\n<p>You could go ... | 2012/09/04 | [
"https://wordpress.stackexchange.com/questions/64165",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14578/"
] | So I am making a news website about the future, 2112 to be specific (hello, critics). I wanted to display a post's date to be from 2112. But when I try to do this from the admin panel, it 'schedules' the post. I really want to publish the post in this century. Any help, people? | I had the same issue as you when I was dealing with events and wanted to show future events.
Here is what I coded:
```
add_action( 'init', 'change_future_posts_to_post_now' );
function change_future_posts_to_post_now() {
remove_action("future_post", '_future_post_hook');
add_action("future_post", 'publish_fut... |
64,191 | <p>I have a custom post type (dibujos) and 4 custom taxonomy. </p>
<p>I would like to get term name in a current post. </p>
<p>The probleme is, how to To display the name of the taxonomy, no matter what taxonomy is.</p>
<p>The code is:</p>
<pre><code><?php // Get terms for post
$terms = get_the_terms( $post-&... | [
{
"answer_id": 64209,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <code>wp_get_object_terms($object_ids, $taxonomies, $args)</code> to get all terms from a defined set of t... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19405/"
] | I have a custom post type (dibujos) and 4 custom taxonomy.
I would like to get term name in a current post.
The probleme is, how to To display the name of the taxonomy, no matter what taxonomy is.
The code is:
```
<?php // Get terms for post
$terms = get_the_terms( $post->ID , 'my-taxonomy' );
// Loop over ea... | You can use `wp_get_object_terms($object_ids, $taxonomies, $args)` to get all terms from a defined set of taxonomies for an object
The `$taxonomies` parameter can be an array of taxonomy names.
<http://codex.wordpress.org/Function_Reference/wp_get_object_terms> |
64,196 | <p>Can anyone help?</p>
<p>I've been building a wordpress site in a sub directory of an umbrella 'development domain' if you will, and am ready to go live with the site.</p>
<p>It's a single install of wordpress.</p>
<p>The wordpress file location is to remain exactly as it is, and we're just repointing the DNS of t... | [
{
"answer_id": 64197,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": false,
"text": "<p>This question has been asked many many times before. </p>\n\n<p>Here's the Codex: <a href=\"http://codex.wordpress.org... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64196",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13998/"
] | Can anyone help?
I've been building a wordpress site in a sub directory of an umbrella 'development domain' if you will, and am ready to go live with the site.
It's a single install of wordpress.
The wordpress file location is to remain exactly as it is, and we're just repointing the DNS of the live domain to the su... | This question has been asked many many times before.
Here's the Codex: <http://codex.wordpress.org/Changing_The_Site_URL>
The easiest thing to do is add a couple of lines to your wp-config.php
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
``` |
64,205 | <p>I have a function that I only want to run via a cron job. Is there a way I can check that a particular scheduled event is calling this function and not anything else? </p>
| [
{
"answer_id": 64481,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>Just take a look at the <a href=\"https://gist.github.com/987128\" rel=\"nofollow noreferrer\">»Cron API inspector«... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I have a function that I only want to run via a cron job. Is there a way I can check that a particular scheduled event is calling this function and not anything else? | WordPress has a constant `DOING_CRON` that helps us know we're doing the cron jobs or not. It's defined in `wp-cron.php` file.
So, you can check this constant in your code:
```
if ( defined( 'DOING_CRON' ) )
{
// Do something
}
``` |
64,210 | <p>How would I include a post from a specific category on my homepage in buddypress?</p>
<p>Example I have a category 'Homepage Banners' with an ID of 3.</p>
<p>In the admin I create a post and assign the 'Homepage Banners' category to it.</p>
<p>I then need this to show up on the homepage (the latest post).</p>
<p... | [
{
"answer_id": 64212,
"author": "Simon Forster",
"author_id": 17208,
"author_profile": "https://wordpress.stackexchange.com/users/17208",
"pm_score": 0,
"selected": false,
"text": "<p>You could use the inline posts plugin <a href=\"http://aralbalkan.com/wordpress\" rel=\"nofollow\">http:... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64210",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19835/"
] | How would I include a post from a specific category on my homepage in buddypress?
Example I have a category 'Homepage Banners' with an ID of 3.
In the admin I create a post and assign the 'Homepage Banners' category to it.
I then need this to show up on the homepage (the latest post).
I am new to WP/BP, any help ap... | You can also use a new query (with php enabled) so show a single post by ID, i.e. the post with ID 101:
```
<?php $my_query = new WP_Query('p=101'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title(); ?><?php the_cont... |
64,219 | <p>I have two installations of Wordpress in Network mode.</p>
<p>In one network, when I change a theme of any one of my network websites, one particular network website has it's theme changed to the same theme I set the first one to.</p>
<p>In the other network, a similar thing occurs, in that a particular theme has ... | [
{
"answer_id": 65204,
"author": "Lalit Kaushik",
"author_id": 20389,
"author_profile": "https://wordpress.stackexchange.com/users/20389",
"pm_score": 1,
"selected": false,
"text": "<p>Perhaps theme or plugin which are you using that one or more of them support old version wordpress, so y... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I have two installations of Wordpress in Network mode.
In one network, when I change a theme of any one of my network websites, one particular network website has it's theme changed to the same theme I set the first one to.
In the other network, a similar thing occurs, in that a particular theme has become stuck, and... | Fixing the base
---------------
I'm pretty sure that you've actually checked the base yourself and I don't have to ask …
>
> [»Have you tried turning it off and on again?«](http://www.youtube.com/watch?v=t2F1rFmyQmY)
>
>
>
Anyway, you need to run through the following chart again, just to be sure:
![http://i.im... |
64,231 | <p>I have to load a couple of ads, some normal html and two are java script. I've tried the PHP method of this:</p>
<pre><code><?php $postnum++; if($postnum%10 == 0) { ?>
<div id="topset">
<ul id="top_ad_list">
<?php dynamic_sidebar('botad'); ?>
</ul>
</div>
<?php } ... | [
{
"answer_id": 64237,
"author": "Simon Forster",
"author_id": 17208,
"author_profile": "https://wordpress.stackexchange.com/users/17208",
"pm_score": 0,
"selected": false,
"text": "<p>The solution to your problem is to add functionality using the <code>onLoadItems</code> event, whereby y... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16946/"
] | I have to load a couple of ads, some normal html and two are java script. I've tried the PHP method of this:
```
<?php $postnum++; if($postnum%10 == 0) { ?>
<div id="topset">
<ul id="top_ad_list">
<?php dynamic_sidebar('botad'); ?>
</ul>
</div>
<?php } ?>
```
What occurs is for the first pagination from... | See this: <http://infiniteajaxscroll.com/docs/events.html#rendered>
So, place all the ad code in an ajax function (<http://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_%28action%29>)
```
add_action( 'wp_ajax_your_ad_fn', 'your_ad_fn');
add_action( 'wp_ajax_nopriv_your_ad_fn', 'your_ad_fn');
function your_... |
64,243 | <p>I've been trying to set up the comments section of a site I am working on to use the default Wordpress WYSIWYG (TinyMCE). But it's harder than expected.</p>
<p>I used this <a href="http://www.revood.com/blog/tag/tinymce-wordpress-comments-box/" rel="noreferrer">tutorial</a> to take me almost all the way there. The ... | [
{
"answer_id": 64325,
"author": "developdaly",
"author_id": 3293,
"author_profile": "https://wordpress.stackexchange.com/users/3293",
"pm_score": 3,
"selected": false,
"text": "<p>Give this a shot:</p>\n\n<pre><code><?php\n/* Add WYSISYG editor to comment form. */\nadd_filter( 'commen... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10175/"
] | I've been trying to set up the comments section of a site I am working on to use the default Wordpress WYSIWYG (TinyMCE). But it's harder than expected.
I used this [tutorial](http://www.revood.com/blog/tag/tinymce-wordpress-comments-box/) to take me almost all the way there. The tutorial makes it so I can use the WYS... | Give this a shot:
```
<?php
/* Add WYSISYG editor to comment form. */
add_filter( 'comment_form_field_comment', 'wpse_64243_comment_editor' );
function wpse_64243_comment_editor( $field ) {
if (!is_single()) return $field; //only on single post pages.
global $post;
ob_start();
wp_editor( '', 'comme... |
64,268 | <p>Is there a way to have always the <code>the_title()</code> tag also includes a custom field called subtitle?</p>
<p>I want to have a title like this: "<em>subtitle-custom-field: Post Title</em>". For example, "<em>Cool: The new TV show from Werner Herzog</em>."</p>
<p>In this case, <em>cool</em> would be the custo... | [
{
"answer_id": 64269,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 3,
"selected": true,
"text": "<pre><code><?php\nfunction add_subtitle($title, $id) {\n $subtitle = get_post_meta($id, 'myCustomField... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17376/"
] | Is there a way to have always the `the_title()` tag also includes a custom field called subtitle?
I want to have a title like this: "*subtitle-custom-field: Post Title*". For example, "*Cool: The new TV show from Werner Herzog*."
In this case, *cool* would be the custom field value, and *the new TV...* would be `the_... | ```
<?php
function add_subtitle($title, $id) {
$subtitle = get_post_meta($id, 'myCustomField', true);
$new_title = $title;
if(!empty($subtitle))
$new_title = $subtitle . ': ' . $new_title;
return $new_title;
}
add_filter('the_title', 'add_subtitle', 10, 2);
```
Basically, this uses the `the_ti... |
64,275 | <p>I just want to get the most latest posts by an author. I am using get_posts at the moment but I notice it doesn't take an author argument, so how I can I specify my author?</p>
<pre><code>$args = array( 'numberposts' => '1');
$posts=get_posts( $args );
foreach($posts as $post)
{
s... | [
{
"answer_id": 64269,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 3,
"selected": true,
"text": "<pre><code><?php\nfunction add_subtitle($title, $id) {\n $subtitle = get_post_meta($id, 'myCustomField... | 2012/09/05 | [
"https://wordpress.stackexchange.com/questions/64275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14739/"
] | I just want to get the most latest posts by an author. I am using get\_posts at the moment but I notice it doesn't take an author argument, so how I can I specify my author?
```
$args = array( 'numberposts' => '1');
$posts=get_posts( $args );
foreach($posts as $post)
{
setup_postdata($po... | ```
<?php
function add_subtitle($title, $id) {
$subtitle = get_post_meta($id, 'myCustomField', true);
$new_title = $title;
if(!empty($subtitle))
$new_title = $subtitle . ': ' . $new_title;
return $new_title;
}
add_filter('the_title', 'add_subtitle', 10, 2);
```
Basically, this uses the `the_ti... |