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
85,373
<p>I've used a custom post type for one of my website. Custom post type contains scratch card data along with some custom fields.</p> <p>I've developed an android application to manage those items from android device.</p> <p>In the android app, I want to keep search feature which will help admin users to search card ...
[ { "answer_id": 85378, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 6, "selected": true, "text": "<p>You can use either <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter\" rel=\"...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85373", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8096/" ]
I've used a custom post type for one of my website. Custom post type contains scratch card data along with some custom fields. I've developed an android application to manage those items from android device. In the android app, I want to keep search feature which will help admin users to search card numbers to manage...
You can use either [search parameter of wp\_query](https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter) : ``` Code $args = array("post_type" => "mytype", "s" => $title); $query = get_posts( $args ); ``` Or you can get posts based on title throught [wpdb class](https://codex.wordpress.org/Class_Refe...
85,393
<p>Is there any way to evaluate the language a post/page is written in? I am building a multilingual site and am almost pulling my hair out trying to get the front-end navigation to take the chosen language into account. So far the polylang plugin <a href="http://wordpress.org/extend/plugins/polylang/" rel="nofollow">h...
[ { "answer_id": 85394, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>The main language of a post should be saved in a post meta field. There is no way to detect that automatically. Even Go...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85393", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27302/" ]
Is there any way to evaluate the language a post/page is written in? I am building a multilingual site and am almost pulling my hair out trying to get the front-end navigation to take the chosen language into account. So far the polylang plugin <http://wordpress.org/extend/plugins/polylang/> has worked fine for everyth...
The main language of a post should be saved in a post meta field. There is no way to detect that automatically. Even Google’s heuristics fail regularly with that. So add a custom field `lang` and check with … ``` $language = get_post_meta( get_the_ID(), 'lang', TRUE ); ``` … what language the post was written in. ...
85,400
<p>I set up Wordpress as a multisite and as part of the steps, it gave some instruction to update and replace the .htaccess file.</p> <p>Wordpress instructed me to replace the htaccess with this: </p> <pre><code>RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin Rewrite...
[ { "answer_id": 85409, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 2, "selected": false, "text": "<p><code>RewriteRule ^wp-admin$ wp-admin/ [R=301,L]</code><br>\nRedirects <a href=\"http://yourdomain.ext/wp-...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85400", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26088/" ]
I set up Wordpress as a multisite and as part of the steps, it gave some instruction to update and replace the .htaccess file. Wordpress instructed me to replace the htaccess with this: ``` RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^wp-admin$ wp-ad...
`RewriteRule ^wp-admin$ wp-admin/ [R=301,L]` Redirects <http://yourdomain.ext/wp-admin> to <http://yourdomain.ext/wp-admin/> `RewriteCond %{REQUEST_FILENAME} -f [OR]` `RewriteCond %{REQUEST_FILENAME} -d` Conditional logic, check if the requested filename is ***not*** a existing file (`-f`) or directory (`-d`)...
85,422
<p>I tried to develop a plugin in OOP approach. I tried to load all the function needed inside the constructor class e.g action hooks. The problem is this hook "register_activation_hook". It wont load when the plugin is being activated. My main plugin file is in the root directory of my plugin and my class files are i...
[ { "answer_id": 85424, "author": "djb", "author_id": 7905, "author_profile": "https://wordpress.stackexchange.com/users/7905", "pm_score": 2, "selected": false, "text": "<p>It doesn't really matter. If you simply must have it inside a class, I would use a constant and a static method.</p>...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26640/" ]
I tried to develop a plugin in OOP approach. I tried to load all the function needed inside the constructor class e.g action hooks. The problem is this hook "register\_activation\_hook". It wont load when the plugin is being activated. My main plugin file is in the root directory of my plugin and my class files are in...
It doesn't really matter. If you simply must have it inside a class, I would use a constant and a static method. ``` // in the main plugin file define( 'MYPLUGIN_FILE', __FILE__ ); // include another file with this class in class MyPlugin { public static function init() { register_activation_hook( MYPLUG...
85,435
<p>I'm trying to use the add_action() hook to run a custom function, but am struggling with the post status.</p> <p>I originally tried using:</p> <pre><code>add_action('pending_to_publish_portfolio', 'my_function'); </code></pre> <p>(portfolio being my custom post type).</p> <p>This didn't work, so i posted in the ...
[ { "answer_id": 85424, "author": "djb", "author_id": 7905, "author_profile": "https://wordpress.stackexchange.com/users/7905", "pm_score": 2, "selected": false, "text": "<p>It doesn't really matter. If you simply must have it inside a class, I would use a constant and a static method.</p>...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85435", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27318/" ]
I'm trying to use the add\_action() hook to run a custom function, but am struggling with the post status. I originally tried using: ``` add_action('pending_to_publish_portfolio', 'my_function'); ``` (portfolio being my custom post type). This didn't work, so i posted in the official Wordpress Support forum for so...
It doesn't really matter. If you simply must have it inside a class, I would use a constant and a static method. ``` // in the main plugin file define( 'MYPLUGIN_FILE', __FILE__ ); // include another file with this class in class MyPlugin { public static function init() { register_activation_hook( MYPLUG...
85,439
<p>I'm using the following code in my plugin to display a <code>&lt;textarea&gt;</code> field on a page:</p> <pre><code>echo '&lt;textarea required="required" name="Message" class="textarea" cols="70" rows="10"&gt;'.esc_textarea($message).'&lt;/textarea&gt;'; </code></pre> <p>However, WordPress seems to be inserting ...
[ { "answer_id": 85446, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>Add a priority to push your function to the end of the hook queue.</p>\n\n<pre><code>add_action('the_content',...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85439", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21285/" ]
I'm using the following code in my plugin to display a `<textarea>` field on a page: ``` echo '<textarea required="required" name="Message" class="textarea" cols="70" rows="10">'.esc_textarea($message).'</textarea>'; ``` However, WordPress seems to be inserting `<p>` and `<br />` tags into the textarea contents if t...
Add a priority to push your function to the end of the hook queue. ``` add_action('the_content', 'my_plugin_content_hook', 1000); ``` Then, in your `get_special_content` function you will need to apply `wpautop` manually to the content to which you want it applied. ``` function get_special_content() { $text = '...
85,447
<p>I've got a few special needs in terms of post formatting, but do not want (and cannot) break out of <a href="http://codex.wordpress.org/Post_Formats#Supported_Formats" rel="nofollow">the standard Post Format paradigm</a> per best practices. </p> <p>I've come up with a mapping of WordPress core types to my company's...
[ { "answer_id": 85446, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>Add a priority to push your function to the end of the hook queue.</p>\n\n<pre><code>add_action('the_content',...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85447", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1860/" ]
I've got a few special needs in terms of post formatting, but do not want (and cannot) break out of [the standard Post Format paradigm](http://codex.wordpress.org/Post_Formats#Supported_Formats) per best practices. I've come up with a mapping of WordPress core types to my company's own nomenclature (e.g. show "chat" ...
Add a priority to push your function to the end of the hook queue. ``` add_action('the_content', 'my_plugin_content_hook', 1000); ``` Then, in your `get_special_content` function you will need to apply `wpautop` manually to the content to which you want it applied. ``` function get_special_content() { $text = '...
85,451
<p>I'm trying to make a dynamic button that goes to portfolio page (no matter what ID/name it has), it's currently like this:</p> <pre><code>$portfolio_page = get_option('theme_portfolio_page'); $portfolio_pid = get_page_by_title($portfolio_page); &lt;a href="&lt;?php echo get_option ('theme_portfolio_page') ?&g...
[ { "answer_id": 87549, "author": "Michael Dozark", "author_id": 23464, "author_profile": "https://wordpress.stackexchange.com/users/23464", "pm_score": 0, "selected": false, "text": "<p>What I do is:</p>\n\n<ol>\n<li><p>Create a new database on the receiving host. Import the SQL file.\nRu...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85451", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27278/" ]
I'm trying to make a dynamic button that goes to portfolio page (no matter what ID/name it has), it's currently like this: ``` $portfolio_page = get_option('theme_portfolio_page'); $portfolio_pid = get_page_by_title($portfolio_page); <a href="<?php echo get_option ('theme_portfolio_page') ?>">Voltar</a> ``` Th...
There's a pretty good [step by step on moving WordPress in the Codex](https://wordpress.org/support/article/moving-wordpress/#moving-to-a-new-server). It is what I follow when changing domains. Moving the files is pretty straight-forward. It is the hard-coded references in the database that are tricky. However, [seria...
85,459
<p>1) Custom Post Type named "Buying_Locations"</p> <p>2) Each Post has three meta values of: State, City, Store Name</p> <p><strong>QUESTION:</strong> How can you show a list of these posts sorted alphabetically by State, then City and then the Store Name? For example...</p> <p><strong>STATE 1</strong></p> <ul> <...
[ { "answer_id": 87549, "author": "Michael Dozark", "author_id": 23464, "author_profile": "https://wordpress.stackexchange.com/users/23464", "pm_score": 0, "selected": false, "text": "<p>What I do is:</p>\n\n<ol>\n<li><p>Create a new database on the receiving host. Import the SQL file.\nRu...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85459", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27325/" ]
1) Custom Post Type named "Buying\_Locations" 2) Each Post has three meta values of: State, City, Store Name **QUESTION:** How can you show a list of these posts sorted alphabetically by State, then City and then the Store Name? For example... **STATE 1** * CITY 1 + STORE NAME + STORE NAME + STORE NAME * CITY ...
There's a pretty good [step by step on moving WordPress in the Codex](https://wordpress.org/support/article/moving-wordpress/#moving-to-a-new-server). It is what I follow when changing domains. Moving the files is pretty straight-forward. It is the hard-coded references in the database that are tricky. However, [seria...
85,464
<p>I have built a Wordpress plugin that is based on jQuery and I am using <code>wp_enqueue_script('jquery');</code> to make it all work.</p> <p>Let say the default version of jQuery loaded by Wordpress is 1.7.2, what would happen if the users installs a theme based on a different version of jQuery?</p> <ol> <li><p><...
[ { "answer_id": 85507, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Typically the theme developer would declare all the dependencies and include them in the theme. WordPress ships wi...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23605/" ]
I have built a Wordpress plugin that is based on jQuery and I am using `wp_enqueue_script('jquery');` to make it all work. Let say the default version of jQuery loaded by Wordpress is 1.7.2, what would happen if the users installs a theme based on a different version of jQuery? 1. **What version of jQuery will run i...
As other have mentioned , there is no great answer to this, ultimately you cannot control how other people write plugins/themes and there are no standards for naming `wp_enqueue_script`'s, though there probably should be. Also there is no current way to check if jQuery is loaded using `wp_enqueue_script`, though this ...
85,476
<p>Hy, i want to count years of an actor.</p> <p>The date that actor is born is stored in a custom field.</p> <pre><code>$date = get_field('data_nasterii'); </code></pre> <p>Date stored in custom field is : yymmdd</p> <p>How can i stick bouth togeder to make it work. </p> <pre><code>&lt;?php //dat...
[ { "answer_id": 85478, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<p>Assuming that your date format - for whatever reason - really is <code>yymmdd</code> instead of being set to what yo...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85476", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17885/" ]
Hy, i want to count years of an actor. The date that actor is born is stored in a custom field. ``` $date = get_field('data_nasterii'); ``` Date stored in custom field is : yymmdd How can i stick bouth togeder to make it work. ``` <?php //date in mm/dd/yyyy format; or it can be in other formats ...
Assuming that your date format - for whatever reason - really is `yymmdd` instead of being set to what you defined in the admin settings section: There's the native PHP function [`date_parse_from_format()`](http://php.net/manual/de/function.date-parse-from-format.php) that you can use in conjunction with the core sett...
85,485
<p>Based on my understanding of hooks, you create a hook, by doing do_action('hook_name'); then add something to said hook and call the method where you want it to do the hook, so:</p> <pre><code>public function hook_name(){ do_action('hook_name'); } </code></pre> <p>some where you do something like:</p> <pre><c...
[ { "answer_id": 90885, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 2, "selected": false, "text": "<p>It seems, you're mixing up <a href=\"http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters\" rel...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27670/" ]
Based on my understanding of hooks, you create a hook, by doing do\_action('hook\_name'); then add something to said hook and call the method where you want it to do the hook, so: ``` public function hook_name(){ do_action('hook_name'); } ``` some where you do something like: ``` add_action('hook_name', 'some_h...
The do\_action is in the wrong place. It is calling it's self. You have this: ``` public function hook_name() { do_action('hook_name'); } ``` Do this: ``` do_action('hook_name'); public function hook_name() { do_action('other_hook_name'); } ```
85,489
<p>First of all, Multisite isn't what I'm looking for. I have 5 websites using Wordpress all on separate domains that I would like to enable user accounts for. I need user data to be shared across the entire network and when a user creates an account, they would have instant access to all other websites as well. What I...
[ { "answer_id": 85525, "author": "Ian", "author_id": 11583, "author_profile": "https://wordpress.stackexchange.com/users/11583", "pm_score": 4, "selected": true, "text": "<p>Ok, first of all, I feel like an idiot, although in my defense most of the articles that talk about this don't ment...
2013/02/11
[ "https://wordpress.stackexchange.com/questions/85489", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11583/" ]
First of all, Multisite isn't what I'm looking for. I have 5 websites using Wordpress all on separate domains that I would like to enable user accounts for. I need user data to be shared across the entire network and when a user creates an account, they would have instant access to all other websites as well. What I'm ...
Ok, first of all, I feel like an idiot, although in my defense most of the articles that talk about this don't mention a very crucial detail in making this work. The answer is that you need to set permission for at least one admin in the database. This info can be found in the Codex here: <http://codex.wordpress.org/Ed...
85,495
<p>I have a bunch of code that I tend to put into the <code>header.php</code> of every site I do which are specific to Internet Explorer.</p> <p>I was wondering if there was a way to insert code into a 'standard' <code>header.php</code>. </p> <p>Yes, I can simply modify the header. But the idea is to make this a plug...
[ { "answer_id": 85496, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Specifically, I'd like to create a plugin to echo the following in the\n header immediately af...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85495", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17248/" ]
I have a bunch of code that I tend to put into the `header.php` of every site I do which are specific to Internet Explorer. I was wondering if there was a way to insert code into a 'standard' `header.php`. Yes, I can simply modify the header. But the idea is to make this a plugin which is generic. Specifically, I'd...
> > Specifically, I'd like to create a plugin to echo the following in the > header immediately after the default stylesheet > > > The preferred way is to *enqueue* it, with the default/main stylesheet as the *dependency*. Here's a demo plugin, with the structure: ``` + plugins/ | +--+ my-ie-style/ | ...
85,497
<p>I have read that it is always desirable to create a "child theme" so that any changes I make don't get washed away if the main theme is updated.</p> <p>However, one of Jetpack's features is a CSS editor that lets me override the theme's default style.css. Therefore the original style.css is never edited.</p> <p>D...
[ { "answer_id": 85496, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Specifically, I'd like to create a plugin to echo the following in the\n header immediately af...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85497", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27332/" ]
I have read that it is always desirable to create a "child theme" so that any changes I make don't get washed away if the main theme is updated. However, one of Jetpack's features is a CSS editor that lets me override the theme's default style.css. Therefore the original style.css is never edited. Does that provide e...
> > Specifically, I'd like to create a plugin to echo the following in the > header immediately after the default stylesheet > > > The preferred way is to *enqueue* it, with the default/main stylesheet as the *dependency*. Here's a demo plugin, with the structure: ``` + plugins/ | +--+ my-ie-style/ | ...
85,512
<p>I want to remove a CSS from loading in the header, this is the code that appears:</p> <pre><code>&lt;link rel='stylesheet' id='my-css' href='http://test.tld/wp-content/themes/mytheme/my.css?ver=3.5' type='text/css' media='all' /&gt; </code></pre> <p>I tried using these functions but it didn't work:</p> <pre><cod...
[ { "answer_id": 85513, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 5, "selected": true, "text": "<p>If your stylesheet is registered and enqueued correctly then...</p>\n\n<pre><code>function dequeue_my_css() {\...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85512", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20972/" ]
I want to remove a CSS from loading in the header, this is the code that appears: ``` <link rel='stylesheet' id='my-css' href='http://test.tld/wp-content/themes/mytheme/my.css?ver=3.5' type='text/css' media='all' /> ``` I tried using these functions but it didn't work: ``` wp_dequeue_style('my-css'); wp_deregister...
If your stylesheet is registered and enqueued correctly then... ``` function dequeue_my_css() { wp_dequeue_style('my-css'); wp_deregister_style('my-css'); } add_action('wp_enqueue_scripts','dequeue_my_css'); // add a priority if you need it // add_action('wp_enqueue_scripts','dequeue_my_css',100); ``` ... should...
85,529
<p>If we try to access a non-existant Multisite site, e.g., <code>http://site1.example.com</code> or <code>http://example.com/site1/</code>, we are redirected to <code>http://example.com/wp-signup.php?new=site1</code>.</p> <p>How to block this and redirect the browser to another page?</p>
[ { "answer_id": 85530, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 5, "selected": true, "text": "<h3>[Update]</h3>\n<p>An alternative (maybe better) is to use the following <a href=\"http://codex.wordpress.org...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12615/" ]
If we try to access a non-existant Multisite site, e.g., `http://site1.example.com` or `http://example.com/site1/`, we are redirected to `http://example.com/wp-signup.php?new=site1`. How to block this and redirect the browser to another page?
### [Update] An alternative (maybe better) is to use the following [constant](http://codex.wordpress.org/Editing_wp-config.php#Redirect_Nonexistent_Blogs) in `wp-config.php`: ``` define( 'NOBLOGREDIRECT', 'http://example.com' ); ``` --- At the very beginning of [`wp-signup.php`](http://core.trac.wordpress.org/brow...
85,539
<p>I want a static home page on my wordpress website, I have already set this up and have a bit of content on it, the next step is I want to have 5 recent posts underneath the content. As a normal page this is no problem, as soon as I set the page to a static home page, the posts disappear. </p> <p>From hours of searc...
[ { "answer_id": 85541, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 1, "selected": false, "text": "<p>First, Welcome!</p>\n\n<p>I guess you use the file <code>front-page.php</code> for displaying your homepag...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27348/" ]
I want a static home page on my wordpress website, I have already set this up and have a bit of content on it, the next step is I want to have 5 recent posts underneath the content. As a normal page this is no problem, as soon as I set the page to a static home page, the posts disappear. From hours of searching I am ...
First, Welcome! I guess you use the file `front-page.php` for displaying your homepage. What you have to do, is add the following code into your `front-page.php`: ``` <h2>Recent Posts</h2> <ul> <?php $args = array( 'numberposts' => '5' ); $recent_posts = wp_get_recent_posts( $args ); foreach( $recent_...
85,540
<p>I'm trying to create a basic affiliation system plugin that for now, will do the following:</p> <ul> <li>If it exists, read a $_GET URL parameter in <em>any</em> page (for instance <a href="http://mysite.com/about/?affid=1234" rel="nofollow noreferrer">http://mysite.com/about/?affid=1234</a>). If not skip the follo...
[ { "answer_id": 85546, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": true, "text": "<p>This should work<del>, though untested.</del></p>\n\n<pre><code>&lt;?php\nadd_action('send_headers', 'affilia...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8862/" ]
I'm trying to create a basic affiliation system plugin that for now, will do the following: * If it exists, read a $\_GET URL parameter in *any* page (for instance <http://mysite.com/about/?affid=1234>). If not skip the following two steps. * Save it in a cookie * Redirect to a clean URL (<http://mysite.com/about/>) ...
This should work~~, though untested.~~ ``` <?php add_action('send_headers', 'affiliate_redirect'); function affiliate_redirect() { // it's possible to use 'if( !empty( $_GET['affid']) )' if( isset($_GET['affid']) && '' != $_GET['affid'] ) { if( empty($_COOKIE['affid']) ) setcookie('affid', ...
85,544
<p>I'm building a Directory in Wordpress, and using Advanced Custom Fields for the client to populate the directory entries. One of the sections is for Social Media icons.</p> <p>Using the following code, I can check to see if any of the three fields (twitter / facebook / linked-in) is empty, and if empty to not show ...
[ { "answer_id": 85547, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 0, "selected": false, "text": "<p>Your if-statement wont work the way you want it.</p>\n\n<p><strong>Change this part of the code</strong></...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27351/" ]
I'm building a Directory in Wordpress, and using Advanced Custom Fields for the client to populate the directory entries. One of the sections is for Social Media icons. Using the following code, I can check to see if any of the three fields (twitter / facebook / linked-in) is empty, and if empty to not show an icon: ...
Note that [`get_field`](http://www.advancedcustomfields.com/docs/functions/get_field/) returns `false` and **not** an empty string when no value is found. It's not written in the docs there but you can try a `var_dump` on an empty `get_field` item to confirm. So you should check them against `false`. I've broken down ...
85,552
<p>I added the below code to the <code>function.php</code> of a <strong>.po</strong> file and finished localization and edited the <code>webconfig.php</code> to add Arabic language but nothing happened. I want to know what should happen. Will the site include the new language - in my situation Arabic, or what?</p> <p...
[ { "answer_id": 85556, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 4, "selected": true, "text": "<p>First, read <a href=\"http://codex.wordpress.org/Translating_WordPress\" rel=\"nofollow\"><strong>this Code...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85552", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27084/" ]
I added the below code to the `function.php` of a **.po** file and finished localization and edited the `webconfig.php` to add Arabic language but nothing happened. I want to know what should happen. Will the site include the new language - in my situation Arabic, or what? Now the website is in English and I want to a...
First, read [**this Codex page**](http://codex.wordpress.org/Translating_WordPress) about translating WordPress. You have to create a language file to put into your language directory, do this by following the next steps: **I assume you want to use *poedit* since you talk about a `.po` file** 1. [download poedit](ht...
85,575
<p>I have this function:</p> <pre><code>function the_breadcrumb() { if (!is_home()) { echo "Start » "; echo '&lt;a href="'; echo get_option('home'); echo '"&gt;'; bloginfo('name'); echo "&lt;/a&gt; » "; if (is_category() || is_single() ) { the_categor...
[ { "answer_id": 85582, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>This is a classic failure to indent code leading to confusion issue.</p>\n\n<p>If we reformat your code corre...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85575", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22826/" ]
I have this function: ``` function the_breadcrumb() { if (!is_home()) { echo "Start » "; echo '<a href="'; echo get_option('home'); echo '">'; bloginfo('name'); echo "</a> » "; if (is_category() || is_single() ) { the_category('title_li='); if...
This is a classic failure to indent code leading to confusion issue. If we reformat your code correctly we see: ``` function the_breadcrumb() { if (!is_home()) { echo "Start » "; echo '<a href="'; echo get_option('home'); echo '">'; bloginfo('name'); echo "</a> » ";...
85,609
<p>i have this snippet for specific category it works perfect but i want little modification to show posts by Ascending order.</p> <pre><code>&lt;?php // The Query query_posts( array ( 'category_name' =&gt; 'A', 'posts_per_page' =&gt; -1 ) ); // The Loop while ( have_posts() ) : the_post(); ?&gt; &lt;li&gt; ...
[ { "answer_id": 85611, "author": "user156", "author_id": 27376, "author_profile": "https://wordpress.stackexchange.com/users/27376", "pm_score": 1, "selected": false, "text": "<p>Add 'order'=> 'ASC' to your query</p>\n\n<pre><code> query_posts( array ( 'category_name' =&gt; 'A', 'order' =...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85609", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23407/" ]
i have this snippet for specific category it works perfect but i want little modification to show posts by Ascending order. ``` <?php // The Query query_posts( array ( 'category_name' => 'A', 'posts_per_page' => -1 ) ); // The Loop while ( have_posts() ) : the_post(); ?> <li> <a href="<?php the_permalink(...
Pretty sure query\_posts is the worst way to query... Always use get\_posts from what I'm constantly told. Remove the arguments that you don't use on the array below. ``` $args = array( 'posts_per_page' => 5000, 'offset' => 0, 'category' => , 'orderby' => 'post_date', 'or...
85,635
<p>In my <code>functions.php</code></p> <pre><code> function load_scripts() { wp_enqueue_script( 'jquery' ); wp_register_script( 'modernizr', get_template_directory_uri() .'/js/modernizr.foundation.js' ); wp_enqueue_script( 'modernizr' ); wp_register_script( 'jquery.simpleWeather', get_template_directory...
[ { "answer_id": 85636, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>You don't need <code>if ( !is_admin() )</code>. <code>wp_enqueue_scripts</code> only runs on the front end.</p...
2013/02/12
[ "https://wordpress.stackexchange.com/questions/85635", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
In my `functions.php` ``` function load_scripts() { wp_enqueue_script( 'jquery' ); wp_register_script( 'modernizr', get_template_directory_uri() .'/js/modernizr.foundation.js' ); wp_enqueue_script( 'modernizr' ); wp_register_script( 'jquery.simpleWeather', get_template_directory_uri() .'/js/jquery.simple...
You don't need `if ( !is_admin() )`. `wp_enqueue_scripts` only runs on the front end. WordPress loads jQuery in ["No Conflict" mode](http://api.jquery.com/jQuery.noConflict/). The `$` alias does not work. Use `jQuery` or wrap your script is a function as demonstrated in the jQuery docs: ``` jQuery.noConflict(); (fun...
85,651
<p>When you access mysite's feed you get the error message shown below. I've checked my <code>functions.php</code> file that no have any extra space on bottom end of file.</p> <blockquote> <p>error on line 1 at column 6: XML declaration allowed only at the start of the document Below is a rendering of the page up ...
[ { "answer_id": 85663, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>This sounds similar to a problem I had with my RSS feed</p>\n\n<p>just as @s_ha_dum suggests it could be theme...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85651", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25119/" ]
When you access mysite's feed you get the error message shown below. I've checked my `functions.php` file that no have any extra space on bottom end of file. > > error on line 1 at column 6: XML declaration allowed only at the start > of the document Below is a rendering of the page up to the first > error. > > >
This sounds similar to a problem I had with my RSS feed just as @s\_ha\_dum suggests it could be theme or plugin related: a) is it a theme related problem? --> switch to the default theme 2012 to check. if yes: You should also check if you have empty lines in between your code in functions.php: ``` ?> <?php ``` ...
85,653
<p>I've a very simple <code>index.php</code>:</p> <pre><code>&lt;div id="content"&gt; &lt;? get_template_part('content', get_post_format()) ?&gt; &lt;/div&gt; &lt;div id="pagination"&gt; &lt;? previous_posts_link() ?&gt; &lt;? next_posts_link() ?&gt; &lt;/div&gt; </code></pre> <p>And my <code>content.php</code...
[ { "answer_id": 85656, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>By the time you reach the template, WordPress has already queried the database and decided what to display based on ...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8536/" ]
I've a very simple `index.php`: ``` <div id="content"> <? get_template_part('content', get_post_format()) ?> </div> <div id="pagination"> <? previous_posts_link() ?> <? next_posts_link() ?> </div> ``` And my `content.php` looks roughly like this: ``` <? $paged = get_query_var('paged') ? get_query_var('paged'...
By the time you reach the template, WordPress has already queried the database and decided what to display based on those results. You're seeing a 404 error because based on the default main query, there are no more posts to show. When you call `query_posts` in the template, you overwrite that original query. Despite...
85,677
<p>Is there any software that I can run on either a Linux or a Windows server to check for domains that have out dated WordPress installations. I have seen a rise in hacked WordPress sites and in all the cases it was because the clients had not installed updates.</p>
[ { "answer_id": 85806, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>A simple solution would be to just use <code>wget</code> and grep the meta generator for example:</p>\n\n<pre><code...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19828/" ]
Is there any software that I can run on either a Linux or a Windows server to check for domains that have out dated WordPress installations. I have seen a rise in hacked WordPress sites and in all the cases it was because the clients had not installed updates.
If you can access the files from the server just include `wp-includes/version.php` from each installation. That file is completely stand-alone, it just defines five variables: ``` /** * The WordPress version string * * @global string $wp_version */ $wp_version = '3.5.1'; /** * Holds the WordPress DB revision, in...
85,681
<p>The default WordPress function <code>get_users('orderby=post_count');</code> only orders users with the count of the <em>posts</em> they've made.</p> <p>Any idea how to modify this to support custom post types as well?</p> <p><strong>UPDATE:</strong></p> <p>I only want to query posts of type "company-item". Curre...
[ { "answer_id": 85707, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>you can try to replace the where clause of the query by hooking to <code>pre_user_query</code>. Something lik...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27396/" ]
The default WordPress function `get_users('orderby=post_count');` only orders users with the count of the *posts* they've made. Any idea how to modify this to support custom post types as well? **UPDATE:** I only want to query posts of type "company-item". Currently, this snippet is in my functions.php: ``` functi...
you can try to replace the where clause of the query by hooking to `pre_user_query`. Something like: ``` function user_query_count_post_type($args){ $args->query_from = str_replace("post_type = post AND", "post_type IN ('post','cpt') AND ", $args->query_from); } ``` Usage ex: ``` add_action('pre_user_query','u...
85,774
<p>I've set up three custom taxonomies within my theme for attachment post types within Wordpress 3.5.1. One taxonomy is non-hierarchical (i.e. tags) and has about 800 terms in it. (I'm using WP to build a quick &amp; dirty stock photo site, and these taxonomy terms are akin to photo keywords. Yes, one could debate whe...
[ { "answer_id": 85778, "author": "rememberlenny", "author_id": 16720, "author_profile": "https://wordpress.stackexchange.com/users/16720", "pm_score": -1, "selected": false, "text": "<p>My experiences with slow WordPress websites, due to changes, are related to the PHP memory space. This ...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85774", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26696/" ]
I've set up three custom taxonomies within my theme for attachment post types within Wordpress 3.5.1. One taxonomy is non-hierarchical (i.e. tags) and has about 800 terms in it. (I'm using WP to build a quick & dirty stock photo site, and these taxonomy terms are akin to photo keywords. Yes, one could debate whether WP...
This has nothing to do with custom taxonomies. I was using a snippet of code from the default 'twentytwelve' theme for image.php that was looping through every single post in the blog to get child attachments, and thus the taxonomy associations for each of those posts. Amending my image.php by removing this foreach() l...
85,790
<p>How can I get WordPress to render a page without it adding any addtional html? I'm trying to build a dialog that will work on mobile devices and I only want to show that dialog and not have any of the standard wordpress content around it.</p>
[ { "answer_id": 85795, "author": "smithandteam", "author_id": 27446, "author_profile": "https://wordpress.stackexchange.com/users/27446", "pm_score": 0, "selected": false, "text": "<p>Make a new template, add your loops, etc, without the HTML present in your desktop site. This is the only...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85790", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27444/" ]
How can I get WordPress to render a page without it adding any addtional html? I'm trying to build a dialog that will work on mobile devices and I only want to show that dialog and not have any of the standard wordpress content around it.
You have to implement your own hook for `template_redirect` action: ``` add_action( 'template_redirect', 'wpse8170_template_redirect', 1 ); function wpse8170_template_redirect() { global $wp_query; // check if it is not a page or if it is front page, then exit from the hook if ( !$wp_query->is_page() || $...
85,793
<p>I want to add a class to the body tag to all pages EXCEPT the homepage. Right now I have.</p> <p><code>&lt;?php body_class('interior'); ?&gt;</code></p> <p>But it adds 'interior' to ALL pages including the home page.</p> <p>What is the best standard way of adding a class to the body tag?</p>
[ { "answer_id": 85796, "author": "Thiago Locks", "author_id": 27447, "author_profile": "https://wordpress.stackexchange.com/users/27447", "pm_score": 4, "selected": true, "text": "<p>Try it:</p>\n\n<pre><code>&lt;?php\n$class = ! is_home() ? \"interior\" : \"\";\nbody_class( $class );\n?&...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85793", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5369/" ]
I want to add a class to the body tag to all pages EXCEPT the homepage. Right now I have. `<?php body_class('interior'); ?>` But it adds 'interior' to ALL pages including the home page. What is the best standard way of adding a class to the body tag?
Try it: ``` <?php $class = ! is_home() ? "interior" : ""; body_class( $class ); ?> ``` Or this: ``` <?php body_class( ! is_home() ? "interior" : "" ); ?> ```
85,810
<p>I've been unable to find anything on how to do this, or if it's even possible.</p> <p>What I want to do is not display results of search in custom post type "resources" on which "resource_usertype" (key) is not "Public" or "Students" or "Alumni" (values). </p> <p>Or maybe a better way to say it is to only display ...
[ { "answer_id": 85814, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 0, "selected": false, "text": "<p>It's perfectly possible!</p>\n\n<pre><code>$args = array(\n 'post_type' =&gt; 'resources',\n 'meta_query'...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30/" ]
I've been unable to find anything on how to do this, or if it's even possible. What I want to do is not display results of search in custom post type "resources" on which "resource\_usertype" (key) is not "Public" or "Students" or "Alumni" (values). Or maybe a better way to say it is to only display search results i...
You need to implement a hook for `pre_get_posts` filter, in which you can set what you need. Pay attention that you should change only search query, so you have to check if `is_search()` method returns true. The hook should look like this: ``` add_filter( 'pre_get_posts', 'wpse8170_pre_get_posts' ); function wpse8170_...
85,824
<p>I am trying to load the chosen library: <a href="http://harvesthq.github.com/chosen/" rel="nofollow">http://harvesthq.github.com/chosen/</a></p> <p>I am enqueuing a .js file as below:</p> <pre><code>wp_register_script( 'js_custom', plugin_dir_url( __FILE__ ) . 'js/jquery.js', false ); wp_enqueue_script ( 'js_custo...
[ { "answer_id": 85835, "author": "Marcin Bobowski", "author_id": 25644, "author_profile": "https://wordpress.stackexchange.com/users/25644", "pm_score": 2, "selected": false, "text": "<p>You forgot to load chosen library:</p>\n\n<pre><code>wp_register_script( 'js_chosen', 'https://raw.git...
2013/02/13
[ "https://wordpress.stackexchange.com/questions/85824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16641/" ]
I am trying to load the chosen library: <http://harvesthq.github.com/chosen/> I am enqueuing a .js file as below: ``` wp_register_script( 'js_custom', plugin_dir_url( __FILE__ ) . 'js/jquery.js', false ); wp_enqueue_script ( 'js_custom' ); ``` Inside the .js file I loading chosen like this: ``` jQuery(document).re...
You forgot to load chosen library: ``` wp_register_script( 'js_chosen', 'https://raw.github.com/harvesthq/chosen/master/chosen/chosen.jquery.js', array('jquery') ); wp_register_script( 'js_custom', plugin_dir_url( __FILE__ ) . 'js/jquery.js', array('jquery', 'js_chosen') ); wp_enqueue_script ( 'js_custom' ); ```
85,841
<p>We are about to purchase a site that uses Amazon affiliate links. </p> <p>Naturally, they have their own affiliate ID, Amazon affiliate links look like this:</p> <pre><code>http://www.amazon.com/gp/product/productcode/?tag=affiliateID-20 </code></pre> <p>What would be the best way to alter the ending string for t...
[ { "answer_id": 85835, "author": "Marcin Bobowski", "author_id": 25644, "author_profile": "https://wordpress.stackexchange.com/users/25644", "pm_score": 2, "selected": false, "text": "<p>You forgot to load chosen library:</p>\n\n<pre><code>wp_register_script( 'js_chosen', 'https://raw.git...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/85841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26435/" ]
We are about to purchase a site that uses Amazon affiliate links. Naturally, they have their own affiliate ID, Amazon affiliate links look like this: ``` http://www.amazon.com/gp/product/productcode/?tag=affiliateID-20 ``` What would be the best way to alter the ending string for these links' URL's in a Wordpress ...
You forgot to load chosen library: ``` wp_register_script( 'js_chosen', 'https://raw.github.com/harvesthq/chosen/master/chosen/chosen.jquery.js', array('jquery') ); wp_register_script( 'js_custom', plugin_dir_url( __FILE__ ) . 'js/jquery.js', array('jquery', 'js_chosen') ); wp_enqueue_script ( 'js_custom' ); ```
85,845
<p>I have a folder and file structure already in place for a site to which I am inserting WordPress. My goal is to execute WP at the root level (/) when a visitor just visits the domain without a path, however I want WP to be installed within the <code>wordpress</code> subfolder folder.</p> <p>So far I've reviewed sev...
[ { "answer_id": 85846, "author": "bvillebud", "author_id": 27167, "author_profile": "https://wordpress.stackexchange.com/users/27167", "pm_score": 1, "selected": false, "text": "<p>WordPress has a good writeup about this at <a href=\"http://codex.wordpress.org/Giving_WordPress_Its_Own_Dir...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/85845", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27313/" ]
I have a folder and file structure already in place for a site to which I am inserting WordPress. My goal is to execute WP at the root level (/) when a visitor just visits the domain without a path, however I want WP to be installed within the `wordpress` subfolder folder. So far I've reviewed several hits on this, bu...
WordPress has a good writeup about this at [Giving\_WordPress\_Its\_Own\_Directory](http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory). > > Many people want WordPress to power their site's root (e.g. `http://example.com`) but they don't want all of the WordPress files cluttering up their root directory. W...
86,853
<p>I'm currently using a custom made Twentytwelve child theme and would like to display the last 5 posts on the homepage using a shortcode. I have tried using the code below (added to <code>functions.php</code>) but to no avail - when I add the shortcode to the homepage, it doesn't display anything although as far as I...
[ { "answer_id": 85846, "author": "bvillebud", "author_id": 27167, "author_profile": "https://wordpress.stackexchange.com/users/27167", "pm_score": 1, "selected": false, "text": "<p>WordPress has a good writeup about this at <a href=\"http://codex.wordpress.org/Giving_WordPress_Its_Own_Dir...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86853", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26686/" ]
I'm currently using a custom made Twentytwelve child theme and would like to display the last 5 posts on the homepage using a shortcode. I have tried using the code below (added to `functions.php`) but to no avail - when I add the shortcode to the homepage, it doesn't display anything although as far as I can see, it s...
WordPress has a good writeup about this at [Giving\_WordPress\_Its\_Own\_Directory](http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory). > > Many people want WordPress to power their site's root (e.g. `http://example.com`) but they don't want all of the WordPress files cluttering up their root directory. W...
86,864
<p>I previously declared the taxonomy " artist " for a profile post type.</p> <p>Now i am creating a CD post type and would like to use the same artist list from the profile post type </p> <p>That is one example if i get a solution i will be using this to share a number of other taxonomies among-st post types :D</p> ...
[ { "answer_id": 86865, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": false, "text": "<p>You can use an array of post types in <code>register_taxonomy()</code></p>\n\n<blockquote>\n <p>$object_type ...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86864", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27461/" ]
I previously declared the taxonomy " artist " for a profile post type. Now i am creating a CD post type and would like to use the same artist list from the profile post type That is one example if i get a solution i will be using this to share a number of other taxonomies among-st post types :D Thanks in Advance. ...
You can use an array of post types in `register_taxonomy()` > > $object\_type (array/string) (required) Name of the object type for the > taxonomy object. Object-types can be built-in Post Type or any Custom > Post Type that may be registered. > > > <http://codex.wordpress.org/Function_Reference/register_taxono...
86,868
<p>I know this has been asked many times. But from what i got after searching, i could not understand much. I have used <code>wp_update_nav_menu_item</code> to add menu items programatically. But i don't know how to remove a specific menu item. In one of the forums, it has been told to unset the array element (<a href=...
[ { "answer_id": 86874, "author": "Ahmad M", "author_id": 12961, "author_profile": "https://wordpress.stackexchange.com/users/12961", "pm_score": 5, "selected": true, "text": "<p>I think the best way to remove a menu item from a menu is by hooking to <code>wp_nav_menu_objects</code> filter...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86868", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26706/" ]
I know this has been asked many times. But from what i got after searching, i could not understand much. I have used `wp_update_nav_menu_item` to add menu items programatically. But i don't know how to remove a specific menu item. In one of the forums, it has been told to unset the array element ([forum](https://wordpr...
I think the best way to remove a menu item from a menu is by hooking to `wp_nav_menu_objects` filter (@Otto answer from the thread you mentioned). And the way you use is first check for the correct menu to filter, and then search for the menu item and remove it by unsetting it from the `$sorted_menu_objects` array. Th...
86,885
<p>Currently, I'm building multi languages blog. As I know, almost WP language translator plugins are based on .po &amp; .mo files. here is a problem. A new language what I'm going to add does not exist with .po &amp; .mo files, it's just a dialect(local) language.</p> <p>That's why I defined in php and grab the lan...
[ { "answer_id": 86874, "author": "Ahmad M", "author_id": 12961, "author_profile": "https://wordpress.stackexchange.com/users/12961", "pm_score": 5, "selected": true, "text": "<p>I think the best way to remove a menu item from a menu is by hooking to <code>wp_nav_menu_objects</code> filter...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86885", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27469/" ]
Currently, I'm building multi languages blog. As I know, almost WP language translator plugins are based on .po & .mo files. here is a problem. A new language what I'm going to add does not exist with .po & .mo files, it's just a dialect(local) language. That's why I defined in php and grab the language.php files as...
I think the best way to remove a menu item from a menu is by hooking to `wp_nav_menu_objects` filter (@Otto answer from the thread you mentioned). And the way you use is first check for the correct menu to filter, and then search for the menu item and remove it by unsetting it from the `$sorted_menu_objects` array. Th...
86,897
<p>I'm making my own theme. In my theme I have a page that display custom post using a custom query. I added a form to this page. The form contain 2 comboboxes that contain values of meta data of my custom post. I want that when the user select values from this comboboxes and click the submit, Wordpress will show agai...
[ { "answer_id": 86898, "author": "jberculo", "author_id": 20349, "author_profile": "https://wordpress.stackexchange.com/users/20349", "pm_score": 2, "selected": false, "text": "<p>If you leave the action empty, the form will submit to the same page.</p>\n\n<p>So just do this: \n<code>&lt;...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86897", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25010/" ]
I'm making my own theme. In my theme I have a page that display custom post using a custom query. I added a form to this page. The form contain 2 comboboxes that contain values of meta data of my custom post. I want that when the user select values from this comboboxes and click the submit, Wordpress will show again t...
I found the problem and the solution. **The problem:** Using: ``` <form action="<?php echo get_page_link(66) ?>" method="get"> ``` is no good. In the generated HTML I can see: ``` <form action="http://mySite/?page_id=66" method="get"> ``` But when submitting the form, the ?page\_id=66 is disappear. So Wordpre...
86,901
<p>I'm trying to display a list of authors by their last name. I can get the list to display but as yet I don't seem to be able to order the list by last name. Any help would be greatly appreciated. Josh</p> <pre><code>&lt;?php $args = array( // search only for Authors role // order results by display_nam...
[ { "answer_id": 86902, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>The following works on my install: </p>\n\n<pre><code>$args = array(\n 'orderby' =&gt; 'meta_value'...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24931/" ]
I'm trying to display a list of authors by their last name. I can get the list to display but as yet I don't seem to be able to order the list by last name. Any help would be greatly appreciated. Josh ``` <?php $args = array( // search only for Authors role // order results by display_name 'orderby' =...
There is apparently an open ticket about this [bug](http://core.trac.wordpress.org/ticket/21581). Here is a workaround that I tested: ``` $args = array( 'meta_key' => 'last_name', 'role' => 'guest-teacher' ); $wp_user_query = new WP_User_Query($args); $wp_user_query->query_orderby = str_replace( 'user_l...
86,914
<p>I'm building a navigation, outside of the main loop, that includes drop downs. I have a custom post type called 'Events', that has its own categories. I would like there to be a drop down if there are posts within that custom post type and category, but I'm not sure what functions I should be using to determine th...
[ { "answer_id": 86924, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 4, "selected": true, "text": "<p>It all boils down to WP_Query in the end even if you use get_posts, here's my modified version:</p>\n\n<pre><c...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86914", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12294/" ]
I'm building a navigation, outside of the main loop, that includes drop downs. I have a custom post type called 'Events', that has its own categories. I would like there to be a drop down if there are posts within that custom post type and category, but I'm not sure what functions I should be using to determine this......
It all boils down to WP\_Query in the end even if you use get\_posts, here's my modified version: ``` $hasposts = get_posts('post_type=sc-events&category=40'); if( !empty ( $hasposts ) ) { ..// show the drop down menu } ``` or ``` $query = new WP_Query(array( 'post_type' => 'sc-events', 'category' => 40...
86,918
<p>I like to publish drafts in my 'Uncategorized' category. This category is not linked anywhere on my site. It's great for allowing contributors to an article to read the draft before it is made public. The problem is that after just 2 or 3 days, search engines begin picking up the draft and people start posting co...
[ { "answer_id": 86921, "author": "Sunyatasattva", "author_id": 24240, "author_profile": "https://wordpress.stackexchange.com/users/24240", "pm_score": 0, "selected": false, "text": "<p>Something like this in your <code>robots.txt</code>?</p>\n\n<pre><code>User-agent: *\nDisallow: /categor...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86918", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22989/" ]
I like to publish drafts in my 'Uncategorized' category. This category is not linked anywhere on my site. It's great for allowing contributors to an article to read the draft before it is made public. The problem is that after just 2 or 3 days, search engines begin picking up the draft and people start posting comments...
How about something like this on your `functions.php`: ``` add_action('wp_head', 'no_robots_on_uncategorized_posts'); function no_robots_on_uncategorized_posts() { if(in_category('uncategorized')) { wp_no_robots(); } } ``` This will output the following line of code on the header of your 'uncategor...
86,950
<p>The <code>$content_width</code> GLOBAL in WordPress effects many themes and even some plugins by limiting the size of images and embeds in posts, it is a requirement for themes submitted to wordpress.org. </p> <p>It is set by using:</p> <pre><code>$content_width = 584; // Twenty Twelve example </code></pre> <p>If...
[ { "answer_id": 87556, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>Keep in mind that the <code>$content_width</code> global is not only used for images, but also for embedded ...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86950", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1509/" ]
The `$content_width` GLOBAL in WordPress effects many themes and even some plugins by limiting the size of images and embeds in posts, it is a requirement for themes submitted to wordpress.org. It is set by using: ``` $content_width = 584; // Twenty Twelve example ``` If you insert a large image (default 1024x1024...
Keep in mind that the `$content_width` global is not only used for images, but also for embedded objects, such as video. So, any solution won't merely be a case of dropping use/support of `$content_width` itself. Usually a Theme will constrain content-area images in a few ways: 1. **Large** Image size: Defining `$con...
86,967
<p>I am trying to add a variation product to my cart directly through a link. I am setting the variation_id with the query string. As far as I can tell I am sending the data the exact same way as the default variation product form does.</p> <p>Here's the code inside of my single-product page:</p> <pre><code>&lt;a hre...
[ { "answer_id": 87381, "author": "ezekielDFM", "author_id": 16985, "author_profile": "https://wordpress.stackexchange.com/users/16985", "pm_score": 4, "selected": true, "text": "<p>Figured this one out. I was missing a couple parameters needed to add a variable product to my cart. The mis...
2013/02/14
[ "https://wordpress.stackexchange.com/questions/86967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16985/" ]
I am trying to add a variation product to my cart directly through a link. I am setting the variation\_id with the query string. As far as I can tell I am sending the data the exact same way as the default variation product form does. Here's the code inside of my single-product page: ``` <a href="<?php echo esc_url( ...
Figured this one out. I was missing a couple parameters needed to add a variable product to my cart. The missing params are the `variation_id` and the attribute type that the `variation_id` is referring to. The variation id can be found in the admin > woocomerce > products and under the variations tab next to the produ...
86,976
<p>What is the proper way to display User Meta in the BP Loop using this line from codex?</p> <pre><code> &lt;?php get_user_meta($user_id, $key, $single); ?&gt; </code></pre> <p>I added that line to the profile loop and switched those values with ones from my DB and nothing happened. What am I doing wrong?</p> <pre...
[ { "answer_id": 87033, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 0, "selected": false, "text": "<p>Silly me. I forgot to replace this line </p>\n\n<pre><code>$user_last = get_user_meta( $user_id, $key, $sin...
2013/02/15
[ "https://wordpress.stackexchange.com/questions/86976", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17636/" ]
What is the proper way to display User Meta in the BP Loop using this line from codex? ``` <?php get_user_meta($user_id, $key, $single); ?> ``` I added that line to the profile loop and switched those values with ones from my DB and nothing happened. What am I doing wrong? ``` <?php $user_id = 9; $key = 'las...
Inside the loop, you can get the currently iterated user id using `bp_get_member_user_id()`. Also, it's best practice to use `bp_get_user_meta()`, because it works better with certain kinds of BP plugins (multi-network, etc). Thus: ``` if ( bp_has_members() ) { while ( bp_members() ) { bp_the_member(); ...
86,986
<p>Some of my pages/posts have very short custom stylesheets at the beginning of them. I know this isn't great practice, but it's worked very well thus far. The problem, however, is linking on Facebook: Facebook auto-generates a preview of the page, and it includes a picture, the page title, and a snippet from the begi...
[ { "answer_id": 87033, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 0, "selected": false, "text": "<p>Silly me. I forgot to replace this line </p>\n\n<pre><code>$user_last = get_user_meta( $user_id, $key, $sin...
2013/02/15
[ "https://wordpress.stackexchange.com/questions/86986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22999/" ]
Some of my pages/posts have very short custom stylesheets at the beginning of them. I know this isn't great practice, but it's worked very well thus far. The problem, however, is linking on Facebook: Facebook auto-generates a preview of the page, and it includes a picture, the page title, and a snippet from the beginni...
Inside the loop, you can get the currently iterated user id using `bp_get_member_user_id()`. Also, it's best practice to use `bp_get_user_meta()`, because it works better with certain kinds of BP plugins (multi-network, etc). Thus: ``` if ( bp_has_members() ) { while ( bp_members() ) { bp_the_member(); ...
86,992
<p>I'm using a theme that gets updated pretty frequently. For this, it has added a custom.php file to include modifications. Now, in this theme, under the functions.php, the developer has included his own meta section which is added using the following function:</p> <pre><code>add_action('wp_head', 'theme_metas'); </c...
[ { "answer_id": 87033, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 0, "selected": false, "text": "<p>Silly me. I forgot to replace this line </p>\n\n<pre><code>$user_last = get_user_meta( $user_id, $key, $sin...
2013/02/15
[ "https://wordpress.stackexchange.com/questions/86992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27507/" ]
I'm using a theme that gets updated pretty frequently. For this, it has added a custom.php file to include modifications. Now, in this theme, under the functions.php, the developer has included his own meta section which is added using the following function: ``` add_action('wp_head', 'theme_metas'); ``` I want to l...
Inside the loop, you can get the currently iterated user id using `bp_get_member_user_id()`. Also, it's best practice to use `bp_get_user_meta()`, because it works better with certain kinds of BP plugins (multi-network, etc). Thus: ``` if ( bp_has_members() ) { while ( bp_members() ) { bp_the_member(); ...
87,024
<p>I'm trying to get W3 Total Cache to rewrite URLs to minified files. I've tried every tutorial I could find but I don't seem to be able to get it right. I keep getting a W3 Total Cache error saying this:</p> <p><code>It appears Minify URL rewriting is not working. If using apache, verify that the server configuratio...
[ { "answer_id": 88951, "author": "wp student", "author_id": 23841, "author_profile": "https://wordpress.stackexchange.com/users/23841", "pm_score": -1, "selected": false, "text": "<p>Just disable javascript minification. I did it for my site and it worked.</p>\n" }, { "answer_id":...
2013/02/15
[ "https://wordpress.stackexchange.com/questions/87024", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27522/" ]
I'm trying to get W3 Total Cache to rewrite URLs to minified files. I've tried every tutorial I could find but I don't seem to be able to get it right. I keep getting a W3 Total Cache error saying this: `It appears Minify URL rewriting is not working. If using apache, verify that the server configuration allows .htacc...
Create a file specifically for W3 Total Cache configuration for your site, in a location Nginx/PHP-FPM can write to. Include this file in your site's Nginx server configuration. Then on the General Settings page, under Miscellaneous provide the full path to this file in the "Nginx server configuration file path" field....
87,036
<p>I'm trying to filter my content and on matches on flow I would like to change my html structure, but my rule doesn't really apply. I have the following filter which searches the first image of posts and on rule match attaching a css container. The <code>preg_match_all</code> is working but the <code>str_replace</cod...
[ { "answer_id": 87041, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": true, "text": "<p>Change, </p>\n\n<pre><code>str_replace($to_search , $replacement, $post-&gt;post_content);\n</code></pre>\n\n<p>to...
2013/02/15
[ "https://wordpress.stackexchange.com/questions/87036", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23759/" ]
I'm trying to filter my content and on matches on flow I would like to change my html structure, but my rule doesn't really apply. I have the following filter which searches the first image of posts and on rule match attaching a css container. The `preg_match_all` is working but the `str_replace` doesn't ``` function...
Change, ``` str_replace($to_search , $replacement, $post->post_content); ``` to.. ``` $content = str_replace($to_search , $replacement, $post->post_content); ```
87,081
<p>I added bbpress forum pluggin in my site to handle discussions, forum or comments. The bbPress CSS file is added to every page of my blog. Now, I want to load it only on forum directory to consider page speed. Is there any way to do this?</p>
[ { "answer_id": 87087, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 0, "selected": false, "text": "<p><em>try</em> this in your header</p>\n\n<pre><code>&lt;?php\nif(is_page_template('bbpress.php' 'forum.php' ...
2013/02/15
[ "https://wordpress.stackexchange.com/questions/87081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27543/" ]
I added bbpress forum pluggin in my site to handle discussions, forum or comments. The bbPress CSS file is added to every page of my blog. Now, I want to load it only on forum directory to consider page speed. Is there any way to do this?
The styles are enqueued in the function `enqueue_styles()` inside the file `/wp-content/plugins/bbpress/templates/default/bbpress-functions.php`. It's a matter of using [`is_bbpress()`](https://wordpress.stackexchange.com/q/24683/12615) and [`wp_dequeue_style`](http://codex.wordpress.org/Function_Reference/wp_dequeue_...
87,119
<p>After reading through here and trying various options, I am finally able to get my custom post types 'testimonial' (created with product 'Toolset') to show along with my standard cat/tag queries WITHOUT the menu disappearing!! Here is the code I came up with, and placed in my theme's custom-functions.php file:</p> ...
[ { "answer_id": 87121, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>It looks like you are just trying to get WordPress to include your custom post type in the queries. All you s...
2013/02/16
[ "https://wordpress.stackexchange.com/questions/87119", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27557/" ]
After reading through here and trying various options, I am finally able to get my custom post types 'testimonial' (created with product 'Toolset') to show along with my standard cat/tag queries WITHOUT the menu disappearing!! Here is the code I came up with, and placed in my theme's custom-functions.php file: ``` add...
`pre_get_posts` runs on every query, so you want to check if [`is_main_query()`](http://codex.wordpress.org/Function_Reference/is_main_query) so it only applies to the default query and not additional queries you run on the page. You should also get in the habit of referencing the query object passed to the function l...
87,135
<p>I've read a lot of documentation tonight, can't see why this isn't working. Obviously something I'm missing.</p> <pre><code>$newstr = "18,19"; $defid = 1; $table = "wp_tablename"; $data = "array( 'somecol' =&gt; '".$newstr."' )"; $where = "array( 'id' =&gt; ".$defid." )"; if ($wpdb-&gt;update( $table, $data, $wher...
[ { "answer_id": 87137, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>you're creating the <code>$data</code> and <code>$where</code> values as strings, not arrays.</p>\n\n<p>this:</p>\n...
2013/02/16
[ "https://wordpress.stackexchange.com/questions/87135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27561/" ]
I've read a lot of documentation tonight, can't see why this isn't working. Obviously something I'm missing. ``` $newstr = "18,19"; $defid = 1; $table = "wp_tablename"; $data = "array( 'somecol' => '".$newstr."' )"; $where = "array( 'id' => ".$defid." )"; if ($wpdb->update( $table, $data, $where) === FALSE) { ech...
you're creating the `$data` and `$where` values as strings, not arrays. this: ``` $data = "array( 'somecol' => '".$newstr."' )"; $where = "array( 'id' => ".$defid." )"; ``` should be: ``` $data = array( 'somecol' => $newstr ); $where = array( 'id' => $defid ); ```
87,146
<p>I have a button at the top of the website in <strong>header.php</strong>. That button should transfer me to the Arabic version of the page if I am on an English page. </p> <p>For example, on <strong>contact.html</strong> the button should transfer me to <strong>contact-ar.html</strong> and on <strong>info.html</st...
[ { "answer_id": 87151, "author": "Ahmad M", "author_id": 12961, "author_profile": "https://wordpress.stackexchange.com/users/12961", "pm_score": 1, "selected": false, "text": "<p>Try the following. This is given that the original page url has a <code>.html</code> in it (<code>contact.html...
2013/02/16
[ "https://wordpress.stackexchange.com/questions/87146", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27084/" ]
I have a button at the top of the website in **header.php**. That button should transfer me to the Arabic version of the page if I am on an English page. For example, on **contact.html** the button should transfer me to **contact-ar.html** and on **info.html** the button should transfer me to **info-ar.html**. ``` <...
Try the following. This is given that the original page url has a `.html` in it (`contact.html` and `info.html`) ``` <li><a href="<?php if (false !== strpos(strtolower($_SERVER['REQUEST_URI']), '.html')) { $uri = str_replace('.html', '-ar.html', strtolower($_SERVER['REQUEST_URI'])); } else { $uri = ''; } echo ...
87,190
<p>I want to make a crop on the images of my blog page that have more than 443px adjust it to 645x443 size, exactly.</p> <p>I used this code:</p> <pre><code>add_theme_support ('post-thumbnails'); add_image_size ('blog-page', 645, 445, true); </code></pre> <p>However, the image is resized instead of making the crop.<...
[ { "answer_id": 87194, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>From this comment:</p>\n\n<blockquote>\n <p>Sry, i forgot it, but i want size of 645x445, exactly, and that...
2013/02/16
[ "https://wordpress.stackexchange.com/questions/87190", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25881/" ]
I want to make a crop on the images of my blog page that have more than 443px adjust it to 645x443 size, exactly. I used this code: ``` add_theme_support ('post-thumbnails'); add_image_size ('blog-page', 645, 445, true); ``` However, the image is resized instead of making the crop. Exemples: Original image: <http...
From this comment: > > Sry, i forgot it, but i want size of 645x445, exactly, and that image dont have it. The width of it is 588px. Look: img201.imageshack.us/img201/4728/40405258.png Wordpress need make a zoom on it. > > > WordPress does not zoom. It only crops. If you want an image to have a custom intermediat...
87,208
<p>I want make all my blog thumbs the size of 227x133. I need images width have 100% (for responsive design). Some images have width greater than the other and vice versa.</p> <p>I'm using this code to show the thumbs of my blog:</p> <pre><code>/ / Post thumbnails sizes add_theme_support ('post-thumbnails'); add_imag...
[ { "answer_id": 87209, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 0, "selected": false, "text": "<p>I see you are fairly new here . I hope we can assist you and if you find an answer helpful, please upvote a...
2013/02/16
[ "https://wordpress.stackexchange.com/questions/87208", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25881/" ]
I want make all my blog thumbs the size of 227x133. I need images width have 100% (for responsive design). Some images have width greater than the other and vice versa. I'm using this code to show the thumbs of my blog: ``` / / Post thumbnails sizes add_theme_support ('post-thumbnails'); add_image_size ('blog-page', ...
Intermediate image sizes are discrete, not variable. When you define an image size, with specific dimensions (whether hard-cropped or box-resized), WordPress will create a discrete image, with the specified dimensions. Otherwise, if width could be defined dynamically, WordPress would have to create a prohibitively lar...
87,216
<p>I'm thinking it's just a PHP code error, but for some reason the following code won't work, it just keeps giving me <em>Internal Server Error 500</em></p> <pre><code>&lt;?php $ajfl_adLuck = rand(1,3); if ($ajfl_adLuck == 2) { echo "&lt;div id=\"sidebar-awesome-container\"&gt;"; echo "&lt;div id=\"sideba...
[ { "answer_id": 87209, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 0, "selected": false, "text": "<p>I see you are fairly new here . I hope we can assist you and if you find an answer helpful, please upvote a...
2013/02/16
[ "https://wordpress.stackexchange.com/questions/87216", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27591/" ]
I'm thinking it's just a PHP code error, but for some reason the following code won't work, it just keeps giving me *Internal Server Error 500* ``` <?php $ajfl_adLuck = rand(1,3); if ($ajfl_adLuck == 2) { echo "<div id=\"sidebar-awesome-container\">"; echo "<div id=\"sidebar-awesome-wrapper\">"; echo "...
Intermediate image sizes are discrete, not variable. When you define an image size, with specific dimensions (whether hard-cropped or box-resized), WordPress will create a discrete image, with the specified dimensions. Otherwise, if width could be defined dynamically, WordPress would have to create a prohibitively lar...
87,233
<p>I'm trying to figure out how to make a function to automatically add a "featured" tag to a post, based on a checkbox in a metabox I've added to the edit screen.</p> <p>I think the function I need to use is <a href="http://codex.wordpress.org/Function_Reference/wp_set_object_terms" rel="nofollow">wp_set_object_terms...
[ { "answer_id": 87242, "author": "Anagio", "author_id": 10413, "author_profile": "https://wordpress.stackexchange.com/users/10413", "pm_score": 0, "selected": false, "text": "<p>You can hook into the action with <code>add_action ( 'publish_post', 'your_function' );</code></p>\n\n<p>Write ...
2013/02/17
[ "https://wordpress.stackexchange.com/questions/87233", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27598/" ]
I'm trying to figure out how to make a function to automatically add a "featured" tag to a post, based on a checkbox in a metabox I've added to the edit screen. I think the function I need to use is [wp\_set\_object\_terms](http://codex.wordpress.org/Function_Reference/wp_set_object_terms), but I don't get how it work...
I accidentally found this question searching for something similar, and I liked your approach, so I improved your code a bit. 1. I updated the action hook so it's being triggered on save AND update. 2. Added the `wp_remove_object_terms` to be able to switch back ( toggle ) custom meta box value ( in this case check-bo...
87,234
<p>I am using Add From Server plugin <a href="http://wordpress.org/extend/plugins/add-from-server/" rel="nofollow">http://wordpress.org/extend/plugins/add-from-server/</a> basically it imports/upload image from the server. Currently the plugin copies the images into month/year folder format but I want to change it by m...
[ { "answer_id": 87484, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": true, "text": "<p>You can try to add this into your <code>functions.php</code> file:</p>\n\n<pre><code>add_filter( 'upload_dir','...
2013/02/17
[ "https://wordpress.stackexchange.com/questions/87234", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17971/" ]
I am using Add From Server plugin <http://wordpress.org/extend/plugins/add-from-server/> basically it imports/upload image from the server. Currently the plugin copies the images into month/year folder format but I want to change it by making it copy by the Post ID folder format instead of month/year. I have already t...
You can try to add this into your `functions.php` file: ``` add_filter( 'upload_dir','wpse87234_upload_dir'); function wpse87234_upload_dir($uploads){ // check if we are in the "Add From Server" media tab if (isset($_REQUEST['post_id']) && isset($_GET['tab']) && $_GET['tab']=="server") { $prefix="post...
87,235
<p>Using <code>wp_nav_menu()</code> , how can I append a value at end of each URL?<br> For example, I have the following url: <code>http://www.example.com/</code> but I have to append a language parameter at the end, so the url should be: <code>http://www.example.com/?lang=$language</code></p>
[ { "answer_id": 87240, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 2, "selected": false, "text": "<p>You can either use a <a href=\"https://codex.wordpress.org/Function_Reference/wp_nav_menu#Using_a_Custom_W...
2013/02/17
[ "https://wordpress.stackexchange.com/questions/87235", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20920/" ]
Using `wp_nav_menu()` , how can I append a value at end of each URL? For example, I have the following url: `http://www.example.com/` but I have to append a language parameter at the end, so the url should be: `http://www.example.com/?lang=$language`
I found the solution modifying the behaviour of `wp_nav_menu` with the `wp_get_nav_menu_items-filter`. Here's a somewhat complete example: ``` class ModifyLinkFilter { protected $_prio = 10; protected $_args; public function __construct($addargs = array(), $prio = 10) { $this->_args = $addargs; $this->_prio =...
87,244
<p>I need to paginate an archive page. Pagination works perfectly fine for everything except tag/category archives. Basically if I use /tags/tag_name/?paged=2 it gives me a 404 error. But if I use /tags/tag_name/?page=2 it works fine. Unfortunately I need to use /tags/tag_name/?paged=2</p> <p>I reckon it has to do wit...
[ { "answer_id": 87247, "author": "Thiago Locks", "author_id": 27447, "author_profile": "https://wordpress.stackexchange.com/users/27447", "pm_score": -1, "selected": false, "text": "<p>A very simple way is to insert in your <em>functions.php</em>:</p>\n\n<pre><code>if ( isset( $_GET['page...
2013/02/17
[ "https://wordpress.stackexchange.com/questions/87244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27603/" ]
I need to paginate an archive page. Pagination works perfectly fine for everything except tag/category archives. Basically if I use /tags/tag\_name/?paged=2 it gives me a 404 error. But if I use /tags/tag\_name/?page=2 it works fine. Unfortunately I need to use /tags/tag\_name/?paged=2 I reckon it has to do with rewri...
I change the pagination param from "paged" to "page" and works! Dont give 404 more =)
87,256
<p>This is default wordpress add_editor_style function:</p> <pre><code>function add_editor_style( $stylesheet = 'editor-style.css' ) { add_theme_support( 'editor-style' ); if ( ! is_admin() ) return; global $editor_styles; $editor_styles = (array) $editor_styles; $stylesheet = (array)...
[ { "answer_id": 87258, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/add_editor_style\" rel=\"nofollow\"><code>add_editor_...
2013/02/17
[ "https://wordpress.stackexchange.com/questions/87256", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1372/" ]
This is default wordpress add\_editor\_style function: ``` function add_editor_style( $stylesheet = 'editor-style.css' ) { add_theme_support( 'editor-style' ); if ( ! is_admin() ) return; global $editor_styles; $editor_styles = (array) $editor_styles; $stylesheet = (array) $stylesheet...
Here is my solution: ``` add_filter('the_editor_content', "firmasite_tinymce_style"); function firmasite_tinymce_style($content) { add_editor_style('assets/css/custom.css'); // This is for front-end tinymce customization if ( ! is_admin() ) { global $editor_styles; $editor_styles = (array)...
87,264
<p>I'm writing my first WordPress theme and have a question about the use of The Loop in page templates. The page templates I've looked at all follow basically the same pattern (example from Twenty Twelve):</p> <pre><code>&lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;?php get_template_part( 'content', 'page'...
[ { "answer_id": 87270, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": false, "text": "<p>The only potential (edit: functional) issue I see is that the <a href=\"http://codex.wordpress.org/Plugin_API/Actio...
2013/02/17
[ "https://wordpress.stackexchange.com/questions/87264", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27606/" ]
I'm writing my first WordPress theme and have a question about the use of The Loop in page templates. The page templates I've looked at all follow basically the same pattern (example from Twenty Twelve): ``` <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php comments_t...
According to the [Theme Guide](http://developer.wordpress.com/themes/), full loops should be used, even on single templates. > > Full loops must be used in all templates. Just calling `the_post()` in a > template like `single.php` or `page.php` is not enough. > > > So yes, it's a best practice to use full loops...
87,295
<p>I am trying to put different body background-image for each category. </p> <pre><code>body { background-color: #000; background-image: url(img/bg.png); background-repeat: no-repeat; background-position: center top; font-size: 14px; color: #555; font-family: Arial, Helvetica, Verdana, sans-serif; } </code></pr...
[ { "answer_id": 87296, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>This is already built-in: the function <code>body_class()</code> creates special classes for each category:</p>\n\n<p>...
2013/02/17
[ "https://wordpress.stackexchange.com/questions/87295", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25933/" ]
I am trying to put different body background-image for each category. ``` body { background-color: #000; background-image: url(img/bg.png); background-repeat: no-repeat; background-position: center top; font-size: 14px; color: #555; font-family: Arial, Helvetica, Verdana, sans-serif; } ``` I only want differe...
You can do this using Wordpress's handy `body_class()` function. Depending on whether and how it is used in your theme, it may already be giving you what you need. Here's how to find out: Check the source of your page to see if the `<body>` tag in your category archive pages has any classes containing your category s...
87,304
<p>I am curious how WordPress know that if I have a category.php and do the basic loop inside there that when I click on category A I get all of A's posts. The reason I ask, is because I have seen themes that just have an index.php and when you click on Category A in those themes you get all of A's posts, and they do n...
[ { "answer_id": 87305, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>The request is parsed and the database is queried <em>before</em> the template is loaded. The loop simply iterates ...
2013/02/17
[ "https://wordpress.stackexchange.com/questions/87304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27670/" ]
I am curious how WordPress know that if I have a category.php and do the basic loop inside there that when I click on category A I get all of A's posts. The reason I ask, is because I have seen themes that just have an index.php and when you click on Category A in those themes you get all of A's posts, and they do not ...
If you look at [the template hierarchy](http://codex.wordpress.org/Template_Hierarchy) for categories you will see it follows: 1. category-{slug}.php 2. category-{id}.php 3. category.php 4. archive.php 5. index.php As Milo says these templates are just using the loop to display what is already queried, so there templ...
87,357
<p>Media Manager once again. This time I'm looking for a simple hack/hook/filter to change default "Attachment Display Settings" from media manager. The option is "Link To" that is default set to "Media File" and I would like to force it for all users to be default set to "none".</p> <p><img src="https://i.stack.imgur...
[ { "answer_id": 87455, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 3, "selected": true, "text": "<p>You can do what you want by overriding appropriate Backbone view, which is responsible for rendering atta...
2013/02/18
[ "https://wordpress.stackexchange.com/questions/87357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25644/" ]
Media Manager once again. This time I'm looking for a simple hack/hook/filter to change default "Attachment Display Settings" from media manager. The option is "Link To" that is default set to "Media File" and I would like to force it for all users to be default set to "none". ![Media Manager Screen](https://i.stack.i...
You can do what you want by overriding appropriate Backbone view, which is responsible for rendering attachments display settings form. **plugin.php** ``` add_action( 'load-post.php', 'wpse8170_media_popup_init' ); add_action( 'load-post-new.php', 'wpse8170_media_popup_init' ); function wpse8170_media_popup_init() { ...
87,399
<p>I'm developing a child-theme off of the Twenty Twelve (1.1), using Wordpress (3.5.1) and the Woocommerce plugin (1.6.6). </p> <p>I've noticed that the problem with creating the online shop, single product page and the taxonomy pages (categories and tags), is that it uses it's own templates to display these pages (...
[ { "answer_id": 87414, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>You could add a sidebar area after checking <a href=\"http://codex.wordpress.org/Function_Reference/is_plugin_activ...
2013/02/18
[ "https://wordpress.stackexchange.com/questions/87399", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16795/" ]
I'm developing a child-theme off of the Twenty Twelve (1.1), using Wordpress (3.5.1) and the Woocommerce plugin (1.6.6). I've noticed that the problem with creating the online shop, single product page and the taxonomy pages (categories and tags), is that it uses it's own templates to display these pages (*which can ...
Instead of using page templates to define *layouts*, define *layouts* using *custom post meta*. The *custom post meta* can then be shown or not shown using `is_plugin_active()`. If you're going to define the page template itself in the Theme, then you're pretty much stuck with doing something like determining if the P...
87,410
<p>I am developing custom registration form. Is it possible to get current action (comment adding or user registration) in function? For example i am using:</p> <pre><code>add_filter('preprocess_comment', 'checkQuestion'); add_filter('registration_errors', 'checkQuestion', 10, 3); </code></pre> <p>So, from function <...
[ { "answer_id": 87418, "author": "Cole", "author_id": 2130, "author_profile": "https://wordpress.stackexchange.com/users/2130", "pm_score": 0, "selected": false, "text": "<p>This can be un-reliable because it depends on the values coming in from the registration_errors filter, but hopeful...
2013/02/18
[ "https://wordpress.stackexchange.com/questions/87410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22622/" ]
I am developing custom registration form. Is it possible to get current action (comment adding or user registration) in function? For example i am using: ``` add_filter('preprocess_comment', 'checkQuestion'); add_filter('registration_errors', 'checkQuestion', 10, 3); ``` So, from function `checkQuestion` i need some...
You can simply use `current_filter()` WordPress function. <http://codex.wordpress.org/Function_Reference/current_filter>
87,422
<p>I'm attempting to develop an <code>is_blog()</code> function which returns true if the current view is a single post, blog home, or post archive. I have successfully excluded pages and attachments. My current code is in my theme's <code>functions.php</code>, as follows:</p> <pre><code>function is_blog() { globa...
[ { "answer_id": 87418, "author": "Cole", "author_id": 2130, "author_profile": "https://wordpress.stackexchange.com/users/2130", "pm_score": 0, "selected": false, "text": "<p>This can be un-reliable because it depends on the values coming in from the registration_errors filter, but hopeful...
2013/02/18
[ "https://wordpress.stackexchange.com/questions/87422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99/" ]
I'm attempting to develop an `is_blog()` function which returns true if the current view is a single post, blog home, or post archive. I have successfully excluded pages and attachments. My current code is in my theme's `functions.php`, as follows: ``` function is_blog() { global $post; $post_type = get_post_t...
You can simply use `current_filter()` WordPress function. <http://codex.wordpress.org/Function_Reference/current_filter>
87,433
<p>I'm using the following code to generate some pagination: </p> <pre><code>$wp_query = new WP_Query(); $wp_query-&gt;query('posts_per_page=5'.'&amp;paged='.$paged); $big = 999999999; echo '&lt;div class="pagination"&gt;'; echo paginate_links(array( 'base' =&gt; '%_%', 'format' =&gt; str...
[ { "answer_id": 87446, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p><strong>Short answer:</strong></p>\n\n<p>Try</p>\n\n<pre><code>'base' =&gt; str_replace( $big, '%#%', esc_url( ...
2013/02/18
[ "https://wordpress.stackexchange.com/questions/87433", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25318/" ]
I'm using the following code to generate some pagination: ``` $wp_query = new WP_Query(); $wp_query->query('posts_per_page=5'.'&paged='.$paged); $big = 999999999; echo '<div class="pagination">'; echo paginate_links(array( 'base' => '%_%', 'format' => str_replace($big, '%#%', esc_url(get_...
**Short answer:** Try ``` 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', ``` **Long answer:** I took a look at the `paginate_links()` source code ([v3.5.1](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L1922)) and there is t...
87,440
<p>In a previous question, I was struggling with how to get my custom post type(s) to show when performing standard category/tag queries, since by default Wordpress doesn't include CPT's in these queries. After quite a bit of hunting I found the answer to be this:</p> <pre><code>add_filter('pre_get_posts', 'query_pos...
[ { "answer_id": 87446, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p><strong>Short answer:</strong></p>\n\n<p>Try</p>\n\n<pre><code>'base' =&gt; str_replace( $big, '%#%', esc_url( ...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87440", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27557/" ]
In a previous question, I was struggling with how to get my custom post type(s) to show when performing standard category/tag queries, since by default Wordpress doesn't include CPT's in these queries. After quite a bit of hunting I found the answer to be this: ``` add_filter('pre_get_posts', 'query_post_type'); funct...
**Short answer:** Try ``` 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', ``` **Long answer:** I took a look at the `paginate_links()` source code ([v3.5.1](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L1922)) and there is t...
87,453
<p>I have created a page and added the following shortcode from wp-orbit-slider</p> <pre><code> [orbit-slider category="test"] </code></pre> <p>I want the contents of </p> <pre><code> [orbit-slider category="test"] </code></pre> <p>be displayed on the header part, instead of on the content area part, which the wo...
[ { "answer_id": 87446, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p><strong>Short answer:</strong></p>\n\n<p>Try</p>\n\n<pre><code>'base' =&gt; str_replace( $big, '%#%', esc_url( ...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27422/" ]
I have created a page and added the following shortcode from wp-orbit-slider ``` [orbit-slider category="test"] ``` I want the contents of ``` [orbit-slider category="test"] ``` be displayed on the header part, instead of on the content area part, which the wordpress usually does . I tried adding the the sho...
**Short answer:** Try ``` 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', ``` **Long answer:** I took a look at the `paginate_links()` source code ([v3.5.1](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L1922)) and there is t...
87,461
<p>What I want to do:</p> <p>I have four custom post types. I only want to use one, which I can do like this: <code>$current_posttype = get_post_type( $post-&gt;ID ); // get current post type </code>. </p> <p>Next up, I want to loop through all the custom taxonomies that are attached to that custom post type. So, for...
[ { "answer_id": 87469, "author": "RRikesh", "author_id": 17305, "author_profile": "https://wordpress.stackexchange.com/users/17305", "pm_score": 1, "selected": false, "text": "<p>You can make a loop to retrieve the taxonomies:</p>\n\n<pre><code>foreach( array('genre', 'rating', 'year') as...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23478/" ]
What I want to do: I have four custom post types. I only want to use one, which I can do like this: `$current_posttype = get_post_type( $post->ID ); // get current post type`. Next up, I want to loop through all the custom taxonomies that are attached to that custom post type. So, for example: ``` custom post type:...
You can make a loop to retrieve the taxonomies: ``` foreach( array('genre', 'rating', 'year') as $taxo ){ #loop over each taxonomy $terms = get_the_terms( $post->ID , $taxo ); if( $terms && ! is_wp_error( $terms ) ){ echo $taxo . ': '; $myterm = array(); #get list of term names foreach($terms as...
87,489
<p>i'm using a query-loop on my template pages like this:</p> <pre><code>&lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); $wp_query-&gt;query('posts_per_page='.get_option('posts_per_page').'&amp;paged=' . $paged); global $wp_query; query_posts(array_merge($wp_que...
[ { "answer_id": 87491, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>If you merely want to modify <code>posts_per_page</code> for tag and category archive index pages, don't use...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87489", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27701/" ]
i'm using a query-loop on my template pages like this: ``` <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); $wp_query->query('posts_per_page='.get_option('posts_per_page').'&paged=' . $paged); global $wp_query; query_posts(array_merge($wp_query->query, array( ...
If you merely want to modify `posts_per_page` for tag and category archive index pages, don't use `query_posts()`; instead, filter the `$query` via `pre_get_posts`: ``` function wpse87489_filter_pre_get_posts( $query ) { if ( ( is_category() || is_tag() ) && $query->is_main_query ) { $query->set( 'posts_pe...
87,514
<p>While this is a question, it is as well a <strong>serious warning</strong> to publishers that separate their posts using <code>&lt;!--nextpage--&gt;</code>.</p> <p>Bare with me. I run a highly trafficked multiple author platform that rank very high on search engines. While making SEO related improvements, I noticed...
[ { "answer_id": 88227, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>The basic problem for a script solution is: <code>rel_canonical</code> does not offer any useful filter. So we have to ...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87514", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
While this is a question, it is as well a **serious warning** to publishers that separate their posts using `<!--nextpage-->`. Bare with me. I run a highly trafficked multiple author platform that rank very high on search engines. While making SEO related improvements, I noticed that only the first page of an article ...
The basic problem for a script solution is: `rel_canonical` does not offer any useful filter. So we have to replace that function: ``` remove_action( 'wp_head', 'rel_canonical' ); add_action( 'wp_head', 't5_canonical_subpages' ); ``` The next problem: `$GLOBALS['numpages']` is empty before `setup_postdata()`. We cou...
87,522
<p>By default, the Status, Visibility, and Date fields in the Publish metabox are closed, and you have to click <strong>Edit</strong> to show them. </p> <p>Is there a way to make these fields visible by default?</p> <p>The hidden elements all have a class of <code>hide-if-js</code>.</p>
[ { "answer_id": 87527, "author": "supertrue", "author_id": 3564, "author_profile": "https://wordpress.stackexchange.com/users/3564", "pm_score": 1, "selected": false, "text": "<p>This jQuery code seems to work, when added via the <code>admin_footer</code> hook.</p>\n\n<ul>\n<li><code>#sub...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
By default, the Status, Visibility, and Date fields in the Publish metabox are closed, and you have to click **Edit** to show them. Is there a way to make these fields visible by default? The hidden elements all have a class of `hide-if-js`.
This jQuery code seems to work, when added via the `admin_footer` hook. * `#submitdiv` = the whole Publish metabox * `.misc-pub-section` = each UI section (except the Publish and Save sections) * `.hide-if-js` = the fields that are hidden by default ``` $('#submitdiv .misc-pub-section') .has("#post-status-display...
87,523
<p>I need to get the last posts' ID and the post_tile within categories 1 and 2, and exclude those within category 3. It must be SQL, because if I use WP_Query it retrieves too much info and I only need the ID and post_title.</p> <p>The following query works fine getting posts from the 2 categories, but if I try exclu...
[ { "answer_id": 87530, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": false, "text": "<p>You had to use <code>LEFT JOIN</code> to simplify the stuff. By the way, the same can be accomplished using ...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87523", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27715/" ]
I need to get the last posts' ID and the post\_tile within categories 1 and 2, and exclude those within category 3. It must be SQL, because if I use WP\_Query it retrieves too much info and I only need the ID and post\_title. The following query works fine getting posts from the 2 categories, but if I try excluding th...
You had to use `LEFT JOIN` to simplify the stuff. By the way, the same can be accomplished using `WP_Query` and I actualy don't understand why you don't want to use it. Also I've changed the way you write the query and I've not use the hardcoded `$table_prefix` for answer to be useful for others too. You can replace `...
87,535
<p>I'm currently working on a plugin in which I would like to have a new setting (called 'show_introduction') that has the default value 'true'.</p> <p>I did this by the following which is hooked into 'admin_init'</p> <pre><code>register_setting('tf-song-list-settings-group', 'show_introduction'); if (get_option('sho...
[ { "answer_id": 87530, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": false, "text": "<p>You had to use <code>LEFT JOIN</code> to simplify the stuff. By the way, the same can be accomplished using ...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27722/" ]
I'm currently working on a plugin in which I would like to have a new setting (called 'show\_introduction') that has the default value 'true'. I did this by the following which is hooked into 'admin\_init' ``` register_setting('tf-song-list-settings-group', 'show_introduction'); if (get_option('show_introduction') ==...
You had to use `LEFT JOIN` to simplify the stuff. By the way, the same can be accomplished using `WP_Query` and I actualy don't understand why you don't want to use it. Also I've changed the way you write the query and I've not use the hardcoded `$table_prefix` for answer to be useful for others too. You can replace `...
87,539
<p>How can I identify what category the current page is showing in the <code>&lt;head&gt;</code>? Here's the code I have now:</p> <pre><code>&lt;?php if ( is_home() ) { ?&gt; &lt;!-- set up for home page ad --&gt; &lt;?php } elseif ( in_category( 'Restaurant Reviews' )) { ?&gt; &lt;!-- set up for restaurant re...
[ { "answer_id": 87530, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": false, "text": "<p>You had to use <code>LEFT JOIN</code> to simplify the stuff. By the way, the same can be accomplished using ...
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13981/" ]
How can I identify what category the current page is showing in the `<head>`? Here's the code I have now: ``` <?php if ( is_home() ) { ?> <!-- set up for home page ad --> <?php } elseif ( in_category( 'Restaurant Reviews' )) { ?> <!-- set up for restaurant reviews ad --> <?php } else { ?> <!-- set up for r...
You had to use `LEFT JOIN` to simplify the stuff. By the way, the same can be accomplished using `WP_Query` and I actualy don't understand why you don't want to use it. Also I've changed the way you write the query and I've not use the hardcoded `$table_prefix` for answer to be useful for others too. You can replace `...
87,566
<p>I opened a similar topic, but since it is a little confusing, I decided to create a new topic to clarify more. i run the website and i found the errors seems like: <code>Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() instead. in C:\xampp\htdocs\website\wp-includes\functions.php on line...
[ { "answer_id": 87530, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": false, "text": "<p>You had to use <code>LEFT JOIN</code> to simplify the stuff. By the way, the same can be accomplished using ...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87566", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I opened a similar topic, but since it is a little confusing, I decided to create a new topic to clarify more. i run the website and i found the errors seems like: `Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() instead. in C:\xampp\htdocs\website\wp-includes\functions.php on line 2638` I se...
You had to use `LEFT JOIN` to simplify the stuff. By the way, the same can be accomplished using `WP_Query` and I actualy don't understand why you don't want to use it. Also I've changed the way you write the query and I've not use the hardcoded `$table_prefix` for answer to be useful for others too. You can replace `...
87,567
<p>I'm creating a plugin for creating Landing Pages.</p> <p>I use custom post type and custom fields for the landing pages, but i need to add some on-page options for each entry. For example i need to have a an option(check box) for hiding the header(header is edited through a WYSIWYG custom field) on a specific landi...
[ { "answer_id": 87569, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 1, "selected": false, "text": "<p>What you want is a <a href=\"http://wp.tutsplus.com/tutorials/plugins/how-to-create-custom-wordpress-writ...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87567", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27732/" ]
I'm creating a plugin for creating Landing Pages. I use custom post type and custom fields for the landing pages, but i need to add some on-page options for each entry. For example i need to have a an option(check box) for hiding the header(header is edited through a WYSIWYG custom field) on a specific landing page. ...
What you want is a [custom meta box](http://wp.tutsplus.com/tutorials/plugins/how-to-create-custom-wordpress-writemeta-boxes/). Searching this site will give you plenty of examples as well, but here's a brief run down. You hook into `add_meta_boxes` and call, appropriately, [`add_meta_box`](http://codex.wordpress.org...
87,590
<p>I want to include files from the root directory of my site within the WordPress "header" file.</p> <p>Is there any function for including a file from the root folder?</p>
[ { "answer_id": 87595, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 0, "selected": false, "text": "<p>In your <code>wp-config.php</code> file, add the following line before <code>/* That's all, stop editing! ...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87590", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27740/" ]
I want to include files from the root directory of my site within the WordPress "header" file. Is there any function for including a file from the root folder?
If you are talking about the WordPress root, use: ``` include ABSPATH . "/extra-file.php"; ``` `ABSPATH` is always the WordPress root, you can see that in your `wp-config.php`.
87,594
<p><strong>Introduction:</strong></p> <p>I have created several post type for my theme. To display a post from a post-type I need to go in appearance/menu and then add the post manually.</p> <p><strong>My Goal:</strong></p> <p>I want to add two radio buttons in the post add/edit page to choose whether the current po...
[ { "answer_id": 89665, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 1, "selected": false, "text": "<p>The following is just a proof of concept and needs to be adapted/improved to work per the Question requireme...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24321/" ]
**Introduction:** I have created several post type for my theme. To display a post from a post-type I need to go in appearance/menu and then add the post manually. **My Goal:** I want to add two radio buttons in the post add/edit page to choose whether the current post will be in menu. **Attempts:** So I have crea...
The following is just a proof of concept and needs to be adapted/improved to work per the Question requirements. It creates a meta box with a dropdown listing all available Navigation Menus. On post save, it is added to the selected menu. This Q&A was used as starting point: [Programmatically add a Navigation menu a...
87,611
<p>I'm building a table with items in it. What I don't understand is the following:</p> <p>When I type <code>&lt;td&gt; &lt;?php custom_get_terms('landschapspakket');?&gt; &lt;/td&gt;</code>, it echoes the value of <code>custom_get_terms('landschapspakket')</code>. </p> <p>What I want to do is use some conditional lo...
[ { "answer_id": 87614, "author": "Alex Older", "author_id": 3365, "author_profile": "https://wordpress.stackexchange.com/users/3365", "pm_score": 3, "selected": true, "text": "<p>Instead of doing: <code>print $term-&gt;name;</code> you need to <code>return $term-&gt;name;</code> so you ca...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87611", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23478/" ]
I'm building a table with items in it. What I don't understand is the following: When I type `<td> <?php custom_get_terms('landschapspakket');?> </td>`, it echoes the value of `custom_get_terms('landschapspakket')`. What I want to do is use some conditional logic over it to see which value it has, and then echo it. ...
Instead of doing: `print $term->name;` you need to `return $term->name;` so you can then use it for queries you could run on it.
87,639
<p>I have this query...</p> <pre><code>&lt;?php $press = new WP_Query(array( 'posts_per_page' =&gt; -1, 'post_type' =&gt; 'individual', 'post_status' =&gt; 'private' )); if ($press-&gt;have_posts()) : while ($press-&gt;have_posts()) : $press-&gt;the_post(); ?&gt; </code><...
[ { "answer_id": 87643, "author": "heathenJesus", "author_id": 13643, "author_profile": "https://wordpress.stackexchange.com/users/13643", "pm_score": 0, "selected": false, "text": "<p>Sure, in the <code>orderby</code> parameter, there is an option called <code>meta_value_num</code> which ...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11327/" ]
I have this query... ``` <?php $press = new WP_Query(array( 'posts_per_page' => -1, 'post_type' => 'individual', 'post_status' => 'private' )); if ($press->have_posts()) : while ($press->have_posts()) : $press->the_post(); ?> ``` But my custom post-types are using custo...
No, there is no way to do this with default WP Core. @heathenJesus talks about meta data not taxonomies. See <http://scribu.net/wordpress/sortable-taxonomy-columns.html> for a proper solution. And a more thorough explanation of why this is not something built into Core: [Using wp\_query is it possible to orderby taxon...
87,644
<p>I found an answered question here <a href="https://wordpress.stackexchange.com/questions/31255/remove-menus-and-submenus">Remove menus and submenus</a> <strong>2 Answers</strong> for my problem but is there a way of changing the code a bit so that it removed the submenus for all Editor roles. not only for one user? ...
[ { "answer_id": 87643, "author": "heathenJesus", "author_id": 13643, "author_profile": "https://wordpress.stackexchange.com/users/13643", "pm_score": 0, "selected": false, "text": "<p>Sure, in the <code>orderby</code> parameter, there is an option called <code>meta_value_num</code> which ...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87644", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27761/" ]
I found an answered question here [Remove menus and submenus](https://wordpress.stackexchange.com/questions/31255/remove-menus-and-submenus) **2 Answers** for my problem but is there a way of changing the code a bit so that it removed the submenus for all Editor roles. not only for one user? and is there a way of impro...
No, there is no way to do this with default WP Core. @heathenJesus talks about meta data not taxonomies. See <http://scribu.net/wordpress/sortable-taxonomy-columns.html> for a proper solution. And a more thorough explanation of why this is not something built into Core: [Using wp\_query is it possible to orderby taxon...
87,661
<p>I'm just trying to add a simple bit of Show/Hide jQuery to a child theme. </p> <pre><code>$(document).ready(function(){ $("#openbtn").click(function(){ $("#openingtimes").toggle(300); }); }); </code></pre> <p>I've saved the above code in a file called <code>buttons.js</code>. </p> <p>I have then registered an...
[ { "answer_id": 87662, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>jQuery scripts in WordPress <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25146/" ]
I'm just trying to add a simple bit of Show/Hide jQuery to a child theme. ``` $(document).ready(function(){ $("#openbtn").click(function(){ $("#openingtimes").toggle(300); }); }); ``` I've saved the above code in a file called `buttons.js`. I have then registered and enquequed the script using the following i...
jQuery scripts in WordPress [require no-conflict wrappers](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers). Instead of this: ``` $(document).ready(function(){ $(#somefunction) ... }); ``` Use this: ``` jQuery(document).ready(function($) { // $() will work as an ...
87,673
<p>I am using a child theme with WordPress twentytwelve.</p> <p>I'm confused as to what function I can use in the child theme's functions.php to just change the site title separator, from its default vertical slash | to a hyphen -</p>
[ { "answer_id": 87679, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>From this comment:</p>\n\n<blockquote>\n <p>I know the title could be defined in the header.php file as b...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87673", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27103/" ]
I am using a child theme with WordPress twentytwelve. I'm confused as to what function I can use in the child theme's functions.php to just change the site title separator, from its default vertical slash | to a hyphen -
From this comment: > > I know the title could be defined in the header.php file as but I din't want to touch the existing header.php, but do it in a child theme's functions.php instead > > > But Twenty Twelve isn't modifying the separator in its `wp_title` filter callback; rather, it is defining it in its call to...
87,677
<p>How can i change those editing inputs to title from caption? <img src="https://i.stack.imgur.com/MDUwZ.png" alt="wp3.5 gallery edit"></p> <p>Some sources i found about new upload system:</p> <ul> <li><a href="http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/" rel="nofollow norefe...
[ { "answer_id": 87679, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>From this comment:</p>\n\n<blockquote>\n <p>I know the title could be defined in the header.php file as b...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1372/" ]
How can i change those editing inputs to title from caption? ![wp3.5 gallery edit](https://i.stack.imgur.com/MDUwZ.png) Some sources i found about new upload system: * [Using the WordPress 3.5 Media Uploader within plugins](http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/) * [How t...
From this comment: > > I know the title could be defined in the header.php file as but I din't want to touch the existing header.php, but do it in a child theme's functions.php instead > > > But Twenty Twelve isn't modifying the separator in its `wp_title` filter callback; rather, it is defining it in its call to...
87,682
<p>Hello and thanks for the guidance!</p> <p>Trying to load a custom .php file for only my home page (template is <strong>page-home.php</strong>) by using this code:</p> <pre><code>add_action('admin_init','load_home_meta'); function load_home_meta() { global $pagenow, $post; if ($pagenow=='edit.php' &amp;&amp; '104...
[ { "answer_id": 87684, "author": "PrivateUser", "author_id": 5074, "author_profile": "https://wordpress.stackexchange.com/users/5074", "pm_score": 0, "selected": false, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/is_front_page\" rel=\"nofollow\">is_front_page()...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87682", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27555/" ]
Hello and thanks for the guidance! Trying to load a custom .php file for only my home page (template is **page-home.php**) by using this code: ``` add_action('admin_init','load_home_meta'); function load_home_meta() { global $pagenow, $post; if ($pagenow=='edit.php' && '104' == $post->ID) { include 'metab...
Based on this comment: > > @ChipBennett, it's the site's front page, i.e. the home page. > > > (Side note: in WordPress the *home* page is **not** the **Site Front Page**, but rather the **Blog Posts Index**. `is_home()` returns true on the *blog posts index*, and not necessarily on the *site front page*. This is...
87,691
<p>If there are comments, I want to wrap the amount eg "5 comments" in the link to the comments section of the post, but when I add the echo for comments_link it errors.</p> <pre><code>&lt;?php comments_number( '', '&lt;span class="comment_meta"&gt;With:&lt;/span&gt; 1 Comment', '&lt;span class="comment_meta"&gt;Wi...
[ { "answer_id": 87693, "author": "PrivateUser", "author_id": 5074, "author_profile": "https://wordpress.stackexchange.com/users/5074", "pm_score": 0, "selected": false, "text": "<p>You should not echo your comments_link.</p>\n\n<pre><code> &lt;a href=\"&lt;?php comments_link(); ?&gt;\"&g...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87691", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22448/" ]
If there are comments, I want to wrap the amount eg "5 comments" in the link to the comments section of the post, but when I add the echo for comments\_link it errors. ``` <?php comments_number( '', '<span class="comment_meta">With:</span> 1 Comment', '<span class="comment_meta">With:</span> <a href="'echo . $comme...
The problem is that you are echoing inside a string concatenation. Think of `echo` as something that will always begin on a new line. In most cases it's wisest to perform any calculations or string concatenations and store the result in a variable, and then call `echo $var;` on the following line. In this particular c...
87,711
<p>Hi I have tried to optimize my website energyshop.se for a cpl of days but I cant seem to get it done. This is how my .htaccess looks like:</p> <pre><code>Header unset ETag FileETag None # Hantera och redirecta användare till en gemensam error-sia ErrorDocument 404 /psych/cgi-bin/error/error?404 # BEGIN Compress ...
[ { "answer_id": 87718, "author": "Dwayne Charrington", "author_id": 1687, "author_profile": "https://wordpress.stackexchange.com/users/1687", "pm_score": 2, "selected": true, "text": "<p>My advice to you is not to worry about adding in the copious amount of .htaccess rules for forcing bro...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87711", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24909/" ]
Hi I have tried to optimize my website energyshop.se for a cpl of days but I cant seem to get it done. This is how my .htaccess looks like: ``` Header unset ETag FileETag None # Hantera och redirecta användare till en gemensam error-sia ErrorDocument 404 /psych/cgi-bin/error/error?404 # BEGIN Compress text files <i...
My advice to you is not to worry about adding in the copious amount of .htaccess rules for forcing browser caching and setting correct expire time values for assets. If you download the W3 Total Cache plugin it handles adding all of the above into your .htaccess file for you. If you would prefer not to install the cac...
87,713
<p>I cannot figure out why these functions aren't saving the data for price and location while saving startdate and starttime. When I do print_r($custom) - I can see that [events_price] => Array ( [0] => ) is blank..</p> <pre><code> function event_detail_box_content( $post ) { $custom = get_post_custom($post-&gt;I...
[ { "answer_id": 87714, "author": "Dwayne Charrington", "author_id": 1687, "author_profile": "https://wordpress.stackexchange.com/users/1687", "pm_score": 1, "selected": false, "text": "<p>I can see a couple of errors you've made in your code above, so I've taken the liberty of fixing it u...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87713", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5416/" ]
I cannot figure out why these functions aren't saving the data for price and location while saving startdate and starttime. When I do print\_r($custom) - I can see that [events\_price] => Array ( [0] => ) is blank.. ``` function event_detail_box_content( $post ) { $custom = get_post_custom($post->ID); $meta_s...
I can see a couple of errors you've made in your code above, so I've taken the liberty of fixing it up for you and let me know if it resolves your problem. You were a little vague in your question, but can see your code should be fine with the following fixes. I've annotated with double forward slash comments where va...
87,717
<p>I am having an issue with the WordPress admin bar overlapping the Twitter Bootstrap (<code>2.3.0</code>) nav bar. I have tried this fix:</p> <pre><code>body.admin-bar .navbar-fixed-top { top: 28px; } .navbar .brand { color: #000 !important; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 30px ...
[ { "answer_id": 89183, "author": "Tamara", "author_id": 28310, "author_profile": "https://wordpress.stackexchange.com/users/28310", "pm_score": 2, "selected": false, "text": "<p>you can try this: </p>\n\n<pre><code> .navbar-fixed-top { top: 0px; }\n body.admin-bar .navbar-fixed-top {...
2013/02/20
[ "https://wordpress.stackexchange.com/questions/87717", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27670/" ]
I am having an issue with the WordPress admin bar overlapping the Twitter Bootstrap (`2.3.0`) nav bar. I have tried this fix: ``` body.admin-bar .navbar-fixed-top { top: 28px; } .navbar .brand { color: #000 !important; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 30px rgba(255, 255, 255, 0.1...
[How to prevent the WordPress admin bar from overlapping with your Twitter Bootstrap navigation bar.](https://wordpress.stackexchange.com/a/116908/9579) -------------------------------------------------------------------------------------------------------------------------------------------------------- **In response...
87,723
<p>I need a <code>&lt;a href="Something Like &lt;?get_contact_page&gt;"&gt;Contact Page&lt;/a&gt;</code> Code that always links to the Contact page, no matter what is it's ID</p> <p>There's a page template for contact page.</p> <p>Is it possible to do this?</p> <p>I'll gladly provide any further information you need...
[ { "answer_id": 87725, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>If the contact page is identified solely by the associated template, you can query for a page with the template name...
2013/02/21
[ "https://wordpress.stackexchange.com/questions/87723", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27278/" ]
I need a `<a href="Something Like <?get_contact_page>">Contact Page</a>` Code that always links to the Contact page, no matter what is it's ID There's a page template for contact page. Is it possible to do this? I'll gladly provide any further information you need :) Thanks!!
If the contact page is identified solely by the associated template, you can query for a page with the template name in meta key `_wp_page_template`: ``` $args = array( 'post_type' => 'page', 'posts_per_page' => 1, 'meta_query' => array( array( 'key' => '_wp_page_template', ...
87,734
<p>In the book 'Professional WordPress Development' I found this tip:</p> <p><em>As a rule of thumb, if your options are needed by the public part of the blog, save them with autoload. If they are only needed in the admin area, save them without autoload.</em></p> <p>Wouldn't that result in many extra SQL queries in ...
[ { "answer_id": 87737, "author": "Dwayne Charrington", "author_id": 1687, "author_profile": "https://wordpress.stackexchange.com/users/1687", "pm_score": 4, "selected": true, "text": "<p>Quite personally I disagree with the author of the book to an extent. If you are auto-loading multiple...
2013/02/21
[ "https://wordpress.stackexchange.com/questions/87734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
In the book 'Professional WordPress Development' I found this tip: *As a rule of thumb, if your options are needed by the public part of the blog, save them with autoload. If they are only needed in the admin area, save them without autoload.* Wouldn't that result in many extra SQL queries in the backend if all plugi...
Quite personally I disagree with the author of the book to an extent. If you are auto-loading multiple options in your database when Wordpress is initialising it's doing a lookup that looks like this: \*"SELECT option\_name, option\_value FROM wp\_options WHERE autoload = 'yes'"\* — at the beginning. Now, imagine if yo...
87,804
<p>I recently purchased Wooslider plugin and would like to add custom css to override the Woothemes slider defaults.</p> <p>However if I add custom css to the theme css file it gets overridden by the wooslider css since that css comes after my theme css in the head of the document.</p> <p>Is there a way around this? ...
[ { "answer_id": 87822, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>You need to <a href=\"http://codex.wordpress.org/Function_Reference/wp_register_style\" rel=\"nofollow\">regi...
2013/02/21
[ "https://wordpress.stackexchange.com/questions/87804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23507/" ]
I recently purchased Wooslider plugin and would like to add custom css to override the Woothemes slider defaults. However if I add custom css to the theme css file it gets overridden by the wooslider css since that css comes after my theme css in the head of the document. Is there a way around this? some method or Wo...
You need to [register](http://codex.wordpress.org/Function_Reference/wp_register_style) and/or [enqueue](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) your stylesheet and hook it to [`wp_enqueue_scripts`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) with a priority high enough that...
87,806
<p>Is is possible to redirect a user on front end login to a post that they have created?</p> <p>I have the form below on the front end which works great to log people in but doesn't quite achieve what I want.</p> <p>I've created a front end registration process, that creates a new user and a post and fills in certai...
[ { "answer_id": 87818, "author": "Jake", "author_id": 11966, "author_profile": "https://wordpress.stackexchange.com/users/11966", "pm_score": 2, "selected": false, "text": "<p>If I were you, I would use the wp_login_form function to create your form, but it looks like you got everything r...
2013/02/21
[ "https://wordpress.stackexchange.com/questions/87806", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
Is is possible to redirect a user on front end login to a post that they have created? I have the form below on the front end which works great to log people in but doesn't quite achieve what I want. I've created a front end registration process, that creates a new user and a post and fills in certain details into th...
If I were you, I would use the wp\_login\_form function to create your form, but it looks like you got everything right, and maybe you have a good reason to use a manual form. ``` <?php wp_login_form(); ?> ``` Either way, you can use this action to update the login redirect, add it to functions.php: ``` add_action(...
87,836
<p>I was hoping somebody could help me out with custom fields.</p> <p>I created a custom post type called game-type in WordPress. In this I have the categories "Android", "iOS" and "PC", then within these I have categories for types of games "3D Action", "Classics", "Platform" etc.</p> <p>So an example hierarchy for ...
[ { "answer_id": 87820, "author": "Jake", "author_id": 11966, "author_profile": "https://wordpress.stackexchange.com/users/11966", "pm_score": 1, "selected": false, "text": "<p>The easiest thing by FAR is going to be to fire up MAMP again, create a MySQL dump of the database from phpmyadmi...
2013/02/21
[ "https://wordpress.stackexchange.com/questions/87836", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27833/" ]
I was hoping somebody could help me out with custom fields. I created a custom post type called game-type in WordPress. In this I have the categories "Android", "iOS" and "PC", then within these I have categories for types of games "3D Action", "Classics", "Platform" etc. So an example hierarchy for each post works l...
The easiest thing by FAR is going to be to fire up MAMP again, create a MySQL dump of the database from phpmyadmin, and then import that into your new XAMP database through phpmyadmin. If you can't do that, it might still be doable, but will be more work and confusing... I never got it to work right trying copying the...
87,846
<p>im creating a wordpress query for custom taxonomy. However im unable to get the last post that i queried to go to the permalink. Please could somebody help me get this query right, much appreciated in advance.</p> <pre><code>&lt;?php /* Template Name: taxonomy-slug */ ?&gt; &lt;?php get_header(); ?&gt; &lt;?ph...
[ { "answer_id": 87847, "author": "chifliiiii", "author_id": 4130, "author_profile": "https://wordpress.stackexchange.com/users/4130", "pm_score": 0, "selected": false, "text": "<p>Try changing </p>\n\n<pre><code>&lt;?php wp_reset_query(); ?&gt;\n</code></pre>\n\n<p>to</p>\n\n<pre><code>&l...
2013/02/21
[ "https://wordpress.stackexchange.com/questions/87846", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27410/" ]
im creating a wordpress query for custom taxonomy. However im unable to get the last post that i queried to go to the permalink. Please could somebody help me get this query right, much appreciated in advance. ``` <?php /* Template Name: taxonomy-slug */ ?> <?php get_header(); ?> <?php $loop = new WP_Query( array...
You don't need to call [`wp_reset_query()`](http://codex.wordpress.org/Function_Reference/wp_reset_query) here, because you're not modifying the *main* query. Instead, call [`wp_reset_postdata()`](http://codex.wordpress.org/Function_Reference/wp_reset_postdata). You only need to call `wp_reset_query()` when modifying ...