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 |
|---|---|---|---|---|---|---|
112,155 | <p>I'm using a child theme created from a twenty-twelve theme, the theme packs a number of sidebars one which is called "Main Sidebar".</p>
<p>Is it possible to change it's name to something else?</p>
| [
{
"answer_id": 112160,
"author": "ahmetlutfu",
"author_id": 25086,
"author_profile": "https://wordpress.stackexchange.com/users/25086",
"pm_score": 0,
"selected": false,
"text": "<p>Look <strong>functions.php</strong> file of twenty-twelve theme.</p>\n\n<p>there is <strong>twentytwelve_w... | 2013/08/29 | [
"https://wordpress.stackexchange.com/questions/112155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2488/"
] | I'm using a child theme created from a twenty-twelve theme, the theme packs a number of sidebars one which is called "Main Sidebar".
Is it possible to change it's name to something else? | Hook into `register_sidebar` and change the name after the sidebar was registered.
Example:
```
add_action( 'register_sidebar', function( $sidebar )
{
global $wp_registered_sidebars;
if ( 'Main Sidebar' !== $sidebar[ 'name' ] )
return;
$id = $sidebar[ 'id' ];
$sidebar[ 'name' ] = 'Master';
... |
112,223 | <p>I'm developing a small online-courses website for a friend and got stuck with ACF repeater field!</p>
<p>Here's my code to display the course dates table:</p>
<pre><code><?php
$rows = get_field('dates');
$i = 1;
if($rows) { ?>
<table class="specs">
<thead>
<tr>
... | [
{
"answer_id": 112183,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<ol>\n<li>You can write your own function to do the matching at the SQL level</li>\n<li>Grab all of the keys and... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112223",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19398/"
] | I'm developing a small online-courses website for a friend and got stuck with ACF repeater field!
Here's my code to display the course dates table:
```
<?php
$rows = get_field('dates');
$i = 1;
if($rows) { ?>
<table class="specs">
<thead>
<tr>
<th colspan="5">Course Dates</th... | 1. You can write your own function to do the matching at the SQL level
2. Grab all of the keys and process them in PHP. You shouldn't need regex. Simple string functions should do it.
3. Don't bother processing the results at all and instead just use the
keys you need and ignore the rest-- something like `echo $meta['k... |
112,226 | <p>I want to upload images in a unique folder. Then retrieve the path of this image saved on server like</p>
<pre><code>http://example.com/wp-content/uploads/myimages/image1.jpg
</code></pre>
<p>Now I want to save this URL in a post having custom field as url.</p>
<p>I'll be overwriting the posts on regular basis as... | [
{
"answer_id": 112239,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Notice:</strong> Haven't tested my idea or code provided below. </p>\n\n<p>*media_sideload_image*... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37018/"
] | I want to upload images in a unique folder. Then retrieve the path of this image saved on server like
```
http://example.com/wp-content/uploads/myimages/image1.jpg
```
Now I want to save this URL in a post having custom field as url.
I'll be overwriting the posts on regular basis as well as replacing corresponding ... | Here is simple function to create your own sub directory for every upload.
```
function kv_custom_image_dir( $pathdata ) {
$subdir = '/uploads_img'.$pathdata['subdir'];
$pathdata['path'] = str_replace($pathdata['subdir'], $subdir, $pathdata['path']);
$pathdata['url'] = str_replace($pathdata['subdir'], $sub... |
112,229 | <p>I have a problem with AJAX returning 0 always!</p>
<p>I have done everything by the book and can't figure out what is wrong? Please help!!</p>
<p>Here is my Ajax call:</p>
<pre><code>//Pass data through AJAX
var amountToConvert = price;
jQuery.ajax({
type:"POST",
url: "../../wp-admin/admin-ajax.php",... | [
{
"answer_id": 112230,
"author": "Jayawi Perera",
"author_id": 36654,
"author_profile": "https://wordpress.stackexchange.com/users/36654",
"pm_score": 5,
"selected": true,
"text": "<p>Could you place the action (ajaxConversion) in your Data and check?</p>\n\n<pre><code>jQuery.ajax({\n t... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112229",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37189/"
] | I have a problem with AJAX returning 0 always!
I have done everything by the book and can't figure out what is wrong? Please help!!
Here is my Ajax call:
```
//Pass data through AJAX
var amountToConvert = price;
jQuery.ajax({
type:"POST",
url: "../../wp-admin/admin-ajax.php", // our PHP handler file
... | Could you place the action (ajaxConversion) in your Data and check?
```
jQuery.ajax({
type:"POST",
url: ajaxurl,
data: {
action: "ajaxConversion",
amount: amountToConvert
},
success:function(data){
alert(data);
},
error: function(errorThrown){
alert(errorThrown);
}
});
``` |
112,246 | <p>I have registerd a post type called <strong>Books</strong> in function.php and this post type will display only for editor role. Now when i am login with my dummy editor i am seeing two post type one is Books and second Profile. I want to change default selected Books post type not profile.</p>
<p>What i want:
<a h... | [
{
"answer_id": 112230,
"author": "Jayawi Perera",
"author_id": 36654,
"author_profile": "https://wordpress.stackexchange.com/users/36654",
"pm_score": 5,
"selected": true,
"text": "<p>Could you place the action (ajaxConversion) in your Data and check?</p>\n\n<pre><code>jQuery.ajax({\n t... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112246",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26201/"
] | I have registerd a post type called **Books** in function.php and this post type will display only for editor role. Now when i am login with my dummy editor i am seeing two post type one is Books and second Profile. I want to change default selected Books post type not profile.
What i want:
[My backed view](http://pos... | Could you place the action (ajaxConversion) in your Data and check?
```
jQuery.ajax({
type:"POST",
url: ajaxurl,
data: {
action: "ajaxConversion",
amount: amountToConvert
},
success:function(data){
alert(data);
},
error: function(errorThrown){
alert(errorThrown);
}
});
``` |
112,253 | <p>I'm trying to get_results() in my widget's front end, this is my current code:</p>
<pre><code>public function widget( $args, $instance ) {
echo $args['before_widget'];
if($children = $wpdb->get_results( "SELECT ID FROM $wpdb->posts" ))
echo "working";
echo $args['after_widget'];
}
</c... | [
{
"answer_id": 112230,
"author": "Jayawi Perera",
"author_id": 36654,
"author_profile": "https://wordpress.stackexchange.com/users/36654",
"pm_score": 5,
"selected": true,
"text": "<p>Could you place the action (ajaxConversion) in your Data and check?</p>\n\n<pre><code>jQuery.ajax({\n t... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112253",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2488/"
] | I'm trying to get\_results() in my widget's front end, this is my current code:
```
public function widget( $args, $instance ) {
echo $args['before_widget'];
if($children = $wpdb->get_results( "SELECT ID FROM $wpdb->posts" ))
echo "working";
echo $args['after_widget'];
}
```
However I'm gett... | Could you place the action (ajaxConversion) in your Data and check?
```
jQuery.ajax({
type:"POST",
url: ajaxurl,
data: {
action: "ajaxConversion",
amount: amountToConvert
},
success:function(data){
alert(data);
},
error: function(errorThrown){
alert(errorThrown);
}
});
``` |
112,258 | <p>WP frontend output of custom textarea fields not respecting line breakes. In admin it's OK.</p>
<p>Right now I am using this:</p>
<pre><code><?php $options = get_option('my_custom_plugin_options'); ?>
<?php echo $options['my_custom_plugin_options_textarea']; ?>
</code></pre>
<p>The output in frontend ... | [
{
"answer_id": 112259,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 4,
"selected": true,
"text": "<p>Explode your $options value by \"/n\" ( new line ), then do a echo in foreach:</p>\n\n<pre><code>$options = ... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | WP frontend output of custom textarea fields not respecting line breakes. In admin it's OK.
Right now I am using this:
```
<?php $options = get_option('my_custom_plugin_options'); ?>
<?php echo $options['my_custom_plugin_options_textarea']; ?>
```
The output in frontend is this:
>
> Lorem ipsum dolor sit amet, co... | Explode your $options value by "/n" ( new line ), then do a echo in foreach:
```
$options = get_option('my_custom_plugin_options');
$textarea = $options['my_custom_plugin_options_textarea'];
$lines = explode("\n", $textarea);
foreach( $lines as $line ){
echo $line;
}
```
**UPDATE #1**
For reference, it's possibl... |
112,282 | <p>I can't get the loop to work as it's supposed to, without using the not-so-recommended:</p>
<pre><code><?php query_posts('post_type=post&post_status=publish&paged='. get_query_var('paged')); ?>
</code></pre>
<p>I'm using a custom page template named "template-blog.php" with this content: <a href="htt... | [
{
"answer_id": 112259,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 4,
"selected": true,
"text": "<p>Explode your $options value by \"/n\" ( new line ), then do a echo in foreach:</p>\n\n<pre><code>$options = ... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112282",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37247/"
] | I can't get the loop to work as it's supposed to, without using the not-so-recommended:
```
<?php query_posts('post_type=post&post_status=publish&paged='. get_query_var('paged')); ?>
```
I'm using a custom page template named "template-blog.php" with this content: <http://pastebin.com/raw.php?i=9W3akEcX>
And here's... | Explode your $options value by "/n" ( new line ), then do a echo in foreach:
```
$options = get_option('my_custom_plugin_options');
$textarea = $options['my_custom_plugin_options_textarea'];
$lines = explode("\n", $textarea);
foreach( $lines as $line ){
echo $line;
}
```
**UPDATE #1**
For reference, it's possibl... |
112,286 | <p>It is possible that I'm doing something wrong. Currently I'm using <code>index.php</code> as the main blog page. I have a page setup for the Blog and set it up in my Settings. When I try to get the Blog Page ID though it always shows the first posts ID instead. I'm not running any additional queries anywhere besides... | [
{
"answer_id": 112303,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 3,
"selected": true,
"text": "<p>the 'posts page' ID when using a static front page and a different posts page is:</p>\n\n<pre><code>get_option( ... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | It is possible that I'm doing something wrong. Currently I'm using `index.php` as the main blog page. I have a page setup for the Blog and set it up in my Settings. When I try to get the Blog Page ID though it always shows the first posts ID instead. I'm not running any additional queries anywhere besides the normal Lo... | the 'posts page' ID when using a static front page and a different posts page is:
```
get_option( 'page_for_posts' )
```
in some context:
```
if( is_home() && get_option( 'page_for_posts' ) ) {
$page_ID = get_option( 'page_for_posts' );
}
``` |
112,289 | <p>I'm currently using this loop: </p>
<pre><code>if (is_single() || is_page() ) :
if (have_posts() ) :
while (have_posts() ) :
the_post();
</code></pre>
<p>How can I exclude multiple pages within the loop?<br/>
For an example, I want to exclude pages <code>example.com/music</code> and <code>example.com/con... | [
{
"answer_id": 112292,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/is_page\" rel=\"nofollow\"><code>is_page()</code></a... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37369/"
] | I'm currently using this loop:
```
if (is_single() || is_page() ) :
if (have_posts() ) :
while (have_posts() ) :
the_post();
```
How can I exclude multiple pages within the loop?
For an example, I want to exclude pages `example.com/music` and `example.com/contact`.
EDIT:
I've done the way G.M provide... | An alternative way is putting the unwanted pages in an array. Useful for storing them in a option or in a serialized custom field.
```
$exclude_pages = array('music', 'contact');
// can be something like this: $exclude_pages = get_option('exclude_pages');
if ( have_posts() ) : while ( have_posts() ) : the_post();
i... |
112,294 | <p>Is there a hook in WordPress that I can use to filter the output of a specific shortcode? Something like this:</p>
<pre><code>add_filter('shortcode_output', 'my_filter_function', 2);
function my_filter_function ( $output, $shortcode ) {
....
}
</code></pre>
<p>Where <code>$shortcode</code> would be something ... | [
{
"answer_id": 112298,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/shortcodes.php\" rel=\"nofollow\">There... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12495/"
] | Is there a hook in WordPress that I can use to filter the output of a specific shortcode? Something like this:
```
add_filter('shortcode_output', 'my_filter_function', 2);
function my_filter_function ( $output, $shortcode ) {
....
}
```
Where `$shortcode` would be something like `[my_schortcode]` or even better... | [There is no filter](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/shortcodes.php) that I know of that is meant to target individual shortcodes like you want.
You can filter attributes with [`shortcode_atts_{$shortcode}`](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/shortcodes.php#L332) t... |
112,312 | <p>One of my clients is on a rather large blog in terms of number of posts and traffic. I'm trying to get her database down to a manageable size, and one thing that's bulking up is literally tens of thousands of post revisions.</p>
<p>I've already set Wordpress config to limit the number of revisions in the future to ... | [
{
"answer_id": 112322,
"author": "Tara",
"author_id": 5021,
"author_profile": "https://wordpress.stackexchange.com/users/5021",
"pm_score": 2,
"selected": false,
"text": "<p>Run SQL query:</p>\n\n<pre><code>DELETE FROM wp_posts WHERE post_type = \"revision\" // for \"wptest\" DB, note th... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37377/"
] | One of my clients is on a rather large blog in terms of number of posts and traffic. I'm trying to get her database down to a manageable size, and one thing that's bulking up is literally tens of thousands of post revisions.
I've already set Wordpress config to limit the number of revisions in the future to two:
```
... | >
> Is it safe to directly delete all rows in the wp\_posts table that have
> a post\_type of revision? (I've seen conflicting answers on this—but
> I'd love to be able to just do it this way if it's safe)
>
>
>
Safe, it's *safe*.
If there is only one user (you) that can edit posts on the site it's safe and doe... |
112,324 | <p>Before the update to WP 3.6 I could add this code in the header.php of the theme, which made it possible to have another menu when logged in:</p>
<pre><code> <?php
if( is_user_logged_in() ) {
$menu = 'logged-in';
} else {
$menu = 'logged-out';
}
wp_... | [
{
"answer_id": 112327,
"author": "ferne97",
"author_id": 24814,
"author_profile": "https://wordpress.stackexchange.com/users/24814",
"pm_score": 1,
"selected": false,
"text": "<p>Try changing the theme location as well. How are you registering the menus? You could try this..</p>\n\n<p>fu... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36207/"
] | Before the update to WP 3.6 I could add this code in the header.php of the theme, which made it possible to have another menu when logged in:
```
<?php
if( is_user_logged_in() ) {
$menu = 'logged-in';
} else {
$menu = 'logged-out';
}
wp_nav_menu( array(
... | >
> Actually, all I need is to change one specific button in the menu, so
> it is different when the user is logged in - in that case that menu
> button will be a "Member profile" button instead of a "Log in" button
>
>
>
Yes, you can use only one menu, assuming its slug is 'my\_menu' do not add to it member pro... |
112,333 | <p>I've been looking for this all day and can't find it.</p>
<p>I'm working on a custom contacts page and I am using the custom post type feature so that I can have more control over it. I'm looking to change the edit page to be a custom template, (example when I go to <code>/wp-admin/post.php?post=1234&action=edi... | [
{
"answer_id": 112345,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 3,
"selected": false,
"text": "<p>As far as I know you can remove almost everything except the title <code>h2</code> tag, and the <code>.postbox-co... | 2013/08/30 | [
"https://wordpress.stackexchange.com/questions/112333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12920/"
] | I've been looking for this all day and can't find it.
I'm working on a custom contacts page and I am using the custom post type feature so that I can have more control over it. I'm looking to change the edit page to be a custom template, (example when I go to `/wp-admin/post.php?post=1234&action=edit`), I want it to s... | As far as I know you can remove almost everything except the title `h2` tag, and the `.postbox-container` border. Also note that the `#message` is not visible by default but can pop up depending on what you do.
When you register your CPT set `supports` to an empty array.
```
'supports' => array ('')
```
Then you ca... |
112,352 | <p>I am in the process of converting a mobile responsive page, currently built in Bootstrap into WordPress.</p>
<p>Using <code>wp_register_style()</code> and <code>wp_enqueue_style()</code> will add the stylesheets to all pages, including the wp-admin. I know I could get around that by using an <code>if ( ! is_admin()... | [
{
"answer_id": 112356,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 3,
"selected": false,
"text": "<p>You should always use <code>wp_enqueue_style()</code> and <code>wp_enqueue_script()</code> where possible, unles... | 2013/08/31 | [
"https://wordpress.stackexchange.com/questions/112352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30778/"
] | I am in the process of converting a mobile responsive page, currently built in Bootstrap into WordPress.
Using `wp_register_style()` and `wp_enqueue_style()` will add the stylesheets to all pages, including the wp-admin. I know I could get around that by using an `if ( ! is_admin() )` conditional statement.
Is it bet... | To load scrpits only in front-end pages use:
```
add_action( 'wp_enqueue_scripts', 'my_front_end_scripts' );
function my_front_end_scripts(){
wp_enqueue_script('script_handle');
wp_enqueue_style('style_handle');
}
```
To load scripts only in login use:
```
add_action( 'login_enqueue_scripts', 'my_logi... |
112,361 | <p>I want to modify search.php so that it only shows posts and not pages. Can you help?</p>
<p>Here is the loop in search.php:</p>
<pre><code><?php if (have_posts()) : ?>
<?php while(have_posts()): the_post(); ?>
</code></pre>
| [
{
"answer_id": 112364,
"author": "user2506619",
"author_id": 34354,
"author_profile": "https://wordpress.stackexchange.com/users/34354",
"pm_score": 0,
"selected": false,
"text": "<p>replace your loop with this and let me know if this work.</p>\n\n<pre><code><?php if ( have_posts() ) ... | 2013/08/31 | [
"https://wordpress.stackexchange.com/questions/112361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36052/"
] | I want to modify search.php so that it only shows posts and not pages. Can you help?
Here is the loop in search.php:
```
<?php if (have_posts()) : ?>
<?php while(have_posts()): the_post(); ?>
``` | The search template is way too late to change anything: The pages are searched already here, and your page numbers would be wrong. Do not alter the output, alter the query.
Filter `posts_search` instead, and if there is a search term, filter `posts_where_paged` and remove the post type you don’t want to be searched.
... |
112,366 | <p>I want to remove a widget area (lateral), and extend the page width getting this area. What is the better way to do it?</p>
| [
{
"answer_id": 112367,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Hook into <code>register_sidebar</code> and remove the sidebar from the global array <code>$wp_registered_sidebars</c... | 2013/08/31 | [
"https://wordpress.stackexchange.com/questions/112366",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36778/"
] | I want to remove a widget area (lateral), and extend the page width getting this area. What is the better way to do it? | I've found an easy way:
Simply change your stile.css file.
Replace this code snippet:
```
/**
* 5.0 Content
* ----------------------------------------------------------------------------
*/
.hentry {
padding: 40px 0;
}
.entry-header,
.entry-content,
.entry-summary,
.entry-meta {
margin: 0 auto;
max-width: 60... |
112,368 | <p>I'm pretty sure that it's not possible but can I get the result of <code>wp_title()</code> into a variable if I know post's ID?</p>
<p>So, for instance I'm on a "blog" page and I want to have the title of "about" page in a variable (not in the <code><title></code> tag like in this questions: <a href="https://... | [
{
"answer_id": 112369,
"author": "Anatol Bivol",
"author_id": 34944,
"author_profile": "https://wordpress.stackexchange.com/users/34944",
"pm_score": 0,
"selected": false,
"text": "<p>wp_title() function has a second parameter 'display' . Set it to false to get the title in a variable : ... | 2013/08/31 | [
"https://wordpress.stackexchange.com/questions/112368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | I'm pretty sure that it's not possible but can I get the result of `wp_title()` into a variable if I know post's ID?
So, for instance I'm on a "blog" page and I want to have the title of "about" page in a variable (not in the `<title>` tag like in this questions: [Setting title using wp\_title filter](https://wordpres... | As you said, `wp_title` works only for current post, so can be a little tricky save it in a variable for a post that is not the current.
However, `wp_title` works not only for singular post / page / cpt but also for every type of archive. So it's easy create a custom function that copy the part of the core function th... |
112,380 | <p>I am trying to insert two 125x125 ads into the comment section of a Genesis Child Theme - </p>
<p><img src="https://i.stack.imgur.com/ASQbz.png" alt="Where I would love 2 ads"></p>
<p>The screen above shows where I would want it but I am at a total loss on where to insert this overall. I have search for a code sni... | [
{
"answer_id": 112369,
"author": "Anatol Bivol",
"author_id": 34944,
"author_profile": "https://wordpress.stackexchange.com/users/34944",
"pm_score": 0,
"selected": false,
"text": "<p>wp_title() function has a second parameter 'display' . Set it to false to get the title in a variable : ... | 2013/08/31 | [
"https://wordpress.stackexchange.com/questions/112380",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1623/"
] | I am trying to insert two 125x125 ads into the comment section of a Genesis Child Theme -

The screen above shows where I would want it but I am at a total loss on where to insert this overall. I have search for a code snippet for functions.php or even ... | As you said, `wp_title` works only for current post, so can be a little tricky save it in a variable for a post that is not the current.
However, `wp_title` works not only for singular post / page / cpt but also for every type of archive. So it's easy create a custom function that copy the part of the core function th... |
112,405 | <p>I need some help. My wife teaches french, and I would like to set up website for her. The problem is I don't know so much about wordpress and googling did not help as well.</p>
<p>I know how to make simple wordpress site, but how do I make something like intranet. I mean that every one of her students would have th... | [
{
"answer_id": 112369,
"author": "Anatol Bivol",
"author_id": 34944,
"author_profile": "https://wordpress.stackexchange.com/users/34944",
"pm_score": 0,
"selected": false,
"text": "<p>wp_title() function has a second parameter 'display' . Set it to false to get the title in a variable : ... | 2013/08/31 | [
"https://wordpress.stackexchange.com/questions/112405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37406/"
] | I need some help. My wife teaches french, and I would like to set up website for her. The problem is I don't know so much about wordpress and googling did not help as well.
I know how to make simple wordpress site, but how do I make something like intranet. I mean that every one of her students would have there own si... | As you said, `wp_title` works only for current post, so can be a little tricky save it in a variable for a post that is not the current.
However, `wp_title` works not only for singular post / page / cpt but also for every type of archive. So it's easy create a custom function that copy the part of the core function th... |
112,441 | <p>This is my current code:</p>
<pre><code>$initial_data = $this->options['my_plugin_editor'];
$settings = array(
'quicktags' => array('buttons' => 'em,strong,link',),
'quicktags' => true,
'tinymce' => true,
'textarea_rows' => 20,
);
$id = 'my_plugin_editor_options[my_plugin_editor]';... | [
{
"answer_id": 112445,
"author": "Laniakea",
"author_id": 34301,
"author_profile": "https://wordpress.stackexchange.com/users/34301",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure if you even can set the cols\"number\" in the array.</p>\n\n<p>But one way to achieve what you ... | 2013/09/01 | [
"https://wordpress.stackexchange.com/questions/112441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | This is my current code:
```
$initial_data = $this->options['my_plugin_editor'];
$settings = array(
'quicktags' => array('buttons' => 'em,strong,link',),
'quicktags' => true,
'tinymce' => true,
'textarea_rows' => 20,
);
$id = 'my_plugin_editor_options[my_plugin_editor]';
wp_editor($initial_data,$id,$se... | There are two parameters that you can use to change the size of the text editor generated with `wp_editor()`, here there are:
```
$settings = array(
'editor_height' => 425, // In pixels, takes precedence and has no default value
'textarea_rows' => 20, // Has no visible effect if editor_height is set, default ... |
112,442 | <p>According to the <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu">docs of <code>wp_nav_menu</code></a> we can specify our own walker function. They suggest to copy the default one and modify it as needed. But to be honest, it is a bit too complicated for the to understand.</p>
<p>Could you please... | [
{
"answer_id": 112444,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You could create a very simple walker, like <a href=\"https://wordpress.stackexchange.com/a/87437/73\">this one</a>. T... | 2013/09/01 | [
"https://wordpress.stackexchange.com/questions/112442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16542/"
] | According to the [docs of `wp_nav_menu`](http://codex.wordpress.org/Function_Reference/wp_nav_menu) we can specify our own walker function. They suggest to copy the default one and modify it as needed. But to be honest, it is a bit too complicated for the to understand.
Could you please provide a minimal example of a ... | You could create a very simple walker, like [this one](https://wordpress.stackexchange.com/a/87437/73). To detect the current item, inspect `$item->current`. It is `TRUE` for the current item only.
I wouldn’t add a class, but deactivate the useless link completely, because it doesn’t have to be clickable anyway.
Exam... |
112,465 | <p>I need to create specific sections of my site which should only allow certain users to access them.</p>
<p>So basically, I'll be having a staff section - if the user is a staff member, they'll see a link to the section and obviously be able to see all the info there.</p>
<p>I've looked into a couple of things, nam... | [
{
"answer_id": 112466,
"author": "Sue",
"author_id": 37432,
"author_profile": "https://wordpress.stackexchange.com/users/37432",
"pm_score": 0,
"selected": false,
"text": "<p>If your needs are simple, the Log Me In custom login plugin might do. You can control what user roles have access... | 2013/09/01 | [
"https://wordpress.stackexchange.com/questions/112465",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37430/"
] | I need to create specific sections of my site which should only allow certain users to access them.
So basically, I'll be having a staff section - if the user is a staff member, they'll see a link to the section and obviously be able to see all the info there.
I've looked into a couple of things, namely adding user r... | You could create a new role, say `staff`, and add the users you want to that specific role. Then link that role a new capability of your choice, e.g. `access_staff`.
Now you have a new role with a new capability, so all you need to do to restrict the access to any part of the site is add this piece of code:
```
if ( ... |
112,482 | <p>The title pretty much explains itself, I'm looking for a way/plugin to hide the menu link to a specific page from users that aren't logged in.</p>
| [
{
"answer_id": 112484,
"author": "Twifty",
"author_id": 36977,
"author_profile": "https://wordpress.stackexchange.com/users/36977",
"pm_score": -1,
"selected": false,
"text": "<pre><code><?php \n if (is_user_logged_in())\n // echo the link\n else\n // Dont echo the lin... | 2013/09/01 | [
"https://wordpress.stackexchange.com/questions/112482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35822/"
] | The title pretty much explains itself, I'm looking for a way/plugin to hide the menu link to a specific page from users that aren't logged in. | No plugin or PHP code is needed to do this. If you look at your HTML body class, you will see that WP helpfully adds the class of "logged-in" for any users who are registered and logged into the site.
With this info along with the class name you give for the particular menu link you want to hide/show, you can draft a ... |
112,492 | <p>I'm using the following <a href="https://wordpress.stackexchange.com/questions/18122/toggle-admin-metabox-based-upon-chosen-page-template">JQuery script from this answer</a> to toggle the display of metaboxes dependant on the Page Template selected. The example below shows the <strong>featured image</strong> metabox... | [
{
"answer_id": 112493,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p>The value of the select is setted to <strong>the file name</strong> so, assuming youf template file is <code>... | 2013/09/01 | [
"https://wordpress.stackexchange.com/questions/112492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37441/"
] | I'm using the following [JQuery script from this answer](https://wordpress.stackexchange.com/questions/18122/toggle-admin-metabox-based-upon-chosen-page-template) to toggle the display of metaboxes dependant on the Page Template selected. The example below shows the **featured image** metabox when the **default** templ... | The `value` is not the same thing that you see when you look at the toggle. That part is for humans. To see the value you have to look at the source of the page. If you have a template created by `template.contact.php` the `value` in that box would be `template.contact.php`, so it looks like the `value` is the `php` fi... |
112,497 | <p>My wordpress site works fine on my mac via localhost, using Xammp. I want to view the site on my iPhone. So I type in 192.168.0.2 and voila, it brings up my localhost directory. I then click on the site in question and the content is there but no styling or images. I realise that this is because the paths to all the... | [
{
"answer_id": 112499,
"author": "Rahil Wazir",
"author_id": 36349,
"author_profile": "https://wordpress.stackexchange.com/users/36349",
"pm_score": 0,
"selected": false,
"text": "<p>Yes you won't get style and images until you tell your iPhone to look for an IP instead of localhost.</p>... | 2013/09/01 | [
"https://wordpress.stackexchange.com/questions/112497",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14739/"
] | My wordpress site works fine on my mac via localhost, using Xammp. I want to view the site on my iPhone. So I type in 192.168.0.2 and voila, it brings up my localhost directory. I then click on the site in question and the content is there but no styling or images. I realise that this is because the paths to all the re... | You can adapt the site url which is stored in the database based on what domain you are viewing the site from. Add the following to `wp-config.php`:
```
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/yourwebsitename' );
define( 'WP_SITEURL', WP_HOME );
```
If you use a subdirectory install (ie: you view th... |
112,504 | <p>I would like to know what template wordpress uses to display post formats archive pages? What is parent template file that is used when there is no specified template file and what is specified template file that covers all post formats templates? Also is there a way to know if loaded page is post formats archive pa... | [
{
"answer_id": 112509,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Post_Formats\" rel=\"nofollow\">Post formats</a> are used to customize... | 2013/09/01 | [
"https://wordpress.stackexchange.com/questions/112504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37438/"
] | I would like to know what template wordpress uses to display post formats archive pages? What is parent template file that is used when there is no specified template file and what is specified template file that covers all post formats templates? Also is there a way to know if loaded page is post formats archive page? | [Post formats](http://codex.wordpress.org/Post_Formats) are used to customize posts according to their "meta" content, but they are always posts and as posts they will be listed on archive and category pages.
>
> What is parent template file that is used when there is no specified
> template file and what is specifi... |
112,516 | <p>I created a plugin that will render a shortcode that is entered to a page. </p>
<p>This Shortcode shall override the theme's page template and use the one that I included on the plugin</p>
<p>Here's my code:</p>
<p>api.php</p>
<pre><code> class Api{
public static $logger = null;
function Api() {
... | [
{
"answer_id": 112509,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Post_Formats\" rel=\"nofollow\">Post formats</a> are used to customize... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112516",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37449/"
] | I created a plugin that will render a shortcode that is entered to a page.
This Shortcode shall override the theme's page template and use the one that I included on the plugin
Here's my code:
api.php
```
class Api{
public static $logger = null;
function Api() {
add_shortcode('my_shortcode', a... | [Post formats](http://codex.wordpress.org/Post_Formats) are used to customize posts according to their "meta" content, but they are always posts and as posts they will be listed on archive and category pages.
>
> What is parent template file that is used when there is no specified
> template file and what is specifi... |
112,520 | <p>This may be a syntax problem but if so I can't see the problem.</p>
<p>I want to select specific terms of a custom taxonomy and display their names. I'm having a problem with the selection process in the following code.</p>
<pre><code>$taxonomy = 'chapters';
echo("Test Term Display ");
$args1=array(
'include'=... | [
{
"answer_id": 112509,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Post_Formats\" rel=\"nofollow\">Post formats</a> are used to customize... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112520",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2865/"
] | This may be a syntax problem but if so I can't see the problem.
I want to select specific terms of a custom taxonomy and display their names. I'm having a problem with the selection process in the following code.
```
$taxonomy = 'chapters';
echo("Test Term Display ");
$args1=array(
'include'=> array(74,76
... | [Post formats](http://codex.wordpress.org/Post_Formats) are used to customize posts according to their "meta" content, but they are always posts and as posts they will be listed on archive and category pages.
>
> What is parent template file that is used when there is no specified
> template file and what is specifi... |
112,524 | <p>At present all https pages have their own canonical tags referencing https, which is incorrect, they should be referencing the http versions. </p>
<p>e.g:</p>
<pre><code>https://www.example.com
</code></pre>
<p>has the following canonical tag: </p>
<p><code><link rel='canonical' href='https://www.example.com'... | [
{
"answer_id": 112965,
"author": "Faishal",
"author_id": 33150,
"author_profile": "https://wordpress.stackexchange.com/users/33150",
"pm_score": 4,
"selected": true,
"text": "<p>You can change it using following code, add it in your theme function.php or in plugin.</p>\n\n<pre><code>rem... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112524",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33751/"
] | At present all https pages have their own canonical tags referencing https, which is incorrect, they should be referencing the http versions.
e.g:
```
https://www.example.com
```
has the following canonical tag:
`<link rel='canonical' href='https://www.example.com' />`
How can we make the canonical tags on http... | You can change it using following code, add it in your theme function.php or in plugin.
```
remove_action ( 'wp_head' , 'rel_canonical' ) ;
add_action ( 'wp_head' , 'my_rel_canonical' ) ;
function my_rel_canonical () {
ob_start () ;
rel_canonical () ;
$rel_content = ob_get_contents () ;
ob_end_clean (... |
112,539 | <p>I am building a website with whole bunch of custom fields and need to implement several custom fields that will auto calculate values by using values from other custom fields.
All files which I need to use in these calculation are in loop, so I would love to use hooks in functions.php.</p>
<p>Can somebody give me ... | [
{
"answer_id": 112569,
"author": "eskimo",
"author_id": 36783,
"author_profile": "https://wordpress.stackexchange.com/users/36783",
"pm_score": 0,
"selected": false,
"text": "<p>I don't really understand why you have a custom field with the total price (do you fill in these by hand?). Wo... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37464/"
] | I am building a website with whole bunch of custom fields and need to implement several custom fields that will auto calculate values by using values from other custom fields.
All files which I need to use in these calculation are in loop, so I would love to use hooks in functions.php.
Can somebody give me few exampl... | Define your own template tag
----------------------------
One idea is to use the template tag:
```
<?php the_price();?>
```
or
```
<?php the_price( '%.1f' );?>
```
to change the format to your needs.
Then you can add filters to it as you like.
In your `functions.php` file you could add
```
// setup the price ... |
112,552 | <p>First of all i am sorry if my question is not correct formulated, i am new in to wordpress and php. I hope i am not being too silly.</p>
<p>i have this:</p>
<pre><code><div class="propsmeta clearfix">
<div class="propslist"><span>Locatie- </span> <span class="propval"> <?ph... | [
{
"answer_id": 112569,
"author": "eskimo",
"author_id": 36783,
"author_profile": "https://wordpress.stackexchange.com/users/36783",
"pm_score": 0,
"selected": false,
"text": "<p>I don't really understand why you have a custom field with the total price (do you fill in these by hand?). Wo... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37402/"
] | First of all i am sorry if my question is not correct formulated, i am new in to wordpress and php. I hope i am not being too silly.
i have this:
```
<div class="propsmeta clearfix">
<div class="propslist"><span>Locatie- </span> <span class="propval"> <?php echo get_the_term_list( $post->ID, 'location', '', '... | Define your own template tag
----------------------------
One idea is to use the template tag:
```
<?php the_price();?>
```
or
```
<?php the_price( '%.1f' );?>
```
to change the format to your needs.
Then you can add filters to it as you like.
In your `functions.php` file you could add
```
// setup the price ... |
112,555 | <p>I am developing a child theme for the new twenty thirteen theme and I am trying to add a sidebar (widget area) next to my content. I only want it to display in <code>single</code> posts.</p>
<p>What I did: edit single.php (and add it to my child theme's folder) like so:</p>
<pre><code>get_header(); ?>
<... | [
{
"answer_id": 112556,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 1,
"selected": false,
"text": "<pre><code><?php get_sidebar('Widget Area Next to Content'); ?> \n</code></pre>\n\n<p>should be </p>\... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112555",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16574/"
] | I am developing a child theme for the new twenty thirteen theme and I am trying to add a sidebar (widget area) next to my content. I only want it to display in `single` posts.
What I did: edit single.php (and add it to my child theme's folder) like so:
```
get_header(); ?>
<div id="primary" class="content-area">... | In additon to wordpresser answer, you can also call to get\_sidebar('sidebar-aside-content'); only in the template files where you want the sidebar be displayed. For example, if you include
```
<?php get_sidebar('sidebar-aside-content'); ?>
```
in "theme\_folder/single.php" file, the sidebar will be displayed only ... |
112,559 | <p>I'm creating a custom upload field for a wordpress theme that uploads pdf files.The code is:</p>
<pre><code>function custom_news_meta_box($post)
{
$file_name = get_post_meta($post->ID, 'file_name', true);
$pdf = get_post_meta($post->ID, 'pdf', true);
wp_nonce_field('news_meta_nonce', 'news_nonce'... | [
{
"answer_id": 112556,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 1,
"selected": false,
"text": "<pre><code><?php get_sidebar('Widget Area Next to Content'); ?> \n</code></pre>\n\n<p>should be </p>\... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37040/"
] | I'm creating a custom upload field for a wordpress theme that uploads pdf files.The code is:
```
function custom_news_meta_box($post)
{
$file_name = get_post_meta($post->ID, 'file_name', true);
$pdf = get_post_meta($post->ID, 'pdf', true);
wp_nonce_field('news_meta_nonce', 'news_nonce');
?>
<p>
... | In additon to wordpresser answer, you can also call to get\_sidebar('sidebar-aside-content'); only in the template files where you want the sidebar be displayed. For example, if you include
```
<?php get_sidebar('sidebar-aside-content'); ?>
```
in "theme\_folder/single.php" file, the sidebar will be displayed only ... |
112,561 | <p>I have been looking for an answer for the last couple of hours but could not find anything pointing me in the right direction. Some advice would be very much appreciated!</p>
<ul>
<li>What I already have:
<ul>
<li>A custom post type <code>'stores'</code></li>
<li>A public query var using the <code>'query_vars'</cod... | [
{
"answer_id": 112579,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe this is not the best solution, nor the solution you are looking for, but this comes in my mind now, som... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37473/"
] | I have been looking for an answer for the last couple of hours but could not find anything pointing me in the right direction. Some advice would be very much appreciated!
* What I already have:
+ A custom post type `'stores'`
+ A public query var using the `'query_vars'` filter hook: `'state'`.
+ Added the accordin... | I figured out a solution myself. No javascript required, only another template function. URL building done manually.
The idea is to use the hook 'template\_redirect', check if the requested page is the corresponding store archive page, then check for $\_REQUEST vars there and build a new URL. Finally redirect to this ... |
112,587 | <p>I have this code </p>
<pre><code><?php
$prefix = 'wtf_';
$meta_box = array(
'id' => 'propertybox',
'title' => 'Property listing details',
'page' => 'listings',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'P... | [
{
"answer_id": 112608,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 3,
"selected": true,
"text": "<p>It's hard to answer this given that each site is most likely different and each server is also configured different... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37402/"
] | I have this code
```
<?php
$prefix = 'wtf_';
$meta_box = array(
'id' => 'propertybox',
'title' => 'Property listing details',
'page' => 'listings',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'Propert ID number',
'desc' ... | It's hard to answer this given that each site is most likely different and each server is also configured differently.
If these sites are individual WordPress installs then 1GB /30 sites is normal, an absolute bare minimum per site would be 32MB for `apc.shm_size`, this equals 960MB with no overhead.
32MB is in my o... |
112,592 | <p>I'm writing a custom plugin and i would like to add the "Add Media" button.</p>
<p>I just need to upload media, not to retrieve any content/data from the uploaded file.</p>
<p>How can I add this button?</p>
<p>Thanks</p>
| [
{
"answer_id": 112927,
"author": "tiltedtimmy",
"author_id": 11467,
"author_profile": "https://wordpress.stackexchange.com/users/11467",
"pm_score": 6,
"selected": true,
"text": "<p>If you want to add a add media button to your <strong>admin</strong> panels:</p>\n\n<p>You need to use wp_... | 2013/09/02 | [
"https://wordpress.stackexchange.com/questions/112592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33504/"
] | I'm writing a custom plugin and i would like to add the "Add Media" button.
I just need to upload media, not to retrieve any content/data from the uploaded file.
How can I add this button?
Thanks | If you want to add a add media button to your **admin** panels:
You need to use wp\_enqueue\_media();
```
add_action ( 'admin_enqueue_scripts', function () {
if (is_admin ())
wp_enqueue_media ();
} );
```
Then use this js:
```
jQuery(document).ready(function() {
var $ = jQuery;
if ($('.set_cust... |
112,648 | <p>I'm trying to display the Woocommerce nav filters on the home page so visitors can filter all the shop products from any page (when they hit the filter they will be taken to the shop page as usual). What I wanted is to include it on the header to accomplish this but it doesn't work.</p>
<p>To my understanding it lo... | [
{
"answer_id": 112674,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 1,
"selected": false,
"text": "<p>look for this piece of code in wp-content/plugins/woocommerce/classes/widgets</p>\n\n<pre><code>if ( ! i... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112648",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16150/"
] | I'm trying to display the Woocommerce nav filters on the home page so visitors can filter all the shop products from any page (when they hit the filter they will be taken to the shop page as usual). What I wanted is to include it on the header to accomplish this but it doesn't work.
To my understanding it loads only w... | I didn't found any documentation at all on how to do this. So here comes the work arround that worked for me.
1. Register a sidebar in the functions.php file (you can change the name to whatever you want):
```
function meir_widgets_init() {
register_sidebar( array(
'name' => 'Filters Sidebar',
'i... |
112,655 | <p>I've recently come across the Transients API in Wordpress in hopes of improving the performance of the plugin that I'm trying to write.</p>
<p>Basically the plugin is storing product details from the amazon product advertising API in the database. The product details are stored using the json encoded representation... | [
{
"answer_id": 112675,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>Is this ok or should I just store it in an array form so I can just\n directly access it with... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27291/"
] | I've recently come across the Transients API in Wordpress in hopes of improving the performance of the plugin that I'm trying to write.
Basically the plugin is storing product details from the amazon product advertising API in the database. The product details are stored using the json encoded representation of the ar... | >
> Is this ok or should I just store it in an array form so I can just
> directly access it without using json\_decode?
>
>
>
In your case store it *directly* means store it *serialized*. Because `$data` is an array and cannot be stored as is, but converted to a string.
Even if you access it directly like:
```... |
112,686 | <p>I've created some custom taxonomies using <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy#Arguments">register_taxonomy</a>, but I want to prevent new terms from being added. I noticed that there is a 'capabilities' argument available in register_taxonomy, is that what I should be using and i... | [
{
"answer_id": 112721,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 6,
"selected": true,
"text": "<p>You can block addition of new terms with a filter on <code>pre_insert_term</code>. The <a href=\"http://core.... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112686",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2685/"
] | I've created some custom taxonomies using [register\_taxonomy](http://codex.wordpress.org/Function_Reference/register_taxonomy#Arguments), but I want to prevent new terms from being added. I noticed that there is a 'capabilities' argument available in register\_taxonomy, is that what I should be using and if so, how wo... | You can block addition of new terms with a filter on `pre_insert_term`. The [source is helpful](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/taxonomy.php#L2041) in working out what you can do.
```
add_action( 'pre_insert_term', function ( $term, $taxonomy )
{
return ( 'yourtax' === $taxonomy )
... |
112,687 | <p>I have a form on my website and depending on if the user check paypal or wire-transfer the form action should always go to functions.php where I have this simple check at the end of the file:</p>
<pre><code>if ( isset( $_POST['submitted'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( ... | [
{
"answer_id": 112721,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 6,
"selected": true,
"text": "<p>You can block addition of new terms with a filter on <code>pre_insert_term</code>. The <a href=\"http://core.... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112687",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I have a form on my website and depending on if the user check paypal or wire-transfer the form action should always go to functions.php where I have this simple check at the end of the file:
```
if ( isset( $_POST['submitted'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( $_POST['post_nonce_field'], 'p... | You can block addition of new terms with a filter on `pre_insert_term`. The [source is helpful](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/taxonomy.php#L2041) in working out what you can do.
```
add_action( 'pre_insert_term', function ( $term, $taxonomy )
{
return ( 'yourtax' === $taxonomy )
... |
112,705 | <p>I am trying to create a theme using <a href="https://github.com/Victa/curtain.js/blob/development/v2.0/curtain.js" rel="nofollow">curtains.js</a> but am having a few problems. I have both registered and enqueued the script and the part that would go in the footer like so: </p>
<pre><code>add_action('wp_enqueue_scri... | [
{
"answer_id": 112721,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 6,
"selected": true,
"text": "<p>You can block addition of new terms with a filter on <code>pre_insert_term</code>. The <a href=\"http://core.... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34045/"
] | I am trying to create a theme using [curtains.js](https://github.com/Victa/curtain.js/blob/development/v2.0/curtain.js) but am having a few problems. I have both registered and enqueued the script and the part that would go in the footer like so:
```
add_action('wp_enqueue_scripts', 'tf_load_custom_scripts');
functi... | You can block addition of new terms with a filter on `pre_insert_term`. The [source is helpful](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/taxonomy.php#L2041) in working out what you can do.
```
add_action( 'pre_insert_term', function ( $term, $taxonomy )
{
return ( 'yourtax' === $taxonomy )
... |
112,706 | <p>I tried ajax to get some info a php inside my plugin.but getting error-call to undefined function.
<strong>Ajax</strong></p>
<pre><code>jQuery.ajax({
type: "POST",
url: "<?php echo plugins_url();?>/tester/inc/test.php",
data: { param: 'st1' }
}).done(function( msg ) {
... | [
{
"answer_id": 112711,
"author": "J.D.",
"author_id": 27757,
"author_profile": "https://wordpress.stackexchange.com/users/27757",
"pm_score": 0,
"selected": false,
"text": "<p>You are right, because of the way you are making your AJAX call, WordPress is not being loaded. The proper way i... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35819/"
] | I tried ajax to get some info a php inside my plugin.but getting error-call to undefined function.
**Ajax**
```
jQuery.ajax({
type: "POST",
url: "<?php echo plugins_url();?>/tester/inc/test.php",
data: { param: 'st1' }
}).done(function( msg ) {
alert( "Data Saved: " + msg );
... | Please, **avoid the use of require('../../../wp-load.php'); and things like that** as suggested in other answers. You should always use the Wordpress AJAX way. It is really easy and you will have all Wordpress engine loaded in your PHP script.
Just three considerations:
1. You have to **send the ajax request to ...wp... |
112,723 | <p>I have the followign code in my functions.php file </p>
<pre><code>function __adapted_search_function($search, $query) {
if(is_admin() || !$query->is_main_query() || !$query->is_search)
return; //determine if we are modifying the right query
global $wpdb;
$search_term = $query->get('s');
$sear... | [
{
"answer_id": 112727,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nofollow noreferrer\"... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26814/"
] | I have the followign code in my functions.php file
```
function __adapted_search_function($search, $query) {
if(is_admin() || !$query->is_main_query() || !$query->is_search)
return; //determine if we are modifying the right query
global $wpdb;
$search_term = $query->get('s');
$search = ' AND (';
//poi... | I managed to resolve by extending the query
```
function extend_search( $search, &$wp_query ) {
global $wpdb;
if ( empty( $search ))
return $search;
$terms = $wp_query->query_vars[ 's' ];
$exploded = explode( ' ', $terms );
if( $exploded === FALSE || count( $exploded ) == 0 )
$ex... |
112,734 | <p>I'm looking for a strong streamlined workflow idea for working with Wordpress.</p>
<ol>
<li>Would like to have my git environment on my own server internally, not using Github to handle repos.</li>
<li>Automatic creation of subdomains upon git branch creation (development.domain.com , ryan.development.domain.com) -... | [
{
"answer_id": 113778,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": true,
"text": "<h3>General Questions answered</h3>\n\n<blockquote>\n <p><strong>Nr.1.</strong> Would like to have my git environment... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112734",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6027/"
] | I'm looking for a strong streamlined workflow idea for working with Wordpress.
1. Would like to have my git environment on my own server internally, not using Github to handle repos.
2. Automatic creation of subdomains upon git branch creation (development.domain.com , ryan.development.domain.com) - Probably some shel... | ### General Questions answered
>
> **Nr.1.** Would like to have my git environment on my own server internally, not using Github to handle repos.
>
>
>
The first thing I'd do is to check out [composer and how it works with WordPress](http://composer.rarst.net/), which is a project by [Andrey "@Rarst" Savchenko](h... |
112,745 | <p>I am having a tough time removing the subfolders from the URL in my WordPress site.</p>
<p>Currently, the URL format is:
<code>www.mysite.com/subfolder/index.php/category/postname</code></p>
<p>I would like to remove both the subfolder AND index.php from the URL.</p>
<p>The site must stay in a subfolder of root o... | [
{
"answer_id": 113778,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": true,
"text": "<h3>General Questions answered</h3>\n\n<blockquote>\n <p><strong>Nr.1.</strong> Would like to have my git environment... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112745",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31468/"
] | I am having a tough time removing the subfolders from the URL in my WordPress site.
Currently, the URL format is:
`www.mysite.com/subfolder/index.php/category/postname`
I would like to remove both the subfolder AND index.php from the URL.
The site must stay in a subfolder of root on my server.
My current `htaccess... | ### General Questions answered
>
> **Nr.1.** Would like to have my git environment on my own server internally, not using Github to handle repos.
>
>
>
The first thing I'd do is to check out [composer and how it works with WordPress](http://composer.rarst.net/), which is a project by [Andrey "@Rarst" Savchenko](h... |
112,753 | <p>I would need the following in Wordpress:</p>
<pre><code><div class="posts-wrapped">
<div id="post-1" class="post">
<h1>Title 1</h1>
</div>
<div id="post-2" class="post">
<h1>Title 2</h1>
</div>
</div>
<div class="posts-wr... | [
{
"answer_id": 112758,
"author": "M Khalid Junaid",
"author_id": 20920,
"author_profile": "https://wordpress.stackexchange.com/users/20920",
"pm_score": 0,
"selected": false,
"text": "<p>Get the index that counts the loop iteration and check the modulus operation to know that its even or... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37543/"
] | I would need the following in Wordpress:
```
<div class="posts-wrapped">
<div id="post-1" class="post">
<h1>Title 1</h1>
</div>
<div id="post-2" class="post">
<h1>Title 2</h1>
</div>
</div>
<div class="posts-wrapped">
<div id="post-3" class="post">
<h1>Title 3</h1>
</div... | This is really just a matter of logic. You need to conditionally print the `div` markup. The counter in `$wp_query` will let you chose every second post.
```
if (have_posts()) {
echo '<div class="posts-wrapped">';
while (have_posts()) {
the_post();
if (0 !== $wp_query->current_post
&& 0 =... |
112,755 | <p>I'm using a basic shortcode to wrap some text in an expandable div. What appears to be happening is that the wpautop is inserting a stray closing paragraph tag at the beginning and a stray opening paragraph tag at the end of the content being wrapped.</p>
<p>Here's how it looks in the editor:</p>
<blockquote>
<... | [
{
"answer_id": 113116,
"author": "RuFFCuT",
"author_id": 37668,
"author_profile": "https://wordpress.stackexchange.com/users/37668",
"pm_score": -1,
"selected": false,
"text": "<p>Install the <a href=\"http://wordpress.org/plugins/raw-html/\" rel=\"nofollow\">WP RAW HTML plugin</a>.</p>\... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112755",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3032/"
] | I'm using a basic shortcode to wrap some text in an expandable div. What appears to be happening is that the wpautop is inserting a stray closing paragraph tag at the beginning and a stray opening paragraph tag at the end of the content being wrapped.
Here's how it looks in the editor:
>
> [expandable text="Show Con... | This is frustrating issue as I can't depend on the content editors to be savvy enough with Wordpress / HTML to understand how the text they input will be parsed...
--EDIT--
Having thought of this a bit more I have reconsidered my earlier answer. HTML5+ comes with the [Tidy extension](http://php.net/manual/en/book.tid... |
112,762 | <p>So I've searched the net and attempted to code a custom walker class that will do this, but I'm new to WordPress and although similar questions exist none fit exactly what I'm looking for, or suggest CSS, jQuery or a plugin as a solution (which is not really ideal).</p>
<p>I currently have the following code:</p>
... | [
{
"answer_id": 125766,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>If you will work with sessions, then init this at first in your plugin, theme.</p>\n\n<pre><code>add_action( 'ini... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37541/"
] | So I've searched the net and attempted to code a custom walker class that will do this, but I'm new to WordPress and although similar questions exist none fit exactly what I'm looking for, or suggest CSS, jQuery or a plugin as a solution (which is not really ideal).
I currently have the following code:
```
class desc... | I have a really simple script that is linked <https://wordpress.stackexchange.com/questions/154802/what-do-i-need-to-do-to-fully-integrate-a-custom-session-login-into-wp>.
Basically I am assuming that your SSO is secure, that you have the users in your database, and that you don't need to keep the session alive except... |
112,787 | <p>i need the code which will add default thumb, if there is not featured image available. I was using default thumb plus for this but this plugin is using a lot of resource so i need to remove it.</p>
<p>I was trying to follow this <a href="http://www.wpbeginner.com/wp-themes/how-to-set-a-default-fallback-image-for-w... | [
{
"answer_id": 112789,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>There is no such functionality in WordPress core. You'll have to create, upload, and call your own default... | 2013/09/03 | [
"https://wordpress.stackexchange.com/questions/112787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35867/"
] | i need the code which will add default thumb, if there is not featured image available. I was using default thumb plus for this but this plugin is using a lot of resource so i need to remove it.
I was trying to follow this [tutorial](http://www.wpbeginner.com/wp-themes/how-to-set-a-default-fallback-image-for-wordpress... | While there's no such functionality built into core, there's a [***Track Ticket***](http://core.trac.wordpress.org/ticket/18951) I proposed 2 years ago. You can simply rip of the functionality from the suggested [`wp_default_img()`](http://core.trac.wordpress.org/attachment/ticket/18951/18951.patch) function. I'll grea... |
112,799 | <p>I had asked this earlier and solved it using the <a href="http://wordpress.org/plugins/relevanssi/" rel="nofollow noreferrer">Relevanssi</a> plugin, however that plugin is now breaking things so I can't use it anymore. How is something so freaking simple made so impossible by woocommerce?? AAARG!</p>
<p>I tried usi... | [
{
"answer_id": 112801,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>So far your plugin looks good. Could you dump the final SQL string and add it to your question? Also: Does the WC ... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31938/"
] | I had asked this earlier and solved it using the [Relevanssi](http://wordpress.org/plugins/relevanssi/) plugin, however that plugin is now breaking things so I can't use it anymore. How is something so freaking simple made so impossible by woocommerce?? AAARG!
I tried using [this solution](https://wordpress.stackexcha... | This is an 9 months question, but since I had the same issue and found a solution, I came here to post it.
On file `wp-content/plugins/woocommerce/classes/class-wc-query.php`, function `pre_get_posts( $q )`, WooCommerce defines at line 114:
```
add_filter( 'posts_where', array( $this, 'search_post_excerpt' ) );
```
... |
112,807 | <p>I am in the process of migrating from qTranslate to WPML to handle my languages.</p>
<p>With qTranslate, I had a very simple way to get an url to a page or post knowing it's slug: <code>$url = get_language_url(home_url($slug));</code></p>
<p>Now with WPML I can't find a way to do that...</p>
<p>There's the <code>... | [
{
"answer_id": 112823,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>You can get link to a post by it's slug using following code.</p>\n\n<pre><code><?php\nglobal $wpdb;\n... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112807",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26697/"
] | I am in the process of migrating from qTranslate to WPML to handle my languages.
With qTranslate, I had a very simple way to get an url to a page or post knowing it's slug: `$url = get_language_url(home_url($slug));`
Now with WPML I can't find a way to do that...
There's the `icl_link_to_element` function but it dir... | Actually Wordpress lacks a real function to get posts by slug/post-name. But you can use [get\_page\_by\_path()](http://codex.wordpress.org/Function_Reference/get_page_by_path) for it so you don't have to use a custom query:
```
if(function_exists('icl_object_id')) {
$post = get_page_by_path('your-slug');
$id = ... |
112,815 | <p>I am new to custom post types so I might not be explaining this the right way (apologies), but I am developing a WP project based on football games - with a major part of this involving which teams playing one another. </p>
<p>The problem I am having is working out a way to easily add teams to the dropdown list tha... | [
{
"answer_id": 112823,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>You can get link to a post by it's slug using following code.</p>\n\n<pre><code><?php\nglobal $wpdb;\n... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112815",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15712/"
] | I am new to custom post types so I might not be explaining this the right way (apologies), but I am developing a WP project based on football games - with a major part of this involving which teams playing one another.
The problem I am having is working out a way to easily add teams to the dropdown list that I am usi... | Actually Wordpress lacks a real function to get posts by slug/post-name. But you can use [get\_page\_by\_path()](http://codex.wordpress.org/Function_Reference/get_page_by_path) for it so you don't have to use a custom query:
```
if(function_exists('icl_object_id')) {
$post = get_page_by_path('your-slug');
$id = ... |
112,824 | <p>I use the following shortcode and function to display members of some departments:</p>
<pre><code>add_shortcode( 'list_of_members', 'members_listing' );
/* usage: [list_of_members department = 'psychology'] */
function members_listing( $department ) {
$members = get_users( array( 'meta_key' => 'department'... | [
{
"answer_id": 112825,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 4,
"selected": true,
"text": "<p>Why don't use built-in functionality of PHP?</p>\n\n<p>Put the following line right before the <code>foreach<... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112824",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I use the following shortcode and function to display members of some departments:
```
add_shortcode( 'list_of_members', 'members_listing' );
/* usage: [list_of_members department = 'psychology'] */
function members_listing( $department ) {
$members = get_users( array( 'meta_key' => 'department', 'meta_value' =>... | Why don't use built-in functionality of PHP?
Put the following line right before the `foreach`:
```
usort($members, create_function('$a, $b', 'return strnatcasecmp($a->last_name, $b->last_name);'));
```
**References:**
* [`usort`](http://php.net/manual/en/function.usort.php)
* [`create_function`](http://php.net/ma... |
112,852 | <p>I have a client that wants two pages for each author profile:<br /></p>
<p>First Page - has user info, bunch of social media links, etc. Using author.php for this.<br />
Second Page - list of author posts<br /></p>
<p>I've built everything, and here's my question:</p>
<p><strong>Is there a way to have get_author_... | [
{
"answer_id": 112854,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>There is a filter called <a href=\"http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/author-templat... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24181/"
] | I have a client that wants two pages for each author profile:
First Page - has user info, bunch of social media links, etc. Using author.php for this.
Second Page - list of author posts
I've built everything, and here's my question:
**Is there a way to have get\_author\_posts\_url() use a template other than ... | There is a filter called [`author_link`](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/author-template.php#L235). You can use that change the URL to whatever you want.
```
add_filter(
'author_link',
function ($link, $author_id, $author_nicename) {
var_dump($link, $author_id, $author_nicename); /... |
112,855 | <p>How do i do something when a (normal) user creates a post (that is submitted for approval)</p>
<p>I currently have:</p>
<pre><code>function emailinvestment( $new_status, $old_status, $post_id ) {
if ( $old_status != 'new' && $new_status != 'pending' ) {
// Do something (not working at... | [
{
"answer_id": 112884,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to target only one specific status change is probably easy / efficient use the\n<code>{$old_statu... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36341/"
] | How do i do something when a (normal) user creates a post (that is submitted for approval)
I currently have:
```
function emailinvestment( $new_status, $old_status, $post_id ) {
if ( $old_status != 'new' && $new_status != 'pending' ) {
// Do something (not working atm)
}
}
add_... | Found it! The following line:
```
if ( $old_status != 'new' && $new_status != 'pending' ) {
```
Should be:
```
if ( $old_status != 'new' && $new_status == 'pending' ) {
```
Thanks for the help guys! |
112,858 | <p>I'm sure this isn't possible but thought I'd ask.</p>
<p>I have a testimonials section, the html of each testimonial is like so</p>
<pre><code> <p>
the testimonal here blah, blah, blah, blah, blah, blah, blah, blah
<em>Name of person</em>
</p>
</code></pre>
<p>Now in WP ... | [
{
"answer_id": 112861,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>You can just repeat the_title() after the_content(), as @Howdy_McGee suggested, or use <a href=\"http://codex... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31546/"
] | I'm sure this isn't possible but thought I'd ask.
I have a testimonials section, the html of each testimonial is like so
```
<p>
the testimonal here blah, blah, blah, blah, blah, blah, blah, blah
<em>Name of person</em>
</p>
```
Now in WP I have the testimonials as a Custom post type. The Name o... | You can just repeat the\_title() after the\_content(), as @Howdy\_McGee suggested, or use [the\_content filter](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content). For example:
```
//Make your conditional to check if the current post is of your custom post type
//Maybe remove wpautop to not have neste... |
112,902 | <p>I am trying to get the first paragraph on a page where page ID=2 and blog ID=1. I want to display this paragraph on a page in blog id=2. I have added the following code to the template page.</p>
<pre><code>//gets active blog
global $blog_id;
switch_to_blog(1);
$pageid = 2; //author page
$post = get_post( $pageid );... | [
{
"answer_id": 112875,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 1,
"selected": true,
"text": "<p>Looking a the source code of <a href=\"http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/link-templa... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31560/"
] | I am trying to get the first paragraph on a page where page ID=2 and blog ID=1. I want to display this paragraph on a page in blog id=2. I have added the following code to the template page.
```
//gets active blog
global $blog_id;
switch_to_blog(1);
$pageid = 2; //author page
$post = get_post( $pageid );
$excerpt = g... | Looking a the source code of [get\_permalink()](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/link-template.php#L0), that function not always generates additional queries. It depends on the particular situation. get\_user\_meta() is always performing aditional queries although they can be stored in wp cah... |
112,909 | <p>By default the 'all posts' page contains the following filters</p>
<ul>
<li>by date</li>
<li>by category</li>
</ul>
<p>Is there a way I can add 'by tags' as well ?<img src="https://i.stack.imgur.com/wir02.png" alt="enter image description here"></p>
| [
{
"answer_id": 112982,
"author": "Dipesh KC",
"author_id": 7247,
"author_profile": "https://wordpress.stackexchange.com/users/7247",
"pm_score": 2,
"selected": false,
"text": "<p>User <code>'restrict_manage_posts'</code> filter to add another filter. Use the following code in functions.p... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24656/"
] | By default the 'all posts' page contains the following filters
* by date
* by category
Is there a way I can add 'by tags' as well ? | User `'restrict_manage_posts'` filter to add another filter. Use the following code in functions.php
```
function kc_add_taxonomy_filters() {
global $typenow;
// an array of all the taxonomyies you want to display. Use the taxonomy name or slug
$my_taxonomies = array( 'post_tag' );
switch($typenow){
case 'post'... |
112,920 | <p>I am developing a plugin that adds a Custom Post Type to my theme. It's a retail directory and the post type is a retail listing.</p>
<p>Everything is working fine. I can upload content to the DB and then print in a customized CSS framework I have developed. However, when i want to upload and display an image, th... | [
{
"answer_id": 112953,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 0,
"selected": false,
"text": "<p>i think the problem is in your save meta values function, try with <code>global $post;</code></p>\n\n<pre><code>f... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37605/"
] | I am developing a plugin that adds a Custom Post Type to my theme. It's a retail directory and the post type is a retail listing.
Everything is working fine. I can upload content to the DB and then print in a customized CSS framework I have developed. However, when i want to upload and display an image, that's when I ... | The action sends the `$post_id` just like you have so that's not the problem.
Have you tried a `var_dump` of `$_POST` to make sure it's actually posting something other than null?
Also, using the `save_post` action is going to be called every time a post is saved, so you probably need to use the `save_post_{custom_po... |
112,923 | <p>I have a unique problem I guess.</p>
<p>I am working on a site and the client needs to have a way in Wordpress backend from where he can add a post, and from the same page (where he is creating a post) he can add sub posts to that post.</p>
<p>He wants to be able to as many sub posts as he wants. </p>
<p>And then... | [
{
"answer_id": 112953,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 0,
"selected": false,
"text": "<p>i think the problem is in your save meta values function, try with <code>global $post;</code></p>\n\n<pre><code>f... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/112923",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a unique problem I guess.
I am working on a site and the client needs to have a way in Wordpress backend from where he can add a post, and from the same page (where he is creating a post) he can add sub posts to that post.
He wants to be able to as many sub posts as he wants.
And then he wants on the front e... | The action sends the `$post_id` just like you have so that's not the problem.
Have you tried a `var_dump` of `$_POST` to make sure it's actually posting something other than null?
Also, using the `save_post` action is going to be called every time a post is saved, so you probably need to use the `save_post_{custom_po... |
112,929 | <p>i want to do something if my url is /pagethatdontexist
But I dont want wp sending 404 headers. I tried this:</p>
<pre><code>add_action('wp', array($this,'awp'));
function awp(){
global $wp_query ;
debug($wp_query->is_404);
if($wp_query->query_vars['name'] == 'pagethatdontexist')
debug('yes were at pag... | [
{
"answer_id": 112935,
"author": "mircobabini",
"author_id": 37607,
"author_profile": "https://wordpress.stackexchange.com/users/37607",
"pm_score": 0,
"selected": false,
"text": "<p>As someone (somewhere) said it's not a good idea to fall into a 404 without sending headers. The right wa... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17881/"
] | i want to do something if my url is /pagethatdontexist
But I dont want wp sending 404 headers. I tried this:
```
add_action('wp', array($this,'awp'));
function awp(){
global $wp_query ;
debug($wp_query->is_404);
if($wp_query->query_vars['name'] == 'pagethatdontexist')
debug('yes were at pagethatdontexist');;
$w... | You can use an earlier action, [`request`](http://codex.wordpress.org/Plugin_API/Filter_Reference/request), to do whatever you need. It allows you to modify query variables, or even cancel the entire request without issuing a 404 error:
```
function wpse112929_cancel_request_parsing( $query_vars ) {
if ( in_array(... |
112,934 | <p>I have an specific page on my website where I can't have any stylesheets being enqueued, so I need to unenqueue all stylessheets loaded there. Problem is I don't know their IDs, because they can come from either several different themes or other plugins.</p>
<p>What I've tried to do is remove the wp_enqueue_styles ... | [
{
"answer_id": 112938,
"author": "mircobabini",
"author_id": 37607,
"author_profile": "https://wordpress.stackexchange.com/users/37607",
"pm_score": -1,
"selected": false,
"text": "<pre><code>function dequeue_all () {\n global $wp_styles;\n // var_dump($wp_styles->queue);\n\n ... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37153/"
] | I have an specific page on my website where I can't have any stylesheets being enqueued, so I need to unenqueue all stylessheets loaded there. Problem is I don't know their IDs, because they can come from either several different themes or other plugins.
What I've tried to do is remove the wp\_enqueue\_styles action, ... | Check the `$wp_styles` global to get the stylesheet IDs.
```
global $wp_styles;
var_dump($wp_styles);
```
Look for the `handle` key. Or...
```
var_dump(array_keys($wp_styles->registered));
```
That should give you what you need to dequeue them. |
112,957 | <p>I"m trying to filter an archive page by custom meta query. </p>
<p>I've tried using <code>query_posts($args)</code> prior to the loop, but it returns nothing.
Any ideas?</p>
<p>Here's what I have so far:</p>
<pre><code><?php
//$wolfName = $_GET['wolfName'];
$archiveArgs = array(
... | [
{
"answer_id": 112960,
"author": "Faishal",
"author_id": 33150,
"author_profile": "https://wordpress.stackexchange.com/users/33150",
"pm_score": 4,
"selected": true,
"text": "<p>Use <code>pre_get_posts</code> action hook</p>\n\n<pre><code>function archive_meta_query( $query ) {\n if (... | 2013/09/04 | [
"https://wordpress.stackexchange.com/questions/112957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4432/"
] | I"m trying to filter an archive page by custom meta query.
I've tried using `query_posts($args)` prior to the loop, but it returns nothing.
Any ideas?
Here's what I have so far:
```
<?php
//$wolfName = $_GET['wolfName'];
$archiveArgs = array(
'meta_key' => 'wolf',
... | Use `pre_get_posts` action hook
```
function archive_meta_query( $query ) {
if ( $query->is_archive){
$query->query_vars["meta_key"] = 'wolf';
$query->query_vars["meta_value"] = 'boltz';
}
}
add_action( 'pre_get_posts', 'archive_meta_query', 1 );
``` |
113,022 | <p>How to get active menu class in wordpress, I want to get it in one plugin to change menu style.</p>
<p>Just to clear, I do not want active menu element class.</p>
<pre><code><ul id="menu-scroll" class="nav-menu">
<li id="menu-item-1461" class="menu-item menu-item-type-custom menu-item-object-custom menu-i... | [
{
"answer_id": 112981,
"author": "Bindiya Patoliya",
"author_id": 34932,
"author_profile": "https://wordpress.stackexchange.com/users/34932",
"pm_score": 1,
"selected": false,
"text": "<p>You need to login to the database and manually edit 2 entries. In the wp_options table you can find ... | 2013/09/05 | [
"https://wordpress.stackexchange.com/questions/113022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12261/"
] | How to get active menu class in wordpress, I want to get it in one plugin to change menu style.
Just to clear, I do not want active menu element class.
```
<ul id="menu-scroll" class="nav-menu">
<li id="menu-item-1461" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1461"><a href="#home">Home... | You need to login to the database and manually edit 2 entries. In the wp\_options table you can find `siteurl` and `home`. Update those appropriately, you should then be able to login properly.
You also need to update your `.htaccess` file but if you edit your permalink options and then change them back this should re... |
113,066 | <p>I have a custom registration form that I insert into a page via shortcode. The shortcode function looks like this:</p>
<pre><code>function custom_registration_form_shortcode() {
$error = FALSE;
if (isset($_POST["submit"])) {
//Get other $_POST data here
$email = is_email($_POST["email"]);
... | [
{
"answer_id": 113056,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 3,
"selected": false,
"text": "<p>if you have access to the .htaccess file in your www folder. Just include the following 2 lines in .htac... | 2013/09/05 | [
"https://wordpress.stackexchange.com/questions/113066",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37654/"
] | I have a custom registration form that I insert into a page via shortcode. The shortcode function looks like this:
```
function custom_registration_form_shortcode() {
$error = FALSE;
if (isset($_POST["submit"])) {
//Get other $_POST data here
$email = is_email($_POST["email"]);
if (!$email)... | **OPTION 1: If a WordPress WXR file, an XML file exported from WordPress, is too large to import, there are several things you might try to overcome that limit.**
* **Increase the amount of memory a PHP script may consume. Note: If using a shared hosting service, you may need to ask your host to increase the limit.**
... |
113,069 | <p>Is there anyway to get notified when someone logs on to the site or is even just browsing the site? I would like to receive email notifications when this happens but I cannot seem to find anywhere to activate this feature.</p>
| [
{
"answer_id": 113103,
"author": "Morgan Estes",
"author_id": 26317,
"author_profile": "https://wordpress.stackexchange.com/users/26317",
"pm_score": 2,
"selected": false,
"text": "<p>You can trigger <a href=\"http://codex.wordpress.org/Function_Reference/wp_mail\" rel=\"nofollow norefer... | 2013/09/05 | [
"https://wordpress.stackexchange.com/questions/113069",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37324/"
] | Is there anyway to get notified when someone logs on to the site or is even just browsing the site? I would like to receive email notifications when this happens but I cannot seem to find anywhere to activate this feature. | You can trigger [`wp_mail()`](http://codex.wordpress.org/Function_Reference/wp_mail) to send you an email when you have a visitor, although you may end up getting flooded with emails since it'll email you **every time** a page is viewed.
```
/**
* Send an email with every visit.
*/
function wpse113069_email_me_every... |
113,075 | <p>I have a Wordpress custom post type set up in my <code>functions.php</code> called "Research"</p>
<p>I have a custom taxonomy called "Classifications"</p>
<p>Under that taxonomy I have the terms/categories:</p>
<pre><code>Old Research (parent)
--- sub cat 1
--- sub cat 2
</code></pre>
<p>I have created the fil... | [
{
"answer_id": 113077,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>Change template file name taxonomy-Classifications-oldresearch.php to taxonomy-Classifications.php so tha... | 2013/09/05 | [
"https://wordpress.stackexchange.com/questions/113075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37657/"
] | I have a Wordpress custom post type set up in my `functions.php` called "Research"
I have a custom taxonomy called "Classifications"
Under that taxonomy I have the terms/categories:
```
Old Research (parent)
--- sub cat 1
--- sub cat 2
```
I have created the file "taxonomy-Classifications-oldresearch.php" which ... | Hook into `template_include` filter
```
add_filter('template_include', 'research_term_template');
function research_term_template( $template ) {
if ( is_tax('classifications') ) {
$parent = get_term_by('slug', 'oldresearch', 'classifications');
// to improve performance you can hardcoding 'oldresearch' term... |
113,079 | <p>I just can't get how to do this.
When inserting a gallery I have this output:</p>
<pre><code><a href="path_to_files/image.jpg" title="fancy title">
<img width="150" height="150" src="path_to_files/image-150x150.jpg" class="attachment-thumbnail" alt="fancy alt"/>
</a>
</code></pre>
<p>But when ins... | [
{
"answer_id": 113077,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>Change template file name taxonomy-Classifications-oldresearch.php to taxonomy-Classifications.php so tha... | 2013/09/05 | [
"https://wordpress.stackexchange.com/questions/113079",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31277/"
] | I just can't get how to do this.
When inserting a gallery I have this output:
```
<a href="path_to_files/image.jpg" title="fancy title">
<img width="150" height="150" src="path_to_files/image-150x150.jpg" class="attachment-thumbnail" alt="fancy alt"/>
</a>
```
But when inserting single images the title doesn't shows... | Hook into `template_include` filter
```
add_filter('template_include', 'research_term_template');
function research_term_template( $template ) {
if ( is_tax('classifications') ) {
$parent = get_term_by('slug', 'oldresearch', 'classifications');
// to improve performance you can hardcoding 'oldresearch' term... |
113,088 | <p>This may be a very basic question, but I'm a beginner. How can I list my subpages in alphabetical order? I have 14 subpages total. </p>
<p>This is what I was told to use but my page is a mess.</p>
<pre><code>[subpages page=27 items=12 order=alphabetical desc]
</code></pre>
| [
{
"answer_id": 113091,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>You can use following code in your theme to get it. For more information visit <a href=\"http://codex.wor... | 2013/09/05 | [
"https://wordpress.stackexchange.com/questions/113088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37661/"
] | This may be a very basic question, but I'm a beginner. How can I list my subpages in alphabetical order? I have 14 subpages total.
This is what I was told to use but my page is a mess.
```
[subpages page=27 items=12 order=alphabetical desc]
``` | get a list of sub pages using `wp_list_pages();` function for more information visit [codex](http://codex.wordpress.org/Function_Reference/wp_list_pages)
```
$args = array('child_of' => 27);
wp_list_pages( $args );
```
this will print a list of sub pages (child) of page 27, sort alphabetically order, also you can g... |
113,127 | <p>What is the best way to link to a CSS file in WordPress?</p>
<p><strong>Method 1:</strong> Use the following whenever needed</p>
<pre><code><link href="<?php echo get_template_directory_uri(); ?>/my-style.css" rel="stylesheet" type="text/css" />
</code></pre>
<p><strong>Method 2:</strong> Use enqueue ... | [
{
"answer_id": 113128,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You don't want to hardcode anything. Enqueueing is the best practice and in addition, you can load it whenever y... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | What is the best way to link to a CSS file in WordPress?
**Method 1:** Use the following whenever needed
```
<link href="<?php echo get_template_directory_uri(); ?>/my-style.css" rel="stylesheet" type="text/css" />
```
**Method 2:** Use enqueue as follows
```
add_action('wp_enqueue_scripts', 'load_my_style');
fun... | **Method 2**
1. You can enqueue all of your stylesheets form the same place even
controlling where the stylesheets load by means of template
conditionals, which is convenient and prevents a lot of mess in your `<head>`.
2. You can remove enqueued stylesheets if you need to via a plugin, for
example.
3. Enqueued styles... |
113,154 | <p>Here I am not getting whats the meaning passing <code>$page</code> with admin_print_scripts ?</p>
<p>My code is like :</p>
<pre><code>$page = add_submenu_page('edit.php?post_type=' . $post_type, __('text', 'plugin-dir-name'), __('text', 'plugin-dir-name'), 'edit_posts', 'text_' . $post_type, array(&$this, 'te... | [
{
"answer_id": 113155,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/admin_print_scripts\" rel=\"nofollow\">ht... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113154",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37136/"
] | Here I am not getting whats the meaning passing `$page` with admin\_print\_scripts ?
My code is like :
```
$page = add_submenu_page('edit.php?post_type=' . $post_type, __('text', 'plugin-dir-name'), __('text', 'plugin-dir-name'), 'edit_posts', 'text_' . $post_type, array(&$this, 'text_list_admin'));
add_action( "admi... | <http://codex.wordpress.org/Plugin_API/Action_Reference/admin_print_scripts> echos inline javascript in all admin pages header but <http://codex.wordpress.org/Plugin_API/Action_Reference/admin_print_scripts-%28hookname%29> echos inline javascript in specific admin page header passed as second parameter. |
113,156 | <p>I'm using Woocommerce for a 1800+ product e-shop. Woocommerce comes with a built-in PrettyPhoto lightbox plugin. By default it loads the original Wordpress image size when you click to zoom the image in the lightbox.</p>
<p>Woocommerce calls for this original image in the template 'product-image.php'. I can modify ... | [
{
"answer_id": 113155,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/admin_print_scripts\" rel=\"nofollow\">ht... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28356/"
] | I'm using Woocommerce for a 1800+ product e-shop. Woocommerce comes with a built-in PrettyPhoto lightbox plugin. By default it loads the original Wordpress image size when you click to zoom the image in the lightbox.
Woocommerce calls for this original image in the template 'product-image.php'. I can modify that one. ... | <http://codex.wordpress.org/Plugin_API/Action_Reference/admin_print_scripts> echos inline javascript in all admin pages header but <http://codex.wordpress.org/Plugin_API/Action_Reference/admin_print_scripts-%28hookname%29> echos inline javascript in specific admin page header passed as second parameter. |
113,175 | <p>I have a wordpress site and I want to be able to completely change a page that is displayed based on the browser size in my Custom CSS, so that if it is over 1500 pixels it loads a completely different page. Don't ask why it has to be this way, CSS syling does not do what I need as it's a complicated gallery that re... | [
{
"answer_id": 113178,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function my_styles() {\n // REGISTER MULTIPLE STYLESHEETS TO BE USED LATER USING wp_enqueue_sty... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37697/"
] | I have a wordpress site and I want to be able to completely change a page that is displayed based on the browser size in my Custom CSS, so that if it is over 1500 pixels it loads a completely different page. Don't ask why it has to be this way, CSS syling does not do what I need as it's a complicated gallery that requi... | Two options.
The first would be as you said to determine the browser size using javascript. Then have your code do something where it changes the link if the browser us either above or below a certain size.
The second, and this may be your preferred method, would be to use css. If your theme has the body tag written ... |
113,181 | <p>I want to add a new endpoint to the author page, so that the URL looks like this:</p>
<blockquote>
<p><a href="http://example.com/writer/username/articles" rel="nofollow">http://example.com/writer/username/articles</a></p>
</blockquote>
<p>So far, I have:</p>
<ul>
<li>Changed the author base</li>
<li>Added a re... | [
{
"answer_id": 113205,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 3,
"selected": true,
"text": "<p>Your code should works. The line:</p>\n\n<pre><code>include (get_template_directory_uri() . '/articles.php');\... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24181/"
] | I want to add a new endpoint to the author page, so that the URL looks like this:
>
> <http://example.com/writer/username/articles>
>
>
>
So far, I have:
* Changed the author base
* Added a rewrite rule
* Setup the query\_vars
* Added the endpoint
* Used template\_redirect to use my template
Result: 404 Page No... | Your code should works. The line:
```
include (get_template_directory_uri() . '/articles.php');
```
Needs to have allow\_url\_include=1 in the server configration because you are trying to include a file via http. Can you check this?
You must know also that template\_redirect should be use for a real redirect, a `i... |
113,185 | <pre><code> query posts
if posts exist
then begin the loop
if post is even: <h1>title</h1><p>content</p>
if post is odd: <div>its image</div>
</code></pre>
<p>this is what i'm trying to get, a different output for odd/even posts: for even posts w... | [
{
"answer_id": 113192,
"author": "Pothi Kalimuthu",
"author_id": 9584,
"author_profile": "https://wordpress.stackexchange.com/users/9584",
"pm_score": 1,
"selected": false,
"text": "<p>You can have a new variable to count the number of posts, then increase it inside the <em>while loop</e... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36820/"
] | ```
query posts
if posts exist
then begin the loop
if post is even: <h1>title</h1><p>content</p>
if post is odd: <div>its image</div>
```
this is what i'm trying to get, a different output for odd/even posts: for even posts we will show the title and the content while for odd pos... | You don't need a new variable for counting posts, WordPress has one already in `$wp_query->current_post`.
```
<?php while (have_posts()): the_post() ?>
<?php if ($wp_query->current_post % 2 == 0): ?>
even
<?php else: ?>
odd
<?php endif ?>
<?php endwhile ?>
```
If you use a custom `WP_Quer... |
113,201 | <p>I would like to stop all email functionality in my wordpress installation.</p>
<p>Is this possible with a global flag? </p>
<p>or maybe by forbidding this installation to use the php <code>mail</code> function at all in htaccess?</p>
| [
{
"answer_id": 113192,
"author": "Pothi Kalimuthu",
"author_id": 9584,
"author_profile": "https://wordpress.stackexchange.com/users/9584",
"pm_score": 1,
"selected": false,
"text": "<p>You can have a new variable to count the number of posts, then increase it inside the <em>while loop</e... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37700/"
] | I would like to stop all email functionality in my wordpress installation.
Is this possible with a global flag?
or maybe by forbidding this installation to use the php `mail` function at all in htaccess? | You don't need a new variable for counting posts, WordPress has one already in `$wp_query->current_post`.
```
<?php while (have_posts()): the_post() ?>
<?php if ($wp_query->current_post % 2 == 0): ?>
even
<?php else: ?>
odd
<?php endif ?>
<?php endwhile ?>
```
If you use a custom `WP_Quer... |
113,226 | <p>I have created Custom Post type called "places"</p>
<p>For that I created Custom Taxonomy Category called "Music".</p>
<p>Here is the code:</p>
<pre><code>add_action( 'init', 'register_taxonomy_music' );
function register_taxonomy_music() {
$labels = array(
'name' => _x( 'Music', 'music' ),
'singula... | [
{
"answer_id": 113230,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 3,
"selected": true,
"text": "<p>you can get terms in single post type template by using <code>wp_get_post_terms();</code> inside loop</p>\n\n<pre>... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37664/"
] | I have created Custom Post type called "places"
For that I created Custom Taxonomy Category called "Music".
Here is the code:
```
add_action( 'init', 'register_taxonomy_music' );
function register_taxonomy_music() {
$labels = array(
'name' => _x( 'Music', 'music' ),
'singular_name' => _x( 'Music', 'music'... | you can get terms in single post type template by using `wp_get_post_terms();` inside loop
```
<?php $terms = wp_get_post_terms($post->ID, 'music');
if ($terms) {
$out = array();
foreach ($terms as $term) {
$out[] = '<a class="' .$term->slug .'" href="' .get_term_link( $term->slug, 'music') .'">' .$ter... |
113,227 | <p>good day<br /></p>
<p>I found a code that works, but it creates several posts of the same name, do not want that, he wanted to create only once post_type if the value is 'x', but he is creating a 'x' every time updates , how do I create it only once this post_type?
<br /><br />
<strong>My Code</strong>: </p>
<pre>... | [
{
"answer_id": 113275,
"author": "Jake",
"author_id": 11966,
"author_profile": "https://wordpress.stackexchange.com/users/11966",
"pm_score": 0,
"selected": false,
"text": "<ol>\n<li>Create a post_type named \"Products\"</li>\n<li>Create a post_type named \"Suppliers\"</li>\n<li>In \"Cus... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32355/"
] | good day
I found a code that works, but it creates several posts of the same name, do not want that, he wanted to create only once post\_type if the value is 'x', but he is creating a 'x' every time updates , how do I create it only once this post\_type?
**My Code**:
```
<?php
wp_insert_post( array(
... | Before inserting check if post exists:
```
$exists = get_page_by_title( get_field('fornecedor'), OBJECT, 'fornecedores');
if ( empty( $exists ) ) {
wp_insert_post( array(
'post_status' => 'publish',
'post_type' => 'fornecedores', // post_type which is created posting
'post_title' => get_field('fornecedo... |
113,233 | <p>The newest version of Bootstrap (v3.0) adds a new <strong>List Group</strong> component which has the following structure:</p>
<pre><code><ul class="list-group">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class... | [
{
"answer_id": 113456,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 1,
"selected": false,
"text": "<p>what about creating a seperate sidebar for this widget and adding class using <code>register_sidebar</co... | 2013/09/06 | [
"https://wordpress.stackexchange.com/questions/113233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12116/"
] | The newest version of Bootstrap (v3.0) adds a new **List Group** component which has the following structure:
```
<ul class="list-group">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<li class="list-gr... | **Update: 12/19/15** :
[Here's a plugin on Github](https://github.com/Wordpress-Development/wordpress-widgets-bootstrapped) that I developed (using the method in answer I provided below) adding support for changing all widget to bootstrap components/styling.
---
[` will return a `WP_Error` object if the term does not exist, you could try:
```
$termchildren = get_term_children( $taxID, $taxType );
echo '<ul>';
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxType );
$term_link = get_term_link( $term->name, $taxType );
... |
113,314 | <p>I am trying to write a plugin. I have added an extra field in a registration form using the plugin successfully. I would like to check whether the value in the extra field matches any username already registered.</p>
<p>When I try to validate using the predefined usermeta functions. I get the below errors:</p>
<pr... | [
{
"answer_id": 113327,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Please look at the last two lines of code. I am trying to print the id of the user. ... | 2013/09/07 | [
"https://wordpress.stackexchange.com/questions/113314",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37731/"
] | I am trying to write a plugin. I have added an extra field in a registration form using the plugin successfully. I would like to check whether the value in the extra field matches any username already registered.
When I try to validate using the predefined usermeta functions. I get the below errors:
```
require( 'C:\... | >
> Please look at the last two lines of code. I am trying to print the id of the user. It works when used in the theme files but not inside the plugin.
>
>
>
```
//Test Usermeta
$user = get_userdatabylogin('vijay');
echo $user->ID; // prints the id of the user;
```
In PHP, you cannot (normally) execute a user ... |
113,323 | <p>How to change space (-) sign to plus (+) sign in clean URL WordPress?</p>
<p>Like:</p>
<p><code>http://www.whitelotuscorporation.co.in/anax_wp/about-us/</code></p>
<p>to:</p>
<p><code>http://www.whitelotuscorporation.co.in/anax_wp/about+us/</code></p>
<p>You can see where the change need to be done— <code... | [
{
"answer_id": 117451,
"author": "rohmann",
"author_id": 39230,
"author_profile": "https://wordpress.stackexchange.com/users/39230",
"pm_score": 1,
"selected": false,
"text": "<p>This isn't possible without modifying a core file. The function WordPress uses for this is called <code>sanit... | 2013/09/07 | [
"https://wordpress.stackexchange.com/questions/113323",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37734/"
] | How to change space (-) sign to plus (+) sign in clean URL WordPress?
Like:
`http://www.whitelotuscorporation.co.in/anax_wp/about-us/`
to:
`http://www.whitelotuscorporation.co.in/anax_wp/about+us/`
You can see where the change need to be done— `about+us` instead of `about-us` in the URL. | This isn't possible without modifying a core file. The function WordPress uses for this is called `sanitize_title_with_dashes` You can find it in wp-includes/formatting.php on
It doesn't offer any filters, so you will need to make a change to this line:
```
$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%... |
113,326 | <p>I have been looking at <a href="http://codex.wordpress.org/Function_Reference/get_current_screen" rel="nofollow"><code>get_current_screen();</code></a>. I have seen there is also a global <a href="http://core.trac.wordpress.org/browser/tags/3.6/wp-admin/includes/screen.php#L182" rel="nofollow"><code>$current_screen;... | [
{
"answer_id": 113332,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>In your example, there is currently no difference. You get the same object, if there is one. Try it:</p>\n\n<pre><code... | 2013/09/07 | [
"https://wordpress.stackexchange.com/questions/113326",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17937/"
] | I have been looking at [`get_current_screen();`](http://codex.wordpress.org/Function_Reference/get_current_screen). I have seen there is also a global [`$current_screen;`](http://core.trac.wordpress.org/browser/tags/3.6/wp-admin/includes/screen.php#L182) that I could use.
Here are two examples:
```
// Using function
... | In your example, there is currently no difference. You get the same object, if there is one. Try it:
```
global $current_screen;
$current_screen->foo = 1;
$screen = get_current_screen();
$screen->foo = 2;
echo '$current_screen->foo: ' . $current_screen->foo; // 2!
```
The simple reason: objects are not passed as a... |
113,345 | <p>I cant seem to get my custom Metaboxes to display paragraphs. Here is my code:</p>
<p><strong>page.php</strong></p>
<pre><code><?php // Custom Excerpt
$custom_metabox = get_post_meta($post->ID,'_custom_meta',TRUE);
if($custom_metabox['child-subexcerpt']!=false) {
echo $custom_metabox['child-subexcerpt... | [
{
"answer_id": 113332,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>In your example, there is currently no difference. You get the same object, if there is one. Try it:</p>\n\n<pre><code... | 2013/09/07 | [
"https://wordpress.stackexchange.com/questions/113345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37441/"
] | I cant seem to get my custom Metaboxes to display paragraphs. Here is my code:
**page.php**
```
<?php // Custom Excerpt
$custom_metabox = get_post_meta($post->ID,'_custom_meta',TRUE);
if($custom_metabox['child-subexcerpt']!=false) {
echo $custom_metabox['child-subexcerpt'];
} ?>
```
**functions.php**
```
... | In your example, there is currently no difference. You get the same object, if there is one. Try it:
```
global $current_screen;
$current_screen->foo = 1;
$screen = get_current_screen();
$screen->foo = 2;
echo '$current_screen->foo: ' . $current_screen->foo; // 2!
```
The simple reason: objects are not passed as a... |
113,350 | <p>So I created a transient object that used <code>get_posts()</code> to get a series of posts based on some argument. Well the transient was stored - it was created - YAY - now I tried to write this loop:</p>
<pre><code>public function transient_loop($transient_name){
global $post;
if(false !== get_transient(... | [
{
"answer_id": 113332,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>In your example, there is currently no difference. You get the same object, if there is one. Try it:</p>\n\n<pre><code... | 2013/09/07 | [
"https://wordpress.stackexchange.com/questions/113350",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27670/"
] | So I created a transient object that used `get_posts()` to get a series of posts based on some argument. Well the transient was stored - it was created - YAY - now I tried to write this loop:
```
public function transient_loop($transient_name){
global $post;
if(false !== get_transient($transient_name)){
... | In your example, there is currently no difference. You get the same object, if there is one. Try it:
```
global $current_screen;
$current_screen->foo = 1;
$screen = get_current_screen();
$screen->foo = 2;
echo '$current_screen->foo: ' . $current_screen->foo; // 2!
```
The simple reason: objects are not passed as a... |
113,352 | <p>As the home page of my blog I've a static page.
There I want to show the navigation of the site.</p>
<p>Category1</p>
<ul>
<li>Sub-Category1
<ul>
<li>tag1, tag2, tag3</li>
</ul></li>
</ul>
<p>Category1</p>
<ul>
<li>Sub-Category2
<ul>
<li>tag1, tag2, tag3</li>
</ul></li>
</ul>
<p>Category2</p>
<ul>
<li>Sub-Cate... | [
{
"answer_id": 113332,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>In your example, there is currently no difference. You get the same object, if there is one. Try it:</p>\n\n<pre><code... | 2013/09/07 | [
"https://wordpress.stackexchange.com/questions/113352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37350/"
] | As the home page of my blog I've a static page.
There I want to show the navigation of the site.
Category1
* Sub-Category1
+ tag1, tag2, tag3
Category1
* Sub-Category2
+ tag1, tag2, tag3
Category2
* Sub-Category1
+ tag1, tag2, tag3
Category2
* Sub-Category2
+ tag1, tag2, tag3
All the above words are hyperl... | In your example, there is currently no difference. You get the same object, if there is one. Try it:
```
global $current_screen;
$current_screen->foo = 1;
$screen = get_current_screen();
$screen->foo = 2;
echo '$current_screen->foo: ' . $current_screen->foo; // 2!
```
The simple reason: objects are not passed as a... |
113,361 | <p><a href="http://kimberlygenevieve.com/blog/" rel="nofollow">live site.</a></p>
<p>I'm using wp_nav_menu called "blog-nav". It's displaying ok, however I'd like to have it horizontally oriented and with sub-menu drop downs(all lower cased items should be in the drop down portion). I've searched around various posts ... | [
{
"answer_id": 113332,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>In your example, there is currently no difference. You get the same object, if there is one. Try it:</p>\n\n<pre><code... | 2013/09/07 | [
"https://wordpress.stackexchange.com/questions/113361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | [live site.](http://kimberlygenevieve.com/blog/)
I'm using wp\_nav\_menu called "blog-nav". It's displaying ok, however I'd like to have it horizontally oriented and with sub-menu drop downs(all lower cased items should be in the drop down portion). I've searched around various posts here, alistapart.com, etc but noth... | In your example, there is currently no difference. You get the same object, if there is one. Try it:
```
global $current_screen;
$current_screen->foo = 1;
$screen = get_current_screen();
$screen->foo = 2;
echo '$current_screen->foo: ' . $current_screen->foo; // 2!
```
The simple reason: objects are not passed as a... |
113,368 | <p>i have a custom plugin and i want the link to the plugin be accessible in the <strong>admin menu bar</strong> of the <code>wp-admin</code></p>
<p>right now, im using below code. but the link to this shows under my settings. what hook should i replace with the <code>add_option_page</code>?</p>
<pre><code>function c... | [
{
"answer_id": 113373,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 2,
"selected": true,
"text": "<p>if you want to add a top level menu page then you need to use <code>add_menu_page()</code> function more details o... | 2013/09/08 | [
"https://wordpress.stackexchange.com/questions/113368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25549/"
] | i have a custom plugin and i want the link to the plugin be accessible in the **admin menu bar** of the `wp-admin`
right now, im using below code. but the link to this shows under my settings. what hook should i replace with the `add_option_page`?
```
function custom_plugin() {
add_options_page("my plugin", "plug... | if you want to add a top level menu page then you need to use `add_menu_page()` function more details on [codex](http://codex.wordpress.org/Function_Reference/add_menu_page)
```
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page(){
add_menu_page( 'my plugin', 'plugin... |
113,371 | <p>Hi can anyone explain me about this?</p>
<pre><code>wp_localize_script( 'jquery', 'ZillaShortcodes', array('plugin_folder' => WP_PLUGIN_URL .'/zilla-shortcodes') );
</code></pre>
| [
{
"answer_id": 113375,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>You can get more information about <a href=\"http://codex.wordpress.org/Function_Reference/wp_localize_sc... | 2013/09/08 | [
"https://wordpress.stackexchange.com/questions/113371",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30937/"
] | Hi can anyone explain me about this?
```
wp_localize_script( 'jquery', 'ZillaShortcodes', array('plugin_folder' => WP_PLUGIN_URL .'/zilla-shortcodes') );
``` | `wp_localize_scripts` writes content to the page in the form of a [Javascript object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects) that can be accesses by other Javascript that runs on the page. The point is to be able to pass dynamic data to the executing Javascript without havin... |
113,377 | <p>I have a Dropdown Categories .. </p>
<pre><code><?php wp_dropdown_categories('taxonomy=faenas_combenef_category&hide_empty=0&orderby=name&order=asc&name=location') ?>
</code></pre>
<p>And my post Process... for tax</p>
<pre><code>if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_... | [
{
"answer_id": 113378,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 1,
"selected": false,
"text": "<p>I think you have used wrong tax_input parameter value for <a href=\"http://codex.wordpress.org/Function_R... | 2013/09/08 | [
"https://wordpress.stackexchange.com/questions/113377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37754/"
] | I have a Dropdown Categories ..
```
<?php wp_dropdown_categories('taxonomy=faenas_combenef_category&hide_empty=0&orderby=name&order=asc&name=location') ?>
```
And my post Process... for tax
```
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) {
$title = trim($_POST['title']);
$content ... | I think you have used wrong tax\_input parameter value for [wp\_insert\_post()](http://codex.wordpress.org/Function_Reference/wp_insert_post) function it should be array like this
```
array( 'taxonomy_name' => array( 'term', 'term2', 'term3' ) )
```
as shown in the following code
```
$my_post = array(
'p... |
113,382 | <p>I've been searching for some WP specific way to detect any referrer. Have an idea?
I know how to do that in PHP but I just want to know if there's some WP function to do that?</p>
<p><strong>EDIT:</strong> here is what I 'm trying to test =></p>
<pre><code>$referer = wp_get_referer();
if ( strpos($referer ,'http:... | [
{
"answer_id": 113383,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 2,
"selected": false,
"text": "<p>You can get it using <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_referer\" rel=\"nofol... | 2013/09/08 | [
"https://wordpress.stackexchange.com/questions/113382",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31376/"
] | I've been searching for some WP specific way to detect any referrer. Have an idea?
I know how to do that in PHP but I just want to know if there's some WP function to do that?
**EDIT:** here is what I 'm trying to test =>
```
$referer = wp_get_referer();
if ( strpos($referer ,'http://wordpress.org') !== false ) echo... | The best way to check the referrer will depends of what are you trying to do. You can use [wp\_get\_referer()](http://codex.wordpress.org/Function_Reference/wp_get_referer) or [wp\_get\_original\_referer()](http://codex.wordpress.org/Function_Reference/wp_get_original_referer), but if you want to check the referer for ... |
113,391 | <p>Is it enough to just create a child-theme - let's say technically without adding anything else but the bare minimum <code>style.css</code> - to have the translation of the parent-theme being used automatically for the child-theme as well?</p>
<p><em><code>child-theme/style.css</code></em></p>
<pre><code>/**
* The... | [
{
"answer_id": 113396,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n <p>Is it enough to just create a child-theme - let's say technically without adding anything else but... | 2013/09/08 | [
"https://wordpress.stackexchange.com/questions/113391",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/178/"
] | Is it enough to just create a child-theme - let's say technically without adding anything else but the bare minimum `style.css` - to have the translation of the parent-theme being used automatically for the child-theme as well?
*`child-theme/style.css`*
```
/**
* Theme Name: Child-Theme Child
* Theme URI: ... | >
> Is it enough to just create a child-theme - let's say technically without adding anything else but the bare minimum style.css - to have the translation of the parent-theme being used automatically for the child-theme as well?
>
>
>
Basically, the answer is *NO*, ... ***but***... there's an option:
Add a mu-pl... |
113,416 | <p>Captions in wordpress do not support nested shortcodes at the moment (<code>v3.6</code>). So, If I do write</p>
<pre><code>[caption]<img src=""> I love my [city][/caption]
</code></pre>
<p>Where city is suppose to be processed but it does not. <strong>How do I fix this?</strong></p>
<p>Ticket: <a href="http... | [
{
"answer_id": 113417,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 2,
"selected": false,
"text": "<p>Using latest function <code>has_shortcode()</code> introduced on <code>v3.6</code></p>\n\n<pre><code>add_filter( ... | 2013/09/08 | [
"https://wordpress.stackexchange.com/questions/113416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | Captions in wordpress do not support nested shortcodes at the moment (`v3.6`). So, If I do write
```
[caption]<img src=""> I love my [city][/caption]
```
Where city is suppose to be processed but it does not. **How do I fix this?**
Ticket: [#24990](https://core.trac.wordpress.org/ticket/24990) | There is a [hook inside the caption shortcode](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/media.php#L639) that will allow you to hijack the whole thing. Most of the following is copied from the Core `img_caption_shortcode` function.
```
function nested_img_caption_shortcode($nada, $attr, $content = nu... |
113,444 | <p>Insert post thumbnail with '<strong>wp_insert_post</strong>', i'm trying this code but does not work, the field '<strong>get_field('imagem_do_produto')</strong> returns the url of the image, why not work?</p>
<pre><code><?php $exists = get_page_by_title( get_field('fornecedor'), OBJECT, 'fornecedores');
if(e... | [
{
"answer_id": 113445,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": true,
"text": "<p>To set a thumbnail for product you can't pass the argument <code>post_thumbnail</code> to <code>wp_insert_post... | 2013/09/08 | [
"https://wordpress.stackexchange.com/questions/113444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32355/"
] | Insert post thumbnail with '**wp\_insert\_post**', i'm trying this code but does not work, the field '**get\_field('imagem\_do\_produto')** returns the url of the image, why not work?
```
<?php $exists = get_page_by_title( get_field('fornecedor'), OBJECT, 'fornecedores');
if(empty($exists)){
$insert_post =... | To set a thumbnail for product you can't pass the argument `post_thumbnail` to `wp_insert_post` it does nothing.
The right way is to use the wp function [`set_post_thumbnail`](http://codex.wordpress.org/Function_Reference/set_post_thumbnail). Problem is that to use this function you need the ID of the image, not the u... |
113,470 | <p>I have two custom post types:</p>
<ul>
<li>Events</li>
<li>Businesses</li>
</ul>
<p>I have a new taxonomy that both these CTP's share:</p>
<ul>
<li>Locations</li>
</ul>
<p>If I go to "domain.com/events/" I see an archive of all the events, and if I go to "domain.com/businesses/" I see an archive of all the busi... | [
{
"answer_id": 113671,
"author": "Richard Howarth",
"author_id": 23984,
"author_profile": "https://wordpress.stackexchange.com/users/23984",
"pm_score": 0,
"selected": false,
"text": "<p>You can specify the slug to use in the args when calling the register_taxonomy function by using 'rew... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113470",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14396/"
] | I have two custom post types:
* Events
* Businesses
I have a new taxonomy that both these CTP's share:
* Locations
If I go to "domain.com/events/" I see an archive of all the events, and if I go to "domain.com/businesses/" I see an archive of all the businesses. So far, so good.
If I go to "domain.com/locations/" ... | You'll have to add some new rewrite rules, thankfully WordPress makes it fairly straightforward using a few function calls.
```
// use the init action to modify rewrite rules
add_action( 'init', function() {
global $wp_rewrite;
// add rewrite tag for the post type
// - %posttype% is a new tag that will be... |
113,473 | <p>I created a custom post type ("Portfolio") and I can create the posts perfectly fine. The problem is when I go to view the item, it gives me a 404 error.</p>
<p><a href="http://www.animavivo.com/portfolio/lala-1/" rel="nofollow">Here is the portfolio item</a> </p>
<p>Here is my code registering the custom post typ... | [
{
"answer_id": 113475,
"author": "hariprasad",
"author_id": 17931,
"author_profile": "https://wordpress.stackexchange.com/users/17931",
"pm_score": 4,
"selected": true,
"text": "<p>Do the following things and try.</p>\n\n<ol>\n<li>Flush rewrite rules.(Check the link <a href=\"http://code... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113473",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37786/"
] | I created a custom post type ("Portfolio") and I can create the posts perfectly fine. The problem is when I go to view the item, it gives me a 404 error.
[Here is the portfolio item](http://www.animavivo.com/portfolio/lala-1/)
Here is my code registering the custom post type:
```
add_action( 'init', 'create_post_ty... | Do the following things and try.
1. Flush rewrite rules.(Check the link [enter link description here](http://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation)).
2. Update your permalink. |
113,481 | <p>I would like some advice on how to improve the code I use for allowing people to comment posts.</p>
<p>Users can only submit a comment if they are connected with Facebook.
I started developping this feature directly in the comments.php template. It works but there is another feature which permit people to publish a... | [
{
"answer_id": 113485,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": true,
"text": "<blockquote>\n <p>or should I create a plugin ? if it's the case, why ?</p>\n</blockquote>\n\n<p>Yes you should: Sepa... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113481",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23524/"
] | I would like some advice on how to improve the code I use for allowing people to comment posts.
Users can only submit a comment if they are connected with Facebook.
I started developping this feature directly in the comments.php template. It works but there is another feature which permit people to publish a message o... | >
> or should I create a plugin ? if it's the case, why ?
>
>
>
Yes you should: Separation of concerns. A theme is the *view* of the application. As the facebook functionality is part of your application, it belongs into a plugin.
You have one large benefit from moving stuff into plugins: If you exchange your the... |
113,482 | <p>I just want to add a class for the active page in the wp_list_pages().Is it possible?
If so can I provide a particular class for a active page.
Here is my code for listing the parent page and its sub page.</p>
<pre><code> <?php
$output = wp_list_pages('echo=0&depth=1&title_li= &sort_column... | [
{
"answer_id": 113484,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>As <a href=\"https://github.com/WordPress/WordPress/blob/3.6/wp-includes/post-template.php#L821\" rel=\"nofollow n... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37788/"
] | I just want to add a class for the active page in the wp\_list\_pages().Is it possible?
If so can I provide a particular class for a active page.
Here is my code for listing the parent page and its sub page.
```
<?php
$output = wp_list_pages('echo=0&depth=1&title_li= &sort_column=menu_order' );
if (is_page( ))... | Problem solved..
I just add the css like as follows and it solve the my problem.
```
.page-menu ul li.current_page_item a{
background-color:#445C1C;
}
```
For adding the class for parent page I have used the following code
```
<li><a href="<?php echo get_permalink( $post->post_parent ); ?>" <?php if(is_pa... |
113,491 | <p>So I have multiple custom parameters in the url, and at some point when the query reaches 3 parameters (e.g. <code>index.php?post_type=foo&<param-1>=<val-1>&<param-2>=<val-2>&<param-3>=<val-3></code>) there can be either one post or none. Instead of displaying archive ... | [
{
"answer_id": 113494,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>Here is a rough filter:</p>\n\n<pre><code>add_filter(\n 'template_include',\n function($template) {\n gl... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37142/"
] | So I have multiple custom parameters in the url, and at some point when the query reaches 3 parameters (e.g. `index.php?post_type=foo&<param-1>=<val-1>&<param-2>=<val-2>&<param-3>=<val-3>`) there can be either one post or none. Instead of displaying archive (`archive-foo.php`) with this one post, I want wordpress to di... | Here is a rough filter:
```
add_filter(
'template_include',
function($template) {
global $wp_query;
if (1 == $wp_query->found_posts) {
global $wp_query;
$type = $wp_query->get('post_type') ?: false;
$template_type = $type ? 'single-' . $type. '.php' : 'single.php';
if ( locate_templ... |