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 |
|---|---|---|---|---|---|---|
116,305 | <p>After mapping the domains to each WP MU blog I'm having to separately login to each of the blogs and from what I've read online it's not possible or not secure to keep a user logged in on different domains if you're using cookies.
<br/><br/>
Is it possible to still have each WP blog mapped (wpmu1.hubdomain.com => ww... | [
{
"answer_id": 116287,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 4,
"selected": true,
"text": "<p>Finally, I wrote some code and it worked very well.</p>\n\n<p>I hope it helps.</p>\n\n<p>Put this in your <c... | 2013/10/01 | [
"https://wordpress.stackexchange.com/questions/116305",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38836/"
] | After mapping the domains to each WP MU blog I'm having to separately login to each of the blogs and from what I've read online it's not possible or not secure to keep a user logged in on different domains if you're using cookies.
Is it possible to still have each WP blog mapped (wpmu1.hubdomain.com => www.newdomain.c... | Finally, I wrote some code and it worked very well.
I hope it helps.
Put this in your `functions.php` file
```
//remove sitename from email subject
add_filter('wp_mail', 'email_subject_remove_sitename');
function email_subject_remove_sitename($email) {
$blogname = wp_specialchars_decode(get_option('blogname'), ENT... |
116,310 | <p>I am about to migrate WordPress Installation from One Domain to another which are under the same host and have common cpanel. Besides the first step of backing up and moving the WP filesystem, can we just use the same database without exporting/importing it via PHPmyAdmin ?</p>
| [
{
"answer_id": 116287,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 4,
"selected": true,
"text": "<p>Finally, I wrote some code and it worked very well.</p>\n\n<p>I hope it helps.</p>\n\n<p>Put this in your <c... | 2013/10/01 | [
"https://wordpress.stackexchange.com/questions/116310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26393/"
] | I am about to migrate WordPress Installation from One Domain to another which are under the same host and have common cpanel. Besides the first step of backing up and moving the WP filesystem, can we just use the same database without exporting/importing it via PHPmyAdmin ? | Finally, I wrote some code and it worked very well.
I hope it helps.
Put this in your `functions.php` file
```
//remove sitename from email subject
add_filter('wp_mail', 'email_subject_remove_sitename');
function email_subject_remove_sitename($email) {
$blogname = wp_specialchars_decode(get_option('blogname'), ENT... |
116,316 | <p>Let's say this was in my plugin:</p>
<pre><code>class pluginslug_foo {
public function bar() {
//stuff
}
}
</code></pre>
<p>and I wanted to make the method bar available for use outside of the plugin, for instance in a theme file so it could be called with <code>pluginslug_bar();</code>.</p>
<p>I... | [
{
"answer_id": 116317,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>If your aren’t very familiar with PHP, use simple actions and filters in your theme, and register callbacks for those... | 2013/10/01 | [
"https://wordpress.stackexchange.com/questions/116316",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25300/"
] | Let's say this was in my plugin:
```
class pluginslug_foo {
public function bar() {
//stuff
}
}
```
and I wanted to make the method bar available for use outside of the plugin, for instance in a theme file so it could be called with `pluginslug_bar();`.
I tried:
```
function pluginslug_get_foo() {... | An alternative way is to use static class methods in plugins, and optionally write functions as alias:
in Plugin:
----------
```
class Pluginslug_Foo {
static $foo = 'Bar!';
public static function bar() {
return self::$foo;
}
}
if ( ! function_exists( 'pluginslug_bar' ) ) {
function plugins... |
116,347 | <p>I am trying to add h1,h2 .. in the TinyMCE Styles Dropdown with my other html elements. I have tried the following code, but the problem is it only adds styles if I use <code>span</code> as 'block' value. If I use div, h3, h4, the code doesn't add anything</p>
<p>I have searched a lot for the solution but haven't ... | [
{
"answer_id": 116317,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>If your aren’t very familiar with PHP, use simple actions and filters in your theme, and register callbacks for those... | 2013/10/01 | [
"https://wordpress.stackexchange.com/questions/116347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30913/"
] | I am trying to add h1,h2 .. in the TinyMCE Styles Dropdown with my other html elements. I have tried the following code, but the problem is it only adds styles if I use `span` as 'block' value. If I use div, h3, h4, the code doesn't add anything
I have searched a lot for the solution but haven't found anything helpful... | An alternative way is to use static class methods in plugins, and optionally write functions as alias:
in Plugin:
----------
```
class Pluginslug_Foo {
static $foo = 'Bar!';
public static function bar() {
return self::$foo;
}
}
if ( ! function_exists( 'pluginslug_bar' ) ) {
function plugins... |
116,355 | <p>I have a blog, with Duena Theme, and when I write is all ok.
The problem is when I publish that text, and the margins of the paragraphs split my words.</p>
<p>For example</p>
<p>The horse is a very wil<br>
d animal and he is eatin<br>
g carrots, salads and lot<br>
s of....</p>
<p>I dont want it to be like that, I... | [
{
"answer_id": 116357,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 1,
"selected": false,
"text": "<p>This can be done with css. Look for <code>word-wrap</code> and change it to below:</p>\n\n<pre><code>.... | 2013/10/01 | [
"https://wordpress.stackexchange.com/questions/116355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38857/"
] | I have a blog, with Duena Theme, and when I write is all ok.
The problem is when I publish that text, and the margins of the paragraphs split my words.
For example
The horse is a very wil
d animal and he is eatin
g carrots, salads and lot
s of....
I dont want it to be like that, I don t want my words splitt... | This can be done with css. Look for `word-wrap` and change it to below:
```
.class-name {
word-wrap: normal;
-webkit-hyphens: none;
-moz-hyphens: none;
hyphens: none;
}
``` |
116,372 | <p>I've been searching the internet for 6 hours now, so I decided to ask this in the forum and would appreciate every help.</p>
<p>I just want <strong>my permalink</strong> to say (e.g. portfolio, post, etc)</p>
<pre><code>http://mysite.com/?portfolio=xxxx&param=whatever
</code></pre>
<p>I need the <strong>param... | [
{
"answer_id": 116380,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>The Codex page for <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/post_link\" rel=\"nofollow\"><... | 2013/10/01 | [
"https://wordpress.stackexchange.com/questions/116372",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38860/"
] | I've been searching the internet for 6 hours now, so I decided to ask this in the forum and would appreciate every help.
I just want **my permalink** to say (e.g. portfolio, post, etc)
```
http://mysite.com/?portfolio=xxxx¶m=whatever
```
I need the **param**, because the post itself defines the "whatever" param... | The Codex page for [`post_link`](http://codex.wordpress.org/Plugin_API/Filter_Reference/post_link) has an example similar to what you need. For custom post types, there's also the [`post_type_link`](https://codex.wordpress.org/Plugin_API/Filter_Reference/post_type_link) filter.
This would go in your theme's `functions... |
116,442 | <p>I am working with a multisite setup and I have created some custom post types, which seem to work fine except when trying to view any of the post types pages on the front end, I get a white screen. After looking into the issue it seems that flush rewrite rules fixes it. The problem with this is that admins wont have... | [
{
"answer_id": 116444,
"author": "gwillie",
"author_id": 36790,
"author_profile": "https://wordpress.stackexchange.com/users/36790",
"pm_score": 0,
"selected": false,
"text": "<p>are you deploying site yourself, or are you giving a files and letting others do it. are defining <code>WP_DE... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | I am working with a multisite setup and I have created some custom post types, which seem to work fine except when trying to view any of the post types pages on the front end, I get a white screen. After looking into the issue it seems that flush rewrite rules fixes it. The problem with this is that admins wont have ac... | Ok, I was able to figure it out. While Eugene Manuilov answer was good and may work for others, it unfortunately didnt work for me. What ended working for me was adding the flush rewrite right before the closing of my last custom post type.
```
function register_cpt_attorney() {
$labels = array(
'name' =... |
116,445 | <p>I am trying to use the <a href="http://www.tinymce.com/">http://www.tinymce.com/</a> plugin to add a tinymce to my textareas in my meta boxes I have created. I've googled other ways and either I cant get it to work or didnt grasp the concept. SO this is what Im trying now -- </p>
<p>I tried creating plugin to add t... | [
{
"answer_id": 116452,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 2,
"selected": false,
"text": "<pre><code>// for pages use 'edit_page_form' as the first parameter. And see my comment below.\nadd_action( 'e... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | I am trying to use the <http://www.tinymce.com/> plugin to add a tinymce to my textareas in my meta boxes I have created. I've googled other ways and either I cant get it to work or didnt grasp the concept. SO this is what Im trying now --
I tried creating plugin to add the script to my admin dashboard --
```
add_ac... | Here's a [pastebin](http://pastebin.com/HkzarH7h) with your code included.
Get the old value of the tinyMCE
```
$meta_biography = get_post_meta( $post->ID, 'meta_biography', true );
```
Call the TinyMCE Editor
```
wp_editor( $meta_biography, 'biography', array(
'wpautop' => true,
'media_buttons' => ... |
116,463 | <p>I'm creating a child theme (My first in over 3 years) of a WooCommerce theme and I'm having some trouble with the fact that some of the layout styles are enqueued in the parent theme and I'm having to add <code>!important</code> to all the styles I want to override.</p>
<p>This is the current enqueue code in the pa... | [
{
"answer_id": 117175,
"author": "epilektric",
"author_id": 36634,
"author_profile": "https://wordpress.stackexchange.com/users/36634",
"pm_score": 1,
"selected": false,
"text": "<p>Because the Woo function is wrapped in <code>if( ! function_exists('function_name') )</code> you can overr... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116463",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33310/"
] | I'm creating a child theme (My first in over 3 years) of a WooCommerce theme and I'm having some trouble with the fact that some of the layout styles are enqueued in the parent theme and I'm having to add `!important` to all the styles I want to override.
This is the current enqueue code in the parent themes functions... | I had the same problem and epilektric's answer put me in the right path.
I am using "function" wootheme and it needs to load the parent style.css before another parent css called layout.css. So this order needs to be kept when loading the child theme's style.css.
So basically, to avoid using `!important` to override ... |
116,473 | <p>I really want to run a simple code in my template file.</p>
<p>E.g. if I put somethign like this in my page.php:</p>
<pre><code><script type="text/javascript">
jQuery(document).ready(function($) {
alert("Hello world!");
});
</script>
</code></pre>
<p>It's not working.</p>
<p>But simpl... | [
{
"answer_id": 116476,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": -1,
"selected": true,
"text": "<p>I don't think jQuery script is en-queued by default with WordPress templates. So you should place the jQuery scri... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116473",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I really want to run a simple code in my template file.
E.g. if I put somethign like this in my page.php:
```
<script type="text/javascript">
jQuery(document).ready(function($) {
alert("Hello world!");
});
</script>
```
It's not working.
But simple javascript is working:
```
<script type="text/jav... | I don't think jQuery script is en-queued by default with WordPress templates. So you should place the jQuery script in the header/footer for your code snippet to work. |
116,483 | <p>I am trying to display a list of all categories and sub-categories underneath that category, I have managed to get a list of all categories that are parents but am struggling to detect if it has children and then display them in the current loop. Here is my code at the moment:</p>
<pre><code>$args = array(
'order... | [
{
"answer_id": 116500,
"author": "SimonStaton",
"author_id": 37348,
"author_profile": "https://wordpress.stackexchange.com/users/37348",
"pm_score": 2,
"selected": true,
"text": "<p>Solved with the following:</p>\n\n<pre><code>$args = array(\n 'orderby' => 'name',\n 'parent' => 0... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116483",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37348/"
] | I am trying to display a list of all categories and sub-categories underneath that category, I have managed to get a list of all categories that are parents but am struggling to detect if it has children and then display them in the current loop. Here is my code at the moment:
```
$args = array(
'orderby' => 'name',... | Solved with the following:
```
$args = array(
'orderby' => 'name',
'parent' => 0
);
$categories = get_categories( $args );
$first = true;
foreach ($categories as $category) {
if ( $first )
{
echo '<li class="title" style="border-top: 0px;"><a href="acatalog/abovegroundpools.html">'.$category->c... |
116,499 | <p>In a simple loop, for example:</p>
<pre><code>$loop = new wp_query(array('posts_per_page' => 3));
while($loop->have_posts()) : $loop->the_post();
if(get_post_meta($post->ID, 'skip_me', true) == true){
// do something to ask for one more post,
// as we really want 3 total!
c... | [
{
"answer_id": 116503,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>You should probably <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters\"... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116499",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13676/"
] | In a simple loop, for example:
```
$loop = new wp_query(array('posts_per_page' => 3));
while($loop->have_posts()) : $loop->the_post();
if(get_post_meta($post->ID, 'skip_me', true) == true){
// do something to ask for one more post,
// as we really want 3 total!
continue;
} else {
... | You should probably [add a meta query to your `WP_Query()` args](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters):
```
$loop = new wp_query(
array(
'posts_per_page' => 3,
// Meta Query
'meta_query' => array(
array(
'key' => 'skip_me',
... |
116,511 | <p>I am not a coder, but I usually get by with Wordpress by doing my research and find my solution. I can't find what I need to do this time so I have attempted to crib together some code - what I am attempting to do is, when I am on the Category Archive, I want to add a body class of the category parent. This is what ... | [
{
"answer_id": 116512,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>Use <code>get_ancestors()</code> to get the parent terms. Here is an excerpt from my plugin <a href=\"https://gist.gi... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116511",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38919/"
] | I am not a coder, but I usually get by with Wordpress by doing my research and find my solution. I can't find what I need to do this time so I have attempted to crib together some code - what I am attempting to do is, when I am on the Category Archive, I want to add a body class of the category parent. This is what I h... | Use `get_ancestors()` to get the parent terms. Here is an excerpt from my plugin [T5 Parent Terms in body\_class](https://gist.github.com/thefuxia/2930463):
```
$ancestors = get_ancestors(
get_queried_object_id(),
get_queried_object()->taxonomy
);
if ( empty ( $ancestors ) )
{
... |
116,520 | <p>I just noticed something weird I never saw before. I'm working on a project using WP 3.6.1. This project that has two different menus (actually, three, but that's not important). I'm calling them through the <code>wp_nav_menu</code> function.</p>
<p>I've done this kind of thing quite a few times now... but today is... | [
{
"answer_id": 116524,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>You're not calling <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu\" rel=\"nofollow\"><... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116520",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16582/"
] | I just noticed something weird I never saw before. I'm working on a project using WP 3.6.1. This project that has two different menus (actually, three, but that's not important). I'm calling them through the `wp_nav_menu` function.
I've done this kind of thing quite a few times now... but today is different. Today it ... | You're not calling [`wp_nav_menu()`](http://codex.wordpress.org/Function_Reference/wp_nav_menu) correctly.
You need to pass it an args array, and declare the `theme_location` key.
I'm assuming that, since you're passing a string rather than an array, `wp_nav_menu()` doesn't recognize the parameter, and is falling bac... |
116,534 | <p>I know that using an underscore in front of a custom field name hides it from display on the front-end, e.g. <code>_custom_field_name</code>. In my experience, WordPress also prevents one from adding such a custom field on the front end.</p>
<p>Before I go spelunking around core, I wanted to ask: Is there an "easy"... | [
{
"answer_id": 116548,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 1,
"selected": false,
"text": "<p>Custom fields that begin with an underscore are hidden from the editor. This is so other methods can acces... | 2013/10/02 | [
"https://wordpress.stackexchange.com/questions/116534",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1860/"
] | I know that using an underscore in front of a custom field name hides it from display on the front-end, e.g. `_custom_field_name`. In my experience, WordPress also prevents one from adding such a custom field on the front end.
Before I go spelunking around core, I wanted to ask: Is there an "easy" way to allow `_custo... | I found the [following filter](http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/meta.php#L870), here unlocking all protected meta data:
```
add_filter( 'is_protected_meta', '__return_false' );
```
Or it can be fine tuned:
```
add_filter( 'is_protected_meta', function( $protected, $meta_key, $meta_type... |
116,569 | <p>I want to to show a specific content on the top of each post (on single page) depending of the post-type.</p>
<p>If it's <code>normal</code>, show something, if it's <code>gallery</code>, show another.</p>
<p>By now the code is like this:</p>
<pre><code><?php
if (has_post_format( 'post-format-normal' , $p... | [
{
"answer_id": 116572,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 0,
"selected": false,
"text": "<p>First of all your problem I think is <code>$postid</code> variable, where are you setting it?</p>\n\n<p>The c... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38945/"
] | I want to to show a specific content on the top of each post (on single page) depending of the post-type.
If it's `normal`, show something, if it's `gallery`, show another.
By now the code is like this:
```
<?php
if (has_post_format( 'post-format-normal' , $post_id )) {
<div class="post-image-section se... | There is no "default" post format type, though internally in core, a post that has no post format assigned is usually referred to as *standard*. So, your first conditional will return `false` using `post-format-normal` because there is no such post format - but would still return false using `post-format-standard`.
Yo... |
116,579 | <p>I created a plugin that is used on every site within my Multisite setup. Within this plugin I have an admin setting page that allows each site to set the options according to the sites needs. Each site saves its data with the <code>add_option()</code> function.</p>
<p>How do I query all the custom options values fr... | [
{
"answer_id": 116583,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_site_option\" rel=\"nofollow\">ge... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38950/"
] | I created a plugin that is used on every site within my Multisite setup. Within this plugin I have an admin setting page that allows each site to set the options according to the sites needs. Each site saves its data with the `add_option()` function.
How do I query all the custom options values from all the sites on t... | You can use [get\_site\_option()](http://codex.wordpress.org/Function_Reference/get_site_option) function to get single network-wide option.
Example :
```
$singleoption = get_site_option( 'siteurl' );
```
If you want to get all options from all sites use wp\_load\_alloptions() function.
Example :
```
$alloptions ... |
116,592 | <blockquote>
<p><strong>To all would-be close-voters:</strong> This question is not a duplicate, because I need to remove all scripts added by plugin using <code>remove_action</code>.</p>
<p>In <a href="https://wordpress.stackexchange.com/questions/116535/very-stubborn-wp-register-script-add-action-vs-remove">Very stub... | [
{
"answer_id": 116601,
"author": "Imperative Ideas",
"author_id": 28719,
"author_profile": "https://wordpress.stackexchange.com/users/28719",
"pm_score": 0,
"selected": false,
"text": "<p>Just a thought here - try moving back the priority on your action. Without the priority, it's going ... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27488/"
] | >
> **To all would-be close-voters:** This question is not a duplicate, because I need to remove all scripts added by plugin using `remove_action`.
>
>
> In [Very stubborn wp\_register\_script / add\_action vs remove](https://wordpress.stackexchange.com/questions/116535/very-stubborn-wp-register-script-add-action-vs... | An action can be removed in time that pass since it is added to it is fired. So after is added, before is fired.
You say the plugin has thiss code:
```
add_action('wp_enqueue_scripts', 'poll_scripts');
function poll_scripts() {
// code
}
```
But you don't say if this code is inside a function hooked somewhere.... |
116,616 | <p>When a user clicks the Add New Category for my custom post type of Packages I wish to create a new page with the same name as the new category at the same time. I can create a new page through code but I cannot find the right hook for my function.php to run it.</p>
<p>What I need is a hook that will run for only th... | [
{
"answer_id": 116618,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You can try out the <code>created_term</code> hook:</p>\n\n<pre><code>/**\n * Do 'stuff' when a term is create... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116616",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38969/"
] | When a user clicks the Add New Category for my custom post type of Packages I wish to create a new page with the same name as the new category at the same time. I can create a new page through code but I cannot find the right hook for my function.php to run it.
What I need is a hook that will run for only the Packages... | You can try out the `created_term` hook:
```
/**
* Do 'stuff' when a term is created in the 'country' taxonomy
* using info from the referred page
*
* @param integer $term_id
* @param integer $tt_id
* @param string $taxonomy
* @return void
*/
function custom_created_term( $term_id, $tt_id, $taxonomy )
{
$... |
116,641 | <p>I've manually setup a new table in the <code>wp-db</code> database. Where do I add the name of this table in the <code>wpdb</code> class or anywhere else?</p>
<p>I've noticed that WordPress uses queries like:
<code>$user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" );</code> where the actual ta... | [
{
"answer_id": 116642,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 1,
"selected": false,
"text": "<p>Do not modify your <code>wpdb</code> class at all! It's a bad habit. Next time when WordPress update it... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38977/"
] | I've manually setup a new table in the `wp-db` database. Where do I add the name of this table in the `wpdb` class or anywhere else?
I've noticed that WordPress uses queries like:
`$user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" );` where the actual table name isn't used.
If I were to do:
`$user_cou... | `$wpdb->tables[] = 'friends';` is the basic code you're looking for.
Please note that you'll want to test for the existence of the table in the list so you don't wind up with 100 copies of the table in the tables array, especially if there's a chance your code could be repeated within a page load.
UPDATED with exampl... |
116,656 | <p>I'm working on a fallback menu for a WordPress theme I'm working on. The main menu's <code>menu_class</code> renders a <code>ul</code> which is what I want.</p>
<p>However, if I use the menu fallback, the <code>menu_class</code> renders a <code>div</code> instead. Is there a way to make Wordpress render a <code>ul<... | [
{
"answer_id": 116657,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>First, I think you're confusing the <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu\" r... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116656",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21245/"
] | I'm working on a fallback menu for a WordPress theme I'm working on. The main menu's `menu_class` renders a `ul` which is what I want.
However, if I use the menu fallback, the `menu_class` renders a `div` instead. Is there a way to make Wordpress render a `ul` for the fallback menu instead of a `div`?
Here's my code:... | First, I think you're confusing the [`wp_nav_menu()`](http://codex.wordpress.org/Function_Reference/wp_nav_menu) args. The `'menu_class'` parameter defines the class added to the menu element, which by default is `<ul>`, as per the `'items_wrap'` parameter. The default `'menu_class'` is `'menu'`, which results in `<ul ... |
116,660 | <p>I'm using WooCommerce on a site built with Pagelines Framework. I need to have a subtitle/customisable field appear under the product name anywhere it appears in the site. As it is, WooCommerce doesn't offer that option.</p>
<p>I've tried using custom fields but WooCommerce use these too and output a bunch of stuff... | [
{
"answer_id": 116675,
"author": "pl4g4",
"author_id": 38944,
"author_profile": "https://wordpress.stackexchange.com/users/38944",
"pm_score": 2,
"selected": false,
"text": "<p>You can add an extra metabox to the product post. This meta box should have and input form so u can enter the s... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116660",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31647/"
] | I'm using WooCommerce on a site built with Pagelines Framework. I need to have a subtitle/customisable field appear under the product name anywhere it appears in the site. As it is, WooCommerce doesn't offer that option.
I've tried using custom fields but WooCommerce use these too and output a bunch of stuff I don't w... | To answer your first question, getting your `post meta` »bookauthor« this way will echo/display just that. If you are defining the variable `$id` in your code right - or you can do it like shown below.
The code should answer your second question, how to insert your second title line to the product page via the hook `w... |
116,679 | <p>I know that plugins and theme files should be kept separate but for for internal use I need to do it this way. </p>
<p>In my themes header.php file I want to include a php file which just contains html, from my plugin directory. </p>
<p>The path is basically /wp-content/plugins/my_plugin/my-html.php</p>
<p>I can'... | [
{
"answer_id": 116683,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p>If the <code>plugins/my_plugin/my-html.php</code> file is only going to output HTML, you could do it like this:... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15412/"
] | I know that plugins and theme files should be kept separate but for for internal use I need to do it this way.
In my themes header.php file I want to include a php file which just contains html, from my plugin directory.
The path is basically /wp-content/plugins/my\_plugin/my-html.php
I can't seem to figure out th... | In your main plugin file just define a constant containing the path of the plugin:
```
$pluginpath = plugin_dir_path( __FILE__ );
define('MY_AWESOME_PLUGIN_PATH', $pluginpath);
```
After that in your `header.php`:
```
include(MY_AWESOME_PLUGIN_PATH . 'html_file_name.html');
``` |
116,693 | <p>I am building a wholesale store with wordpress and woocommerce and having a strange problem with the requirement.</p>
<p>The client wants to sell the products in multiple of 6 like 6/12/18/24,
so when a user reach product page , he can select 6/12/18/24 as product quantity.</p>
<p>I have tried variation of produc... | [
{
"answer_id": 116695,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>I had to look into that problem once, but the decision at the end was to sell in packages of 8, I n... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38990/"
] | I am building a wholesale store with wordpress and woocommerce and having a strange problem with the requirement.
The client wants to sell the products in multiple of 6 like 6/12/18/24,
so when a user reach product page , he can select 6/12/18/24 as product quantity.
I have tried variation of product but the problem... | In the bleeding edge of WooCommerce 2.1 you can filter `woocommerce_quantity_input_min` and `woocommerce_quantity_input_step` directly. That should get you 6,12,18, etc. I have no idea if these filters are in WC2.0.?. Note the $product object is passed to the filter in case you don't want this to be a universal change.... |
116,702 | <p>I'm trying to output the password of a newly created user in plain text using the user_register hook as explained <a href="https://wordpress.stackexchange.com/a/66580/38991">in this answer</a>. However, upon doing a var_dump of $_POST, I don't see any password output. Can user_register actually do this?</p>
<p>If... | [
{
"answer_id": 116697,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"http://codex.wordpress.org/\" rel=\"nofollow\">wordpress codex</a> is definitely your... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116702",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38991/"
] | I'm trying to output the password of a newly created user in plain text using the user\_register hook as explained [in this answer](https://wordpress.stackexchange.com/a/66580/38991). However, upon doing a var\_dump of $\_POST, I don't see any password output. Can user\_register actually do this?
If not, might you hav... | Yes. It is an "inside the Loop" global.
>
> $page (int) The page of the post, as specified by the query var page.
>
>
> <http://codex.wordpress.org/Global_Variables>
>
>
>
It is setup and used by [`setup_postdata`](http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/query.php#L3642) which executes at... |
116,703 | <p>I have this code below:</p>
<pre><code>function get_user_fields($user, $output = true, $main_title = 'Anmäld till kurs/kurser', $course_update = false) {
if ($output === true) {
if (strlen($title)>0) {
echo '<h3>' . $main_title . '</h3>';
}
}
//Get location... | [
{
"answer_id": 116937,
"author": "Karine",
"author_id": 39090,
"author_profile": "https://wordpress.stackexchange.com/users/39090",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you can try <code>get_user_meta($user->ID, $course_field_name, true)</code> ?\nBy default, <code>get_... | 2013/10/03 | [
"https://wordpress.stackexchange.com/questions/116703",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38848/"
] | I have this code below:
```
function get_user_fields($user, $output = true, $main_title = 'Anmäld till kurs/kurser', $course_update = false) {
if ($output === true) {
if (strlen($title)>0) {
echo '<h3>' . $main_title . '</h3>';
}
}
//Get locations (course-categories taxonomy... | I finally solved this:
The first issue as that the incorrect User-object was sent to the function (Actuall just an empty string)
**Solved it by writing this:**
```
function save_user_fields($user_id) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
//Save values of checkbox-fields into ... |
116,746 | <p>I am trying to display all the content/posts assigned to a certain category.</p>
<p>I have a custom post type set up called 'Videos' and within this I have created categories called music, commercial, promo & short film. </p>
<p>Now everytime I post under the videos post type and assign it to a category I want... | [
{
"answer_id": 116937,
"author": "Karine",
"author_id": 39090,
"author_profile": "https://wordpress.stackexchange.com/users/39090",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you can try <code>get_user_meta($user->ID, $course_field_name, true)</code> ?\nBy default, <code>get_... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116746",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38592/"
] | I am trying to display all the content/posts assigned to a certain category.
I have a custom post type set up called 'Videos' and within this I have created categories called music, commercial, promo & short film.
Now everytime I post under the videos post type and assign it to a category I want to display all the c... | I finally solved this:
The first issue as that the incorrect User-object was sent to the function (Actuall just an empty string)
**Solved it by writing this:**
```
function save_user_fields($user_id) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
//Save values of checkbox-fields into ... |
116,758 | <p>I currently have videos set up as a custom post type and I have also created a custom meta box for it that allows users to enter the ID of either a youtube/vimeo video - the video is then displayed on the front end.</p>
<p>I want to re-use this meta box for another custom post type. How would I do this?</p>
<p>The... | [
{
"answer_id": 116761,
"author": "Mohit Bumb",
"author_id": 8184,
"author_profile": "https://wordpress.stackexchange.com/users/8184",
"pm_score": 0,
"selected": false,
"text": "<pre><code>add_action( 'add_meta_boxes', 'my_add_custom_box' );\n\nfunction my_add_custom_box($postType) {\n ... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116758",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38592/"
] | I currently have videos set up as a custom post type and I have also created a custom meta box for it that allows users to enter the ID of either a youtube/vimeo video - the video is then displayed on the front end.
I want to re-use this meta box for another custom post type. How would I do this?
The function for the... | Yes, you need to edit your video\_add\_box() function in order to make an array with the post type you need to show that box.
```
$postypes = array('type1', 'type2', 'type3');
foreach ( $postypes as $postype) {
add_meta_box(
'video_information',
'Video Information',
'video_information',
... |
116,764 | <p>I want to edit the following piece of code:</p>
<pre><code><?php if ( (!$theretailer_theme_options['category_listing']) || ($theretailer_theme_options['category_listing'] == 0) ) { ?>
<!-- Show only the first category-->
<?php $gbtr_product_cats = strip_tags($product->get_categorie... | [
{
"answer_id": 116770,
"author": "pl4g4",
"author_id": 38944,
"author_profile": "https://wordpress.stackexchange.com/users/38944",
"pm_score": 0,
"selected": false,
"text": "<p>You can comment out this part</p>\n\n<pre><code> <h3><a href=\"<?php the_permalink(); ?>\">... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39015/"
] | I want to edit the following piece of code:
```
<?php if ( (!$theretailer_theme_options['category_listing']) || ($theretailer_theme_options['category_listing'] == 0) ) { ?>
<!-- Show only the first category-->
<?php $gbtr_product_cats = strip_tags($product->get_categories('|||', '', '')); //Categories ... | The woocommerce function [`get_categories()`](http://docs.woothemes.com/wc-apidocs/source-class-WC_Product.html#992-1004) is declared in `abstract-wc-product.php`, because it is based on the wordpress function [`get_the_term_list()`](http://codex.wordpress.org/Function_Reference/get_the_term_list) there is no way to ge... |
116,771 | <p>I'd love to place the category description just after the main title in a span, like a subtitle.</p>
<pre><code>add_filter ('woocommerce_page_title', function ($title) {
// what should be here?
$title .= "<span class='subtitle'>{$description}</span>";
return $title;
});
</code></pre>
<p>Th... | [
{
"answer_id": 116770,
"author": "pl4g4",
"author_id": 38944,
"author_profile": "https://wordpress.stackexchange.com/users/38944",
"pm_score": 0,
"selected": false,
"text": "<p>You can comment out this part</p>\n\n<pre><code> <h3><a href=\"<?php the_permalink(); ?>\">... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37607/"
] | I'd love to place the category description just after the main title in a span, like a subtitle.
```
add_filter ('woocommerce_page_title', function ($title) {
// what should be here?
$title .= "<span class='subtitle'>{$description}</span>";
return $title;
});
```
Thanks. | The woocommerce function [`get_categories()`](http://docs.woothemes.com/wc-apidocs/source-class-WC_Product.html#992-1004) is declared in `abstract-wc-product.php`, because it is based on the wordpress function [`get_the_term_list()`](http://codex.wordpress.org/Function_Reference/get_the_term_list) there is no way to ge... |
116,778 | <p>I am building up a website for C Programming Tutorial www.programminginc.net . Now I am using a plugin to show my site under construction. What is the code used to create a website under construction setup?</p>
| [
{
"answer_id": 116782,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>The quick and dirty way to do it is to create a file named <code>.maintenance</code> at the root of the site... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116778",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39017/"
] | I am building up a website for C Programming Tutorial www.programminginc.net . Now I am using a plugin to show my site under construction. What is the code used to create a website under construction setup? | The quick and dirty way to do it is to create a file named `.maintenance` at the root of the site-- same directory as `license.txt`-- and add a bit of PHP:
```
<?php
die();
```
Of course, you can create whatever markup and messages you'd like before the `die();`, but there is very little WordPress available since [... |
116,808 | <p>I'm trying to access a second database with my wordpress system. To do this, I've attempted to follow the advice <a href="http://bavotasan.com/2011/access-another-database-in-wordpress/" rel="nofollow">found here</a> which seems to have worked for a lot of people. </p>
<p>In summary, I'm adding the following line... | [
{
"answer_id": 116810,
"author": "pl4g4",
"author_id": 38944,
"author_profile": "https://wordpress.stackexchange.com/users/38944",
"pm_score": 2,
"selected": false,
"text": "<p>try something like this </p>\n\n<pre><code>add_action('init', 'doSomething');\nfunction doSomething(){\n gl... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38991/"
] | I'm trying to access a second database with my wordpress system. To do this, I've attempted to follow the advice [found here](http://bavotasan.com/2011/access-another-database-in-wordpress/) which seems to have worked for a lot of people.
In summary, I'm adding the following line to my functions.php:
```
global $new... | When enhancing WordPress functionality, always use the theme's `functions.php` file (located, generally, in `{WP root}/wp-content/themes/{your theme}/functions.php`), or [put your code into a plugin](https://codex.wordpress.org/Writing_a_Plugin).
The rules for [hacking core code](https://wordpress.stackexchange.com/qu... |
116,809 | <p>I am trying to build a list of thumbnail images linked to their associated single content pages within the same category. So, when I am in the category of 'x' the list returns all image attachments from every post in category 'x'.</p>
<p>I have the following code in my sidebar which is brought into only the content... | [
{
"answer_id": 116816,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this, and it isn't that hard though could be a lot of work for the server. The code, a bit simpli... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116809",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28507/"
] | I am trying to build a list of thumbnail images linked to their associated single content pages within the same category. So, when I am in the category of 'x' the list returns all image attachments from every post in category 'x'.
I have the following code in my sidebar which is brought into only the content-single pa... | You can do this, and it isn't that hard though could be a lot of work for the server. The code, a bit simplified, should look something like this:
```
$cposts = wp_list_pluck($wp_query->posts,'ID');
// var_dump($cposts); // debug
$args = array(
'post_type' => 'attachment',
'post_mime_type' =>'image',
'post_statu... |
116,814 | <p>Everything in explanation is about <strong><a href="http://cdtuts.com" rel="nofollow noreferrer">CDTuts</a></strong></p>
<p>I've created a <strong>WordPress Network</strong> and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest <strong>All</strong> organized by dat... | [
{
"answer_id": 184709,
"author": "jjarolim",
"author_id": 56506,
"author_profile": "https://wordpress.stackexchange.com/users/56506",
"pm_score": 1,
"selected": false,
"text": "<p>Since wordpress multisite uses different tables for all blogs, it is very inefficient to get all recent arti... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26949/"
] | Everything in explanation is about **[CDTuts](http://cdtuts.com)**
I've created a **WordPress Network** and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest **All** organized by date and not organized by *blog ID*.
I don't want to use **switch\_to\_blog** thus, usin... | Since wordpress multisite uses different tables for all blogs, it is very inefficient to get all recent articles of all blogs (content aggregation) on display time since you have to query all blogs, sort the articles by date and display the ammount you need.
Plugins like WordPress Post Indexer (<https://premium.wpmude... |
116,819 | <p>I need to pass the path to a php file (located in a folder in my theme) to a JS file being used in my admin area but I have no idea how to accomplish that. </p>
<p>What Im trying to do, is build a page where selecting some options in a form will pass the input's value to a php script via ajax. But because JS is cli... | [
{
"answer_id": 184709,
"author": "jjarolim",
"author_id": 56506,
"author_profile": "https://wordpress.stackexchange.com/users/56506",
"pm_score": 1,
"selected": false,
"text": "<p>Since wordpress multisite uses different tables for all blogs, it is very inefficient to get all recent arti... | 2013/10/04 | [
"https://wordpress.stackexchange.com/questions/116819",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19536/"
] | I need to pass the path to a php file (located in a folder in my theme) to a JS file being used in my admin area but I have no idea how to accomplish that.
What Im trying to do, is build a page where selecting some options in a form will pass the input's value to a php script via ajax. But because JS is client side, ... | Since wordpress multisite uses different tables for all blogs, it is very inefficient to get all recent articles of all blogs (content aggregation) on display time since you have to query all blogs, sort the articles by date and display the ammount you need.
Plugins like WordPress Post Indexer (<https://premium.wpmude... |
116,832 | <p>I have a big WordPress installation more than 200K posts, with auto publish posts features. My post content is contained "some HTML tags, some text, some <code><img></code> tags". I need to remove all <code><img></code> tags from post content from the specific posts. So I have this function to do this jo... | [
{
"answer_id": 116844,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>The syntax of your <code>foreach</code>-loop is wrong, you are breaking it by putting a <code>;</co... | 2013/10/05 | [
"https://wordpress.stackexchange.com/questions/116832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38852/"
] | I have a big WordPress installation more than 200K posts, with auto publish posts features. My post content is contained "some HTML tags, some text, some `<img>` tags". I need to remove all `<img>` tags from post content from the specific posts. So I have this function to do this job:
```
function remove_images_form_p... | If what you want is for this function to run once a day and loop through all matching posts (removing `img` tags), I think this should do the trick:
```
<?php
function remove_images_form_past_posts() {
if ( get_transient('images_removed_from_past') )
return;
$args = array(
... |
116,851 | <p>I want to load the new entries without reloading the page.<br>
I found a great solution for:<br>
The ajax script:</p>
<pre><code><script>
$(document).ready(function() {
var refreshId = setInterval(function()
{
$('#content').fadeOut("fast").load('http://neocsatblog.mblx.hu/new.php').fadeIn(... | [
{
"answer_id": 116844,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>The syntax of your <code>foreach</code>-loop is wrong, you are breaking it by putting a <code>;</co... | 2013/10/05 | [
"https://wordpress.stackexchange.com/questions/116851",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38916/"
] | I want to load the new entries without reloading the page.
I found a great solution for:
The ajax script:
```
<script>
$(document).ready(function() {
var refreshId = setInterval(function()
{
$('#content').fadeOut("fast").load('http://neocsatblog.mblx.hu/new.php').fadeIn("fast");
}, 10000)... | If what you want is for this function to run once a day and loop through all matching posts (removing `img` tags), I think this should do the trick:
```
<?php
function remove_images_form_past_posts() {
if ( get_transient('images_removed_from_past') )
return;
$args = array(
... |
116,867 | <p>I am looking for a way to use an image url with the WordPress function <code>add_image_size</code>, I have already setup an image size called <code>'custom-thumb'</code> For example, instead of...</p>
<pre><code>the_post_thumbnail( 'custom-thumb' );
</code></pre>
<p>Which would output the posts thumbnail at the c... | [
{
"answer_id": 116844,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>The syntax of your <code>foreach</code>-loop is wrong, you are breaking it by putting a <code>;</co... | 2013/10/05 | [
"https://wordpress.stackexchange.com/questions/116867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I am looking for a way to use an image url with the WordPress function `add_image_size`, I have already setup an image size called `'custom-thumb'` For example, instead of...
```
the_post_thumbnail( 'custom-thumb' );
```
Which would output the posts thumbnail at the custom size I specified, I want to do something li... | If what you want is for this function to run once a day and loop through all matching posts (removing `img` tags), I think this should do the trick:
```
<?php
function remove_images_form_past_posts() {
if ( get_transient('images_removed_from_past') )
return;
$args = array(
... |
116,880 | <p>I need a single Wordpress installation to be available from both the main domain (www.example.com) via HTTP and a subdomain (secure.example.com) via HTTPS.</p>
<p>Of course i can just map the subdomain to the Wordpress folder in Nginx config. But will
Wordpress be aware that it is called via HTTPS and change all li... | [
{
"answer_id": 116844,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>The syntax of your <code>foreach</code>-loop is wrong, you are breaking it by putting a <code>;</co... | 2013/10/06 | [
"https://wordpress.stackexchange.com/questions/116880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39068/"
] | I need a single Wordpress installation to be available from both the main domain (www.example.com) via HTTP and a subdomain (secure.example.com) via HTTPS.
Of course i can just map the subdomain to the Wordpress folder in Nginx config. But will
Wordpress be aware that it is called via HTTPS and change all links on the... | If what you want is for this function to run once a day and loop through all matching posts (removing `img` tags), I think this should do the trick:
```
<?php
function remove_images_form_past_posts() {
if ( get_transient('images_removed_from_past') )
return;
$args = array(
... |
116,922 | <p>I am trying to modify the number of posts_per_page in the loop. This way:</p>
<pre><code>function posts_per_page($query) {
$query->query_vars['posts_per_page'] = 3;
}
add_filter('pre_get_posts', 'posts_per_page', 11);
</code></pre>
<p>The problem I have is that when I do so, then sticky posts appear twice i... | [
{
"answer_id": 116926,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>More correct would be to use the <code>set</code> method.</p>\n\n<pre><code>function posts_per_page($query) ... | 2013/10/06 | [
"https://wordpress.stackexchange.com/questions/116922",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16533/"
] | I am trying to modify the number of posts\_per\_page in the loop. This way:
```
function posts_per_page($query) {
$query->query_vars['posts_per_page'] = 3;
}
add_filter('pre_get_posts', 'posts_per_page', 11);
```
The problem I have is that when I do so, then sticky posts appear twice in the loop: first one at th... | What you describe is not an issue but normal WordPress behaviour. When you mark a post as a sticky it will be at the top of the list **and** it will appear in it's original postition as well, unless the original position is on the first page. A sticky will appear at the top of the posts and in it's original position bu... |
116,929 | <p>So I created a page called test.mydomain.com/hello and when I try to access it, it gives me a 404 error. I tried switching my permalink structure to default and back to post name to see if this was the error, but it's not. In the page editor, I can see that it's the good permalink and when I click on view page, it s... | [
{
"answer_id": 116930,
"author": "wpmemorize",
"author_id": 39075,
"author_profile": "https://wordpress.stackexchange.com/users/39075",
"pm_score": 2,
"selected": false,
"text": "<p>Change your current permalink structure to the WordPress Default Permalink structure and then again change... | 2013/10/06 | [
"https://wordpress.stackexchange.com/questions/116929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | So I created a page called test.mydomain.com/hello and when I try to access it, it gives me a 404 error. I tried switching my permalink structure to default and back to post name to see if this was the error, but it's not. In the page editor, I can see that it's the good permalink and when I click on view page, it stil... | Change your current permalink structure to the WordPress Default Permalink structure and then again change it back to your current permalink structure. Hope it will work!
If not then clear your browser cache and use Wp [Super Cache plugin](http://wordpress.org/plugins/wp-super-cache/) to clear WordPress Cache. and the... |
116,940 | <p>My intention is to have a left and right sidebar on each page. I've registered both of them, implemented my desired widgets, and yet something isn't quite right.</p>
<p>The left sidebar (<code>sidebar(1)</code>) loads correctly on the left side, but is stuck beneath page content. The right sidebar (<code>sidebar(2)... | [
{
"answer_id": 116942,
"author": "wpmemorize",
"author_id": 39075,
"author_profile": "https://wordpress.stackexchange.com/users/39075",
"pm_score": 1,
"selected": false,
"text": "<p>Mostly the problem occurs when you wrongly register sidebar in function.php or you register your sider wit... | 2013/10/06 | [
"https://wordpress.stackexchange.com/questions/116940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | My intention is to have a left and right sidebar on each page. I've registered both of them, implemented my desired widgets, and yet something isn't quite right.
The left sidebar (`sidebar(1)`) loads correctly on the left side, but is stuck beneath page content. The right sidebar (`sidebar(2)`) does not show up on the... | you are using the wrong file names for the sidebar templates;
try the file names *sidebar-l.php* and *sidebar-r.php*
review <http://codex.wordpress.org/Function_Reference/get_sidebar> |
116,946 | <p>I registered one options group with few different options sections. Each section is meant for different page.</p>
<pre><code>register_setting( // http://codex.wordpress.org/Function_Reference/register_setting
'mhp_options', // Options group
'mhp_plugin_options'... | [
{
"answer_id": 116942,
"author": "wpmemorize",
"author_id": 39075,
"author_profile": "https://wordpress.stackexchange.com/users/39075",
"pm_score": 1,
"selected": false,
"text": "<p>Mostly the problem occurs when you wrongly register sidebar in function.php or you register your sider wit... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/116946",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/238/"
] | I registered one options group with few different options sections. Each section is meant for different page.
```
register_setting( // http://codex.wordpress.org/Function_Reference/register_setting
'mhp_options', // Options group
'mhp_plugin_options', //... | you are using the wrong file names for the sidebar templates;
try the file names *sidebar-l.php* and *sidebar-r.php*
review <http://codex.wordpress.org/Function_Reference/get_sidebar> |
116,950 | <p>There is a theme my client is using. It enqueues many scripts in the admin area of WordPress. I'd like to dequeue these so that my plugin works properly. </p>
<p>Commenting out this code <code>wp_enqueue_script( "ocmx-jquery", get_template_directory_uri()."/scripts/ocmx.js", array( "jquery" ) );
</code> makes my p... | [
{
"answer_id": 116952,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You need to dequeue after the other script has been enqueued. That probably means hooking into <code>wp-enqu... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/116950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33067/"
] | There is a theme my client is using. It enqueues many scripts in the admin area of WordPress. I'd like to dequeue these so that my plugin works properly.
Commenting out this code `wp_enqueue_script( "ocmx-jquery", get_template_directory_uri()."/scripts/ocmx.js", array( "jquery" ) );` makes my plugin work properly. So... | `wp_enqueue_script()` also registers the script. So, you'll also need to de-register it first. This code should work depending on how and where the script is enqueued.
```
function my_dequeue() {
wp_deregister_script( 'ocmx-jquery' );
wp_dequeue_script( 'ocmx-jquery' );
}
add_action( 'admin_enqueue_scripts', '... |
116,955 | <p>I can't figure this out but I'm trying to echo the post Tags of the post in the <code><head></code> section. This code resides in the <code><head></code> section of the site.</p>
<p>Basically I want the post tags to appear between the quotes.</p>
<pre><code>ados_setKeywords('');
</code></pre>
<p>I've ... | [
{
"answer_id": 116956,
"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/wp_get_post_tags\" rel=\"nofollow\"><code>wp_get_pos... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/116955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39089/"
] | I can't figure this out but I'm trying to echo the post Tags of the post in the `<head>` section. This code resides in the `<head>` section of the site.
Basically I want the post tags to appear between the quotes.
```
ados_setKeywords('');
```
I've tried using `wp_get_post_tags()`:
```
ados_setKeywords('<?php echo... | [`wp_get_post_tags()`](http://codex.wordpress.org/Function_Reference/wp_get_post_tags) returns an array. You cannot `echo` an array or all you get is "Array".
If [this](http://help.adzerk.com/Ad_Code) is the `ados_setKeywords` you mean, then you need to feed it a comma delimited string, not an array.
```
ados_setKey... |
116,973 | <p>Once in a while, I get comments like these:</p>
<blockquote>
<p>苍天有眼啊,让我在有生之年得以观得如此精彩绝伦的帖子。</p>
</blockquote>
<p>They are absolutely useless to me. I don't even know if it's Chinese / Japanese / Korean / ...</p>
<p>How can I tell WordPress to automatically delete (not just spam) those messages?</p>
| [
{
"answer_id": 135155,
"author": "Nabil Kadimi",
"author_id": 17187,
"author_profile": "https://wordpress.stackexchange.com/users/17187",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the built in black list function in <strong>Dashboard > Settings > Discussion</strong> <code... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/116973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7289/"
] | Once in a while, I get comments like these:
>
> 苍天有眼啊,让我在有生之年得以观得如此精彩绝伦的帖子。
>
>
>
They are absolutely useless to me. I don't even know if it's Chinese / Japanese / Korean / ...
How can I tell WordPress to automatically delete (not just spam) those messages? | Those characters you quoted here are Han (used by Chinese language), as they matched by the [unicode character property](http://php.net/manual/en/regexp.reference.unicode.php) `\p{Han}`.
You can perform a regular expression search in a plugin like so:
```
<?php
/**
* Plugin Name: Drop comments by chars
* Descript... |
116,988 | <p>I am building a wordpress website and I want to show a text widget in the footer just for one page template. That widget shouldnot be seen for other pages. Is there any possible way for that? </p>
| [
{
"answer_id": 116995,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>There are a couple of options:</p>\n\n<ol>\n<li>Use a Plugin that adds contextual <a href=\"http://wordpre... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/116988",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28044/"
] | I am building a wordpress website and I want to show a text widget in the footer just for one page template. That widget shouldnot be seen for other pages. Is there any possible way for that? | There are a couple of options:
1. Use a Plugin that adds contextual [conditions to Widgets](http://wordpress.org/plugins/search.php?q=conditional%20widgets&sort=)
2. Only output the `dynamic_sidebar()` in the page template in question. For example, if your custom page template is named `template-foobar.php`, and the d... |
116,992 | <p>I use the <code>wp_editor</code> function to display an editor in front-end. </p>
<p>The problem is that this editor doesnt behave like the editor in backend based on the settings I give as input:</p>
<pre><code>$settings = array(
'wpautop' => true,
'media_buttons' => false,
'tiny... | [
{
"answer_id": 117011,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>You must filter the content inside the editor, if you save the content. Alternativly add a tiny button to add con... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/116992",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | I use the `wp_editor` function to display an editor in front-end.
The problem is that this editor doesnt behave like the editor in backend based on the settings I give as input:
```
$settings = array(
'wpautop' => true,
'media_buttons' => false,
'tinymce' => array(
'theme_... | The problem was coming from a php function strip\_tags, that was in my code without observing it. I removed it and the problem is resolved. |
116,996 | <p>I am trying to run a local version of a live Wordpress site, however, after setting up the local environment and attempting to access: </p>
<pre><code>http://localhost/wordpress/
</code></pre>
<p>I receive the following error:</p>
<pre><code>This webpage has a redirect loop
The webpage at http://localhost/wor... | [
{
"answer_id": 137423,
"author": "CCN",
"author_id": 48740,
"author_profile": "https://wordpress.stackexchange.com/users/48740",
"pm_score": -1,
"selected": false,
"text": "<p>In your web browser, try deleting cookies for your local domain — in this case <strong>\"localhost\"</strong></p... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/116996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39119/"
] | I am trying to run a local version of a live Wordpress site, however, after setting up the local environment and attempting to access:
```
http://localhost/wordpress/
```
I receive the following error:
```
This webpage has a redirect loop
The webpage at http://localhost/wordpress/ has resulted in too many redirec... | I for instance have MAMP pro running with custom development URLs like `project.dev`. When I created the one-click installation of Wordpress through MAMP, it automaticly entered the port-number into Wordpress as well. I don't think Wordpress likes when the port-number is :80 which is standard. Removing the port-number ... |
117,008 | <p>Wordpress let's users apply CSS classes to links under Appearances-->Menus.</p>
<p>Well based off of this, I would like to know if there is a way to hide links that have a certain CSS class. So say I apply the CSS class </p>
<blockquote>
<p>.members</p>
</blockquote>
<p>to one of my navigation links. The catch ... | [
{
"answer_id": 137423,
"author": "CCN",
"author_id": 48740,
"author_profile": "https://wordpress.stackexchange.com/users/48740",
"pm_score": -1,
"selected": false,
"text": "<p>In your web browser, try deleting cookies for your local domain — in this case <strong>\"localhost\"</strong></p... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/117008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18492/"
] | Wordpress let's users apply CSS classes to links under Appearances-->Menus.
Well based off of this, I would like to know if there is a way to hide links that have a certain CSS class. So say I apply the CSS class
>
> .members
>
>
>
to one of my navigation links. The catch is, I would like this link to only show... | I for instance have MAMP pro running with custom development URLs like `project.dev`. When I created the one-click installation of Wordpress through MAMP, it automaticly entered the port-number into Wordpress as well. I don't think Wordpress likes when the port-number is :80 which is standard. Removing the port-number ... |
117,012 | <p>I have added an extra login field to the main wordpress login page. It is a checkbox which must be checked (to accept terms & conditions), otherwise the user cannot log in.</p>
<p><a href="https://wordpress.stackexchange.com/questions/45900/adding-extra-authentication-field-in-login-page">I have taken code from... | [
{
"answer_id": 117014,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_authenticate_user\" rel=\"nofollow\">Pe... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/117012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34122/"
] | I have added an extra login field to the main wordpress login page. It is a checkbox which must be checked (to accept terms & conditions), otherwise the user cannot log in.
[I have taken code from this question](https://wordpress.stackexchange.com/questions/45900/adding-extra-authentication-field-in-login-page)
which... | Here's the full working code, put it in **functions.php**:
```
add_action('login_form','my_added_login_field');
function my_added_login_field(){
?>
<p>
<label for="my_extra_field">I agree to the terms<br />
<input type="checkbox" value="1" class="input" id="my_extra_field" name="my_extra_field_name... |
117,017 | <p>I've registered a custom taxonomy for 3 custom post types to share, this all works fine.</p>
<p>My issue at the moment is defining a conditional statement within the custom taxonomy file.</p>
<p>I want this taxonomy-{taxonomy}.php file to output different html depending on which custom post type the user is viewin... | [
{
"answer_id": 117043,
"author": "codearachnid",
"author_id": 28798,
"author_profile": "https://wordpress.stackexchange.com/users/28798",
"pm_score": 0,
"selected": false,
"text": "<p>I believe what you are thinking/wanting that the taxonomy-{taxonomy}.php template will filter by CPT. By... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/117017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39124/"
] | I've registered a custom taxonomy for 3 custom post types to share, this all works fine.
My issue at the moment is defining a conditional statement within the custom taxonomy file.
I want this taxonomy-{taxonomy}.php file to output different html depending on which custom post type the user is viewing. However, the t... | When you land in a taxonomy archive page, e.g. the one with url `http://yoursite.com/city/london/` WordPress **can't** know if you want to see London's Hotels, Gym of Supermarkets: you have to inform it.
How inform WordPress? **By url**. So, if your url appear like `http://yoursite.com/city/london/show/gym` now WordPr... |
117,023 | <p>I'd like to include a scrolling gallery in a theme I am developing.
Currently I have the code that "grabs" the attachments and place the thumbs inside a div (without using the gallery shortcode or anything)</p>
<p>I'd like to build a gallery that shows the thumbs scrolling below the content and the image to display... | [
{
"answer_id": 117043,
"author": "codearachnid",
"author_id": 28798,
"author_profile": "https://wordpress.stackexchange.com/users/28798",
"pm_score": 0,
"selected": false,
"text": "<p>I believe what you are thinking/wanting that the taxonomy-{taxonomy}.php template will filter by CPT. By... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/117023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34034/"
] | I'd like to include a scrolling gallery in a theme I am developing.
Currently I have the code that "grabs" the attachments and place the thumbs inside a div (without using the gallery shortcode or anything)
I'd like to build a gallery that shows the thumbs scrolling below the content and the image to display above, as... | When you land in a taxonomy archive page, e.g. the one with url `http://yoursite.com/city/london/` WordPress **can't** know if you want to see London's Hotels, Gym of Supermarkets: you have to inform it.
How inform WordPress? **By url**. So, if your url appear like `http://yoursite.com/city/london/show/gym` now WordPr... |
117,035 | <p>If I restrict my theme framework to 5.4+ (min 5.4) php how much of the average community am I cutting out? All just so I can use traits to help with some inheritance issues I ran into <a href="https://stackoverflow.com/questions/19232542/multiple-inheritance-in-php-or-is-there-a-better-way">in this question I asked<... | [
{
"answer_id": 117036,
"author": "Ben Miller - Remember Monica",
"author_id": 32110,
"author_profile": "https://wordpress.stackexchange.com/users/32110",
"pm_score": -1,
"selected": false,
"text": "<p>The <a href=\"http://wordpress.org/about/requirements/\" rel=\"nofollow noreferrer\">of... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/117035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27670/"
] | If I restrict my theme framework to 5.4+ (min 5.4) php how much of the average community am I cutting out? All just so I can use traits to help with some inheritance issues I ran into [in this question I asked](https://stackoverflow.com/questions/19232542/multiple-inheritance-in-php-or-is-there-a-better-way).
I am con... | In contrast to Ben, I think you can use traits if you have to. Make sure to [check for PHP version](https://wordpress.stackexchange.com/a/95183/73) during plugin installation. Do not let your users run into some obscure PHP errors.
And don't look at the wp.org stats too long. The version stats include abandoned instal... |
117,041 | <p>I created a metabox has a textarea in page admin,
So after validating the data is saved, but it's not displayed in the page (theme) I hope I explain well my problem. </p>
<p>here is my code :</p>
<pre><code><?php
add_action('add_meta_boxes','dar_meta_create');
function dar_meta_create()
{
add_meta_box( ... | [
{
"answer_id": 117036,
"author": "Ben Miller - Remember Monica",
"author_id": 32110,
"author_profile": "https://wordpress.stackexchange.com/users/32110",
"pm_score": -1,
"selected": false,
"text": "<p>The <a href=\"http://wordpress.org/about/requirements/\" rel=\"nofollow noreferrer\">of... | 2013/10/07 | [
"https://wordpress.stackexchange.com/questions/117041",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39088/"
] | I created a metabox has a textarea in page admin,
So after validating the data is saved, but it's not displayed in the page (theme) I hope I explain well my problem.
here is my code :
```
<?php
add_action('add_meta_boxes','dar_meta_create');
function dar_meta_create()
{
add_meta_box(
'dar_meta', // $... | In contrast to Ben, I think you can use traits if you have to. Make sure to [check for PHP version](https://wordpress.stackexchange.com/a/95183/73) during plugin installation. Do not let your users run into some obscure PHP errors.
And don't look at the wp.org stats too long. The version stats include abandoned instal... |
117,061 | <p>I have a widget that appears on my sidebar throughout my website. I have a page where I don't want this widget to show. How would I go about doing this without installing a plugin and instead doing via hooks or something like that?</p>
<p>Below is code I have modified from another post's answer:</p>
<pre><code>fun... | [
{
"answer_id": 117062,
"author": "Karine",
"author_id": 39090,
"author_profile": "https://wordpress.stackexchange.com/users/39090",
"pm_score": -1,
"selected": false,
"text": "<p>You can use CSS to hide this widget on this particular page.\nIf your theme uses <a href=\"http://codex.wordp... | 2013/10/08 | [
"https://wordpress.stackexchange.com/questions/117061",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39138/"
] | I have a widget that appears on my sidebar throughout my website. I have a page where I don't want this widget to show. How would I go about doing this without installing a plugin and instead doing via hooks or something like that?
Below is code I have modified from another post's answer:
```
function remove_the_scri... | There are many plugins for the purpose available:
* [Widget Context](http://wordpress.org/plugins/widget-context/)
* [Widgets Controller](http://wordpress.org/plugins/widgets-controller/)
* [Restrict Widgets](http://wordpress.org/plugins/restrict-widgets/)
* [Display Widgets](http://wordpress.org/plugins/display-widge... |
117,069 | <p>Is it possible to get attachment id by its name? And at once may be it's possible to get parent post, to which this attachment is assigned? </p>
| [
{
"answer_id": 117087,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 4,
"selected": false,
"text": "<p>You have to write custom code to get the attachment id and post_parent by <strong>name</strong>/ <stro... | 2013/10/08 | [
"https://wordpress.stackexchange.com/questions/117069",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24380/"
] | Is it possible to get attachment id by its name? And at once may be it's possible to get parent post, to which this attachment is assigned? | You have to write custom code to get the attachment id and post\_parent by **name**/ **slug** or **filename**(if it has not been changed during the uploading of files).
Put the below code in your theme's **functions.php** file
```
if( ! ( function_exists( 'wp_get_attachment_by_post_name' ) ) ) {
function wp_get_a... |
117,078 | <p>Im trying to create a admin menu link on the backend dashboard, that will take users to the front end of their site. Im trying to use this code, but for some reason the redirect is not working.</p>
<pre><code>// Custom Menus
add_action('admin_menu', 'register_web_menu_page');
function register_web_menu_page() {
... | [
{
"answer_id": 117111,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>Problem is that the function you use run after http header are sent, so it can't redirect.</p>\n\n<p>You have ... | 2013/10/08 | [
"https://wordpress.stackexchange.com/questions/117078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | Im trying to create a admin menu link on the backend dashboard, that will take users to the front end of their site. Im trying to use this code, but for some reason the redirect is not working.
```
// Custom Menus
add_action('admin_menu', 'register_web_menu_page');
function register_web_menu_page() {
add_menu_page... | Problem is that the function you use run after http header are sent, so it can't redirect.
You have to use another way.
One method can be intercept the global `menu` variable and add a new menu item with all properties:
```
add_action( 'admin_menu', 'register_web_menu_page', 999);
function register_web_menu_page ()... |
117,133 | <p>We have is_category() for categories, however I'm not getting a conditional tags for subcategories. I want to enqueue script only on subcategories but on the parent.
So let's say I have a parent category 'fun' which has several sub categories like 'stories', 'arts', 'crafts' . How do I load a script only for the sub... | [
{
"answer_id": 117135,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You can check if a category has a parent, if it does it is a child category.</p>\n\n<pre><code>if( is_category() )... | 2013/10/08 | [
"https://wordpress.stackexchange.com/questions/117133",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34490/"
] | We have is\_category() for categories, however I'm not getting a conditional tags for subcategories. I want to enqueue script only on subcategories but on the parent.
So let's say I have a parent category 'fun' which has several sub categories like 'stories', 'arts', 'crafts' . How do I load a script only for the subca... | You can check if a category has a parent, if it does it is a child category.
```
if( is_category() ){
$this_category = get_queried_object();
if( 0 != $this_category->parent ){
echo 'category has parent';
}
}
``` |
117,146 | <p>I'm currently retrieving a nav menu based on the parent page's title, and if the page doesn't have a parent then it's own title.</p>
<pre><code>global $post;
$page_title;
if ($post->post_parent) {
$page_title = get_the_title($post->post_parent);
} else {
$page_title = get_the_title($post);
}
$sideb... | [
{
"answer_id": 117167,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<p>Assuming that you have custom Nav Menus implemented properly:</p>\n\n<ol>\n<li><p>Registering nav menu The... | 2013/10/08 | [
"https://wordpress.stackexchange.com/questions/117146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39166/"
] | I'm currently retrieving a nav menu based on the parent page's title, and if the page doesn't have a parent then it's own title.
```
global $post;
$page_title;
if ($post->post_parent) {
$page_title = get_the_title($post->post_parent);
} else {
$page_title = get_the_title($post);
}
$sidebar_title = 'Sidebar ... | Assuming that you have custom Nav Menus implemented properly:
1. Registering nav menu Theme Locations:
```
register_nav_menus( array(
'parent_page' => "Parent Page",
'page_a' => "Page A",
'page_b' => "Page B", //etc
) );
```
2. Calling `wp_nav_menu()` correctly:
```
wp_nav_menu( array(
'theme_locati... |
117,147 | <p>I want to order my categories like I order my pages. I've added an extra field called <em>Order</em> to my taxonomy, but how do I order my terms by this value?</p>
<p>Adding and Saving my Order Value:</p>
<pre><code>/** Add New Field To Category **/
function extra_category_fields( $tag ) {
$t_id = $tag->ter... | [
{
"answer_id": 117172,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 4,
"selected": true,
"text": "<p><strong>SOLUTION - Updated: 03/03/2015</strong> - Thanks to /u/G.M.</p>\n\n<p>The below adds a new field to ... | 2013/10/08 | [
"https://wordpress.stackexchange.com/questions/117147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | I want to order my categories like I order my pages. I've added an extra field called *Order* to my taxonomy, but how do I order my terms by this value?
Adding and Saving my Order Value:
```
/** Add New Field To Category **/
function extra_category_fields( $tag ) {
$t_id = $tag->term_id;
$cat_meta = get_optio... | **SOLUTION - Updated: 03/03/2015** - Thanks to /u/G.M.
The below adds a new field to the Term Edit Page and saves the value into the un-used ( for the moment anyway ) `term_group` field which can then be used to order terms. In the below hooks ( actions ) you'll need to replace `TAXONOMY_SLUG` with your actual taxonom... |
117,178 | <p>So this may seem like a pretty menial thing, but follow me here.</p>
<p>I'm trying to add some logic through the <code>pre_get_posts</code> action. This is the entire WP_Query object given to me. (see the end)</p>
<p>Things I have considered using:</p>
<ul>
<li><code>is_single()</code> - too broad.</li>
<li><code... | [
{
"answer_id": 117180,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>I've tried to sort this out before for my own purposes. As far as I can tell ...</p>\n\n<ul>\n<li><code>post_... | 2013/10/08 | [
"https://wordpress.stackexchange.com/questions/117178",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23454/"
] | So this may seem like a pretty menial thing, but follow me here.
I'm trying to add some logic through the `pre_get_posts` action. This is the entire WP\_Query object given to me. (see the end)
Things I have considered using:
* `is_single()` - too broad.
* `is_singular()` - too early to use this, as `get_queried_obje... | I've tried to sort this out before for my own purposes. As far as I can tell ...
* `post_type` is not really set anywhere for the `post` post type.
* For the `page` post type I only see the post type key in
`queried_object`.
* For CPT types there is a `post_type` key in `query_vars` and also in
`query`.
* Nav menus ap... |
117,214 | <p>I had created a custom meta box with the help of <a href="https://wordpress.stackexchange.com/questions/61041/add-a-checkbox-to-post-screen-that-adds-a-class-to-the-title/72997#72997">this answer</a> but this meta box only appear in Post edit screen. How I can make it visible on "Pages" as well as on custom post typ... | [
{
"answer_id": 117204,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>You don't.</p>\n</blockquote>\n\n<p>But there are 3 ways you can if you wanted to, they can all be... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117214",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31988/"
] | I had created a custom meta box with the help of [this answer](https://wordpress.stackexchange.com/questions/61041/add-a-checkbox-to-post-screen-that-adds-a-class-to-the-title/72997#72997) but this meta box only appear in Post edit screen. How I can make it visible on "Pages" as well as on custom post types which creat... | >
> You don't.
>
>
>
But there are 3 ways you can if you wanted to, they can all be circumvented because of open source, thankfully.
**Parse source or something**
Crawl the web and parse the source or an url for a custom comment/id/whatever.
*Chance of failure: Really High* - unless you're Google
**Create... |
117,219 | <p>I have a question about "the loop".</p>
<pre><code><?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</code></pre>
<p>Code taken from <a href="http://codex.wo... | [
{
"answer_id": 117254,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 6,
"selected": true,
"text": "<p>The WordPress template loader will include the appropriate contextual template file in many circumstances, ... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38849/"
] | I have a question about "the loop".
```
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
```
Code taken from [The Loop WordPress Codex page](http://codex.wordpress.org/The_Loop).
Why should I pu... | The WordPress template loader will include the appropriate contextual template file in many circumstances, even if the query for that context returns no posts. For example:
* The Main Blog Posts Index
* Category Archive Index (Category exists, but has no posts)
* Tag Archive Index (Tag exists, but has no posts)
* Auth... |
117,224 | <p>I am developing a custom theme and the navigation part uses hashtags (yes, all content is on one page). So when i use</p>
<pre><code>wp_nav_menu( array( 'theme_location' etc
</code></pre>
<p>the menu items links to the pages. Can i use/edit wp_nav_menu so it adds a # for every page link, like</p>
<pre><code>mysit... | [
{
"answer_id": 117254,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 6,
"selected": true,
"text": "<p>The WordPress template loader will include the appropriate contextual template file in many circumstances, ... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117224",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9936/"
] | I am developing a custom theme and the navigation part uses hashtags (yes, all content is on one page). So when i use
```
wp_nav_menu( array( 'theme_location' etc
```
the menu items links to the pages. Can i use/edit wp\_nav\_menu so it adds a # for every page link, like
```
mysite.com/about-us/
```
becomes
```
... | The WordPress template loader will include the appropriate contextual template file in many circumstances, even if the query for that context returns no posts. For example:
* The Main Blog Posts Index
* Category Archive Index (Category exists, but has no posts)
* Tag Archive Index (Tag exists, but has no posts)
* Auth... |
117,230 | <p>Does anyone know a non-hacky way of getting the plugin directory path from within a theme's functions.php? </p>
<p>I've used plugin_dir_path(<strong>FILE</strong>), but because its called in the theme's functions.php it returns the path to that file. Not the plugins directory. I could string manipulate it and add t... | [
{
"answer_id": 117231,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 5,
"selected": true,
"text": "<p>Maybe what you're looking for is :</p>\n\n<pre><code>WP_PLUGIN_DIR // full path, no trailing slash\nWP_PLUGIN_UR... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16885/"
] | Does anyone know a non-hacky way of getting the plugin directory path from within a theme's functions.php?
I've used plugin\_dir\_path(**FILE**), but because its called in the theme's functions.php it returns the path to that file. Not the plugins directory. I could string manipulate it and add the plugins path, but ... | Maybe what you're looking for is :
```
WP_PLUGIN_DIR // full path, no trailing slash
WP_PLUGIN_URL // full url, no trailing slash
```
See [documentation](http://codex.wordpress.org/Determining_Plugin_and_Content_Directories) |
117,251 | <p>The following function is pluggable as it contains a filter :</p>
<pre><code>// Make function pluggable/overwritable
if ( ! function_exists( 'wpsight_layout_images' ) ) {
function wpsight_layout_images() {
$layout_images = array(
'show_on_single' => true,
'size_archi... | [
{
"answer_id": 117231,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 5,
"selected": true,
"text": "<p>Maybe what you're looking for is :</p>\n\n<pre><code>WP_PLUGIN_DIR // full path, no trailing slash\nWP_PLUGIN_UR... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23894/"
] | The following function is pluggable as it contains a filter :
```
// Make function pluggable/overwritable
if ( ! function_exists( 'wpsight_layout_images' ) ) {
function wpsight_layout_images() {
$layout_images = array(
'show_on_single' => true,
'size_archive' => ... | Maybe what you're looking for is :
```
WP_PLUGIN_DIR // full path, no trailing slash
WP_PLUGIN_URL // full url, no trailing slash
```
See [documentation](http://codex.wordpress.org/Determining_Plugin_and_Content_Directories) |
117,252 | <p>I have a form with some checkboxes and inputboxes selectboxes and it shows what the user wants via an ajax call. The problem is that when the user click on the item and the detail page is shown and then decide to go back to the previous page he needs to click and select his previous choice again.</p>
<p>I would lik... | [
{
"answer_id": 117260,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 6,
"selected": false,
"text": "<p>Sessions aren't enabled in wordpress by default, if you want to activate php sessions add this at t... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117252",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I have a form with some checkboxes and inputboxes selectboxes and it shows what the user wants via an ajax call. The problem is that when the user click on the item and the detail page is shown and then decide to go back to the previous page he needs to click and select his previous choice again.
I would like to make ... | Sessions aren't enabled in wordpress by default, if you want to activate php sessions add this at the beginning of your `functions.php`:
```
if (!session_id()) {
session_start();
}
```
You now can use `$_SESSION['your-var'] = 'your-value';` to set a session variable. Take a look at the [PHP documentation on sess... |
117,280 | <p>someone knows how to limit the number of blogs creation in a wordpress multisite? (3.6.1).</p>
<p>In the wordpress plugins repository there is <a href="http://wordpress.org/plugins/limit-blogs-per-user/" rel="nofollow">this plugin</a>, but It doesn't work, I think it's not up to date.</p>
<p>Any suggestion would b... | [
{
"answer_id": 117286,
"author": "Stubbies",
"author_id": 38933,
"author_profile": "https://wordpress.stackexchange.com/users/38933",
"pm_score": 0,
"selected": false,
"text": "<p>This is what I'd do.</p>\n\n<p>Use this add action:</p>\n\n<pre><code>add_action( 'wpmu_new_blog', 'myFuncti... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117280",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20032/"
] | someone knows how to limit the number of blogs creation in a wordpress multisite? (3.6.1).
In the wordpress plugins repository there is [this plugin](http://wordpress.org/plugins/limit-blogs-per-user/), but It doesn't work, I think it's not up to date.
Any suggestion would be appreciated, thank you very much. | The signup page has validation hooks. How about something like this?
```
add_filter('wpmu_validate_blog_signup','set_blog_creation_limit');
function set_blog_creation_limit($result) {
$blogs = get_blogs_of_user($result['user']->ID);
if (count($blogs) > 2 )
$result['errors']->add('blogname', __('You ... |
117,290 | <p>When building a plugin, I know that you can hook into a function to run some code like</p>
<pre><code>add_action('admin_footer', array($this, 'custom_function'));
</code></pre>
<p>And within that function, test for post_type like so:</p>
<pre><code>public function custom_function() {
$screen = get_cur... | [
{
"answer_id": 117294,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 1,
"selected": false,
"text": "<pre><code>add_Action('init','call_it_to_hook');\nfunction call_it_to_hook() {\n global $post;\n if($... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117290",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29049/"
] | When building a plugin, I know that you can hook into a function to run some code like
```
add_action('admin_footer', array($this, 'custom_function'));
```
And within that function, test for post\_type like so:
```
public function custom_function() {
$screen = get_current_screen();
if (self:... | Using OOP PHP, add your initializer actions in the `__construct` and create appropriate methods for handling them. From your handler you can initialize any class variable (once) you want and reference it later without having to do any further checks. Here is an example:
```
class my_plugin {
private $post_type;
... |
117,337 | <p>I have a function that has an add_action inside it that calls the user_register hook. I would like to be able to echo the variable $user_id from the user_register hook and the $_POST array as well. (Ok, my goal is to do more than that, but you get the idea). See below:</p>
<pre><code>function my_function{
add_a... | [
{
"answer_id": 117338,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>When you use <code>add_action</code> your callback function gets put into a kind of a queue and is executed ... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38991/"
] | I have a function that has an add\_action inside it that calls the user\_register hook. I would like to be able to echo the variable $user\_id from the user\_register hook and the $\_POST array as well. (Ok, my goal is to do more than that, but you get the idea). See below:
```
function my_function{
add_action( 'user... | You can't use an action or hook within a function in the way you are expecting. Actions and hooks are about **delayed execution** You are attaching code that will execute at a later point. After an action is added, your function will continue as normal.
Then when the user is actually being registered, your code will r... |
117,343 | <p>"i am using the_content filter on the category pages like cat=1" I am appending --N in the content. But due the the theme functionality it strip the content after some number of characters therefore in post with the less content i can see the "--N" string but with the large content i cant see "--N" string as the "co... | [
{
"answer_id": 117350,
"author": "P-S",
"author_id": 38771,
"author_profile": "https://wordpress.stackexchange.com/users/38771",
"pm_score": 1,
"selected": false,
"text": "<p><strong>In functions.php:</strong></p>\n\n<pre><code>function myExcerpt($text) {\n $text = str_replace(']]>... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39237/"
] | "i am using the\_content filter on the category pages like cat=1" I am appending --N in the content. But due the the theme functionality it strip the content after some number of characters therefore in post with the less content i can see the "--N" string but with the large content i cant see "--N" string as the "cont... | **In functions.php:**
```
function myExcerpt($text) {
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = 50; // max number of words
$words = explode(' ', $text, $excerpt_length + 1);
array_pop($words);
array_push($words, '-N');
$text = implode(' ', $w... |
117,344 | <p>When I generate XML file with [Tools > Export] and use [Tools > Import] on another WordPress website I get "Failed to import Media" for each attachment post type. And images that failed to load are hotlinked from the previous server which consumes the transfer of that previous server...</p>
<p>But when I download "... | [
{
"answer_id": 117355,
"author": "Imperative Ideas",
"author_id": 28719,
"author_profile": "https://wordpress.stackexchange.com/users/28719",
"pm_score": 1,
"selected": false,
"text": "<p>When you generated your export file, was it on a live server or a localhost? Is that web page still ... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | When I generate XML file with [Tools > Export] and use [Tools > Import] on another WordPress website I get "Failed to import Media" for each attachment post type. And images that failed to load are hotlinked from the previous server which consumes the transfer of that previous server...
But when I download "Unit Test"... | I had a very similar problem when I moved a WordPress Blog from a single WordPress installation to a Multisite installation with different domain names but same IP.
I found out that the problem is the `wp_http_validate_url` function which drops the URL if the source IP is the same as the destination IP.
You can a... |
117,345 | <p>I need to calculate some dynamic CSS based on how many top level categories exist. (NOT how many posts are in a category, or how many categories a post belongs to... Nothing about posts at all, just how many top level categories there are)</p>
<p>I am new to PHP, but I couldn't find any WP functions that would retu... | [
{
"answer_id": 117346,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 3,
"selected": true,
"text": "<p>As the <a href=\"http://codex.wordpress.org/Function_Reference/get_categories#Get_only_top_level_catego... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36266/"
] | I need to calculate some dynamic CSS based on how many top level categories exist. (NOT how many posts are in a category, or how many categories a post belongs to... Nothing about posts at all, just how many top level categories there are)
I am new to PHP, but I couldn't find any WP functions that would return the num... | As the [Codex says](http://codex.wordpress.org/Function_Reference/get_categories#Get_only_top_level_categories), this is the code block to query for only the Top Level categories — the parents. With this, I used the [PHP function `count()`](http://php.net/manual/en/function.count.php).
```
<?php
$args = array(
'... |
117,351 | <p>I set css class for menu items.</p>
<p>I want to get css class of current menu item and set it to body tag.</p>
<p>What should i do ?</p>
| [
{
"answer_id": 117346,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 3,
"selected": true,
"text": "<p>As the <a href=\"http://codex.wordpress.org/Function_Reference/get_categories#Get_only_top_level_catego... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117351",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48231/"
] | I set css class for menu items.
I want to get css class of current menu item and set it to body tag.
What should i do ? | As the [Codex says](http://codex.wordpress.org/Function_Reference/get_categories#Get_only_top_level_categories), this is the code block to query for only the Top Level categories — the parents. With this, I used the [PHP function `count()`](http://php.net/manual/en/function.count.php).
```
<?php
$args = array(
'... |
117,383 | <p>I'm importing Twenty Thirteen's default stylesheet, but I want it to leave my buttons alone.</p>
<p>I could of course disable all mentions of "button" in the temaplate's <code>style.css</code>, but that would only work until the next update - I suppose.</p>
<p>Is there any way to exclude the styling of certain ele... | [
{
"answer_id": 117346,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 3,
"selected": true,
"text": "<p>As the <a href=\"http://codex.wordpress.org/Function_Reference/get_categories#Get_only_top_level_catego... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35726/"
] | I'm importing Twenty Thirteen's default stylesheet, but I want it to leave my buttons alone.
I could of course disable all mentions of "button" in the temaplate's `style.css`, but that would only work until the next update - I suppose.
Is there any way to exclude the styling of certain elements from being imported? | As the [Codex says](http://codex.wordpress.org/Function_Reference/get_categories#Get_only_top_level_categories), this is the code block to query for only the Top Level categories — the parents. With this, I used the [PHP function `count()`](http://php.net/manual/en/function.count.php).
```
<?php
$args = array(
'... |
117,397 | <p>I've got the custom post type <code>foo</code> with meta fields called <code>bar</code> and <code>baz</code>. Now I get the <code>WP_Query</code> object using:</p>
<pre><code>$args = array(
'post_type' => 'foo',
'meta_key' => 'bar',
'meta_value' => $bar_value,
... | [
{
"answer_id": 117401,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>The query arguments are in several places in the query object. You can <code>var_dump</code> the object and ... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38405/"
] | I've got the custom post type `foo` with meta fields called `bar` and `baz`. Now I get the `WP_Query` object using:
```
$args = array(
'post_type' => 'foo',
'meta_key' => 'bar',
'meta_value' => $bar_value,
'posts_per_page' => 10,
);
$res = new WP_Query($args);
```
Now I ... | I've found a solution to my problem myself. Since none of the already existing answers solved the problem, I figured I could best post mine here to help people with similar problems.
The solution:
```
if($res->have_posts()) {
$id = $mail_res->posts[0]->ID; // blindly assuming there is only 1 post having baz = b... |
117,418 | <p>I would like to display the variable price by default in the "from price tab" in the single product page. and not have the from price.</p>
<p>Its confusing to the shopper to see a "from" price then below it a price for each variation, that changes once a variation is chosen.</p>
<p><strong>see attached image</stro... | [
{
"answer_id": 117401,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>The query arguments are in several places in the query object. You can <code>var_dump</code> the object and ... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117418",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39262/"
] | I would like to display the variable price by default in the "from price tab" in the single product page. and not have the from price.
Its confusing to the shopper to see a "from" price then below it a price for each variation, that changes once a variation is chosen.
**see attached image**
So instead of having to s... | I've found a solution to my problem myself. Since none of the already existing answers solved the problem, I figured I could best post mine here to help people with similar problems.
The solution:
```
if($res->have_posts()) {
$id = $mail_res->posts[0]->ID; // blindly assuming there is only 1 post having baz = b... |
117,419 | <p>TinyMCE editor inserts <code><p>&nbsp;</p></code> instead of <code><br></code> tags when I press enter in my text for a new line.</p>
<p>How to force TinyMCE in WP to replace newlines with <code><br></code> and not <code><p>&nbsp;</p></code>?</p>
| [
{
"answer_id": 118860,
"author": "Ray Gulick",
"author_id": 30,
"author_profile": "https://wordpress.stackexchange.com/users/30",
"pm_score": 0,
"selected": false,
"text": "<p>This might not work for you, because I'm not sure what the scenario is that would require the need for a linebre... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | TinyMCE editor inserts `<p> </p>` instead of `<br>` tags when I press enter in my text for a new line.
How to force TinyMCE in WP to replace newlines with `<br>` and not `<p> </p>`? | The answer suggested by [GavinR](https://wordpress.stackexchange.com/users/2001/gavinr) is correct.
You don't need to install the suggested plug-in, though. Just add this mini plugin and you're set:
```php
<?php
defined( 'ABSPATH' ) OR exit;
/* Plugin Name: TinyMCE break instead of paragraph */
function mytheme_tinym... |
117,440 | <p>I need to add a field to the user registration form and then validate it before I add a new user to my WordPress</p>
<p>I know how to hook into the registration form via <code>add_filter('register_form', 'my_function');</code></p>
<p>But how do I hook into the registration process before the user registers? Hence ... | [
{
"answer_id": 118860,
"author": "Ray Gulick",
"author_id": 30,
"author_profile": "https://wordpress.stackexchange.com/users/30",
"pm_score": 0,
"selected": false,
"text": "<p>This might not work for you, because I'm not sure what the scenario is that would require the need for a linebre... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117440",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I need to add a field to the user registration form and then validate it before I add a new user to my WordPress
I know how to hook into the registration form via `add_filter('register_form', 'my_function');`
But how do I hook into the registration process before the user registers? Hence I do not want `add_action('u... | The answer suggested by [GavinR](https://wordpress.stackexchange.com/users/2001/gavinr) is correct.
You don't need to install the suggested plug-in, though. Just add this mini plugin and you're set:
```php
<?php
defined( 'ABSPATH' ) OR exit;
/* Plugin Name: TinyMCE break instead of paragraph */
function mytheme_tinym... |
117,447 | <p>When I create featured images, the markup that wordpress produces has inline css. The image tag for the image has width and height parameters.</p>
<p>This is very frustrating: I'd like to control the image style with my own css.</p>
<p>How can I remove the inline style?</p>
| [
{
"answer_id": 128461,
"author": "RachieVee",
"author_id": 42783,
"author_profile": "https://wordpress.stackexchange.com/users/42783",
"pm_score": 1,
"selected": false,
"text": "<p>You are correct, Inline CSS will always take priority over any CSS in the stylesheet unless you're pepperin... | 2013/10/10 | [
"https://wordpress.stackexchange.com/questions/117447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26187/"
] | When I create featured images, the markup that wordpress produces has inline css. The image tag for the image has width and height parameters.
This is very frustrating: I'd like to control the image style with my own css.
How can I remove the inline style? | You can use wp\_get\_attachment\_image\_src which will return the image url using the thumbnail ID
```
<img src="<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'full'); echo $image[0];?>" />
``` |
117,467 | <p>I am new to WordPress. Can you please suggest the steps to insert an image slider in my site's header? I don't know how to insert the code or where.</p>
| [
{
"answer_id": 117482,
"author": "John T",
"author_id": 39292,
"author_profile": "https://wordpress.stackexchange.com/users/39292",
"pm_score": -1,
"selected": false,
"text": "<p>Quite often, the easiest way of doing this is via a plugin (<a href=\"http://wordpress.org/plugins/search.php... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38966/"
] | I am new to WordPress. Can you please suggest the steps to insert an image slider in my site's header? I don't know how to insert the code or where. | Depends on what theme you are using because some include hooks which make the job easier.
For themes which don't include hooks like Twenty Eleven & Twenty Twelve, you can simply past the PHP tag for the slider into the header.php file in the position you want your slider to display.
Example if using the free version ... |
117,469 | <p>I've tried hard to find a way to not let plugin <a href="http://wpml.org/" rel="nofollow">WPML</a> output the following <code><meta name="generator" content="WPML ver:2.8.1 stt:3,1;0" /></code> tag in <code><head></code> via help of theme's <code>function.php</code>:<br ></p>
<p>It's called in <code>sit... | [
{
"answer_id": 117473,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 0,
"selected": false,
"text": "<p>Try this (note different <code>remove_action()</code>:</p>\n\n<pre><code>if(!is_admin()){\n remove_actio... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28651/"
] | I've tried hard to find a way to not let plugin [WPML](http://wpml.org/) output the following `<meta name="generator" content="WPML ver:2.8.1 stt:3,1;0" />` tag in `<head>` via help of theme's `function.php`:
It's called in `sitepress.class.php` beginning with line 255
```
if ( !is_admin() ) {
add_action( 'wp_h... | The instance of this class is made global by WPML, so this should work:
```
if ( ! empty ( $GLOBALS['sitepress'] ) ) {
add_action( 'wp_head', function()
{
remove_action(
current_filter(),
array ( $GLOBALS['sitepress'], 'meta_generator_tag' )
);
},
0
);
}
``` |
117,495 | <p>Is there any method to close connection similar to <a href="http://php.net/manual/en/function.mysql-close.php" rel="nofollow noreferrer"><code>mysql_close()</code></a> for <a href="https://codex.wordpress.org/wpdb_Class" rel="nofollow noreferrer"><code>$wpdb</code></a> in WordPress?</p>
<p>Is it not necessary to cl... | [
{
"answer_id": 117496,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 3,
"selected": false,
"text": "<p>You don't have to worry about closing connection to you DB because it will be automatically closed when... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117495",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39301/"
] | Is there any method to close connection similar to [`mysql_close()`](http://php.net/manual/en/function.mysql-close.php) for [`$wpdb`](https://codex.wordpress.org/wpdb_Class) in WordPress?
Is it not necessary to close connection for global `$wpdb`? | You don't have to worry about closing connection to you DB because it will be automatically closed when a request will be processed by your server.
But if you have to close it, then you can do something like this:
```
@mysql_close( $wpdb->dbh );
```
Pay attention that it could lead to unexpected results because oth... |
117,503 | <p>I have 5 different custom post types, Is there any way to count all the publish posts regardless of post_type through any inbuilt functions</p>
<p>Like</p>
<pre><code>wp_count_posts(array('post','books','video'))
</code></pre>
<p>any ideas</p>
| [
{
"answer_id": 117510,
"author": "codebreaker",
"author_id": 39154,
"author_profile": "https://wordpress.stackexchange.com/users/39154",
"pm_score": -1,
"selected": false,
"text": "<p>Just try this and reply whether it worked out this will give all pusblish posts ..</p>\n\n<pre><code><... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117503",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28105/"
] | I have 5 different custom post types, Is there any way to count all the publish posts regardless of post\_type through any inbuilt functions
Like
```
wp_count_posts(array('post','books','video'))
```
any ideas | To get the custom post types you would call the `get_post_types` function.The built-in public post types are post, page, and attachment. By setting '\_builtin' to false, we will exclude them and show only the custom public post types. Below is the code.
```
<?php
$args = array(
'public' => true,
'_builtin' => false... |
117,507 | <p>I'm trying to run a query that only shows posts if it's meta value has a date string that is LESS than the current date's string. An example is below;</p>
<pre><code><?php
$current = date('Ymd'); // Eg: today would be 20131011
$date = get_post_meta($post->ID, 'event_date', true); // (Eg; 19690816)
... | [
{
"answer_id": 117517,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 0,
"selected": false,
"text": "<p>Your code looks valid for me. The only thing you can try is 'NUMERIC' instead of 'numeric' and to cast <code>$... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33310/"
] | I'm trying to run a query that only shows posts if it's meta value has a date string that is LESS than the current date's string. An example is below;
```
<?php
$current = date('Ymd'); // Eg: today would be 20131011
$date = get_post_meta($post->ID, 'event_date', true); // (Eg; 19690816)
$args (
'po... | A `meta_query` is an array of arrays. You only have an array (and a syntax error). You need this:
```
$current = date('Ymd'); // Eg: today would be 20131011
$date = get_post_meta($post->ID, 'event_date', true); // (Eg; 19690816)
$args = array(
'post_type' => 'event',
'posts_per_page' => -1,
'meta_query' =>... |
117,508 | <p>Is there any way how to output <code>wp_list_comments()</code> into a variable?</p>
<p>Something like <code>$output = wp_list_comments(array('reverse_top_level' => false ), $comments);</code></p>
<p>I am writing a plugin and it would be handy to use standard WordPress function instead of writing my own.</p>
| [
{
"answer_id": 117513,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 3,
"selected": true,
"text": "<p>In the default usage this is impossible due to the nature of the default comment walker which always directly o... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117508",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/238/"
] | Is there any way how to output `wp_list_comments()` into a variable?
Something like `$output = wp_list_comments(array('reverse_top_level' => false ), $comments);`
I am writing a plugin and it would be handy to use standard WordPress function instead of writing my own. | In the default usage this is impossible due to the nature of the default comment walker which always directly outputs. But the function allows to provide a custom walker.
Further reading about custom walkers:
[Codex Class reference](http://codex.wordpress.org/Class_Reference/Walker)
[example custom walker class](http:... |
117,522 | <p>I wondered if someone here might be able to help.</p>
<p>Basically, I've created a custom registration form that when validated, inserts a user to the user table.</p>
<pre><code>function _new_user($data) {
// Separate Data
$default_newuser = array(
'user_pass' => wp_hash_password( $data['user_... | [
{
"answer_id": 117530,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 5,
"selected": true,
"text": "<p>To accomplish user activation process you need to do following steps:</p>\n\n<ol>\n<li>after create new ... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36014/"
] | I wondered if someone here might be able to help.
Basically, I've created a custom registration form that when validated, inserts a user to the user table.
```
function _new_user($data) {
// Separate Data
$default_newuser = array(
'user_pass' => wp_hash_password( $data['user_pass']),
'user_l... | To accomplish user activation process you need to do following steps:
1. after create new user add a custom user field which indicates that this user has to activate his account
2. send an email with activation code, provide a link in this email to a page where user will be activated
3. implement activation page
4. wh... |
117,540 | <p>I will be designing and developing a website for a client but want to allow the client to add content while I am working on the design and development of the site so that it is pretty mich done by the time I am finished.</p>
<p>Currently, I use XAMPP on port 81 so my project URL looks something like </p>
<pre><co... | [
{
"answer_id": 117533,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 3,
"selected": true,
"text": "<p>That's just not the way it works. <code>wp_hash_password()</code> will always return a different value for the ... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12589/"
] | I will be designing and developing a website for a client but want to allow the client to add content while I am working on the design and development of the site so that it is pretty mich done by the time I am finished.
Currently, I use XAMPP on port 81 so my project URL looks something like
```
http://localhost:81... | That's just not the way it works. `wp_hash_password()` will always return a different value for the same password due to [SALTing](http://en.wikipedia.org/wiki/Salt_%28cryptography%29).
You are searching for the [wp\_check\_password()](http://codex.wordpress.org/Function_Reference/wp_check_password) function. |
117,554 | <p>We're using podpress as our podcast player, but we'd like to give the option to download the file on a page without a player. So I'm trying to figure out how to extract the URI from the metadata.</p>
<p>I'm new to PHP, and struggling to learn it, so I've gotten this far:</p>
<pre><code><?php
$custom_field... | [
{
"answer_id": 121373,
"author": "Tesana",
"author_id": 41397,
"author_profile": "https://wordpress.stackexchange.com/users/41397",
"pm_score": 0,
"selected": false,
"text": "<p>EDIT: using the get_post_meta() returns an unserialized array, re: post from Oleg Butuzov. Thanks! -- I update... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39311/"
] | We're using podpress as our podcast player, but we'd like to give the option to download the file on a page without a player. So I'm trying to figure out how to extract the URI from the metadata.
I'm new to PHP, and struggling to learn it, so I've gotten this far:
```
<?php
$custom_fields = get_post_custom(get_... | ```
$meta = get_post_meta(get_the_ID(), '_podPressMedia', true);
$meta = maybe_unserialize($meta);
if (is_array($meta) && count($meta) > 0)
foreach($meta as $item){
//do something...
}
```
Please, do not use unserialize/serialize with php data stored structures there is native [maybe\_serialize](http:... |
117,558 | <p>I feel like I am definitely missing something simple here... but for the life of me, can't find what I'm missing.</p>
<p>I am of the "bad habit" of including jQuery functions directly in the header.php file (among other spots). This is frowned upon, as I understand, and functions should be kept in a separate file u... | [
{
"answer_id": 117560,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>When using a child theme, <a href=\"http://codex.wordpress.org/Function_Reference/get_template_directory_uri\" rel... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39312/"
] | I feel like I am definitely missing something simple here... but for the life of me, can't find what I'm missing.
I am of the "bad habit" of including jQuery functions directly in the header.php file (among other spots). This is frowned upon, as I understand, and functions should be kept in a separate file using the w... | When using a child theme, [`get_template_directory_uri()`](http://codex.wordpress.org/Function_Reference/get_template_directory_uri) returns the URI of the *parent theme*, you want to swap that for [`get_stylesheet_directory_uri()`](http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri), which will... |
117,565 | <p>Whenever I use <code>wp_redirect(plugins_url('account/login'));</code> in a shortcode function I get the following error: </p>
<pre><code>Warning: Cannot modify header information - headers already sent by ...
</code></pre>
<p>Is there any way to redirect from there? My guess would to echo some Javascript that doe... | [
{
"answer_id": 117567,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 0,
"selected": false,
"text": "<p>To redirect to another page you need to set an http header. To set an header it has to be the first thing that... | 2013/10/11 | [
"https://wordpress.stackexchange.com/questions/117565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38405/"
] | Whenever I use `wp_redirect(plugins_url('account/login'));` in a shortcode function I get the following error:
```
Warning: Cannot modify header information - headers already sent by ...
```
Is there any way to redirect from there? My guess would to echo some Javascript that does the redirect from me, but I was won... | Why does it need to be a Shortcode? Looks like a [XY Problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem).
You're already inserting the shortcode manually in the edit screen. Use a Custom Field instead and hook earlier where you can *actually do the redirect*.
![enter image description here... |
117,593 | <p>I am currently following a tutorial by Steven Slack on <a href="http://s2webpress.com/add-image-uploader-to-profile-admin-page-wordpress/" rel="nofollow">s2webpress.com</a> on how to add an Author Image upload field to a user Profile page.
I've managed to get most of it working, except for the part that allows me to... | [
{
"answer_id": 118867,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, PHP can have JavaScript (and CSS and HTML) in it, but you must tell: <em>\"here ends PHP -> other lang... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19608/"
] | I am currently following a tutorial by Steven Slack on [s2webpress.com](http://s2webpress.com/add-image-uploader-to-profile-admin-page-wordpress/) on how to add an Author Image upload field to a user Profile page.
I've managed to get most of it working, except for the part that allows me to use the WP 3.5 media manager... | Yes, PHP can have JavaScript (and CSS and HTML) in it, but you must tell: *"here ends PHP -> other language -> here starts PHP"*, like so:
```
<?php
echo '<div id="hide-me">something</div>';
?>
<script>
// some JS to hide the div
</script>
<?php
echo 'another thing';
```
On the other hand, your code will not work be... |
117,610 | <p>I have been really hard time to get my site translated.<br>
I have MO and PO files, but my theme is not compatible with WPML and the developer team doesn't to change it.</p>
<p>Therefore I may have to build a plugin or compatibility coding by myself. But I can't really find how to do and what I need to do.</p>
<p>... | [
{
"answer_id": 117611,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 2,
"selected": false,
"text": "<p>WPML has a pretty good documentation on <a href=\"http://wpml.org/documentation/support/achieving-wpml-compati... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117610",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34463/"
] | I have been really hard time to get my site translated.
I have MO and PO files, but my theme is not compatible with WPML and the developer team doesn't to change it.
Therefore I may have to build a plugin or compatibility coding by myself. But I can't really find how to do and what I need to do.
Does anybody know ... | You don’t have to make anything special for WPML, using the regular translation code should be enough. See [I18n for WordPress Developers](http://codex.wordpress.org/I18n_for_WordPress_Developers) in the Codex.
Code preparation
----------------
### style.css
Add `Text Domain` and `Domain Path` to your theme’s `style... |
117,614 | <p>A client's site: causing serious js conflict or js loading disabilities, is under custody. Activating DEBUG, Deactivating all Plugins, and Activating Default theme "T13" found that, still the problem resides. The DEBUG is totally fine - no disabilities or mis-functionalities. It was in an Old WP version, I updated e... | [
{
"answer_id": 118687,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": true,
"text": "<blockquote>\n <p>Thread Status: <strong>PARTIALLY SOLVED!</strong></p>\n</blockquote>\n\n<p>Well, it's a... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117614",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | A client's site: causing serious js conflict or js loading disabilities, is under custody. Activating DEBUG, Deactivating all Plugins, and Activating Default theme "T13" found that, still the problem resides. The DEBUG is totally fine - no disabilities or mis-functionalities. It was in an Old WP version, I updated ever... | >
> Thread Status: **PARTIALLY SOLVED!**
>
>
>
Well, it's a nice journey for me with [kaiser](https://wordpress.stackexchange.com/users/385/kaiser), [s1lv3r](https://wordpress.stackexchange.com/users/27536/s1lv3r) and [Rarst](https://wordpress.stackexchange.com/users/847/rarst) through the debugging.
First of all... |
117,617 | <p>I'm having problems trying to create a custom type post with taxonomies using a form at the Front End.</p>
<p>I have tried to add several lines of code and use 'tax_input' but I always get errors.</p>
<p>The custom post type is: <code>pet</code> and the taxonomies are <code>pet-category</code> and <code>pet-city<... | [
{
"answer_id": 117623,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": true,
"text": "<p>Your code doesn't assign the terms to the post. You can do this with <a href=\"http://codex.wordpres... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39345/"
] | I'm having problems trying to create a custom type post with taxonomies using a form at the Front End.
I have tried to add several lines of code and use 'tax\_input' but I always get errors.
The custom post type is: `pet` and the taxonomies are `pet-category` and `pet-city`. This code is working fine but is only post... | Your code doesn't assign the terms to the post. You can do this with [wp\_set\_post\_terms()](http://codex.wordpress.org/Function_Reference/wp_set_post_terms) which does:
>
> Set terms for a post.
>
>
>
Simplified usage example:
```
$pet_cat_ term = $_POST['pet_category'];
wp_set_post_terms( $post_id, $pet_ca... |
117,618 | <p>I want to be able to hook into the output buffer flow and add some conditional content to my WP pages.</p>
<p>What I want to do is test cookies and display a semi-transparent screen with a content box based on a cookies' condition.</p>
<p>I know how to construct the html and css to make this happen. I know how wri... | [
{
"answer_id": 117619,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Use the action <code>template_redirect</code>. You can still send headers here, be cause there is no output. This is ... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to be able to hook into the output buffer flow and add some conditional content to my WP pages.
What I want to do is test cookies and display a semi-transparent screen with a content box based on a cookies' condition.
I know how to construct the html and css to make this happen. I know how write the php to tes... | You can use this class to buffer and filter any output coming from specific hook, or between two hooks.
```
class HookBuffer {
private static $buffers = [];
private $buffer_name = '';
private $buffer = '';
private $buffer_status = 'waiting';
private $priority1;
private $priority2;
private $... |
117,630 | <p>I'm making my first custom theme using custom post types and I've encountered one problem.
I'd like to make some templates like you can make for Pages (i.e. page-fullwidth.php page-noslider.php etc.)
I know if you want to make template for custom post type you just make for example single-cookingrecipes.php but I'd ... | [
{
"answer_id": 117634,
"author": "Manipur",
"author_id": 39355,
"author_profile": "https://wordpress.stackexchange.com/users/39355",
"pm_score": 0,
"selected": false,
"text": "<p>Suppose you make a new page call art.php </p>\n\n<pre><code> <?php\n/*\nTemplate Name: Art\n*/\n ?>... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39352/"
] | I'm making my first custom theme using custom post types and I've encountered one problem.
I'd like to make some templates like you can make for Pages (i.e. page-fullwidth.php page-noslider.php etc.)
I know if you want to make template for custom post type you just make for example single-cookingrecipes.php but I'd lik... | It sounds like you are talking about this page display template:
>
> `page-{slug}.php` - If the page slug is `recent-news`, WordPress will look
> to use `page-recent-news.php`
>
>
>
And you want `single-{cpt-slug}-{slug}.php`.
If so, I believe you can approximate that page template handling with the following:... |
117,639 | <p>I wrote a small function which displays a quote on the page, whenever the function is being called somewhere in a template. Since nobody likes the same quote, I created an admin page for it, where one can change the quote and a few more settings.</p>
<p>Now I want to use this functions.php for several more themes, ... | [
{
"answer_id": 117641,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>I don't see how that would be possible without parsing every template file. I think a better option would be to ei... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117639",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39358/"
] | I wrote a small function which displays a quote on the page, whenever the function is being called somewhere in a template. Since nobody likes the same quote, I created an admin page for it, where one can change the quote and a few more settings.
Now I want to use this functions.php for several more themes, espesciall... | I don't see how that would be possible without parsing every template file. I think a better option would be to either output the quote via a filter on something, like [`the_content`](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content), or via a [custom action](http://codex.wordpress.org/Function_Refere... |
117,647 | <p>I have a blog with ~15k posts, and a DB size of 14.4M.</p>
<p>The website works blazingly fast from the front end, but post-edit and post-listing screens hang - either loading partially or not at all.</p>
<p>Even worse, the entire server gets bogged down after trying...</p>
<p>Examining the process manager showed... | [
{
"answer_id": 117641,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>I don't see how that would be possible without parsing every template file. I think a better option would be to ei... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39360/"
] | I have a blog with ~15k posts, and a DB size of 14.4M.
The website works blazingly fast from the front end, but post-edit and post-listing screens hang - either loading partially or not at all.
Even worse, the entire server gets bogged down after trying...
Examining the process manager showed that `/public_html/wp-a... | I don't see how that would be possible without parsing every template file. I think a better option would be to either output the quote via a filter on something, like [`the_content`](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content), or via a [custom action](http://codex.wordpress.org/Function_Refere... |