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 |
|---|---|---|---|---|---|---|
91,546 | <p>I am using this script on display google maps on my wordpress site:</p>
<pre><code><head>
<script>
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(51.508742,-0.120850),
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=... | [
{
"answer_id": 91550,
"author": "Douglas.Sesar",
"author_id": 19945,
"author_profile": "https://wordpress.stackexchange.com/users/19945",
"pm_score": 1,
"selected": false,
"text": "<p>Try to add the script to the head with a wordpress hook:</p>\n\n<pre><code>add_action('wp_head','your_go... | 2013/03/19 | [
"https://wordpress.stackexchange.com/questions/91546",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29194/"
] | I am using this script on display google maps on my wordpress site:
```
<head>
<script>
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(51.508742,-0.120850),
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(docume... | Here's a version that uses `wp_localize_script()`, as suggested by others. It's just a little bit cleaner, since you don't mix your PHP with your JS, and generally a neat way to pass things from the server side to your JavaScript.
First, put the following code either in your plugin or your functions.php (I use a plugi... |
91,578 | <p>I have 2 levels of categories ( one sub-category only. No <code>sub-sub</code> category ). I need to get all sub categories without parent category. (I don't want to specify any parent category.)</p>
<p>Example:</p>
<pre><code>p_cat1
s_cat1
s_cat2
p_cat4
p_cat3
s_cat4
s_cat5
s_cat7
</code></pre>
<p... | [
{
"answer_id": 91581,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 3,
"selected": true,
"text": "<p>You could use <a href=\"http://codex.wordpress.org/get_categories\" rel=\"nofollow\"><code>get_categories()... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28533/"
] | I have 2 levels of categories ( one sub-category only. No `sub-sub` category ). I need to get all sub categories without parent category. (I don't want to specify any parent category.)
Example:
```
p_cat1
s_cat1
s_cat2
p_cat4
p_cat3
s_cat4
s_cat5
s_cat7
```
from here, I need
```
s_cat1
s_cat2
s_cat4... | You could use [`get_categories()`](http://codex.wordpress.org/get_categories).
>
> Returns an array of category objects matching the query parameters.
>
>
> Arguments are pretty much the same as [wp\_list\_categories](http://codex.wordpress.org/wp_list_categories) and can be passed as either array or in query synta... |
91,590 | <p>I have a page, let's called it "Artists", that displays a list of posts in a custom post type, again "artists".</p>
<p>How can I redirect pepole who visit the Artists page to the first post in the "artists" post type?</p>
| [
{
"answer_id": 91581,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 3,
"selected": true,
"text": "<p>You could use <a href=\"http://codex.wordpress.org/get_categories\" rel=\"nofollow\"><code>get_categories()... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91590",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18547/"
] | I have a page, let's called it "Artists", that displays a list of posts in a custom post type, again "artists".
How can I redirect pepole who visit the Artists page to the first post in the "artists" post type? | You could use [`get_categories()`](http://codex.wordpress.org/get_categories).
>
> Returns an array of category objects matching the query parameters.
>
>
> Arguments are pretty much the same as [wp\_list\_categories](http://codex.wordpress.org/wp_list_categories) and can be passed as either array or in query synta... |
91,592 | <p>What is the point of the dependencies parameter when using wp_enqueue_script()?</p>
<p>For instance, when I do the following:</p>
<pre><code>wp_enqueue_script(
'jscripts',
get_stylesheet_directory_uri() . "/scripts/jscripts.js",
array('jquery-ui-datepicker'));
echo wp_script_is('jquery-ui-datepicker',... | [
{
"answer_id": 91600,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 2,
"selected": false,
"text": "<p>Try this. You have to call wp_enqueue_script at the appropriate time, so that it can queue your scripts unt... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | What is the point of the dependencies parameter when using wp\_enqueue\_script()?
For instance, when I do the following:
```
wp_enqueue_script(
'jscripts',
get_stylesheet_directory_uri() . "/scripts/jscripts.js",
array('jquery-ui-datepicker'));
echo wp_script_is('jquery-ui-datepicker', 'queue')
? '<b... | Try this. You have to call wp\_enqueue\_script at the appropriate time, so that it can queue your scripts until the dependencies you specify are called -
```
add_action('wp_enqueue_scripts', 'enqueue_my_scripts');
function enqueue_my_scripts(){
wp_enqueue_script(
'jscripts',
get_stylesheet_directo... |
91,593 | <p>I have an array of ids in a specific order. I use <code>post__in</code> in my query to get posts from this array. I have some duplicate post IDs that I need to show twice in the page but the query seems to ignore them.
Let's say the array is as follows</p>
<pre><code>array values = 1,2,3,4,2,5
</code></pre>
<p>Wh... | [
{
"answer_id": 91597,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<h1>The situation</h1>\n\n<p>An array like <code>array( 1,2,3,4,2,5 )</code> will be read like the following:</p>\n\n<... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27613/"
] | I have an array of ids in a specific order. I use `post__in` in my query to get posts from this array. I have some duplicate post IDs that I need to show twice in the page but the query seems to ignore them.
Let's say the array is as follows
```
array values = 1,2,3,4,2,5
```
When I pass this array to `post__in`, i... | The situation
=============
An array like `array( 1,2,3,4,2,5 )` will be read like the following:
```
Array(
0 => 1
,1 => 2
,2 => 3
,3 => 4
,4 => 2
,5 => 5
) [length = 6 ]
```
which seems ok. But when you look at the `WP_Query` object, you'll see the following part added to the query string... |
91,599 | <p>I just have a quick question... I am using the Advanced Custom Fields plugin on a site for a costumer, just to get a little more power into it.... but I wouldn't want the client to be poking around in there, and get all confused... is there an easy none-obtrusive way to sort of hide the options from the end user, bd... | [
{
"answer_id": 91597,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<h1>The situation</h1>\n\n<p>An array like <code>array( 1,2,3,4,2,5 )</code> will be read like the following:</p>\n\n<... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29212/"
] | I just have a quick question... I am using the Advanced Custom Fields plugin on a site for a costumer, just to get a little more power into it.... but I wouldn't want the client to be poking around in there, and get all confused... is there an easy none-obtrusive way to sort of hide the options from the end user, bdut ... | The situation
=============
An array like `array( 1,2,3,4,2,5 )` will be read like the following:
```
Array(
0 => 1
,1 => 2
,2 => 3
,3 => 4
,4 => 2
,5 => 5
) [length = 6 ]
```
which seems ok. But when you look at the `WP_Query` object, you'll see the following part added to the query string... |
91,605 | <p>I am creating a back-end dashboard where I need to show all the post assigned to <strong>current user</strong> by the wp <strong>admin</strong>.</p>
<blockquote>
<p>I assign user role to <strong>Author</strong> and while creating post (as a wp
admin) just assign this post to some author from Author drop-down.</... | [
{
"answer_id": 91606,
"author": "Muhammad Sajid",
"author_id": 18419,
"author_profile": "https://wordpress.stackexchange.com/users/18419",
"pm_score": 2,
"selected": false,
"text": "<p>Thanks to [Sheikh Heera][1]</p>\n<pre class=\"lang-php prettyprint-override\"><code>if ( is_user_logged... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91605",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18419/"
] | I am creating a back-end dashboard where I need to show all the post assigned to **current user** by the wp **admin**.
>
> I assign user role to **Author** and while creating post (as a wp
> admin) just assign this post to some author from Author drop-down.
>
>
>
So I need to show posts with status **Publish**. ... | Thanks to [Sheikh Heera][1]
```php
if ( is_user_logged_in() ):
global $current_user;
get_currentuserinfo();
$author_query = array(
'posts_per_page' => '-1',
'author' => $current_user->ID
);
$author_posts = new WP_Query($author_query);
while($author_posts->have_posts()) : $author... |
91,647 | <p>I've got a multisite sub-domain install with 3 sites on it. 2 of the sites use domain mapping.</p>
<p>The main site (id=1) requires several 301's that are old pages from a previous structure such as:</p>
<pre><code>Redirect 301 /about/careers/ /contact/careers/
</code></pre>
<p>One of the other sites (id=3) has c... | [
{
"answer_id": 91690,
"author": "Mr Jonny Wood",
"author_id": 17579,
"author_profile": "https://wordpress.stackexchange.com/users/17579",
"pm_score": 2,
"selected": false,
"text": "<p>Okay,</p>\n\n<pre><code>RewriteEngine On\nRewriteBase /\n\n# Blog ID1 Rewrite Rules\nRewriteCond %{HTTP_... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17579/"
] | I've got a multisite sub-domain install with 3 sites on it. 2 of the sites use domain mapping.
The main site (id=1) requires several 301's that are old pages from a previous structure such as:
```
Redirect 301 /about/careers/ /contact/careers/
```
One of the other sites (id=3) has content that has moved into the ma... | Okay,
```
RewriteEngine On
RewriteBase /
# Blog ID1 Rewrite Rules
RewriteCond %{HTTP_HOST} ^(www\.)?primary-domain.co.uk [NC]
RewriteRule ^about/careers/$ contact/careers/ [R=301,NC,L]
RewriteRule ^glossary.html$ sitemap/ [R=301,NC,L]
# Blog ID3 Rewrite Rules
RewriteCond %{HTTP_HOST} ^(www\.)?mapped-domain3.co.uk [N... |
91,678 | <p>I am developing a site that must be HTTPS secure and WordPress is loading <code><script src="http://code.jquery.com/jquery-1.7.1.min.js"></script></code> at the very top of my page, before <code><html></code> and giving me an insecure error. I cannot find where this is being loaded from to prevent ... | [
{
"answer_id": 91734,
"author": "Marc Dingena",
"author_id": 28660,
"author_profile": "https://wordpress.stackexchange.com/users/28660",
"pm_score": 5,
"selected": true,
"text": "<p>When I build themes, I also like to make the WordPress header as clean as possible and then reconstruct it... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28949/"
] | I am developing a site that must be HTTPS secure and WordPress is loading `<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>` at the very top of my page, before `<html>` and giving me an insecure error. I cannot find where this is being loaded from to prevent it from loading.
Unfortunately I cannot sh... | When I build themes, I also like to make the WordPress header as clean as possible and then reconstruct it to my own liking. The code below is excessive for your question, but it might help you with other 'WordPress inserted code' in the future. The key snippet of code you are looking for is
```
wp_deregister_script('... |
91,680 | <p>I've got a multisite installation of WP 3.5.1 running, and I'd like to for users to be able to embed screencast.com videos into posts, preferably with a shortcode like you do with YouTube or Vimeo.</p>
<p>I can do this using the full embed code from the screencast.com sharing menu, but I can only do this as a super... | [
{
"answer_id": 91793,
"author": "Gary M.",
"author_id": 29290,
"author_profile": "https://wordpress.stackexchange.com/users/29290",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if this helps you, but I was just scouring some other blogs, and found a suggestion to try <a href=\"... | 2013/03/20 | [
"https://wordpress.stackexchange.com/questions/91680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7879/"
] | I've got a multisite installation of WP 3.5.1 running, and I'd like to for users to be able to embed screencast.com videos into posts, preferably with a shortcode like you do with YouTube or Vimeo.
I can do this using the full embed code from the screencast.com sharing menu, but I can only do this as a super admin. Al... | Screencast.com has a dedicated [GitHub page](https://github.com/TechSmith/screencast-developer-docs/blob/master/sections/getting_started.md) with hands full of tutorials (no need to clone them over here).
You can then utilize [`wp_oembed_get()`](http://queryposts.com/function/wp_oembed_get/) or register a new provider... |
91,705 | <p>I know there are a lot of hooks in WP for altering a posts content (and other fields) before the post is written to the DB upon saving; but what I am interested in doing is running my custom filter before the post is <em>loaded</em> for <em>editing</em>. So basically when my custom post type is loaded by /wp-admin/p... | [
{
"answer_id": 91707,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>You can use the <code>the_editor_content</code> filter:</p>\n\n<pre><code>function wpa_editor_content( $content ) {\... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29251/"
] | I know there are a lot of hooks in WP for altering a posts content (and other fields) before the post is written to the DB upon saving; but what I am interested in doing is running my custom filter before the post is *loaded* for *editing*. So basically when my custom post type is loaded by /wp-admin/post.php?post=##&a... | You can use the `the_editor_content` filter:
```
function wpa_editor_content( $content ) {
global $post;
return "this post's id is $post->ID " . $content;
}
add_filter( 'the_editor_content', 'wpa_editor_content' );
``` |
91,709 | <pre><code><?php
function default_menu() {
<form action="options.php" method="post">
<?php settings_fields( 'sample_check' );?>
<input type="checkbox" name="sample" value="nofollow"/>
</form>
function reg_setting() {
register_setting('sample_check','???');
}
</code></pre>
<p>Hi all, I ha... | [
{
"answer_id": 104225,
"author": "seot",
"author_id": 34534,
"author_profile": "https://wordpress.stackexchange.com/users/34534",
"pm_score": 0,
"selected": false,
"text": "<p>why not simply put checkbox value it in an option instead :</p>\n\n<pre><code><?php update_option( $option, $... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29099/"
] | ```
<?php
function default_menu() {
<form action="options.php" method="post">
<?php settings_fields( 'sample_check' );?>
<input type="checkbox" name="sample" value="nofollow"/>
</form>
function reg_setting() {
register_setting('sample_check','???');
}
```
Hi all, I have struggled all day to store the check box val... | The settings framework can't detect data that is not posted, so either use a call to update\_option or (what I sometimes do) use a yes/no radio button rather than a checkbox. With a radio button where the default value is 0 (no) and the alternative is 1 (yes), the user is setting the post value either way. You're just ... |
91,717 | <p>I have 3 posts types, <code>articles</code>, <code>news</code> and <code>tips</code>. On the home page I want to query 20 posts in this order:</p>
<pre><code>article, article, news, news, tip, ...// same order again until 20
</code></pre>
<p>If I use a custom query like so:</p>
<pre><code>$query = new WP_Query(ar... | [
{
"answer_id": 104225,
"author": "seot",
"author_id": 34534,
"author_profile": "https://wordpress.stackexchange.com/users/34534",
"pm_score": 0,
"selected": false,
"text": "<p>why not simply put checkbox value it in an option instead :</p>\n\n<pre><code><?php update_option( $option, $... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8536/"
] | I have 3 posts types, `articles`, `news` and `tips`. On the home page I want to query 20 posts in this order:
```
article, article, news, news, tip, ...// same order again until 20
```
If I use a custom query like so:
```
$query = new WP_Query(array(
'post_type' => array('articles', 'news', 'tips'),
'posts_per_... | The settings framework can't detect data that is not posted, so either use a call to update\_option or (what I sometimes do) use a yes/no radio button rather than a checkbox. With a radio button where the default value is 0 (no) and the alternative is 1 (yes), the user is setting the post value either way. You're just ... |
91,720 | <p>I run a wordpress <a href="http://www.remkoweijnen.nl/blog/" rel="nofollow">blog</a> with a syntax highlighter plugin (<a href="http://wordpress.org/extend/plugins/crayon-syntax-highlighter/" rel="nofollow">Crayon</a>). The plugin highlights code between pre tags, example:</p>
<pre><code><pre class="lang:languag... | [
{
"answer_id": 92026,
"author": "Hasin Hayder",
"author_id": 12927,
"author_profile": "https://wordpress.stackexchange.com/users/12927",
"pm_score": 1,
"selected": false,
"text": "<p>This one should work</p>\n\n<pre><code>add_filter( 'the_content', 'pre_content_filter', 0 );\n\nfunction ... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91720",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29260/"
] | I run a wordpress [blog](http://www.remkoweijnen.nl/blog/) with a syntax highlighter plugin ([Crayon](http://wordpress.org/extend/plugins/crayon-syntax-highlighter/)). The plugin highlights code between pre tags, example:
```
<pre class="lang:languageid" title="example">
some code
</pre>
```
Wordpress sometimes repl... | Both answers are not the full solution, seems that if I combine them I am very close (just need to fix the replace part). The regex from @hasinhayder answer seems to work well in the plugin that @nathanpowell suggested.
There is no way to split points, [common best practice](https://meta.stackexchange.com/questions/13... |
91,739 | <p>I've read <a href="https://wordpress.stackexchange.com/questions/63085/how-to-display-category-specific-post-content-on-a-page">this</a> and <a href="https://wordpress.stackexchange.com/questions/77966/display-all-posts-from-specific-categories-on-a-page">this</a> but I'm just a basic user.</p>
<p>I have a "technic... | [
{
"answer_id": 91741,
"author": "Marc Dingena",
"author_id": 28660,
"author_profile": "https://wordpress.stackexchange.com/users/28660",
"pm_score": 0,
"selected": false,
"text": "<p>This is basic <code>The Loop</code> manipulation. You can edit your Loop to exclude specified categories.... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4347/"
] | I've read [this](https://wordpress.stackexchange.com/questions/63085/how-to-display-category-specific-post-content-on-a-page) and [this](https://wordpress.stackexchange.com/questions/77966/display-all-posts-from-specific-categories-on-a-page) but I'm just a basic user.
I have a "technical" blog that more and more peop... | There is even an example in the WordPress codex here for this:
<http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts>
```
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-3,-8' );
}
}
add_action( 'pre_get_posts', 'exclude_... |
91,743 | <p>Out of Wordpress, I've made a simple index page wich call the content of 10 other pages thanks to AJAX. Now I need to put this into Wordpress and the AJAX calls don't work at all. </p>
<p>I have created the homepage and 10 other pages. When the user arrives on my website, the homepage has a menu. Each item of this ... | [
{
"answer_id": 91796,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>I already mentioned in the comments, that <a href=\"https://wordpress.stackexchange.com/a/91612/385\">there're pref... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29270/"
] | Out of Wordpress, I've made a simple index page wich call the content of 10 other pages thanks to AJAX. Now I need to put this into Wordpress and the AJAX calls don't work at all.
I have created the homepage and 10 other pages. When the user arrives on my website, the homepage has a menu. Each item of this menu has a... | I already mentioned in the comments, that [there're preferred ways to load your scripts](https://wordpress.stackexchange.com/a/91612/385). The most important is to define the dependencies and the using the proper hooks.
The following part won't work like this:
```
$(document).ready(function() {
$("body").SEOParal... |
91,752 | <p>I am new in WordPress world (before now I always used Joomla and some other old CMS)</p>
<p>Now I am testing WordPress and I have some doubts about how create a navigation menu in my WP Site.</p>
<p>This is my test site (that at this time have not content but only a template): <a href="http://www.scorejava.com/WPT... | [
{
"answer_id": 91760,
"author": "schwarzgrau",
"author_id": 28046,
"author_profile": "https://wordpress.stackexchange.com/users/28046",
"pm_score": 0,
"selected": false,
"text": "<p>First create a custom menu in your admin-area.\nYou find this option under DESIGN > MENUS</p>\n\n<p>On you... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am new in WordPress world (before now I always used Joomla and some other old CMS)
Now I am testing WordPress and I have some doubts about how create a navigation menu in my WP Site.
This is my test site (that at this time have not content but only a template): <http://www.scorejava.com/WPTest/>
I plan to create a... | You have to register menu's in your theme's functions.php unless you only wish to use them in widgetised areas.
As an example:-
```
<?php register_nav_menu('main', 'Main Navigation Menu'); ?>
```
Then you have to call that menu into your template file where you wish it to be displayed, so for example, in the header... |
91,757 | <p>I have mp3 players set up to play mp3s on my site. The mp3s are all being uploaded to the uploads folder. I don't want people accessing these directly, meaning I don't want people to be able to download the mp3s. Is there a way to somehow restrict access to all files ending in .mp3 in the uploads folder while still ... | [
{
"answer_id": 91781,
"author": "Pat",
"author_id": 12920,
"author_profile": "https://wordpress.stackexchange.com/users/12920",
"pm_score": 0,
"selected": false,
"text": "<p>You could do this one of two ways. </p>\n\n<p>1) Simple way. Create a new file in your mp3 directory called index.... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91757",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I have mp3 players set up to play mp3s on my site. The mp3s are all being uploaded to the uploads folder. I don't want people accessing these directly, meaning I don't want people to be able to download the mp3s. Is there a way to somehow restrict access to all files ending in .mp3 in the uploads folder while still hav... | There is a simple approach to hold download access on your file.
**1.** Using .htaccess:
Upload a .htaccess file into your wp-content folder. Have a look if one exists already, then append this code to the end of the file. If you don’t have one, just create a new blank file and add this code to it:
```
RewriteEngine... |
91,762 | <p>Would anybody have a good idea for getting the WP to spit out all posts from a category with (approved) comments only?</p>
<p>I have an ecommerce site set up, and treat comments on product posts as testimonials.</p>
<p>Now I want a page that shows all those 'testimonials' (comments) next to the product (post) titl... | [
{
"answer_id": 91781,
"author": "Pat",
"author_id": 12920,
"author_profile": "https://wordpress.stackexchange.com/users/12920",
"pm_score": 0,
"selected": false,
"text": "<p>You could do this one of two ways. </p>\n\n<p>1) Simple way. Create a new file in your mp3 directory called index.... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29278/"
] | Would anybody have a good idea for getting the WP to spit out all posts from a category with (approved) comments only?
I have an ecommerce site set up, and treat comments on product posts as testimonials.
Now I want a page that shows all those 'testimonials' (comments) next to the product (post) title and thumbnail.
... | There is a simple approach to hold download access on your file.
**1.** Using .htaccess:
Upload a .htaccess file into your wp-content folder. Have a look if one exists already, then append this code to the end of the file. If you don’t have one, just create a new blank file and add this code to it:
```
RewriteEngine... |
91,771 | <p>I'm running Theme Check on a theme I've inherited and I've come across lots of recommendations like this one:</p>
<pre><code>RECOMMENDED: Text domain problems in loop.php. The twentyten text domain is being used!
</code></pre>
<p>The site has no plans for being translated, so what's the best thing to do in this si... | [
{
"answer_id": 91775,
"author": "jfacemyer",
"author_id": 12660,
"author_profile": "https://wordpress.stackexchange.com/users/12660",
"pm_score": 1,
"selected": false,
"text": "<p>If you don't plan on translating it, you should be able to remove the text domain references without any tro... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4109/"
] | I'm running Theme Check on a theme I've inherited and I've come across lots of recommendations like this one:
```
RECOMMENDED: Text domain problems in loop.php. The twentyten text domain is being used!
```
The site has no plans for being translated, so what's the best thing to do in this situation? Replace every ref... | You can remove all the translation references if you don't plan on translating it. You can also leave it in place, it shouldn't hurt anything..
If you want to remove it, go through your theme files and find references to `__(' Your Text', 'Domain')` and just change it to the "Your Text" portion. (Sometimes, you may e... |
91,786 | <p>My idea is that the visitor enters the password on a page and than the wordpress post with belonging password load if there is one.</p>
<p>Here is the code:</p>
<p>Form on page:</p>
<pre><code><form method="post" action="">
<input type="password" name="passwordfield">
<input type="hidden" name=... | [
{
"answer_id": 91775,
"author": "jfacemyer",
"author_id": 12660,
"author_profile": "https://wordpress.stackexchange.com/users/12660",
"pm_score": 1,
"selected": false,
"text": "<p>If you don't plan on translating it, you should be able to remove the text domain references without any tro... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91786",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31025/"
] | My idea is that the visitor enters the password on a page and than the wordpress post with belonging password load if there is one.
Here is the code:
Form on page:
```
<form method="post" action="">
<input type="password" name="passwordfield">
<input type="hidden" name="homepagepassword" value="1">
<input type... | You can remove all the translation references if you don't plan on translating it. You can also leave it in place, it shouldn't hurt anything..
If you want to remove it, go through your theme files and find references to `__(' Your Text', 'Domain')` and just change it to the "Your Text" portion. (Sometimes, you may e... |
91,821 | <p>I have several pages set up in a hierarchy on my site. Currently the site's pages and URLs look like this.</p>
<pre><code>Page name | Current URL | Preferred URL
-----------------|----------------------------------------
Page AAA | /pageAAA/ | /pageAAA/
|-- Page BBB | /page... | [
{
"answer_id": 100520,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 1,
"selected": false,
"text": "<p>I'd be curious if someone can find a better solution to this. Here's what I came up with:</p>\n\n<pre>... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91821",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29303/"
] | I have several pages set up in a hierarchy on my site. Currently the site's pages and URLs look like this.
```
Page name | Current URL | Preferred URL
-----------------|----------------------------------------
Page AAA | /pageAAA/ | /pageAAA/
|-- Page BBB | /pageAAA/pageBBB/ ... | I'd be curious if someone can find a better solution to this. Here's what I came up with:
```
function wpse_91821_flatten_page_paths( $wp ) {
if ( false !== strpos( $wp->matched_query, 'pagename=' ) && isset( $wp->query_vars['pagename'] ) && $wp->query_vars['pagename'] && false === strpos( $wp->query_vars['pagenam... |
91,831 | <p>I'm trying to find the best approach to customising the edit post screen for a custom post type.</p>
<p>I want to add a button which, when clicked will trigger code which looks up an external (not WP) database, gets some data, and then updates various fields - both core WP fields and custom meta fields. Ideally, th... | [
{
"answer_id": 91980,
"author": "Joe Izzard",
"author_id": 18824,
"author_profile": "https://wordpress.stackexchange.com/users/18824",
"pm_score": 1,
"selected": true,
"text": "<p>Add the Javascript code below to your submit button. This should remove the event that provides the warning.... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91831",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27540/"
] | I'm trying to find the best approach to customising the edit post screen for a custom post type.
I want to add a button which, when clicked will trigger code which looks up an external (not WP) database, gets some data, and then updates various fields - both core WP fields and custom meta fields. Ideally, the updates ... | Add the Javascript code below to your submit button. This should remove the event that provides the warning. Please note that this code is untested.
```
window.onbeforeunload = null;
```
This should disable the property however as stated above this code is untested.
Cheers,
Joe |
91,835 | <p>I am finding some problems uploading a WP site from my local webserver to the official online webserver.</p>
<p>The situation is the following one, on my local web server:</p>
<ol>
<li>I have install WP website on my computer</li>
<li>I have configure it</li>
<li>I have custom a template </li>
</ol>
<p>After, I h... | [
{
"answer_id": 91980,
"author": "Joe Izzard",
"author_id": 18824,
"author_profile": "https://wordpress.stackexchange.com/users/18824",
"pm_score": 1,
"selected": true,
"text": "<p>Add the Javascript code below to your submit button. This should remove the event that provides the warning.... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am finding some problems uploading a WP site from my local webserver to the official online webserver.
The situation is the following one, on my local web server:
1. I have install WP website on my computer
2. I have configure it
3. I have custom a template
After, I have upload this site in a folder on my official... | Add the Javascript code below to your submit button. This should remove the event that provides the warning. Please note that this code is untested.
```
window.onbeforeunload = null;
```
This should disable the property however as stated above this code is untested.
Cheers,
Joe |
91,839 | <p>Does anyone know a way to make the price of a second item different from the first in WooCommerce? I tried setting up the product so the first item was $245, second is an additional $150. I used variations and added $150 to each additional variation option. This works fine if users snag their item from the drop-do... | [
{
"answer_id": 91855,
"author": "Ewout",
"author_id": 26106,
"author_profile": "https://wordpress.stackexchange.com/users/26106",
"pm_score": 1,
"selected": false,
"text": "<p>Not a standard option, there's a plugin for that: <a href=\"http://www.woothemes.com/products/dynamic-pricing/\"... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11543/"
] | Does anyone know a way to make the price of a second item different from the first in WooCommerce? I tried setting up the product so the first item was $245, second is an additional $150. I used variations and added $150 to each additional variation option. This works fine if users snag their item from the drop-down me... | Not a standard option, there's a plugin for that: [Dynamic Pricing](http://www.woothemes.com/products/dynamic-pricing/)
Alternatively, you can hide the quantity buttons:
```
div.quantity {
display: none !important;
}
```
or disable it entirely:
```
function woocommerce_quantity_input() {}
```
though both these a... |
91,862 | <p>I am using a function to create new user roles and delete some defaults. However, they are not showing up in the post author box! Only the admin shows up because they are selected as an admin. Any user with a custom role does not show up. Any idea why this would be happening?</p>
<p>Here is my function:</p>
<pre><... | [
{
"answer_id": 91891,
"author": "souporserious",
"author_id": 18241,
"author_profile": "https://wordpress.stackexchange.com/users/18241",
"pm_score": 3,
"selected": false,
"text": "<p>Found a workaround below. I guess it has to do with a bug in the Wordpress core. This will list ALL user... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91862",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18241/"
] | I am using a function to create new user roles and delete some defaults. However, they are not showing up in the post author box! Only the admin shows up because they are selected as an admin. Any user with a custom role does not show up. Any idea why this would be happening?
Here is my function:
```
// Add New User ... | Found a workaround below. I guess it has to do with a bug in the Wordpress core. This will list ALL users in posts, so be cautious.
```
// Filter to fix the Post Author Dropdown
function author_override( $output ) {
global $post, $user_ID;
// return if this isn't the theme author override dropdown
if (!pr... |
91,863 | <p>I wrapped a shortcode around my post content and I have noticed it is making the excerpt blank on archive pages instead of auto generating one from the_content/post. At a loss as to what is causing it or what to try. Its not even outputting the shortcode in <code>the_excerpt</code> its just blank. I would have thoug... | [
{
"answer_id": 91891,
"author": "souporserious",
"author_id": 18241,
"author_profile": "https://wordpress.stackexchange.com/users/18241",
"pm_score": 3,
"selected": false,
"text": "<p>Found a workaround below. I guess it has to do with a bug in the Wordpress core. This will list ALL user... | 2013/03/21 | [
"https://wordpress.stackexchange.com/questions/91863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5962/"
] | I wrapped a shortcode around my post content and I have noticed it is making the excerpt blank on archive pages instead of auto generating one from the\_content/post. At a loss as to what is causing it or what to try. Its not even outputting the shortcode in `the_excerpt` its just blank. I would have thought if there w... | Found a workaround below. I guess it has to do with a bug in the Wordpress core. This will list ALL users in posts, so be cautious.
```
// Filter to fix the Post Author Dropdown
function author_override( $output ) {
global $post, $user_ID;
// return if this isn't the theme author override dropdown
if (!pr... |
91,874 | <p>I'm adapting a script I found online to add custom bulk actions to the screen with the list of posts. It has this line:</p>
<pre><code>add_action('load-edit.php', 'custom_bulk_action');
</code></pre>
<p>I'm trying to adapt it for the media library. I see that in place of <code>edit.php</code> I should use <code>up... | [
{
"answer_id": 92025,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress is missing some <code>apply_filters</code> and <code>do_action</code> in <code>upload.php</code>. So... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23086/"
] | I'm adapting a script I found online to add custom bulk actions to the screen with the list of posts. It has this line:
```
add_action('load-edit.php', 'custom_bulk_action');
```
I'm trying to adapt it for the media library. I see that in place of `edit.php` I should use `upload.php`, which leads me to believe I nee... | If you want to use your code, try this:
If you want to check if the medias are attachments, you can try to use `$_REQUEST['detached']`
```
add_action( 'load-upload.php', 'export_media_test' );
function export_media_test() {
if ( ! isset( $_REQUEST['action'] ) )
return;
echo 'Export Media';
if ... |
91,884 | <p>I want to be able to highlight the most recent post in a list of recent posts. By highlight I mean bold or style slightly differently from the other posts. This is the code I use now:</p>
<pre><code><h2>Assignments</h2>
<ol>
<?php
$recentPosts = new WP_Query();
$recentPosts->query('s... | [
{
"answer_id": 91898,
"author": "zac",
"author_id": 2661,
"author_profile": "https://wordpress.stackexchange.com/users/2661",
"pm_score": 0,
"selected": false,
"text": "<p>How about just using css ?</p>\n\n<pre><code>ol li:last-child {font-weight: 600}\n</code></pre>\n"
},
{
"ans... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91884",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28177/"
] | I want to be able to highlight the most recent post in a list of recent posts. By highlight I mean bold or style slightly differently from the other posts. This is the code I use now:
```
<h2>Assignments</h2>
<ol>
<?php
$recentPosts = new WP_Query();
$recentPosts->query('showposts=15&cat=188&order=ASC');
?>
<?... | I found a better solution:
```
<h2>Assignments</h2>
<ol>
<?php
$recentPosts = new WP_Query();
$recentPosts->query('showposts=15&cat=188&order=DESC');
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<?php $ageunix = get_the_time('U');
$days_old_in_seconds = ((time() - $ageunix));
$days_ol... |
91,890 | <p>I am already using a small code to set default sort orderby a custom field called "Year" I need to add another orderby to also sort by "Post Title" in the same sort.</p>
<p><strong>Sort</strong> = Year-Customfield (DESC) and Post-title (ASC)</p>
<p>Following is the code I'm currently using to sort by Year DESC.</p... | [
{
"answer_id": 91894,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": true,
"text": "<p>You could try using the <code>posts_orderby</code> filter:</p>\n\n<pre><code>add_filter('pre_get_posts', 'sort_... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29321/"
] | I am already using a small code to set default sort orderby a custom field called "Year" I need to add another orderby to also sort by "Post Title" in the same sort.
**Sort** = Year-Customfield (DESC) and Post-title (ASC)
Following is the code I'm currently using to sort by Year DESC.
```
add_filter('pre_get_posts',... | You could try using the `posts_orderby` filter:
```
add_filter('pre_get_posts', 'sort_arc');
function sort_arc($q) {
if ($q->is_category() && $q->is_main_query()) {
$q->set('meta_key', 'the-year');
add_filter('posts_orderby', 'custom_posts_orderby');
}
return $q;
}
```
where
```
function custom_posts_or... |
91,900 | <p>I need to force a 404 on some posts based on conditions. I managed to do it ( although I don't know if I did it the right way) and I'm a getting my <code>404.php</code> template to load as expected.</p>
<p><strong>My code:</strong></p>
<pre><code>function rr_404_my_event() {
global $post;
if ( is_singular( 'ev... | [
{
"answer_id": 91912,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 2,
"selected": false,
"text": "<p>I wouldn't recommend forcing a 404. </p>\n\n<p>If you're worried about search engines why not just do a \"no-ind... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17305/"
] | I need to force a 404 on some posts based on conditions. I managed to do it ( although I don't know if I did it the right way) and I'm a getting my `404.php` template to load as expected.
**My code:**
```
function rr_404_my_event() {
global $post;
if ( is_singular( 'event' ) && !rr_event_should_be_available( $pos... | You could try the Wordpress function `status_header()` to add the `HTTP/1.1 404 Not Found` header;
So your *Code 2* example would be:
```
function rr_404_my_event() {
global $post;
if ( is_singular( 'event' ) && !rr_event_should_be_available( $post->ID ) ) {
global $wp_query;
$wp_query->set_404();
sta... |
91,924 | <p>My question is:
it is possible to change the background color (for exemple) to an article who is categorized under "quote" format. (or whatever format like Aside or Link)?</p>
<p>I want that an article in Quote format appears different from others, with a specific font color, or specific background color.</p>
<p>... | [
{
"answer_id": 91912,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 2,
"selected": false,
"text": "<p>I wouldn't recommend forcing a 404. </p>\n\n<p>If you're worried about search engines why not just do a \"no-ind... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91924",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29341/"
] | My question is:
it is possible to change the background color (for exemple) to an article who is categorized under "quote" format. (or whatever format like Aside or Link)?
I want that an article in Quote format appears different from others, with a specific font color, or specific background color.
Is that possible?... | You could try the Wordpress function `status_header()` to add the `HTTP/1.1 404 Not Found` header;
So your *Code 2* example would be:
```
function rr_404_my_event() {
global $post;
if ( is_singular( 'event' ) && !rr_event_should_be_available( $post->ID ) ) {
global $wp_query;
$wp_query->set_404();
sta... |
91,932 | <p>I have some problems displaying info from my custom meta box in my custom post type single. I'm using <a href="https://github.com/tammyhart/Reusable-Custom-WordPress-Meta-Boxes" rel="nofollow">Reusable Custom Wordpress Meta Boxes</a> by Tammy Hart.</p>
<p>I'm able to display the textfields using this:</p>
<pre><co... | [
{
"answer_id": 91912,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 2,
"selected": false,
"text": "<p>I wouldn't recommend forcing a 404. </p>\n\n<p>If you're worried about search engines why not just do a \"no-ind... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91932",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16605/"
] | I have some problems displaying info from my custom meta box in my custom post type single. I'm using [Reusable Custom Wordpress Meta Boxes](https://github.com/tammyhart/Reusable-Custom-WordPress-Meta-Boxes) by Tammy Hart.
I'm able to display the textfields using this:
```
<?php echo get_post_meta($post->ID, $prefix.... | You could try the Wordpress function `status_header()` to add the `HTTP/1.1 404 Not Found` header;
So your *Code 2* example would be:
```
function rr_404_my_event() {
global $post;
if ( is_singular( 'event' ) && !rr_event_should_be_available( $post->ID ) ) {
global $wp_query;
$wp_query->set_404();
sta... |
91,949 | <p>For one of my current projects, I had to transfer blogposts from an old Wordpress site to my project.</p>
<p>Things went smoothly until I've seen that all the posts were copy pasted from Word, leaving this before pretty much every paragraph:</p>
<pre><code><span style="font-size: medium; font-family: georgia,pa... | [
{
"answer_id": 91968,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>I would check out the content_save_pre filter, and probably apply some fancy regex at that point.</p>\n"
},... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91949",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8895/"
] | For one of my current projects, I had to transfer blogposts from an old Wordpress site to my project.
Things went smoothly until I've seen that all the posts were copy pasted from Word, leaving this before pretty much every paragraph:
```
<span style="font-size: medium; font-family: georgia,palatino;">
```
And at s... | If we want to remove all inline styles, then just simply need to add the following code in functions.php.
```
add_filter('the_content', function( $content ){
//--Remove all inline styles--
$content = preg_replace('/ style=("|\')(.*?)("|\')/','',$content);
return $content;
}, 20);
``` |
91,956 | <p>I am using the <a href="http://codex.wordpress.org/Function_Reference/register_post_type" rel="nofollow">register_post_type</a> function in order to create a custom post type. I am already using the menu_icon parameter in order to set the admin icon for the post type. But, how can I set the 'mouseover' icon? When... | [
{
"answer_id": 91957,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 2,
"selected": false,
"text": "<p>This is more of a CSS question. However, if you create your icon as CSS sprite, you just shift between versio... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | I am using the [register\_post\_type](http://codex.wordpress.org/Function_Reference/register_post_type) function in order to create a custom post type. I am already using the menu\_icon parameter in order to set the admin icon for the post type. But, how can I set the 'mouseover' icon? When I have seen other plugins cr... | This is more of a CSS question. However, if you create your icon as CSS sprite, you just shift between versions of it in your CSS. Something like:
```
#toplevel_page_my_item .wp-menu-image {
background: url('images/sprite.png') no-repeat 0 8px !important;
}
#toplevel_page_my_item:hover .wp-menu-image,
#toplevel_my_... |
91,961 | <p>In a theme I am working there are up to 3 Stylesheets. I am using the hook 'wp_enqueue_scripts'. The order of the stylesheets is important for overwriting styles.
I have a code like this:</p>
<pre><code>add_action('wp_enqueue_scripts', 'add_stylesheet_one', 10);
add_action('wp_enqueue_scripts', 'add_stylesheet_two'... | [
{
"answer_id": 91963,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 2,
"selected": false,
"text": "<p>Hmm, is there a reason that you are doing it this way? The more conventional method is below.</p>\n\n<p>(The ... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91961",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9186/"
] | In a theme I am working there are up to 3 Stylesheets. I am using the hook 'wp\_enqueue\_scripts'. The order of the stylesheets is important for overwriting styles.
I have a code like this:
```
add_action('wp_enqueue_scripts', 'add_stylesheet_one', 10);
add_action('wp_enqueue_scripts', 'add_stylesheet_two', 14);
add_a... | The problem is that your actions are being run in the order you perceive but the styles are just being collected by WordPress and included in a random order.
The order of your add\_actions will not be important. I would do this:
```
function add_all_stylesheets() {
// you omitted this from your question, see below
... |
91,966 | <p>I have been using the advanced custom fields plugin and very much appreciate its abilities.</p>
<p>I have a page on the website i'm working on called About Us and within that page, there is contained, a list of staff members (4 in total). I built this list of staff members using the add on repeater field in the adv... | [
{
"answer_id": 91963,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 2,
"selected": false,
"text": "<p>Hmm, is there a reason that you are doing it this way? The more conventional method is below.</p>\n\n<p>(The ... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23507/"
] | I have been using the advanced custom fields plugin and very much appreciate its abilities.
I have a page on the website i'm working on called About Us and within that page, there is contained, a list of staff members (4 in total). I built this list of staff members using the add on repeater field in the advanced cust... | The problem is that your actions are being run in the order you perceive but the styles are just being collected by WordPress and included in a random order.
The order of your add\_actions will not be important. I would do this:
```
function add_all_stylesheets() {
// you omitted this from your question, see below
... |
91,981 | <p>I'm going nuts.</p>
<p>All I have is a simple loop on the home page of the site (which is a static page), and it should show the most recent (1) post of a certain category. The trouble is no matter what i do, it seems including category parameter makes sorting by date not work.</p>
<p>This is the loop I am using:<... | [
{
"answer_id": 91963,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 2,
"selected": false,
"text": "<p>Hmm, is there a reason that you are doing it this way? The more conventional method is below.</p>\n\n<p>(The ... | 2013/03/22 | [
"https://wordpress.stackexchange.com/questions/91981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15190/"
] | I'm going nuts.
All I have is a simple loop on the home page of the site (which is a static page), and it should show the most recent (1) post of a certain category. The trouble is no matter what i do, it seems including category parameter makes sorting by date not work.
This is the loop I am using:
```
<?php
$a... | The problem is that your actions are being run in the order you perceive but the styles are just being collected by WordPress and included in a random order.
The order of your add\_actions will not be important. I would do this:
```
function add_all_stylesheets() {
// you omitted this from your question, see below
... |
92,012 | <p>I've searched around but I can't quite pin down the answer for this. I am attempting to use the content of a custom field as post_data and save it to the database as such when a post is created or updated. I need to do this in order to make a frontend posting solution work out using the plugin Advanced Custom Fields... | [
{
"answer_id": 92013,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 0,
"selected": false,
"text": "<p>I think you need to have a post ID in your arguments array. From <a href=\"http://codex.wordpress.org/Functi... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | I've searched around but I can't quite pin down the answer for this. I am attempting to use the content of a custom field as post\_data and save it to the database as such when a post is created or updated. I need to do this in order to make a frontend posting solution work out using the plugin Advanced Custom Fields.
... | First, `content_save_pre` is a very old hook. [Adam Brown has a warning that:](http://adambrown.info/p/wp_hooks/hook/content_save_pre)
>
> This hook does not occur in the most recent version of WordPress
> (3.5). **Do not use it**. It is deprecated. You should look at the list of
> "related hooks" below to see if y... |
92,020 | <p>Before I ask this question, I know there is a (legitimate) hesitation to answer questions here about Woo products since they have their own support and their users should be encouraged to use that. I am a paying Woo user but couldn't solve this with their paid support, and my question is about overriding classes in ... | [
{
"answer_id": 92030,
"author": "Ewout",
"author_id": 26106,
"author_profile": "https://wordpress.stackexchange.com/users/26106",
"pm_score": 6,
"selected": true,
"text": "<p>There's actually a filter that you can use, see <code>abstract-wc-email.php</code>, line 214:</p>\n\n<pre><code>r... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92020",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29386/"
] | Before I ask this question, I know there is a (legitimate) hesitation to answer questions here about Woo products since they have their own support and their users should be encouraged to use that. I am a paying Woo user but couldn't solve this with their paid support, and my question is about overriding classes in WP ... | There's actually a filter that you can use, see `abstract-wc-email.php`, line 214:
```
return apply_filters( 'woocommerce_email_recipient_' . $this->id, $this->recipient, $this->object );
```
you can put the following in your functions.php:
```
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'yo... |
92,070 | <p>Is there a way to scale up post thumbnails on Wordpress?</p>
<p>On a featured div I want a post thumbnail/featured image with <strong>584×348 px</strong>. When I upload a smaller image as a featured image on a post, it won’t scale up to this size. <strong>If the image is 250×250, it will appear 250×250.</strong> Bu... | [
{
"answer_id": 92071,
"author": "Hasin Hayder",
"author_id": 12927,
"author_profile": "https://wordpress.stackexchange.com/users/12927",
"pm_score": 3,
"selected": true,
"text": "<p>As WordPress thumbnail generator doesn't do this \"scale up\" thing, you can do it using the following CSS... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29409/"
] | Is there a way to scale up post thumbnails on Wordpress?
On a featured div I want a post thumbnail/featured image with **584×348 px**. When I upload a smaller image as a featured image on a post, it won’t scale up to this size. **If the image is 250×250, it will appear 250×250.** But if I use a larger image as feature... | As WordPress thumbnail generator doesn't do this "scale up" thing, you can do it using the following CSS rule:
```
.featured_thumb img{ width:100%; height: 100%; }
```
Hope it will help. |
92,079 | <p>I've got a custom post type that has hierarchical taxonomies set up. For an example, my post type of "project" has categories of</p>
<pre><code> A
A.1
B
C
</code></pre>
<p>I'm trying to get the taxonomies displayed as classes on <code><li></code> items for each post, but I just want the top level parent... | [
{
"answer_id": 92135,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": false,
"text": "<p><code>wp_get_post_terms</code> doesn't accept <code>'parent'</code> or <code>'hide_empty'</code> parameters ... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92079",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12870/"
] | I've got a custom post type that has hierarchical taxonomies set up. For an example, my post type of "project" has categories of
```
A
A.1
B
C
```
I'm trying to get the taxonomies displayed as classes on `<li>` items for each post, but I just want the top level parents shown. For the post I'm looking at, it is... | Thanks to help from @Bainternet (here, and also his input which led to the [answer in this question](https://wordpress.stackexchange.com/questions/24794/get-the-the-top-level-parent-of-a-custom-taxonomy-term)), I was able to scrape together the code.
```
// determine the topmost parent of a term
function get_term_top_... |
92,081 | <p>When users upload very large photos and memory is tight, it seems like Wordpress runs out of memory - fails to resize the uploaded photos and does not create the necessary metadata (<code>_wp_attachment_metadata</code> entry in <code>wp_postmet</code>a is not created).</p>
<p>The worst part is that the user is neve... | [
{
"answer_id": 92466,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>I'm gonna add this as an answer, though it's probably not the answer you want.</p>\n\n<p>The answer is \"No, ... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11002/"
] | When users upload very large photos and memory is tight, it seems like Wordpress runs out of memory - fails to resize the uploaded photos and does not create the necessary metadata (`_wp_attachment_metadata` entry in `wp_postmet`a is not created).
The worst part is that the user is never notified. At most I get an "HT... | How do your users upload photos? You're right about `register_shutdown_function`. It seems to work well in my code, though I only ever call my back-end **via AJAX** (I've also got file upload functionality), and so only need to account for this case. Here's how I set it up in my plugin. Outside of the plugin class, som... |
92,086 | <p>The following code </p>
<pre><code><?php previous_post('%', '&#60;', 'no'); ?>
<?php next_post('%', '&#62; ', 'no'); ?>
</code></pre>
<p>returns these links, as it should</p>
<pre><code><a href="post_address/"><</a>
<a href="post_address/">></a>
</code></pre>
<p>... | [
{
"answer_id": 92466,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>I'm gonna add this as an answer, though it's probably not the answer you want.</p>\n\n<p>The answer is \"No, ... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13832/"
] | The following code
```
<?php previous_post('%', '<', 'no'); ?>
<?php next_post('%', '> ', 'no'); ?>
```
returns these links, as it should
```
<a href="post_address/"><</a>
<a href="post_address/">></a>
```
My question is about adding a class and title attribute so that the code returns
```
<a class="nor... | How do your users upload photos? You're right about `register_shutdown_function`. It seems to work well in my code, though I only ever call my back-end **via AJAX** (I've also got file upload functionality), and so only need to account for this case. Here's how I set it up in my plugin. Outside of the plugin class, som... |
92,088 | <p>I am trying to get the value of a custom field. The trick? I'm in the loop, currently printing out 2 of 5 for this example. I would like to get some info from 3 of 5 (or even 1 of 5) while printing out info on 2 of 5. I hope that makes sense. Any help would be great!</p>
| [
{
"answer_id": 92091,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>As you posted no code and little in the way of exactly what criteria you are using, I can't really writ functi... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20343/"
] | I am trying to get the value of a custom field. The trick? I'm in the loop, currently printing out 2 of 5 for this example. I would like to get some info from 3 of 5 (or even 1 of 5) while printing out info on 2 of 5. I hope that makes sense. Any help would be great! | As you posted no code and little in the way of exactly what criteria you are using, I can't really writ functioning code but inside your Loop try:
```
var_dump($posts[$wp_query->current_post -1]->post_title);
```
That is, `$posts[$wp_query->current_post -1]` is the previous post. You can change `-1` to plus or minus... |
92,089 | <p>I've created a custom profile field for my BP users and I'm looking to show the value on the user's profile page. The code below does this...</p>
<pre><code><?php bp_profile_field_data( array('user_id'=>get_the_author_meta( 'ID' ),'field'=>'birthday')); ?>
</code></pre>
<p>...But it displays it as "198... | [
{
"answer_id": 92093,
"author": "Rachel Baker",
"author_id": 8054,
"author_profile": "https://wordpress.stackexchange.com/users/8054",
"pm_score": 0,
"selected": false,
"text": "<p>You would use the PHP function date() to format the birthday timestamp. </p>\n\n<p>Example:</p>\n\n<pre><c... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92089",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2289/"
] | I've created a custom profile field for my BP users and I'm looking to show the value on the user's profile page. The code below does this...
```
<?php bp_profile_field_data( array('user_id'=>get_the_author_meta( 'ID' ),'field'=>'birthday')); ?>
```
...But it displays it as "1985-10-30 00:00:00".
How can I format ... | I have no idea if BuddyPress has built in date functions but [WordPress does](http://codex.wordpress.org/Formatting_Date_and_Time) and [PHP does](http://php.net/manual/en/ref.datetime.php). This should do it:
```
$bpress_date = bp_profile_field_data( array('user_id'=>get_the_author_meta( 'ID' ),'field'=>'birthday'));
... |
92,096 | <p>I've inserted a WP 3.5 media uploader into a widget by running this JavaScript when a button is clicked on:</p>
<pre><code>var frame = wp.media( {
title : 'Widget Uploader',
multiple : false,
library : { type : 'image' },
button : { text : 'Select Image' }
} );
frame.on( 'close', ... | [
{
"answer_id": 93586,
"author": "fregante",
"author_id": 1861,
"author_profile": "https://wordpress.stackexchange.com/users/1861",
"pm_score": 0,
"selected": false,
"text": "<p>The point is that that tab returns an external URL to be directly inserted in the post, while the widget is sup... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3898/"
] | I've inserted a WP 3.5 media uploader into a widget by running this JavaScript when a button is clicked on:
```
var frame = wp.media( {
title : 'Widget Uploader',
multiple : false,
library : { type : 'image' },
button : { text : 'Select Image' }
} );
frame.on( 'close', function() {
... | I've been digging through the source code for a similar reason; I'd like to add the "Attachment Display Settings" to the default "select" frame. As far as I can tell, this can't be done by passing parameters to wp.media(), as we would all like. wp.media currently has the two frames ("post" and "select"), and the views ... |
92,102 | <p>I migrated my WP deployment from the old server to the new server. The site still has the same URL (i.e. <a href="http://my.site.com" rel="nofollow">http://my.site.com</a>) but I've moved my WP deploy from the site URL to a subdirectory of said URL (i.e. the WP deploy used to be found at <a href="http://my.site.com"... | [
{
"answer_id": 93586,
"author": "fregante",
"author_id": 1861,
"author_profile": "https://wordpress.stackexchange.com/users/1861",
"pm_score": 0,
"selected": false,
"text": "<p>The point is that that tab returns an external URL to be directly inserted in the post, while the widget is sup... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92102",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5909/"
] | I migrated my WP deployment from the old server to the new server. The site still has the same URL (i.e. <http://my.site.com>) but I've moved my WP deploy from the site URL to a subdirectory of said URL (i.e. the WP deploy used to be found at <http://my.site.com>, but now it's at <http://my.site.com/blog>).
The good n... | I've been digging through the source code for a similar reason; I'd like to add the "Attachment Display Settings" to the default "select" frame. As far as I can tell, this can't be done by passing parameters to wp.media(), as we would all like. wp.media currently has the two frames ("post" and "select"), and the views ... |
92,103 | <p>I recently noticed that Wordpress tries to auto-complete a URL when it's not submitted in its entirety. E.g. I have a post URL that looks like this:</p>
<pre><code>http://www.mysite.com/some-post-title
</code></pre>
<p>If I browse to the following URL:</p>
<pre><code>http://www.mysite.com/some-post-ti
</code></pr... | [
{
"answer_id": 92104,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 6,
"selected": true,
"text": "<p>I believe that is the <a href=\"http://codex.wordpress.org/Function_Reference/redirect_canonical\"><code>redir... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6616/"
] | I recently noticed that Wordpress tries to auto-complete a URL when it's not submitted in its entirety. E.g. I have a post URL that looks like this:
```
http://www.mysite.com/some-post-title
```
If I browse to the following URL:
```
http://www.mysite.com/some-post-ti
```
I can see that the URL is submitted to Wor... | I believe that is the [`redirect_canonical`](http://codex.wordpress.org/Function_Reference/redirect_canonical) function hooked to `template_redirect`. You should be able to disable it with:
```
remove_filter('template_redirect', 'redirect_canonical');
```
But you should really think about whether you want to do tha... |
92,107 | <p>Done a bit of searching and cant really find the answer. </p>
<p>Looking for idea on how I send a user an admin bar notification in BuddyPress after a certain event is actioned in a plugin I'm building?</p>
<p>BP Version - 1.6.4, Wordpress Version - 3.5.1 </p>
| [
{
"answer_id": 92152,
"author": "Slava Abakumov",
"author_id": 28137,
"author_profile": "https://wordpress.stackexchange.com/users/28137",
"pm_score": 0,
"selected": false,
"text": "<p>Each BuddyPress component has a <code>bp-[groups|friends|...]-notifications.php</code> file.\nLook at i... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20964/"
] | Done a bit of searching and cant really find the answer.
Looking for idea on how I send a user an admin bar notification in BuddyPress after a certain event is actioned in a plugin I'm building?
BP Version - 1.6.4, Wordpress Version - 3.5.1 | First you need to setup component for this:
```
function notifier_setup_globals() {
global $bp, $current_blog;
$bp->notifier = new stdClass();
$bp->notifier->id = 'notifier';
$bp->notifier->slug = 'notifier';
$bp->notifier->notification_callback = 'bp_notifier_format_notifications';//this is a func... |
92,108 | <p>I have a number of regular posts and pages in a regular category called "Featured". I have also installed a plugin called "Event Organizer" that creates its own custom post type called "Event" and has its own interface for creating plugin-specific categories.</p>
<p>Anyways, what I've created is a basic highlight s... | [
{
"answer_id": 92112,
"author": "revo",
"author_id": 26909,
"author_profile": "https://wordpress.stackexchange.com/users/26909",
"pm_score": 0,
"selected": false,
"text": "<p>Use </p>\n\n<pre><code>'post_status' => array('featured','publish') \n</code></pre>\n\n<p>and </p>\n\n<pre><co... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29423/"
] | I have a number of regular posts and pages in a regular category called "Featured". I have also installed a plugin called "Event Organizer" that creates its own custom post type called "Event" and has its own interface for creating plugin-specific categories.
Anyways, what I've created is a basic highlight slider usin... | These scenarios become much easier if you use plugins like [posts2posts](http://wordpress.org/extend/plugins/posts-to-posts/) to establish a relation (for example featured posts to this page) and then pull them easily in the context |
92,155 | <p>For auditing issue, I only want a post can be trashed, but not deleted - for all users.</p>
<p>So I have a plugin like</p>
<pre><code>add_action('before_delete_post', function($id) {
wp_die(0);
});
</code></pre>
<p>But seems not all delete action are ajax, so it will be show a black screen with return... | [
{
"answer_id": 92162,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 3,
"selected": false,
"text": "<p>Don't let the action die, just do a redirect (to wherever you'd like):</p>\n\n<pre><code>function wpse_92155_... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16037/"
] | For auditing issue, I only want a post can be trashed, but not deleted - for all users.
So I have a plugin like
```
add_action('before_delete_post', function($id) {
wp_die(0);
});
```
But seems not all delete action are ajax, so it will be show a black screen with return an error page with result "0"
F... | Don't let the action die, just do a redirect (to wherever you'd like):
```
function wpse_92155_before_delete_post() {
wp_redirect(admin_url('edit.php'));
exit();
} // function wpse_92155_before_delete_post
add_action('before_delete_post', 'wpse_92155_before_delete_post', 1);
``` |
92,158 | <p>I have a got custom page template which displays a drop down box that has list of countries.A user selects the box and clicks sumbit.Page then then displays the relevant details for that country .IT has also displays discription which is stored in a the database.</p>
<p>The following sql queries are used to disp... | [
{
"answer_id": 92162,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 3,
"selected": false,
"text": "<p>Don't let the action die, just do a redirect (to wherever you'd like):</p>\n\n<pre><code>function wpse_92155_... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29438/"
] | I have a got custom page template which displays a drop down box that has list of countries.A user selects the box and clicks sumbit.Page then then displays the relevant details for that country .IT has also displays discription which is stored in a the database.
The following sql queries are used to display data.
``... | Don't let the action die, just do a redirect (to wherever you'd like):
```
function wpse_92155_before_delete_post() {
wp_redirect(admin_url('edit.php'));
exit();
} // function wpse_92155_before_delete_post
add_action('before_delete_post', 'wpse_92155_before_delete_post', 1);
``` |
92,167 | <p>I have a loop where I display all posts on the site, the problem is that the_excerpt is not being displayed. What am I doing wrong?</p>
<pre><code> <?php
$all_posts = get_posts(array('numberposts' => -1));
$total_posts = count($all_posts);
$posts_per_column = intval($total_posts / 3);
$count... | [
{
"answer_id": 92169,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>You need to be using <a href=\"https://codex.wordpress.org/Function_Reference/setup_postdata\" rel=\"nofollow\... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/890/"
] | I have a loop where I display all posts on the site, the problem is that the\_excerpt is not being displayed. What am I doing wrong?
```
<?php
$all_posts = get_posts(array('numberposts' => -1));
$total_posts = count($all_posts);
$posts_per_column = intval($total_posts / 3);
$count = 0;
$col = 1;... | You need to be using [`setup_postdata`](https://codex.wordpress.org/Function_Reference/setup_postdata)
```
foreach($all_posts as $post):
setup_postdata($post);
// the rest of your loop
```
[If you look at the docs for `get_posts` you will see that in all of the examples.](http://codex.wordpress.org/Template_... |
92,173 | <p>I'm using custom image dimensions in functions.php like this:</p>
<pre><code>add_image_size( 'custom-size-thumbnail', 120, 120, true );
</code></pre>
<p>I uploaded some pictures with wrong orientation, so I used "edit" options to rotate them...</p>
<p>Problem is, that only original size pictures (full, large, med... | [
{
"answer_id": 94955,
"author": "Ján Bočínec",
"author_id": 2515,
"author_profile": "https://wordpress.stackexchange.com/users/2515",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://wordpress.org/extend/plugins/regenerate-thumbnails/\" rel=\"nofollow\">Regenerate Thumbnail... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29442/"
] | I'm using custom image dimensions in functions.php like this:
```
add_image_size( 'custom-size-thumbnail', 120, 120, true );
```
I uploaded some pictures with wrong orientation, so I used "edit" options to rotate them...
Problem is, that only original size pictures (full, large, medium, thumbnail) are regenerated (... | Asked the same question [here](https://wordpress.stackexchange.com/questions/89925/custom-image-size-not-regenerating-when-image-editted). There is an extra step to fix this, as answered in my question. |
92,191 | <p>How do I hide "Content" and "Discussion" element in the "Right Now" dashboard widget?</p>
<p>Here's a screenshot:</p>
<p><img src="https://i.stack.imgur.com/EtPQT.png" alt="right now dashboard widget"> </p>
| [
{
"answer_id": 92206,
"author": "Pat",
"author_id": 12920,
"author_profile": "https://wordpress.stackexchange.com/users/12920",
"pm_score": 0,
"selected": false,
"text": "<p>You can click on the <code>Screen Options</code> in the top right of the screen, and uncheck them from the options... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29072/"
] | How do I hide "Content" and "Discussion" element in the "Right Now" dashboard widget?
Here's a screenshot:
 | Here are two methods:
Method 1
--------
You could remove the whole **`Right Now`** metabox from your dashboard:
```
function custom_dashboard() {
if(!current_user_can('manage_options')){
// only remove it for non-admins
remove_meta_box('dashboard_right_now', 'dashboard', 'core');
}
}
add_action('... |
92,193 | <p>I've been trying to figure this out all day now.</p>
<p>Consider the following code below:</p>
<pre><code><div class="slider">
<div class="slides"><?php
wp_reset_query();
if(have_posts()) :
while (have_posts()) :
the_post();
if(is_sticky()) ... | [
{
"answer_id": 92195,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>If you look at that code carefully, the only thing it ever prints are sticky posts:</p>\n\n<pre><code>if(is_st... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92193",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I've been trying to figure this out all day now.
Consider the following code below:
```
<div class="slider">
<div class="slides"><?php
wp_reset_query();
if(have_posts()) :
while (have_posts()) :
the_post();
if(is_sticky()) : ?>
<div class="slid... | If you look at that code carefully, the only thing it ever prints are sticky posts:
```
if(is_sticky()) : ?>
<div class="slide"><a rel="bookmark" href="<?php the_permalink() ?>"><?php echo the_post_thumbnail('full'); ?><h2><?php the_title(); ?></h2></a></div>
<?php endif;
```
You stand a better chance of having s... |
92,200 | <p>I created a child theme and installed it but I don't know how exactly it works!</p>
<p>For example, in the parent theme I have the code below:</p>
<pre><code>.header {
margin-top: 10px;
margin-bottom: 10px;
width: 300px;
height: 150px;
background: white;
border-width: 5px;
}
</code></pre>
<p>And... | [
{
"answer_id": 92219,
"author": "gorelog",
"author_id": 16746,
"author_profile": "https://wordpress.stackexchange.com/users/16746",
"pm_score": 0,
"selected": false,
"text": "<p>You may want to copy the header.php file to your child theme folder and look for and delete any style sheet im... | 2013/03/24 | [
"https://wordpress.stackexchange.com/questions/92200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25490/"
] | I created a child theme and installed it but I don't know how exactly it works!
For example, in the parent theme I have the code below:
```
.header {
margin-top: 10px;
margin-bottom: 10px;
width: 300px;
height: 150px;
background: white;
border-width: 5px;
}
```
And I want to not include the width:... | You are correct, that WordPress will load the style.css file from your parent theme first, and then the style.css from your child theme. These means because of how CSS itself works, you have to specifically override any rule you wish to override.
What this means is that you would need to modify the CSS within your Chi... |
92,213 | <p><strong>Context</strong></p>
<ul>
<li><em>Post Type:</em> Resources</li>
<li><em>Taxonomy:</em> Media Type, <em>Term:</em> Audio</li>
<li><em>Taxonomy:</em> Series</li>
</ul>
<p>The following code displays a unique list of the custom taxonomy "Series"</p>
<p>I want to order the list by term_order, but it is not w... | [
{
"answer_id": 92347,
"author": "Jonathan Wold",
"author_id": 1766,
"author_profile": "https://wordpress.stackexchange.com/users/1766",
"pm_score": 2,
"selected": false,
"text": "<p>Instead of <code>menu_order</code> try <code>term_order</code>. </p>\n\n<p>According to <a href=\"http://c... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29455/"
] | **Context**
* *Post Type:* Resources
* *Taxonomy:* Media Type, *Term:* Audio
* *Taxonomy:* Series
The following code displays a unique list of the custom taxonomy "Series"
I want to order the list by term\_order, but it is not working. Any suggestions?
The [site](http://eaglesonline.org/resources/audio/). Currently... | Instead of `menu_order` try `term_order`.
According to [documentation on the Codex](http://codex.wordpress.org/Function_Reference/wp_get_object_terms), `wp_get_object_terms` supports:
* name
* count
* slug
* term\_group
* term\_order and
* term\_id |
92,244 | <p>I don't want clients to deactivate woocommerce plugin even by mistake. And I have recently come across a concept called must use plugins in wordpress. (<a href="http://codex.wordpress.org/Must_Use_Plugins" rel="nofollow">http://codex.wordpress.org/Must_Use_Plugins</a>)</p>
<p>Just want to know if there is possibili... | [
{
"answer_id": 92247,
"author": "Androliyah",
"author_id": 17636,
"author_profile": "https://wordpress.stackexchange.com/users/17636",
"pm_score": -1,
"selected": false,
"text": "<p>Must-use plugins (a.k.a. mu-plugins) are plugins installed in a special directory inside the content folde... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29467/"
] | I don't want clients to deactivate woocommerce plugin even by mistake. And I have recently come across a concept called must use plugins in wordpress. (<http://codex.wordpress.org/Must_Use_Plugins>)
Just want to know if there is possibility to use woocommerce as a must use plugin. | This is a classic XY problem question, the original problem you face is:
>
> "How do I prevent a client from disabling the woocommerce plugin"
>
>
>
For which mu-plugins was your solution, to which you are now asking for a fix for your solution, aka a fix for a fix, never a good sign.
So addressing your original... |
92,253 | <p>I've been looking through Wordpress' codes and they're mostly using PHP's regular string functions, like strlen, strpos, etc. Yet I know Wordpress supports utf8, so how does it do that?</p>
<p>Does it overload the regular string functions with multibyte string functions?</p>
<p>If so, is that a good idea in practi... | [
{
"answer_id": 92254,
"author": "Jason Weber",
"author_id": 26710,
"author_profile": "https://wordpress.stackexchange.com/users/26710",
"pm_score": 0,
"selected": false,
"text": "<p>No, WordPress doesn't support unicode natively. But it's an easy fix.</p>\n\n<p>Open up your wp.config in... | 2013/03/23 | [
"https://wordpress.stackexchange.com/questions/92253",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I've been looking through Wordpress' codes and they're mostly using PHP's regular string functions, like strlen, strpos, etc. Yet I know Wordpress supports utf8, so how does it do that?
Does it overload the regular string functions with multibyte string functions?
If so, is that a good idea in practice? If not, then ... | Wordpress is written in PHP. As far as I know, PHP doesn't support any character encoding (UTF-8, UTF-16, ...). It just assumes the text to be ASCII encoded.
The actual encoding and decoding is done by your browser. When you write a post, your browser sends the text you just entered as UTF-8 to the server. Wordpress j... |
92,272 | <p>On the site that I am working on I have Jobs as a custom post type and Locations as custom taxonomy. The Locations are used by Jobs, Posts, and other CPTs. </p>
<p>I am working on a small filter for the jobs and want to show a list of all Locations as links that after you click on one it will sort the page to show... | [
{
"answer_id": 92278,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>get_categories has no concept of post type, it only looks a the taxonomy term, and that terms post count. The... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92272",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15771/"
] | On the site that I am working on I have Jobs as a custom post type and Locations as custom taxonomy. The Locations are used by Jobs, Posts, and other CPTs.
I am working on a small filter for the jobs and want to show a list of all Locations as links that after you click on one it will sort the page to show only Jobs ... | You should use `wp_get_post_terms()` instead of `get_categories()`. It returns an array of terms associated with a post.
```
<?php
function get_my_custom_terms() {
global $post;
$myterms = wp_get_post_terms($post->ID, 'location');
if ($myterms) {
foreach($myterms as $term) {
$termname... |
92,277 | <p>I'm trying to translate Woosidebars strings in french using PoEdit but my french strings are never shown on the front-end. English strings are always displayed, even when I change the language (And I can see it works since other plugins strings are well translated).</p>
<p>I've created and added a french translati... | [
{
"answer_id": 92278,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>get_categories has no concept of post type, it only looks a the taxonomy term, and that terms post count. The... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92277",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15387/"
] | I'm trying to translate Woosidebars strings in french using PoEdit but my french strings are never shown on the front-end. English strings are always displayed, even when I change the language (And I can see it works since other plugins strings are well translated).
I've created and added a french translation file cal... | You should use `wp_get_post_terms()` instead of `get_categories()`. It returns an array of terms associated with a post.
```
<?php
function get_my_custom_terms() {
global $post;
$myterms = wp_get_post_terms($post->ID, 'location');
if ($myterms) {
foreach($myterms as $term) {
$termname... |
92,285 | <p>I created a custom field called 'Page Description' which I use to create a custom title for each static page of my wordpress site. I use the code:</p>
<pre><code><?php echo get_post_meta(get_the_ID(),'Page Description',true); ?>
</code></pre>
<p>in my header.php.</p>
<p>it displays in all of my pages except... | [
{
"answer_id": 92290,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 2,
"selected": false,
"text": "<p>Well, your blog page is not one particular post/page, it is rather a <strong>template</strong> which populat... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29482/"
] | I created a custom field called 'Page Description' which I use to create a custom title for each static page of my wordpress site. I use the code:
```
<?php echo get_post_meta(get_the_ID(),'Page Description',true); ?>
```
in my header.php.
it displays in all of my pages except for my blog page. Can someone please h... | Try using:
```
<?php
// Determine context
$page_id = ( 'page' == get_option( 'show_on_front' ) ? get_option( 'page_for_posts' ) : get_the_ID );
// Echo post meta for $page_id
echo get_post_meta( $page_id, 'Page Description', true );
?>
```
What's happening:
1. You're using a static page as front page, and a static... |
92,297 | <p>I have moved a wordpress site from one domain and server to another domain and server. Everything looks fine except all the links within the site are still pointing to the previous domain. Please let me know what went wrong with the transfer. I'll really be thankful for the kind response and help.</p>
| [
{
"answer_id": 92300,
"author": "balyhoo",
"author_id": 29488,
"author_profile": "https://wordpress.stackexchange.com/users/29488",
"pm_score": 1,
"selected": false,
"text": "<p>You probably need to log into the admin portal (www.yoursite.com/wp-admin) and change the site's address under... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20406/"
] | I have moved a wordpress site from one domain and server to another domain and server. Everything looks fine except all the links within the site are still pointing to the previous domain. Please let me know what went wrong with the transfer. I'll really be thankful for the kind response and help. | Most probably, nothing went wrong, you just have to set some things to the new server.
Firstly, there are the home and site urls (to be found in the general settings).
Then, possible absolute links pointing to the *old* domain have to be adapted.
To change these links, you have to adapt the SQL table.
Update option... |
92,309 | <p>I have a Custom Post Type of "projects", that is categorized by a Custom Taxonomy of "industry", which is heirarchical. Projects & sub-projects are assigned to the industries. For Example, the "Academic" industry contains, three sub-industries of, University, Community College, & K-12. I need to display the ... | [
{
"answer_id": 92317,
"author": "Julien Le Thuaut",
"author_id": 15387,
"author_profile": "https://wordpress.stackexchange.com/users/15387",
"pm_score": 0,
"selected": false,
"text": "<p>I think you should better use the <a href=\"http://codex.wordpress.org/Template_Tags/wp_list_categori... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92309",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29489/"
] | I have a Custom Post Type of "projects", that is categorized by a Custom Taxonomy of "industry", which is heirarchical. Projects & sub-projects are assigned to the industries. For Example, the "Academic" industry contains, three sub-industries of, University, Community College, & K-12. I need to display the list of pro... | Here is some basic setup for the function that [MavBzh](https://wordpress.stackexchange.com/users/15387/mavbzh) mentioned.
```
<?php
$args = array(
'title_li' => '',
'taxonomy' => 'industry',
'show_option_none' => '',
);
?>
<ul><?php wp_list_categories( $args ); ?></ul>
``` |
92,323 | <p>In the attached screenshot you can see the structure of the theme options we are working with. There are 8 tabs and for each tab, we have created custom fields using code similar to what can be seen below.This is how we are setting the default values for each field. ( ie. default = '<a href="http://facebook.com/samp... | [
{
"answer_id": 92346,
"author": "Andy Jacobs",
"author_id": 23850,
"author_profile": "https://wordpress.stackexchange.com/users/23850",
"pm_score": 1,
"selected": false,
"text": "<p>You should initialize the default values when the theme is first activated by hooking into the <a href=\"h... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92323",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15259/"
] | In the attached screenshot you can see the structure of the theme options we are working with. There are 8 tabs and for each tab, we have created custom fields using code similar to what can be seen below.This is how we are setting the default values for each field. ( ie. default = '<http://facebook.com/samplefacebookt... | Don't initialize defaults, or do an initial save. Just use sane defaults.
For example, define an array of defaults:
```
function wpse92323_get_option_defaults() {
$defaults = array(
'slug1' => 'default1',
'slug2' => 'default2'
);
return apply_filters( 'wpse92323_option_defaults', $defaults... |
92,324 | <p>I noticed today that my error logs are littered with this information. I'm not quite sure what's causing it. Has anyone seen this before?</p>
<p><code>[Mon Mar 25 17:24:23 2013] [error] [client] PHP Warning: Invalid argument supplied for foreach() in /var/www/html/mysite/wp-admin/includes/plugin.php on line 1290, ... | [
{
"answer_id": 92330,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 3,
"selected": true,
"text": "<p>This is most likely caused by a plugin. Deactivate them all, and reactivate one by one.</p>\n"
},
{
"a... | 2013/03/25 | [
"https://wordpress.stackexchange.com/questions/92324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12920/"
] | I noticed today that my error logs are littered with this information. I'm not quite sure what's causing it. Has anyone seen this before?
`[Mon Mar 25 17:24:23 2013] [error] [client] PHP Warning: Invalid argument supplied for foreach() in /var/www/html/mysite/wp-admin/includes/plugin.php on line 1290, referer: http://... | This is most likely caused by a plugin. Deactivate them all, and reactivate one by one. |
92,371 | <p>I want to start a funny images website but I have come across a dilemma. I want the website to display 1 post ( not the thumbnail) but the full post on the home page. (the most recent post). Similar to <a href="http://jokideo.com/" rel="nofollow">jokideo</a> can anyone please direct me to a <code>theme</code> or pro... | [
{
"answer_id": 92375,
"author": "jacquesdeklerk",
"author_id": 29516,
"author_profile": "https://wordpress.stackexchange.com/users/29516",
"pm_score": -1,
"selected": false,
"text": "<p>I would recommend altering the loop that displays the home page posts. Something like </p>\n\n<pre><co... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92371",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23616/"
] | I want to start a funny images website but I have come across a dilemma. I want the website to display 1 post ( not the thumbnail) but the full post on the home page. (the most recent post). Similar to [jokideo](http://jokideo.com/) can anyone please direct me to a `theme` or provide some code that I need to edit in th... | It depends on what theme you use as they are not coded the same.
Use [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) or the reading settings and [`the_content()`](http://codex.wordpress.org/Function_Reference/the_content) rather than the\_excerpt() in your loop.
```
function wp... |
92,398 | <p>How do I place the following javaScript in the <code><head></code> section of the Wordpress <em>Widgets</em> API menu screen?</p>
<pre><code><script type="text/javascript">
jQuery(window).load(function() {
jQuery("#logocheckbox").change(function() {
jQuery("#logocheckboxdiv").fad... | [
{
"answer_id": 92375,
"author": "jacquesdeklerk",
"author_id": 29516,
"author_profile": "https://wordpress.stackexchange.com/users/29516",
"pm_score": -1,
"selected": false,
"text": "<p>I would recommend altering the loop that displays the home page posts. Something like </p>\n\n<pre><co... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92398",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16795/"
] | How do I place the following javaScript in the `<head>` section of the Wordpress *Widgets* API menu screen?
```
<script type="text/javascript">
jQuery(window).load(function() {
jQuery("#logocheckbox").change(function() {
jQuery("#logocheckboxdiv").fadeToggle("slow");
});
});
</scrip... | It depends on what theme you use as they are not coded the same.
Use [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) or the reading settings and [`the_content()`](http://codex.wordpress.org/Function_Reference/the_content) rather than the\_excerpt() in your loop.
```
function wp... |
92,402 | <p>I have a WordPress 3.5.1 installation on my <a href="http://wordpress.camilstaps.nl" rel="nofollow">WordPress Shack</a>, with the <a href="http://wordpress.org/extend/plugins/facebook/" rel="nofollow">Facebook plugin</a> 1.3.1 installed and the TwentyTwelve 1.1 theme. I have the settings on Facebook - Comments box s... | [
{
"answer_id": 95616,
"author": "Steve Buzonas",
"author_id": 7953,
"author_profile": "https://wordpress.stackexchange.com/users/7953",
"pm_score": 0,
"selected": false,
"text": "<p>According to the <a href=\"http://codex.wordpress.org/Template_Hierarchy\" rel=\"nofollow\">Template Hiera... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92402",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a WordPress 3.5.1 installation on my [WordPress Shack](http://wordpress.camilstaps.nl), with the [Facebook plugin](http://wordpress.org/extend/plugins/facebook/) 1.3.1 installed and the TwentyTwelve 1.1 theme. I have the settings on Facebook - Comments box so that I display the comments box on posts and pages. I... | ### Fast 'n' Hacky
The problem can be solved by changing line 319 in `facebook.php` to the following:
```
if (is_home()) {
```
This way, the front page is not treated as a *home* page but as a regular page, for which the facebook feature settings can be applied (and will be handled correctly).
---
### More Elegan... |
92,415 | <p>I am using new 3.5 media uploader in my theme frontend (base on <a href="http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/" rel="nofollow">this</a> example). It is very simple when you want to do something with images after the <code>'Select'</code> button is pressed:</p>
<pre><co... | [
{
"answer_id": 131295,
"author": "Jörn Lund",
"author_id": 35723,
"author_profile": "https://wordpress.stackexchange.com/users/35723",
"pm_score": 4,
"selected": false,
"text": "<p>There is a <code>FileUploaded</code> event being fired in <code>wp-includes/js/plupload/wp-plupload.js</cod... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19226/"
] | I am using new 3.5 media uploader in my theme frontend (base on [this](http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/) example). It is very simple when you want to do something with images after the `'Select'` button is pressed:
```
file_frame.on('select', function() {
// Get ... | There is a `FileUploaded` event being fired in `wp-includes/js/plupload/wp-plupload.js`.
Alternatively (and propably the better way) you may want extend wp.Uploader with your own success callback .
```
(function($){
$.extend( wp.Uploader.prototype, {
success : function( file_attachment ){
c... |
92,419 | <p>I'm using code below to spit out custom post types along with its categories, so</p>
<p>Category 1
---post 1
---post 2</p>
<p>Category 2
---post 1
---post 2
---post 3
etc.</p>
<p>That works well for me, however I would like to be able to sort my categories by count so orderby=count so catgorie... | [
{
"answer_id": 92425,
"author": "ceruleus",
"author_id": 29434,
"author_profile": "https://wordpress.stackexchange.com/users/29434",
"pm_score": 0,
"selected": false,
"text": "<p>Since you didn't tell how \"this doesn't work\", I will cover every problem that I can think right now.</p>\n... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4986/"
] | I'm using code below to spit out custom post types along with its categories, so
Category 1
---post 1
---post 2
Category 2
---post 1
---post 2
---post 3
etc.
That works well for me, however I would like to be able to sort my categories by count so orderby=count so catgories with larger amount of post will go to... | You have `orderby=count`, which [should be correct](http://codex.wordpress.org/Function_Reference/get_terms), but you also have `order=asc`. `order=ASC` means "smallest to largest", at least with numbers. You want the opposite, "largest to smallest". Use `order=DESC` instead. I suspect that `get_terms` is working, you'... |
92,424 | <p>I am literally clueless as to why the code does not function properly on the first page, but functions as expected on the second page. The second query should return the latest 3 posts in the pagination loop, yet it also returns posts from the first query. Instead of 3 posts on the homepage, there are 6, but on the ... | [
{
"answer_id": 92429,
"author": "ceruleus",
"author_id": 29434,
"author_profile": "https://wordpress.stackexchange.com/users/29434",
"pm_score": 1,
"selected": false,
"text": "<p>I see potential bug here:</p>\n<pre><code><?php $sticky_query = new WP_Query('nopaging=true'); ?>\n<... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92424",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am literally clueless as to why the code does not function properly on the first page, but functions as expected on the second page. The second query should return the latest 3 posts in the pagination loop, yet it also returns posts from the first query. Instead of 3 posts on the homepage, there are 6, but on the sec... | I see a number of issues, aside from the use of query\_posts ( this should raise immediate alarm bells ). I strongly recommend you don't use the alt syntax, and that you minimise the unnecessary opening and closing PHP tags as it obscures your code.
Here is a cleaned up version of your first query loop:
```
if(have_p... |
92,430 | <p>I'm considering rebuilding a drupal site in wordpress and am still wrapping my head around the differences between the systems - particularly cck/fields and custom content types and the different ways to use taxonomy.</p>
<p>I would like to know if two custom content types can share one custom taxonomy. In drupal ... | [
{
"answer_id": 92433,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/register_post_type\" rel=\"noreferrer\">From the Code... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92430",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29540/"
] | I'm considering rebuilding a drupal site in wordpress and am still wrapping my head around the differences between the systems - particularly cck/fields and custom content types and the different ways to use taxonomy.
I would like to know if two custom content types can share one custom taxonomy. In drupal I can limit... | Sharing a taxonomy between CPTs
-------------------------------
>
> I would like to know if two custom content types can share one custom taxonomy.
>
>
>
Simple said: **Yes, they can**.
How to share
------------
You should **always register** custom taxonomies and post types **to each other** as early as possib... |
92,459 | <p>I am trying to create a template that will display a list posts of a specific custom type. However, I am missing something fundamental. So far, here is what I have:</p>
<h3>functions.php</h3>
<pre><code>add_action( 'pre_get_posts', 'query_filter', 1);
function query_filter($query)
{
if (!$query->is_admin ... | [
{
"answer_id": 92460,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>You've duplicated your loop:</p>\n\n<pre><code> <?php if ( have_posts() ) : while ( have_posts() ) : the... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | I am trying to create a template that will display a list posts of a specific custom type. However, I am missing something fundamental. So far, here is what I have:
### functions.php
```
add_action( 'pre_get_posts', 'query_filter', 1);
function query_filter($query)
{
if (!$query->is_admin OR
$... | Why reinvent the wheel? [Just create `archive-{posttype}.php`](http://codex.wordpress.org/Template_Hierarchy#Custom_Post_Types_display), and ensure that `'has_archive'` is set to `true` for the post type.
If your post type is `event`: `archive-event.php`.
Then, WordPress will handle the query automatically. If pretty... |
92,476 | <p>I have 5 main posts within a custom post type. Some of these posts will have children. I have content that should only be displayed on the parent post and all children of that post. What's the best way to achieve this?</p>
| [
{
"answer_id": 92478,
"author": "RevCocnept",
"author_id": 18388,
"author_profile": "https://wordpress.stackexchange.com/users/18388",
"pm_score": 1,
"selected": false,
"text": "<p>Your question is a little unclear...I think what you're trying to ask is how to display the parent content ... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28232/"
] | I have 5 main posts within a custom post type. Some of these posts will have children. I have content that should only be displayed on the parent post and all children of that post. What's the best way to achieve this? | You could setup a condition based on post ID:
```
<?php if (is_page(12) || $post->post_parent=="12") { ?>
<ul>
Your Menu
</ul>
<?php } else { ?>
<ul>
Another Menu (or put nothing here)
</ul>
<?php } ?>
```
If you don't know how to locate the post ID:
"Roll over any page, post or ... |
92,488 | <p>The users of my site mainly share documents by inserting links into content (pages/posts) using the built in editor. These files include everything from pdfs to word documents. The users currently get/copy these links from a php file manager like FileRun. My goal is to have the users instead use a path from mapped n... | [
{
"answer_id": 92478,
"author": "RevCocnept",
"author_id": 18388,
"author_profile": "https://wordpress.stackexchange.com/users/18388",
"pm_score": 1,
"selected": false,
"text": "<p>Your question is a little unclear...I think what you're trying to ask is how to display the parent content ... | 2013/03/26 | [
"https://wordpress.stackexchange.com/questions/92488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29558/"
] | The users of my site mainly share documents by inserting links into content (pages/posts) using the built in editor. These files include everything from pdfs to word documents. The users currently get/copy these links from a php file manager like FileRun. My goal is to have the users instead use a path from mapped netw... | You could setup a condition based on post ID:
```
<?php if (is_page(12) || $post->post_parent=="12") { ?>
<ul>
Your Menu
</ul>
<?php } else { ?>
<ul>
Another Menu (or put nothing here)
</ul>
<?php } ?>
```
If you don't know how to locate the post ID:
"Roll over any page, post or ... |
92,504 | <p>Here's the code I'm using to create yearly archives for a custom post type:</p>
<pre><code>function myquery_custom_post_rewrite( $rewrite_rules ) {
$myqueryslug = 'customposttype';
$month_archive = array( $myqueryslug . '/([0-9]{4})/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&post_type='... | [
{
"answer_id": 92478,
"author": "RevCocnept",
"author_id": 18388,
"author_profile": "https://wordpress.stackexchange.com/users/18388",
"pm_score": 1,
"selected": false,
"text": "<p>Your question is a little unclear...I think what you're trying to ask is how to display the parent content ... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/92504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4702/"
] | Here's the code I'm using to create yearly archives for a custom post type:
```
function myquery_custom_post_rewrite( $rewrite_rules ) {
$myqueryslug = 'customposttype';
$month_archive = array( $myqueryslug . '/([0-9]{4})/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&post_type=' . $myqueryslug . '&page... | You could setup a condition based on post ID:
```
<?php if (is_page(12) || $post->post_parent=="12") { ?>
<ul>
Your Menu
</ul>
<?php } else { ?>
<ul>
Another Menu (or put nothing here)
</ul>
<?php } ?>
```
If you don't know how to locate the post ID:
"Roll over any page, post or ... |
92,515 | <p>I'm currently running a Wordpress blog. It's part of a school blog, so unfortunately, I don't have the permissions to install any plugins. I've got a "contact form" set up as a Google Docs form. Right now, I have a page linking to the form. Is there any way that I can embed it directly in the page without having to ... | [
{
"answer_id": 92519,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>No, that's not possible. You can find a list of providers for embeddable coontent in <code>wp-includes/class-oembed.php... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/92515",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29569/"
] | I'm currently running a Wordpress blog. It's part of a school blog, so unfortunately, I don't have the permissions to install any plugins. I've got a "contact form" set up as a Google Docs form. Right now, I have a page linking to the form. Is there any way that I can embed it directly in the page without having to ins... | No, that's not possible. You can find a list of providers for embeddable coontent in `wp-includes/class-oembed.php`:
```
'#https?://(www\.)?youtube.com/watch.*#i'
'http://youtu.be/*'
'http://blip.tv/*'
'#https?://(www\.)?vimeo\.com/.*#i' ... |
92,540 | <p>I want to show the posts under a category in my page.The first 5 posts should be shown when the page loads and When the user clicks the next button/link next 5 posts should be shown. Currently I show all posts under the category.The following is the template I use to show all the posts under that category.I know I n... | [
{
"answer_id": 94121,
"author": "togh_j",
"author_id": 28029,
"author_profile": "https://wordpress.stackexchange.com/users/28029",
"pm_score": -1,
"selected": false,
"text": "<p>You need to use css and jquery to create the slider effect you want to. I don't think you need ajax, since the... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/92540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28044/"
] | I want to show the posts under a category in my page.The first 5 posts should be shown when the page loads and When the user clicks the next button/link next 5 posts should be shown. Currently I show all posts under the category.The following is the template I use to show all the posts under that category.I know I need... | You can use carousel javascript to get the desired output. There are various carousel available, you can use some thing like [jcarousel](http://sorgalla.com/projects/jcarousel).
Download the js and css from the [jcarousel](http://sorgalla.com/projects/jcarousel) website and en-queue it in your theme to use it.
Note :... |
92,544 | <p>I'm displaying two posts on my main page, and using post pagination to go through the older posts. </p>
<p>My problem is I want to change the layout a bit of the most recent post. This sounds like a very basic question, and I have seen a lot of answers, but they only solve the problem for the first post on the page... | [
{
"answer_id": 94121,
"author": "togh_j",
"author_id": 28029,
"author_profile": "https://wordpress.stackexchange.com/users/28029",
"pm_score": -1,
"selected": false,
"text": "<p>You need to use css and jquery to create the slider effect you want to. I don't think you need ajax, since the... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/92544",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29208/"
] | I'm displaying two posts on my main page, and using post pagination to go through the older posts.
My problem is I want to change the layout a bit of the most recent post. This sounds like a very basic question, and I have seen a lot of answers, but they only solve the problem for the first post on the page, not the ... | You can use carousel javascript to get the desired output. There are various carousel available, you can use some thing like [jcarousel](http://sorgalla.com/projects/jcarousel).
Download the js and css from the [jcarousel](http://sorgalla.com/projects/jcarousel) website and en-queue it in your theme to use it.
Note :... |
92,560 | <p>Below is a small tutorial of translation from English To German. (You can change the it as your needs).</p>
<p>in any plugin file, it has unique name in its header.</p>
<pre><code>/*
Plugin Name: SampleTut
.......
*/
</code></pre>
<p>in that plugin folder, make a folder (named "languages");</p>
<p>into your plug... | [
{
"answer_id": 93608,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Do not create a PO file manually. The synchronization must be automatic, or you will waste much time. Each you change ... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/92560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33667/"
] | Below is a small tutorial of translation from English To German. (You can change the it as your needs).
in any plugin file, it has unique name in its header.
```
/*
Plugin Name: SampleTut
.......
*/
```
in that plugin folder, make a folder (named "languages");
into your plugin .php file (somewhere in top), insert ... | Do not create a PO file manually. The synchronization must be automatic, or you will waste much time. Each you change a string, you have to change it in two files now.
[Poedit](http://www.poedit.net/) has a built-in PHP parser. Use it to read your project files.
</code> to execute a single event that sends me an e-mail 8 minutes after the user submits a form.</p>
<h2>The issue</h2>
<p>The following code is in my <code>functions.php</code>:</p>
<pre><code>function nkapi_send_to_system( $args ) {
wp_mail( ... | [
{
"answer_id": 94573,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 4,
"selected": false,
"text": "<p>Firstly, define your custom cron job schedules.</p>\n\n<p><code>add_filter('cron_schedules', array($this... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/93570",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24806/"
] | The goal
--------
I want to use `wp_schedule_single_event( )` to execute a single event that sends me an e-mail 8 minutes after the user submits a form.
The issue
---------
The following code is in my `functions.php`:
```
function nkapi_send_to_system( $args ) {
wp_mail( 'xxx', 'xxx', $args );
}
add_action( 'nka... | First can you please confirm that you don't have any caching plugins enabled? Caching plugins can interfere with cron jobs because your visitors are not served a live page but a cached version of your page.
If you have a caching plugin enabled, you can choose one of your pages, add an exclussion to your caching plugin... |
93,571 | <p>We all know about the default WordPress post types, these being aside, gallery, status, chat and so on. any good theme should support all of them.</p>
<p>In the case where a theme does support all of them, is it best, from a clean programming standard to do if, elseif, else if, else or should I use a switch case wh... | [
{
"answer_id": 94573,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 4,
"selected": false,
"text": "<p>Firstly, define your custom cron job schedules.</p>\n\n<p><code>add_filter('cron_schedules', array($this... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/93571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27670/"
] | We all know about the default WordPress post types, these being aside, gallery, status, chat and so on. any good theme should support all of them.
In the case where a theme does support all of them, is it best, from a clean programming standard to do if, elseif, else if, else or should I use a switch case when checkin... | First can you please confirm that you don't have any caching plugins enabled? Caching plugins can interfere with cron jobs because your visitors are not served a live page but a cached version of your page.
If you have a caching plugin enabled, you can choose one of your pages, add an exclussion to your caching plugin... |
93,577 | <p>I am attempting to post some java code between pre tags but the angel brackets get removed. For example:</p>
<pre><code>private HashMap<String, HashMap<String, Integer>> featureCounts;
</code></pre>
<p>becomes</p>
<pre><code>private HashMap> featureCounts;
</code></pre>
<p>Is there a way I can re... | [
{
"answer_id": 94573,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 4,
"selected": false,
"text": "<p>Firstly, define your custom cron job schedules.</p>\n\n<p><code>add_filter('cron_schedules', array($this... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/93577",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30591/"
] | I am attempting to post some java code between pre tags but the angel brackets get removed. For example:
```
private HashMap<String, HashMap<String, Integer>> featureCounts;
```
becomes
```
private HashMap> featureCounts;
```
Is there a way I can render the actual code? Also I am not a php developer or a wordpres... | First can you please confirm that you don't have any caching plugins enabled? Caching plugins can interfere with cron jobs because your visitors are not served a live page but a cached version of your page.
If you have a caching plugin enabled, you can choose one of your pages, add an exclussion to your caching plugin... |
93,605 | <p>IN my Wordpress blog, I am looking to update a link in header that I believe is outdated:</p>
<p><code><script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?ver=3.5.1'></script></code></p>
<p>How do I get to this link? What file is it in? In my header.php fil... | [
{
"answer_id": 93609,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>If done right there should be a callback hooked to <a href=\"http://codex.wordpress.org/Plugin_API/Action_Refe... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/93605",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30599/"
] | IN my Wordpress blog, I am looking to update a link in header that I believe is outdated:
`<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?ver=3.5.1'></script>`
How do I get to this link? What file is it in? In my header.php file, I see `wp_head()` -- I track that down ... | If done right there should be a callback hooked to [`wp_enqueue_scripts`](http://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts) which has either [`wp_enqueue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) or both [`wp_register_script`](http://codex.wordpress.org/Function_... |
93,627 | <p>I'm using <code>wp_list_categories();</code> to show a list of all the terms within a custom taxonomy but I need to style list items that have children differently to those that don't.</p>
<p>Is there a way, PHP or jQuery, that I can give all parent elements a special class?</p>
| [
{
"answer_id": 93645,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<h2>jQuery solution:</h2>\n\n<p>You could try this if you want to use jQuery:</p>\n\n<pre><code><script>\njQ... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/93627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18547/"
] | I'm using `wp_list_categories();` to show a list of all the terms within a custom taxonomy but I need to style list items that have children differently to those that don't.
Is there a way, PHP or jQuery, that I can give all parent elements a special class? | jQuery solution:
----------------
You could try this if you want to use jQuery:
```
<script>
jQuery(document).ready(function($) {
$('li.cat-item:has(ul.children)').addClass('i-have-kids');
});
</script>
```
to add the class `i-have-kids` to all the `li` parents that include the items `ul.children`, within the ... |
93,630 | <p>Is there anyway to get the password string from the login form?</p>
| [
{
"answer_id": 93633,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Look at the form markup:</p>\n\n<pre><code><input type=\"password\" name=\"pwd\" id=\"user_pass\" class=\"input\" v... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/93630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28744/"
] | Is there anyway to get the password string from the login form? | this should do the job, just add it to `functions.php` or put in a plugin:
```
add_filter( 'wp_authenticate_user', 'my_authenticate_user', 10, 2 );
function my_authenticate_user( $user, $password ) {
// do whatever you want with the $password variable here
return $user;
}
``` |
93,638 | <p>I have a menu that has the following link in it to my homepage:</p>
<pre><code><ul id="css3menu1" class="topmenu">
<li class="topmenu"><a href="<?php bloginfo('template_url'); ?>/homepage.php" target="_top" title="Home" style="height:20px;line-height:20px;">Home</a></li>
</code><... | [
{
"answer_id": 93639,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>Replace</p>\n\n<pre><code><a href=\"<?php bloginfo('template_url'); ?>\n</code></pre>\n\n<p>with</p>... | 2013/03/27 | [
"https://wordpress.stackexchange.com/questions/93638",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30613/"
] | I have a menu that has the following link in it to my homepage:
```
<ul id="css3menu1" class="topmenu">
<li class="topmenu"><a href="<?php bloginfo('template_url'); ?>/homepage.php" target="_top" title="Home" style="height:20px;line-height:20px;">Home</a></li>
```
When I click on the menu link it takes to the homepa... | The problem is not that the PHP doesn't execute. It does execute but you get fatal errors because you are loading your template files directly, which means they are loading without the WordPress framework that supplies necessary functions. View source of those pages and you can see error.
You should not be linking dir... |
93,669 | <p>The codex lists both <strong>create_users</strong> and <strong>add_users</strong> under <a href="http://codex.wordpress.org/Roles_and_Capabilities" rel="nofollow">roles and capabilities</a>.</p>
<p>Does anyone know what is the difference between these two?</p>
| [
{
"answer_id": 93674,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 4,
"selected": true,
"text": "<p>I explored WordPress to find difference between it and in schema.php file i found the following function on... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24579/"
] | The codex lists both **create\_users** and **add\_users** under [roles and capabilities](http://codex.wordpress.org/Roles_and_Capabilities).
Does anyone know what is the difference between these two? | I explored WordPress to find difference between it and in schema.php file i found the following function only where in WordPress add\_users capability is used.
```
/**
* Create and modify WordPress roles for WordPress 3.0.
*
* @since 3.0.0
*/
function populate_roles_300() {
$role =& get_role( 'administrator' );
i... |
93,672 | <p>I develope a filter for posts so that when any user come to my site they can filter the posts on the base of <code>cities/state</code>.
So when i store the posts i just store the cities name as a <code>post-meta</code> tag in the site. The code i am using for adding the <code>post-meta</code> tag is</p>
<pre><code>... | [
{
"answer_id": 93674,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 4,
"selected": true,
"text": "<p>I explored WordPress to find difference between it and in schema.php file i found the following function on... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27912/"
] | I develope a filter for posts so that when any user come to my site they can filter the posts on the base of `cities/state`.
So when i store the posts i just store the cities name as a `post-meta` tag in the site. The code i am using for adding the `post-meta` tag is
```
add_post_meta($post_id, 'post_state' , $state, ... | I explored WordPress to find difference between it and in schema.php file i found the following function only where in WordPress add\_users capability is used.
```
/**
* Create and modify WordPress roles for WordPress 3.0.
*
* @since 3.0.0
*/
function populate_roles_300() {
$role =& get_role( 'administrator' );
i... |
93,683 | <p>I have a contact form built with Contact Form 7. What I want to do is when the user hits the submit button to throw up a pop up window with a notice asking if their sure they want to submit the form with an ok or cancel button. I've found the hook 'wpcf7_before_send_mail'. I was hoping there might be something i cou... | [
{
"answer_id": 93674,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 4,
"selected": true,
"text": "<p>I explored WordPress to find difference between it and in schema.php file i found the following function on... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18219/"
] | I have a contact form built with Contact Form 7. What I want to do is when the user hits the submit button to throw up a pop up window with a notice asking if their sure they want to submit the form with an ok or cancel button. I've found the hook 'wpcf7\_before\_send\_mail'. I was hoping there might be something i cou... | I explored WordPress to find difference between it and in schema.php file i found the following function only where in WordPress add\_users capability is used.
```
/**
* Create and modify WordPress roles for WordPress 3.0.
*
* @since 3.0.0
*/
function populate_roles_300() {
$role =& get_role( 'administrator' );
i... |
93,698 | <p>I wanted a code in Wordpress that could allow me to republish the post every time I add a new custom field.
For example, if I already have a post and wanted to add an update to it; I want it to appear at the top of the site after updating it.</p>
<p>Is that possible ?</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 93674,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 4,
"selected": true,
"text": "<p>I explored WordPress to find difference between it and in schema.php file i found the following function on... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93698",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23774/"
] | I wanted a code in Wordpress that could allow me to republish the post every time I add a new custom field.
For example, if I already have a post and wanted to add an update to it; I want it to appear at the top of the site after updating it.
Is that possible ?
Thanks in advance | I explored WordPress to find difference between it and in schema.php file i found the following function only where in WordPress add\_users capability is used.
```
/**
* Create and modify WordPress roles for WordPress 3.0.
*
* @since 3.0.0
*/
function populate_roles_300() {
$role =& get_role( 'administrator' );
i... |
93,709 | <p>I am using fornt end form submission now i want to add new category and before adding this category i want to check whether it exist or not, if yes then simple add to that category otherwise add new one. So the in codex they said if you have to add catogory just use the </p>
<pre><code>wp_set_post_terms();
</code><... | [
{
"answer_id": 93713,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": 2,
"selected": false,
"text": "<pre><code>$id = wp_create_category('My category name');\n</code></pre>\n\n<p>By above function category created &... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27912/"
] | I am using fornt end form submission now i want to add new category and before adding this category i want to check whether it exist or not, if yes then simple add to that category otherwise add new one. So the in codex they said if you have to add catogory just use the
```
wp_set_post_terms();
```
and there is one... | ```
$id = wp_create_category('My category name');
```
By above function category created & categary id is returned.
If the category already exists, it is not duplicated. The ID of the original existing category is returned without error.
You can use `$id` as category id.
Reference
---------
<http://codex.wordpres... |
93,732 | <p>Previously, I used the <code>get_option()</code> function to get an option in PHP, like this:</p>
<pre><code>$width = get_option('my_width');
</code></pre>
<p>This is inside a shortcode function.</p>
<p>Now, I want to have an option in JavaScript. Is that possible? </p>
<p>The JS is added with <code>wp_enqueue_s... | [
{
"answer_id": 93734,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 5,
"selected": true,
"text": "<p>Define an array of parameters to be injected into the script:</p>\n\n<pre><code>$script_params = array(\n ... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Previously, I used the `get_option()` function to get an option in PHP, like this:
```
$width = get_option('my_width');
```
This is inside a shortcode function.
Now, I want to have an option in JavaScript. Is that possible?
The JS is added with `wp_enqueue_script`, from a shortcode function. | Define an array of parameters to be injected into the script:
```
$script_params = array(
'myWidth' => get_option('my_width')
);
```
Localize the script via [`wp_localize_script`](http://codex.wordpress.org/Function_Reference/wp_localize_script):
```
wp_localize_script( 'your-script-handle', 'scriptParams', $sc... |
93,737 | <p>I have a Wordpress website that written by third party web developer for version 2.9 before custom taxonomies were fully implemented. We have since upgraded to latest wordpress version 3.5.x. There is a SQL Select query that is generating a bunch of errors in the Wordpress error.log file. </p>
<p>In this templat... | [
{
"answer_id": 93734,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 5,
"selected": true,
"text": "<p>Define an array of parameters to be injected into the script:</p>\n\n<pre><code>$script_params = array(\n ... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93737",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30636/"
] | I have a Wordpress website that written by third party web developer for version 2.9 before custom taxonomies were fully implemented. We have since upgraded to latest wordpress version 3.5.x. There is a SQL Select query that is generating a bunch of errors in the Wordpress error.log file.
In this template, we have a ... | Define an array of parameters to be injected into the script:
```
$script_params = array(
'myWidth' => get_option('my_width')
);
```
Localize the script via [`wp_localize_script`](http://codex.wordpress.org/Function_Reference/wp_localize_script):
```
wp_localize_script( 'your-script-handle', 'scriptParams', $sc... |
93,750 | <p>I need to tell whether or not the current custom taxonomy archive page I'm viewing has child categories. I've got a situation where there are a lot of custom categories with children and the site is only to show posts at the end of the line. Otherwise it should show a link to the category that's the next step down. ... | [
{
"answer_id": 93756,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 5,
"selected": true,
"text": "<p>There may or may not be a better way to do this, but here's how I would do it:</p>\n\n<pre><code>$term = get_... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93750",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29489/"
] | I need to tell whether or not the current custom taxonomy archive page I'm viewing has child categories. I've got a situation where there are a lot of custom categories with children and the site is only to show posts at the end of the line. Otherwise it should show a link to the category that's the next step down. I'v... | There may or may not be a better way to do this, but here's how I would do it:
```
$term = get_queried_object();
$children = get_terms( $term->taxonomy, array(
'parent' => $term->term_id,
'hide_empty' => false
) );
// print_r($children); // uncomment to examine for debugging
if($children) { // get_terms will retur... |
93,777 | <p>I'm trying to get my head around a fairly simple concept in PHP but I'm pretty green. </p>
<p>I have a function..</p>
<pre><code>function pa_insertPage($atts, $content = null) {
// Default output if no pageid given
$output = NULL;
// extract atts and assign to array
extract(shortcode_atts(array("pa... | [
{
"answer_id": 93776,
"author": "Jamie",
"author_id": 14761,
"author_profile": "https://wordpress.stackexchange.com/users/14761",
"pm_score": 1,
"selected": false,
"text": "<p>I think a lot of theme development is getting away from using add_image_size because WordPress makes way to many... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30653/"
] | I'm trying to get my head around a fairly simple concept in PHP but I'm pretty green.
I have a function..
```
function pa_insertPage($atts, $content = null) {
// Default output if no pageid given
$output = NULL;
// extract atts and assign to array
extract(shortcode_atts(array("page" => '2404' // Valu... | If you pass `true` for the last `$crop` argument then so called "hard" crop mode is used. This will make WP produce results at exact size specified, except few edge cases (if image uploaded is smaller than specified size for example).
Note that *original* image is still retained as is. If you need to actually modify o... |
93,795 | <p>What is the cleanest way to display a text message beside the submit button like this in screen shot:</p>
<p><img src="https://i.stack.imgur.com/ybV6Y.png" alt="example of what I am talking about"></p>
<p>I am currently doing it by editing the file <code>wp-includes/comment-template</code> line <code>1577</code> (... | [
{
"answer_id": 93801,
"author": "seravifer9",
"author_id": 30656,
"author_profile": "https://wordpress.stackexchange.com/users/30656",
"pm_score": 1,
"selected": false,
"text": "<p>You can add the text from the file comments.php</p>\n\n<pre><code> <?php\n // Do not delete these ... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93795",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27148/"
] | What is the cleanest way to display a text message beside the submit button like this in screen shot:

I am currently doing it by editing the file `wp-includes/comment-template` line `1577` (wordpress 3.5)
before:
```
<input name="submit" typ... | You should **not** edit the Wordpress core files!
If you have `comment_id_fields()` in your comments template, like this:
```
<p class="form-submit">
<input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>"
value="<?php e... |