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 |
|---|---|---|---|---|---|---|
103,214 | <p>We have our own php system, now we want to have a blog function. Because wordpress are widely used, so we decided to use it. And now I want to invoke wordpress's function , for example <code>wp_insert_user</code> , how can I can do that ?</p>
<p>Suppose my system is <code>A</code> and installed on <code>/var/www/A<... | [
{
"answer_id": 103215,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>You can add the following snippet at the start of your PHP file to load WordPress in it.</p>\n\n<pre><code>def... | 2013/06/17 | [
"https://wordpress.stackexchange.com/questions/103214",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34196/"
] | We have our own php system, now we want to have a blog function. Because wordpress are widely used, so we decided to use it. And now I want to invoke wordpress's function , for example `wp_insert_user` , how can I can do that ?
Suppose my system is `A` and installed on `/var/www/A`, and wordpress is `WP` and installed... | You can add the following snippet at the start of your PHP file to load WordPress in it.
```
define( 'WP_USE_THEMES', false );
require('wp-blog-header.php'); // chage the path to match your WP directory
//the rest of your code here
```
**EDIT:**
Alternatively, you could use `wp-load.php` instead of `wp-blog-header.p... |
103,235 | <p>I have custom post types and would like to display the different results based upon a users search meta.</p>
<p>I have three custom post types that are styled differently and want to return the search results based upon their respective styles, not the generic page link and excerpt that it currently shows. could I ... | [
{
"answer_id": 103230,
"author": "Eckstein",
"author_id": 23492,
"author_profile": "https://wordpress.stackexchange.com/users/23492",
"pm_score": 1,
"selected": false,
"text": "<p>If you go to Settings->Permalinks you should be able to set the tag/category base URL rules which should sol... | 2013/06/17 | [
"https://wordpress.stackexchange.com/questions/103235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27569/"
] | I have custom post types and would like to display the different results based upon a users search meta.
I have three custom post types that are styled differently and want to return the search results based upon their respective styles, not the generic page link and excerpt that it currently shows. could I use is\_se... | If you go to Settings->Permalinks you should be able to set the tag/category base URL rules which should solve this problem.
Or, use some sort of plugin to do what you want. This one came up first on Google: <http://wordpress.org/plugins/custom-permalinks/> |
103,242 | <p>I am trying to create a query in order to get all the metadata from a custom post type named match_reports that is associated with a meta_key and meta_value in another custom post type named team_page. The common denominator is the id of team_page which is a meta_value in match_reports. Therefore each team has match... | [
{
"answer_id": 103230,
"author": "Eckstein",
"author_id": 23492,
"author_profile": "https://wordpress.stackexchange.com/users/23492",
"pm_score": 1,
"selected": false,
"text": "<p>If you go to Settings->Permalinks you should be able to set the tag/category base URL rules which should sol... | 2013/06/17 | [
"https://wordpress.stackexchange.com/questions/103242",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34045/"
] | I am trying to create a query in order to get all the metadata from a custom post type named match\_reports that is associated with a meta\_key and meta\_value in another custom post type named team\_page. The common denominator is the id of team\_page which is a meta\_value in match\_reports. Therefore each team has m... | If you go to Settings->Permalinks you should be able to set the tag/category base URL rules which should solve this problem.
Or, use some sort of plugin to do what you want. This one came up first on Google: <http://wordpress.org/plugins/custom-permalinks/> |
103,264 | <p>I want to output all sub-pages of a particular page in a neat <code>ul li</code> list. Including: featured image, title, and first 50 characters of page content.</p>
<p>I'm very new to Wordpress, I've tried reading through the codex and I seem to have found something but I cannot get it to work.</p>
<p>First, I ha... | [
{
"answer_id": 103268,
"author": "jounileander",
"author_id": 32914,
"author_profile": "https://wordpress.stackexchange.com/users/32914",
"pm_score": 1,
"selected": false,
"text": "<p>You can use for example very basic WP Query (or get_pages or what ever. this is just one example) (<a hr... | 2013/06/17 | [
"https://wordpress.stackexchange.com/questions/103264",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34215/"
] | I want to output all sub-pages of a particular page in a neat `ul li` list. Including: featured image, title, and first 50 characters of page content.
I'm very new to Wordpress, I've tried reading through the codex and I seem to have found something but I cannot get it to work.
First, I have created a new template of... | You can use for example very basic WP Query (or get\_pages or what ever. this is just one example) (<http://codex.wordpress.org/Class_Reference/WP_Query>)
```
// The Query
$currentPageId = $post->ID; // get current page id inside loop
$args = array(
'post_parent' => $currentPageId,
'post_type' => 'page',
... |
103,272 | <p>Currently I have a custom post type and I would like to have some different version of it based on user input - so for example when creating a post the user can select if the post is Featured or Free and then there would be an if-else statement that would display different image if Featured and different if Free in ... | [
{
"answer_id": 103268,
"author": "jounileander",
"author_id": 32914,
"author_profile": "https://wordpress.stackexchange.com/users/32914",
"pm_score": 1,
"selected": false,
"text": "<p>You can use for example very basic WP Query (or get_pages or what ever. this is just one example) (<a hr... | 2013/06/17 | [
"https://wordpress.stackexchange.com/questions/103272",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34216/"
] | Currently I have a custom post type and I would like to have some different version of it based on user input - so for example when creating a post the user can select if the post is Featured or Free and then there would be an if-else statement that would display different image if Featured and different if Free in the... | You can use for example very basic WP Query (or get\_pages or what ever. this is just one example) (<http://codex.wordpress.org/Class_Reference/WP_Query>)
```
// The Query
$currentPageId = $post->ID; // get current page id inside loop
$args = array(
'post_parent' => $currentPageId,
'post_type' => 'page',
... |
103,321 | <p>I have website, Administrator setup one post for each register user, only this user can see it when he/she login.(the author of the post is the user's name). I think when user login just search user name equal to author name will be fine.</p>
<p>The question is how to do it, I don't know too much about PHP, Hard to... | [
{
"answer_id": 103323,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 2,
"selected": false,
"text": "<p>You can get the current user ID with <a href=\"http://codex.wordpress.org/Function_Reference/get_current_... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103321",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31425/"
] | I have website, Administrator setup one post for each register user, only this user can see it when he/she login.(the author of the post is the user's name). I think when user login just search user name equal to author name will be fine.
The question is how to do it, I don't know too much about PHP, Hard to make it w... | You can get the current user ID with [`get_current_user_id( )`](http://codex.wordpress.org/Function_Reference/get_current_user_id):
```
$user_id = get_current_user_id( );
```
The user ID can be used to get the userdata with [`get_userdata( )`](http://codex.wordpress.org/Function_Reference/get_userdata):
```
$user_d... |
103,325 | <p>I can't figure out why Jquery isn't working on my Wordpress site. Am I setting it up right? Any help or suggestions is appreciated! Thanks. </p>
<p>Here is what I have in my function.php</p>
<pre><code> function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'ajax.... | [
{
"answer_id": 103328,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>Check the jquery url in your code it is without http:// protocol which is wrong, it should be with http:/... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103325",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34234/"
] | I can't figure out why Jquery isn't working on my Wordpress site. Am I setting it up right? Any help or suggestions is appreciated! Thanks.
Here is what I have in my function.php
```
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'ajax.googleapis.com/ajax/li... | I don't think you have to register jquery. I just put this in my functions.php:
```
function my_scripts_method() {
wp_enqueue_script(
'main',
get_template_directory_uri() . '/js/main.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
```
It includes my custom scripts th... |
103,331 | <p>I have a search page that is the code below, it returns different post types based upon a user search, Is there a way I can add the following title to each post type that is found - everything I've tried only adds it to every item (I'm guessing its the loop).</p>
<h1> Custom post type 1 results - title 1 that I nee... | [
{
"answer_id": 103328,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>Check the jquery url in your code it is without http:// protocol which is wrong, it should be with http:/... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27569/"
] | I have a search page that is the code below, it returns different post types based upon a user search, Is there a way I can add the following title to each post type that is found - everything I've tried only adds it to every item (I'm guessing its the loop).
Custom post type 1 results - title 1 that I need to add
==... | I don't think you have to register jquery. I just put this in my functions.php:
```
function my_scripts_method() {
wp_enqueue_script(
'main',
get_template_directory_uri() . '/js/main.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
```
It includes my custom scripts th... |
103,340 | <p>In a Wordpress 3.5.1 the apache log generates the following error related to wp-cron.php:</p>
<blockquote>
<p>[18/Jun/2013:10:53:21 +0200] "POST /wp-cron.php?doing_wp_cron=1371545601.7393701076507568359375 HTTP/1.0"
200 211 "-" "WordPress/3.5.1; <a href="http://www.foo.com" rel="nofollow">http://www.foo.com</a>... | [
{
"answer_id": 103342,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 4,
"selected": true,
"text": "<p><code>wp_cron</code> is used to schedule tasks such as deleting old posts from trash, deleting old spa... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33381/"
] | In a Wordpress 3.5.1 the apache log generates the following error related to wp-cron.php:
>
> [18/Jun/2013:10:53:21 +0200] "POST /wp-cron.php?doing\_wp\_cron=1371545601.7393701076507568359375 HTTP/1.0"
> 200 211 "-" "WordPress/3.5.1; <http://www.foo.com>"
> [18/Jun/2013:10:54:36 +0200] "POST /wp-cron.php?doing\_wp\... | `wp_cron` is used to schedule tasks such as deleting old posts from trash, deleting old spam comments, and checking for plugin/theme updates. |
103,347 | <p>I have this nice little function to remove buttons from the tinyMCE editor in WordPress, so far I've been able to remove most of the ones I need to.</p>
<pre><code>function custom_disable_mce_buttons( $opt ) {
$opt['theme_advanced_disable'] = 'justifyfull,forecolor,removeformat,justifycenter,justifyright,justif... | [
{
"answer_id": 103356,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": false,
"text": "<p>You can try to remove the <em>Spellchecker</em> and the <em>Insert More Tag</em> buttons by adding:</p>\n\n<p... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22450/"
] | I have this nice little function to remove buttons from the tinyMCE editor in WordPress, so far I've been able to remove most of the ones I need to.
```
function custom_disable_mce_buttons( $opt ) {
$opt['theme_advanced_disable'] = 'justifyfull,forecolor,removeformat,justifycenter,justifyright,justifyleft,charmap,... | `wp_more` - insert more button,
`spellchecker` - spellchecker button
I've tried it with your code on WP 3.5.1 and it worked fine for me. |
103,368 | <p>I'm aware there are several other posts that cover similar ground to what I'm about to ask.</p>
<p>I have three custom post types running, in addition to 'posts'. I want to run a loop that pulls all posts categorised under a particular category</p>
<pre><code> <?php
$args = array(
'post_type' =>... | [
{
"answer_id": 103369,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 5,
"selected": false,
"text": "<p>Just change the <code>post_type</code> bit to:</p>\n\n<p><code>'post_type' => array('testimonial', 'oth... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34257/"
] | I'm aware there are several other posts that cover similar ground to what I'm about to ask.
I have three custom post types running, in addition to 'posts'. I want to run a loop that pulls all posts categorised under a particular category
```
<?php
$args = array(
'post_type' => 'testimonial',
'posts... | Just change the `post_type` bit to:
`'post_type' => array('testimonial', 'other_post_type', 'another-post-type'),`
Assuming that taxonomy is valid across all 3 post types. Otherwise you'll have to leave that out.
*Why?* You can pass an array to `post_type` field. |
103,398 | <p>Thanks to <a href="https://wordpress.stackexchange.com/questions/103379/get-post-terms-not-working-as-expected#103386">GhostToast for helping me on my way with this post</a>.</p>
<p>Now I am successfully able to echo out all of the taxonomy associated terms dynamically.
However, this unfortunately also seems to spi... | [
{
"answer_id": 103369,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 5,
"selected": false,
"text": "<p>Just change the <code>post_type</code> bit to:</p>\n\n<p><code>'post_type' => array('testimonial', 'oth... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103398",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12651/"
] | Thanks to [GhostToast for helping me on my way with this post](https://wordpress.stackexchange.com/questions/103379/get-post-terms-not-working-as-expected#103386).
Now I am successfully able to echo out all of the taxonomy associated terms dynamically.
However, this unfortunately also seems to spit out all the site's ... | Just change the `post_type` bit to:
`'post_type' => array('testimonial', 'other_post_type', 'another-post-type'),`
Assuming that taxonomy is valid across all 3 post types. Otherwise you'll have to leave that out.
*Why?* You can pass an array to `post_type` field. |
103,408 | <pre><code><?php
if (is_single()) {
echo '1';
} elseif ( is_page() ) {
echo '2';
} else {
echo '3';
}
?>
</code></pre>
<p>I put this snippet at the top of index.php, which is what I'm using to govern the layout of my blog post feeds. I then created a new page, set template to default, and left it ... | [
{
"answer_id": 103410,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Conditional tags mostly derive from and rely on main query. </p>\n\n<ul>\n<li><code>is_page()</code> <em>function</... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103408",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34092/"
] | ```
<?php
if (is_single()) {
echo '1';
} elseif ( is_page() ) {
echo '2';
} else {
echo '3';
}
?>
```
I put this snippet at the top of index.php, which is what I'm using to govern the layout of my blog post feeds. I then created a new page, set template to default, and left it blank. It shows all of my... | Conditional tags mostly derive from and rely on main query.
* `is_page()` *function* calls
+ `$wp_query->is_page()` *method*
- which checks `$wp_query->is_page` *property* (set during load) and some more stuff if you asked to check for specific page.
So the likely reason for conditional tag not to produce expecte... |
103,425 | <p>Im really struggling to piece this functionality together, and hope someone can help or provide snippets to get me there.</p>
<p>So I'm creating a section on a website where stories are published, I have created a custom post type for the stories section and taxonomies for the story types (category) and story tags ... | [
{
"answer_id": 103463,
"author": "Mike F",
"author_id": 34285,
"author_profile": "https://wordpress.stackexchange.com/users/34285",
"pm_score": 1,
"selected": false,
"text": "<p>I would take a look at this page on the Codex:</p>\n\n<p><a href=\"http://codex.wordpress.org/Class_Reference/... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103425",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17628/"
] | Im really struggling to piece this functionality together, and hope someone can help or provide snippets to get me there.
So I'm creating a section on a website where stories are published, I have created a custom post type for the stories section and taxonomies for the story types (category) and story tags (the tags)... | I would take a look at this page on the Codex:
<http://codex.wordpress.org/Class_Reference/WP_Query>
I think you need to override your query\_posts() for your landing page, and controlling different queries with if() statements, depending on what areas of a form (guessing you're using a form?) has filled in. For exam... |
103,433 | <p>I have a site with a custom home page, home.php. What's the right way to present the editable home page options in the admin tool?</p>
<p>For example, there's a few custom text fields on the home page that should be editable in the admin tool. I'm looking for the best way to set this up so an admin user can change ... | [
{
"answer_id": 103437,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>It is hard to tell from your question exactly what you are doing but if you are using the <a href=\"http://c... | 2013/06/18 | [
"https://wordpress.stackexchange.com/questions/103433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13981/"
] | I have a site with a custom home page, home.php. What's the right way to present the editable home page options in the admin tool?
For example, there's a few custom text fields on the home page that should be editable in the admin tool. I'm looking for the best way to set this up so an admin user can change these opti... | There are many solutions to this problem. And every one of them is correct, I guess. It depends on what you really want and what will be most friendly/clear to user/administrator of this page.
I usually use 3 ways to solve this. Which one of them I chose? It depends on situation. Sometimes I use 2 of them simultaneous... |
103,453 | <p>I'm new to WordPress theme development and I'm trying to figure out if there is a way to display a list of public attachments similar to how you can view a list of posts with a specific tag or author.</p>
<p>That is, if I want to retrieve a list of posts with a specific tag, I can submit something like '?tag=mytag'... | [
{
"answer_id": 103454,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p><code>attachment.php</code> file displays only one attachment (like <code>single.php</code> or <code>... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103453",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34281/"
] | I'm new to WordPress theme development and I'm trying to figure out if there is a way to display a list of public attachments similar to how you can view a list of posts with a specific tag or author.
That is, if I want to retrieve a list of posts with a specific tag, I can submit something like '?tag=mytag' in the UR... | `attachment.php` file displays only one attachment (like `single.php` or `page.php`).
There is no way to list all attachments without coding. WordPress doesn't have such list ready to use.
But it's rather easy to do it by yourself.
Add your custom page template. Assign it to some page. And place something like this ... |
103,460 | <p>I am registering custom taxonomies ....</p>
<pre><code><?php
add_action( 'init', 'create_book_tax' );
function create_book_tax() {
register_taxonomy(
'genre',
'product',
array(
'label' => __( 'Genre' ),
'rewrite' => array( 'slug' => 'genre' ),
... | [
{
"answer_id": 103454,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p><code>attachment.php</code> file displays only one attachment (like <code>single.php</code> or <code>... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103460",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26188/"
] | I am registering custom taxonomies ....
```
<?php
add_action( 'init', 'create_book_tax' );
function create_book_tax() {
register_taxonomy(
'genre',
'product',
array(
'label' => __( 'Genre' ),
'rewrite' => array( 'slug' => 'genre' ),
'hierarchical' => tru... | `attachment.php` file displays only one attachment (like `single.php` or `page.php`).
There is no way to list all attachments without coding. WordPress doesn't have such list ready to use.
But it's rather easy to do it by yourself.
Add your custom page template. Assign it to some page. And place something like this ... |
103,469 | <p>So hey guys,</p>
<p>I'm trying to get my WooCommerce price per unit done.
Some of the items I'm selling are floortiles, and as of such they're sold per square metre.</p>
<p>I have added the following code to display /m2 behind every price</p>
<pre><code>.amount:after{
content: "/m2";
text-size: 13px;
}
<... | [
{
"answer_id": 103539,
"author": "BFTrick",
"author_id": 19620,
"author_profile": "https://wordpress.stackexchange.com/users/19620",
"pm_score": 0,
"selected": false,
"text": "<p>First I'll answer your question the way you were going about it and then I'm going to answer it the way I thi... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34290/"
] | So hey guys,
I'm trying to get my WooCommerce price per unit done.
Some of the items I'm selling are floortiles, and as of such they're sold per square metre.
I have added the following code to display /m2 behind every price
```
.amount:after{
content: "/m2";
text-size: 13px;
}
```
This adds the /m2 after... | **Firstly**, doing this with CSS in my mind absolutely isn't the way to go.
**Secondly**, paying 129$ for an extension to have this minor feature would just be ridiculous - nothing against the plugin per se.
**Thirdly**, below outlined basic solution is based on the [example from the add\_meta\_box](http://codex.word... |
103,477 | <p>I am trying to insert data into wp_post and wp_postmeta tables but it seems like i am doing something wrong.</p>
<p>Here is my code: </p>
<pre><code>$post_data = array(
'post_title' => $data[0],
'post_content' => $data[1],
... | [
{
"answer_id": 103481,
"author": "moyu",
"author_id": 34296,
"author_profile": "https://wordpress.stackexchange.com/users/34296",
"pm_score": 0,
"selected": false,
"text": "<p>you should try like this:</p>\n\n<pre><code>update_post_meta( $id, '_price', true );\n</code></pre>\n"
},
{
... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31366/"
] | I am trying to insert data into wp\_post and wp\_postmeta tables but it seems like i am doing something wrong.
Here is my code:
```
$post_data = array(
'post_title' => $data[0],
'post_content' => $data[1],
'po... | What user34296 said is `update_post_meta()` will update the value of the existing meta key (custom field) for the specified post. If it does not already exist it will call `add_post_meta($post_id, $meta_key, $meta_value)` instead. That's why you should use it.
**EDIT: in this case it should work, error is coming from ... |
103,478 | <p>I have read this post:
<a href="https://wordpress.stackexchange.com/questions/90220/include-and-exclude-taxonomies-from-archives-feeds-using-pre-get-posts">Include and Exclude Taxonomies From Archives & Feeds Using 'pre_get_posts'</a></p>
<p>And then I have used that function to my theme.
My Taxonomy (t... | [
{
"answer_id": 103481,
"author": "moyu",
"author_id": 34296,
"author_profile": "https://wordpress.stackexchange.com/users/34296",
"pm_score": 0,
"selected": false,
"text": "<p>you should try like this:</p>\n\n<pre><code>update_post_meta( $id, '_price', true );\n</code></pre>\n"
},
{
... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24865/"
] | I have read this post:
[Include and Exclude Taxonomies From Archives & Feeds Using 'pre\_get\_posts'](https://wordpress.stackexchange.com/questions/90220/include-and-exclude-taxonomies-from-archives-feeds-using-pre-get-posts)
And then I have used that function to my theme.
My Taxonomy (tinh-trang) had 3 term: 19,20,21... | What user34296 said is `update_post_meta()` will update the value of the existing meta key (custom field) for the specified post. If it does not already exist it will call `add_post_meta($post_id, $meta_key, $meta_value)` instead. That's why you should use it.
**EDIT: in this case it should work, error is coming from ... |
103,479 | <p>I am working on some rather elaborate comparisons between metadata and having a bit of trouble correctly referring to results from my query. The first query to establish <code>$team_is_home</code> works fine but as soon as I try to capture the ID of the posts where the <code>$team_is_home</code>it goes a bit haywire... | [
{
"answer_id": 103480,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>First of all <code>post</code> field of WP_Query is current post ID and not post object. But I don't t... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103479",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34045/"
] | I am working on some rather elaborate comparisons between metadata and having a bit of trouble correctly referring to results from my query. The first query to establish `$team_is_home` works fine but as soon as I try to capture the ID of the posts where the `$team_is_home`it goes a bit haywire and I get warnings sayin... | First of all `post` field of WP\_Query is current post ID and not post object. But I don't think you should use it before calling `the_post()` method.
Normally you should do it in this way:
```
$args = ...
$hometeams = new WP_Query( $args );
$teamishome = $hometeams->have_posts();
while ( $hometeams->have_posts() ) {... |
103,490 | <p>I'm creating custom theme for my personal website using Wordpress 3.5.1. I have problem with the WordPress custom post type and taxonomy, here's the detail:</p>
<ul>
<li>custom post type name: <code>articles</code></li>
<li>taxonomy name: <code>article-categories</code></li>
<li>rewrite slug: <code>articles</code> ... | [
{
"answer_id": 103571,
"author": "ksr89",
"author_id": 31368,
"author_profile": "https://wordpress.stackexchange.com/users/31368",
"pm_score": 1,
"selected": false,
"text": "<p>You can not name <code>custom post_type</code> name and <code>taxonomy slug</code> same because when you work ... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103490",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34300/"
] | I'm creating custom theme for my personal website using Wordpress 3.5.1. I have problem with the WordPress custom post type and taxonomy, here's the detail:
* custom post type name: `articles`
* taxonomy name: `article-categories`
* rewrite slug: `articles` (same with my cpt)
Currently my URL is like this:
* `exampl... | I have used my jewelery post type bellows code, You can just replace your post type & taxonomy. Just copy & paste on your functions file.
```
<?php
//Register a Jewelry post type.
function jewelry_post_register() {
$labels = array(
'name' => _x( 'Jewelries', 'post type general name', 'twenty... |
103,492 | <p>I am new to wordpress, in table <code>wp_usermeta</code> I notice that we have a row </p>
<pre><code>meta_key meta_value
wp_capabilities a:1:{s:13:"administrator";b:1;}
</code></pre>
<p>First, what's the meaning of meta_value <code>a:1:{s:13:"administrator";b:1;}</code> , where can I found the... | [
{
"answer_id": 103493,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p><code>meta_value</code> is column to store value of meta field. Each meta_field contains key and valu... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34196/"
] | I am new to wordpress, in table `wp_usermeta` I notice that we have a row
```
meta_key meta_value
wp_capabilities a:1:{s:13:"administrator";b:1;}
```
First, what's the meaning of meta\_value `a:1:{s:13:"administrator";b:1;}` , where can I found the exactly explanation of this filed ? Or I what ... | The wp\_capabilities saves the value as serilized array, you can try it in your php or for this example here: <http://blog.tanist.co.uk/files/unserialize/>.
The Code:
```
a:1:{s:13:"administrator";b:1;}
```
Is:
```
Array
(
[administrator] => 1
)
```
Meaning the user is an administrator.
You can add new roles... |
103,504 | <p>As in the title, how to programatically change user's login?</p>
<p>I wanted to use <code>wp_insert_user</code> function, but it appears that when updating current user, it doesn't change their username. Should I use <code>$wpdb->update</code> for that? If yes, how would code for changing username look like? Wha... | [
{
"answer_id": 103509,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 6,
"selected": true,
"text": "<p>I was sure that <a href=\"https://developer.wordpress.org/reference/functions/wp_update_user/\" rel=\"... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15865/"
] | As in the title, how to programatically change user's login?
I wanted to use `wp_insert_user` function, but it appears that when updating current user, it doesn't change their username. Should I use `$wpdb->update` for that? If yes, how would code for changing username look like? What consequences would changing user ... | I was sure that [`wp_update_user()`](https://developer.wordpress.org/reference/functions/wp_update_user/) should do this.
It even gets user\_login as param, but it looks like it ignores it, when you set this param.
So this code looks OK, but it doesn't work as you wish it did :( :
```
wp_update_user(
['ID' => $u... |
103,519 | <p>I am using wp_nav_menu and I have a need for custom implementation. The default markup is like this:</p>
<pre><code><ul>
<li id="menu-item-59" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59"><a href="http://j2designpartnership.com/yip/about/">About</a>
... | [
{
"answer_id": 103524,
"author": "JCHASE11",
"author_id": 13727,
"author_profile": "https://wordpress.stackexchange.com/users/13727",
"pm_score": 1,
"selected": false,
"text": "<p>Its in the wp_nav_menu arguments: <code>'items_wrap' => '<ul>%3$s<span></span></ul&... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103519",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13727/"
] | I am using wp\_nav\_menu and I have a need for custom implementation. The default markup is like this:
```
<ul>
<li id="menu-item-59" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59"><a href="http://j2designpartnership.com/yip/about/">About</a>
<ul class="sub-menu" style="displ... | Its in the wp\_nav\_menu arguments: `'items_wrap' => '<ul>%3$s<span></span></ul>'` |
103,522 | <p>I'm having some trouble with my custom ajax function.
I have this on my console log :
"POST MYSITEURL/wp-admin/admin-ajax.php 302 Found". So my functions won't work...</p>
<p>And I really don't understand why.</p>
<p>I've developed a login form for the front end, it works well on my local but not online.
Here is w... | [
{
"answer_id": 103524,
"author": "JCHASE11",
"author_id": 13727,
"author_profile": "https://wordpress.stackexchange.com/users/13727",
"pm_score": 1,
"selected": false,
"text": "<p>Its in the wp_nav_menu arguments: <code>'items_wrap' => '<ul>%3$s<span></span></ul&... | 2013/06/19 | [
"https://wordpress.stackexchange.com/questions/103522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34309/"
] | I'm having some trouble with my custom ajax function.
I have this on my console log :
"POST MYSITEURL/wp-admin/admin-ajax.php 302 Found". So my functions won't work...
And I really don't understand why.
I've developed a login form for the front end, it works well on my local but not online.
Here is what I do :
```
f... | Its in the wp\_nav\_menu arguments: `'items_wrap' => '<ul>%3$s<span></span></ul>'` |
103,559 | <p>I am using WP_Query to get all posts from a custom post type. This works great for listing out all the posts. However, the post itself has a custom date field and I want to list all posts for a certain month under an <code>H2</code> tag that list the month without repeating the month. Currently I can loop through al... | [
{
"answer_id": 103553,
"author": "Steve",
"author_id": 3206,
"author_profile": "https://wordpress.stackexchange.com/users/3206",
"pm_score": 2,
"selected": false,
"text": "<p>You could export \"all content\", save and edit the XML file to remove the posts and pages, leaving the menu.</p>... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4918/"
] | I am using WP\_Query to get all posts from a custom post type. This works great for listing out all the posts. However, the post itself has a custom date field and I want to list all posts for a certain month under an `H2` tag that list the month without repeating the month. Currently I can loop through all posts but t... | You could export "all content", save and edit the XML file to remove the posts and pages, leaving the menu. |
103,561 | <p>I want to connect with another wp db & then fetch records from new connected db then close that db.</p>
<p>I follow <a href="https://wordpress.stackexchange.com/questions/100666/how-can-i-connect-to-another-wp-database-and-use-wp-query">How can I connect to another WP database and use WP_Query?</a> but after co... | [
{
"answer_id": 103562,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>That's correct, you won't see them. Those table names are coded into the wpdb class, they're not read from the dat... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18419/"
] | I want to connect with another wp db & then fetch records from new connected db then close that db.
I follow [How can I connect to another WP database and use WP\_Query?](https://wordpress.stackexchange.com/questions/100666/how-can-i-connect-to-another-wp-database-and-use-wp-query) but after connect to new db if I pri... | here is what I did with slight change as per your need. May be it will helpful for you. :)
```
function fetch_news()
{
global $wpdb;
$wpdb_backup = $wpdb; // backup existing instance
$wpdb = new wpdb( NEWS_DB_USER, NEWS_DB_PASSWORD, NEWS_DB_NAME, NEWS_DB_HOST ); // create new db instance
wp_set_wpdb_... |
103,575 | <p>In my signup form there is an input field that gets user's facebook ID, I just want to verify if its correct before signing up the user.</p>
| [
{
"answer_id": 103578,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 1,
"selected": false,
"text": "<p>You can do something like this,</p>\n\n<p>before signup test via ajax that is fb id exist and if repon... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103575",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23677/"
] | In my signup form there is an input field that gets user's facebook ID, I just want to verify if its correct before signing up the user. | When user logs in using this FB button. Its session is generated. So I can use PHP API to get any information I want.
I put this code in html body
```
<script>
window.fbAsyncInit = function() {
FB.init({
appId : <?php echo $facebook->getAppId(); ?>, // App ID
channelUrl : '//WWW.examp... |
103,583 | <p>I'd like to serach my blog for articles that contain the two words <code>bash</code> and <code>variable</code>. There is an article that contains both words, but it is not found. It seems to me that the wordpress search only searches for a single string. If I search e.g. for <code>bash script</code>, it finds articl... | [
{
"answer_id": 103578,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 1,
"selected": false,
"text": "<p>You can do something like this,</p>\n\n<p>before signup test via ajax that is fb id exist and if repon... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103583",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19594/"
] | I'd like to serach my blog for articles that contain the two words `bash` and `variable`. There is an article that contains both words, but it is not found. It seems to me that the wordpress search only searches for a single string. If I search e.g. for `bash script`, it finds articles. If I search for `script bash` it... | When user logs in using this FB button. Its session is generated. So I can use PHP API to get any information I want.
I put this code in html body
```
<script>
window.fbAsyncInit = function() {
FB.init({
appId : <?php echo $facebook->getAppId(); ?>, // App ID
channelUrl : '//WWW.examp... |
103,590 | <p>I am trying to modify the login page using <a href="http://codex.wordpress.org/Customizing_the_Login_Form" rel="nofollow">built in filters</a>. The add_actions are working as expected, but I cannot get the filters to work. This is the code that I have in my functions.php:</p>
<pre><code>add_filter( 'login_form_to... | [
{
"answer_id": 103617,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>While <code>login_form_top</code> is a valid hook called by the <a href=\"http://core.trac.wordpress.org/bro... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103590",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | I am trying to modify the login page using [built in filters](http://codex.wordpress.org/Customizing_the_Login_Form). The add\_actions are working as expected, but I cannot get the filters to work. This is the code that I have in my functions.php:
```
add_filter( 'login_form_top', 'filter_top_login' );
function filter... | While `login_form_top` is a valid hook called by the [`wp_login_form`](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L257) function, `wp_login_form` ***is not used*** in [`wp-login.php`](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-login.php), nor is that function used anywh... |
103,608 | <p>I use WooCommerce.<br>
My links are looking like this at the moment:</p>
<pre><code>http://www.mywebsite.com/shop/sample-product/
</code></pre>
<p>but I want them to be like this:</p>
<pre><code>http://www.mywebsite.com/shop/1.html/
http://www.mywebsite.com/shop/2.html/
http://www.mywebsite.com/shop/3.html/
http:... | [
{
"answer_id": 103658,
"author": "Pekz0r",
"author_id": 27468,
"author_profile": "https://wordpress.stackexchange.com/users/27468",
"pm_score": 1,
"selected": false,
"text": "<p>Why do you want this?\nI can't see any good reason. It's much better for both usability and SEO to have the ti... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103608",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34335/"
] | I use WooCommerce.
My links are looking like this at the moment:
```
http://www.mywebsite.com/shop/sample-product/
```
but I want them to be like this:
```
http://www.mywebsite.com/shop/1.html/
http://www.mywebsite.com/shop/2.html/
http://www.mywebsite.com/shop/3.html/
http://www.mywebsite.com/shop/4.html/
http:... | Why do you want this?
I can't see any good reason. It's much better for both usability and SEO to have the titles in the permalinks.
But if you REALLY want this, you can use "/shop/%post\_id%.html" as a product permalink base. You change this under "Settings" -> "Permalinks" and then at the bottom under the section "Pr... |
103,622 | <p>Having little issue with following:</p>
<p>We want to add "Last update" after making important corrections or additional text/images to existing Postings.<br/>
Using following code (hardcoded) does in a way almost what I want:</p>
<pre><code><span style="font-size:85%">Last update <u><time datetime=... | [
{
"answer_id": 103624,
"author": "Jen",
"author_id": 13810,
"author_profile": "https://wordpress.stackexchange.com/users/13810",
"pm_score": 0,
"selected": false,
"text": "<p>You could add a comparison between the last modified time and the original created time, and only show the last m... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15605/"
] | Having little issue with following:
We want to add "Last update" after making important corrections or additional text/images to existing Postings.
Using following code (hardcoded) does in a way almost what I want:
```
<span style="font-size:85%">Last update <u><time datetime="<?php the_modified_time('d-m-y'); ?>"... | You could compare `post_date` to `post_modified` and only echo your content if they do not match.
```
// inside a Loop
if ($post->post_date != $post->post_modified) { ?>
<span style="font-size:85%">Last update <u><time datetime="<?php the_modified_time('d-m-y'); ?>"> <?php the_modified_time('l j F, Y'); ?></time><... |
103,638 | <p>I have a site that lists upcoming events and past events. </p>
<p>In my category-past-event.php template, this is how I've gotten past events appear in descending order (from most recent to oldest): </p>
<pre><code> <?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
... | [
{
"answer_id": 103624,
"author": "Jen",
"author_id": 13810,
"author_profile": "https://wordpress.stackexchange.com/users/13810",
"pm_score": 0,
"selected": false,
"text": "<p>You could add a comparison between the last modified time and the original created time, and only show the last m... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103638",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34346/"
] | I have a site that lists upcoming events and past events.
In my category-past-event.php template, this is how I've gotten past events appear in descending order (from most recent to oldest):
```
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
... | You could compare `post_date` to `post_modified` and only echo your content if they do not match.
```
// inside a Loop
if ($post->post_date != $post->post_modified) { ?>
<span style="font-size:85%">Last update <u><time datetime="<?php the_modified_time('d-m-y'); ?>"> <?php the_modified_time('l j F, Y'); ?></time><... |
103,641 | <p>I am about to start my first WordPress project and I have the task of moving customized core code that override the core into separate functions/files (this way it'll be easier to maintain when we upgrade in the future.</p>
<p>I have been doing research and it looks like <code>add_filter</code> and <code>apply_filt... | [
{
"answer_id": 103643,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 0,
"selected": false,
"text": "<p>I guess you've got it a little bit wrong.</p>\n\n<p>Filters and actions are functions that you \"assi... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34348/"
] | I am about to start my first WordPress project and I have the task of moving customized core code that override the core into separate functions/files (this way it'll be easier to maintain when we upgrade in the future.
I have been doing research and it looks like `add_filter` and `apply_filter` and `do_action` and `a... | >
> I am confused because add\_filter uses the word add when I feel like it
> is more on the lines of replace or overwrite (unless I am
> misunderstanding)
>
>
>
You are misunderstanding. Both `add_action` and `add_filter` insert function callbacks into a kind of queue. You can add many callbacks to the same hoo... |
103,649 | <p>I am using Wordpress to create a Q&A website. </p>
<p>The question is returned by <code>the_content.</code></p>
<p>If I store the answers as post meta field array:</p>
<pre><code>{
[1] => 'first answer',
[2] => 'second answer',
[3] => 'third answer',
.....
}
</code></pre... | [
{
"answer_id": 103643,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 0,
"selected": false,
"text": "<p>I guess you've got it a little bit wrong.</p>\n\n<p>Filters and actions are functions that you \"assi... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | I am using Wordpress to create a Q&A website.
The question is returned by `the_content.`
If I store the answers as post meta field array:
```
{
[1] => 'first answer',
[2] => 'second answer',
[3] => 'third answer',
.....
}
```
How can I create separte comments for each item (comments ... | >
> I am confused because add\_filter uses the word add when I feel like it
> is more on the lines of replace or overwrite (unless I am
> misunderstanding)
>
>
>
You are misunderstanding. Both `add_action` and `add_filter` insert function callbacks into a kind of queue. You can add many callbacks to the same hoo... |
103,653 | <p>I'm trying to embed this code into a post:</p>
<pre><code><script src="http://www.stokerposter.com/swfobject.js"></script>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="422" height="750">
<param name="movie" value="http://www.stokerposter.com/Stoker_Poster_04.swf" />... | [
{
"answer_id": 103674,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 1,
"selected": false,
"text": "<p>Sounds like you are using the Visual side of the editor.</p>\n<p><img src=\"https://i.stack.imgur.com/MO9Y... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103653",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34351/"
] | I'm trying to embed this code into a post:
```
<script src="http://www.stokerposter.com/swfobject.js"></script>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="422" height="750">
<param name="movie" value="http://www.stokerposter.com/Stoker_Poster_04.swf" />
<!--[if !IE]>-->
<object typ... | Sounds like you are using the Visual side of the editor.

**You need to use the Text side.**

Get it?
Update:
-------
Preview won't show embedded objects. Publish it privately if... |
103,660 | <p>In WordPress there's a nonce generating/verifying mechanism, and I'm having trouble understanding why it's not working correctly...</p>
<p>At a point it checks for whether the nonce was generated 0-12 hours ago.</p>
<p><strong>wp-includes\pluggable.php:1260</strong></p>
<pre><code>function wp_verify_nonce($nonce,... | [
{
"answer_id": 103661,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 3,
"selected": true,
"text": "<p>WordPress nonces are not your usually ('use only once') nonce. For a given <code>$action</code>, a new no... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103660",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15816/"
] | In WordPress there's a nonce generating/verifying mechanism, and I'm having trouble understanding why it's not working correctly...
At a point it checks for whether the nonce was generated 0-12 hours ago.
**wp-includes\pluggable.php:1260**
```
function wp_verify_nonce($nonce, $action = -1) {
$user = wp_get_curre... | WordPress nonces are not your usually ('use only once') nonce. For a given `$action`, a new nonce is generated at every 12 hours and a nonces are valid for 24 hours, so at any given point there are two nonces valid for a given `$action`.
The nonce is (a substring of) a hash of
* `$action` - the action
* `$uid` - the... |
103,680 | <p>What is the easiest way to add a background image to a single page like tryghost.org?</p>
<p>I am currently running under WordPress and was wondering what code I need to add and where. The image is only to be placed on the homepage, and when scrolling down the image should be scrolled down as well. It should also b... | [
{
"answer_id": 103682,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 1,
"selected": false,
"text": "<p>Use Conditional Tags: <a href=\"http://codex.wordpress.org/Conditional_Tags\" rel=\"nofollow noreferrer\">... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33728/"
] | What is the easiest way to add a background image to a single page like tryghost.org?
I am currently running under WordPress and was wondering what code I need to add and where. The image is only to be placed on the homepage, and when scrolling down the image should be scrolled down as well. It should also be full wid... | Use Conditional Tags: <http://codex.wordpress.org/Conditional_Tags>
Or a custom template for homepage: <http://codex.wordpress.org/Stepping_Into_Templates>
Then it's a matter of applying a style / class when, for example, `is_front_page()` (or sometimes) `is_home()` (for conditionals), or on your custom template. It's... |
103,694 | <p>I want to display all recently uploaded youtube videos from my youtube account as a widget on the right side of the page. Just like how technobuffalo.com has done. Is there such a plugin that will do this? </p>
<p>ps: as for what I've tried, i have searched on wordpresses plugin pages and all i see are plugins that... | [
{
"answer_id": 103702,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>Forget about WordPress for the time being & concentrate on figuring out the core mechanics of what you... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5919/"
] | I want to display all recently uploaded youtube videos from my youtube account as a widget on the right side of the page. Just like how technobuffalo.com has done. Is there such a plugin that will do this?
ps: as for what I've tried, i have searched on wordpresses plugin pages and all i see are plugins that allow me ... | You can use YouTube developer API. Example how to get recent videos below:
```
$data = wp_remote_get('http://gdata.youtube.com/feeds/api/users/<USERNAME>/uploads/?start-index=1&max-results=40');
$response = new SimpleXMLElement($data['body']);
foreach ($response->entry as $entry):
$vid_id = '';
if ( preg_mat... |
103,696 | <p>I have a slider and I want to create thumb of specific sizes for my slider but only when the post post is sticky or if there is any other way so it won't create all these sizes I set for the slider for all the posts?</p>
| [
{
"answer_id": 103702,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>Forget about WordPress for the time being & concentrate on figuring out the core mechanics of what you... | 2013/06/20 | [
"https://wordpress.stackexchange.com/questions/103696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12508/"
] | I have a slider and I want to create thumb of specific sizes for my slider but only when the post post is sticky or if there is any other way so it won't create all these sizes I set for the slider for all the posts? | You can use YouTube developer API. Example how to get recent videos below:
```
$data = wp_remote_get('http://gdata.youtube.com/feeds/api/users/<USERNAME>/uploads/?start-index=1&max-results=40');
$response = new SimpleXMLElement($data['body']);
foreach ($response->entry as $entry):
$vid_id = '';
if ( preg_mat... |
103,716 | <p>i am an wordpress developer and i am currently in a project in which i have 15 wordpress responsive themes and can be downloaded by users of my site.</p>
<p>In this , i want the feature to show the user previewing the theme. How can set this feature in front end. Any help! Thanks for advance.</p>
| [
{
"answer_id": 103702,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>Forget about WordPress for the time being & concentrate on figuring out the core mechanics of what you... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103716",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17849/"
] | i am an wordpress developer and i am currently in a project in which i have 15 wordpress responsive themes and can be downloaded by users of my site.
In this , i want the feature to show the user previewing the theme. How can set this feature in front end. Any help! Thanks for advance. | You can use YouTube developer API. Example how to get recent videos below:
```
$data = wp_remote_get('http://gdata.youtube.com/feeds/api/users/<USERNAME>/uploads/?start-index=1&max-results=40');
$response = new SimpleXMLElement($data['body']);
foreach ($response->entry as $entry):
$vid_id = '';
if ( preg_mat... |
103,717 | <p>I am trying to attach a pdf file to a custom post type.<br>
I have found this snippet at wpsnipp.com. <br>
The code does the trick, but only for posts.<br>
I have a custom post type named 'events' and I can't make it work.</p>
<pre><code>add_action("admin_init", "pdf_init");
add_action('save_post', 'save_pdf_link')... | [
{
"answer_id": 103721,
"author": "ksr89",
"author_id": 31368,
"author_profile": "https://wordpress.stackexchange.com/users/31368",
"pm_score": 3,
"selected": false,
"text": "<p>Here this is my code which i used in my wordpress site in custom post type for adding the pdf to the post and i... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34372/"
] | I am trying to attach a pdf file to a custom post type.
I have found this snippet at wpsnipp.com.
The code does the trick, but only for posts.
I have a custom post type named 'events' and I can't make it work.
```
add_action("admin_init", "pdf_init");
add_action('save_post', 'save_pdf_link');
function pdf_in... | Here this is my code which i used in my wordpress site in custom post type for adding the pdf to the post and its work for me try to change its and use it. Hope it will help
```
function add_custom_meta_boxes() {
add_meta_box('wp_custom_attachment', 'Hotel Brochure', 'wp_custom_attachment', 'hotel_post', 'normal... |
103,751 | <p>I cannot figure out how to get this <a href="http://www.larentis.eu/switch/" rel="nofollow">Bootstrap Switch extension</a> to work with my WordPress installation.</p>
<p>When I download the example from github and run it on my local machine, the controls work perfectly. But they don't seem to be working in WordPre... | [
{
"answer_id": 103721,
"author": "ksr89",
"author_id": 31368,
"author_profile": "https://wordpress.stackexchange.com/users/31368",
"pm_score": 3,
"selected": false,
"text": "<p>Here this is my code which i used in my wordpress site in custom post type for adding the pdf to the post and i... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | I cannot figure out how to get this [Bootstrap Switch extension](http://www.larentis.eu/switch/) to work with my WordPress installation.
When I download the example from github and run it on my local machine, the controls work perfectly. But they don't seem to be working in WordPress at all. In order to test it, I hav... | Here this is my code which i used in my wordpress site in custom post type for adding the pdf to the post and its work for me try to change its and use it. Hope it will help
```
function add_custom_meta_boxes() {
add_meta_box('wp_custom_attachment', 'Hotel Brochure', 'wp_custom_attachment', 'hotel_post', 'normal... |
103,765 | <p>I want to add meta fields for the sites in my network (such as a thumbnail and a category). I know how to do this using <a href="http://codex.wordpress.org/WPMU_Functions/get_site_option" rel="nofollow"><code>get</code></a>/<a href="http://codex.wordpress.org/WPMU_Functions/add_site_option" rel="nofollow"><code>add<... | [
{
"answer_id": 103769,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p>The Site Info admin page's code is here: <a href=\"http://core.trac.wordpress.org/browser/trunk/wp-admin/netwo... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16975/"
] | I want to add meta fields for the sites in my network (such as a thumbnail and a category). I know how to do this using [`get`](http://codex.wordpress.org/WPMU_Functions/get_site_option)/[`add`](http://codex.wordpress.org/WPMU_Functions/add_site_option)/[`update_site_option`](http://codex.wordpress.org/WPMU_Functions/u... | I finally found a way to add more lines to the Sites > Infos table :

It's a little bit ugly, but it works. I simply use the action `admin_footer` to add a bunch of HTML code at the end of the page, and then use jQuery to move it to the r... |
103,792 | <p>So in template.php the original function looks like this:</p>
<pre><code> function meta_form() {
global $wpdb;
$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
$keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_... | [
{
"answer_id": 103793,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>There are no hooks (that I see) in that function that you can use to alter it in that way. However, the valu... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34348/"
] | So in template.php the original function looks like this:
```
function meta_form() {
global $wpdb;
$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
$keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
HAVI... | Seems like you asked this Q [on SO](https://stackoverflow.com/q/17239871/1981996) as well, I posted following answer over there:
>
> The `meta_form` function is not pluggable, and there are no hooks
> available, so, as hacking the core is not really recommended, you'll
> need another approach. The following is a jQ... |
103,801 | <p>Trying to find an issue with my theme that is not related with this question, I've started the debugger and enabled a breakpoint to the first line of a function hooked to <code>after_setup_theme</code>.</p>
<p>Here I've realized that the function is called three times, before the page is rendered.</p>
<p>Is that n... | [
{
"answer_id": 103803,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>Hooks and filters can have several Actions attached. Hence the <code>$priority</code> argument. In short: It's jus... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7291/"
] | Trying to find an issue with my theme that is not related with this question, I've started the debugger and enabled a breakpoint to the first line of a function hooked to `after_setup_theme`.
Here I've realized that the function is called three times, before the page is rendered.
Is that normal?
Isn't this action sup... | Hooks and filters can have several Actions attached. Hence the `$priority` argument. In short: It's just a big multi dimensional array where the key is the hook/filter name and the values are the attached callbacks plus their priority. |
103,802 | <p>I need users to redirect to login if not logged and once they are, redirect them to backend if they try to see front end pages. This is my code:</p>
<pre><code>add_action( 'template_redirect', function () {
if(is_user_logged_in() ):
bk1_debug('logged in');
if (!is_admin()):
bk1_debug... | [
{
"answer_id": 103805,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>redirecting not logged in user is the only thing that works :) in the\n backend.</p>\n</blo... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103802",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10100/"
] | I need users to redirect to login if not logged and once they are, redirect them to backend if they try to see front end pages. This is my code:
```
add_action( 'template_redirect', function () {
if(is_user_logged_in() ):
bk1_debug('logged in');
if (!is_admin()):
bk1_debug('not in admin... | Following suggestions from @s\_ha\_dum who noted that user need be logged in anyway to go to back end and that 'template\_redirect' doesn't work in backend (even if my code did trigged console messages only in back end), I simplify the code as such:
```
add_action( 'template_redirect', function () {
if(!is_admin()... |
103,814 | <p>I have a big problem.
In a Wordpress page I've a function that generate og meta tags. I want to "append" that generated meta in the head section. So, I write this code:</p>
<pre><code>add_action('wp_head', '_set_meta_tag');
function _set_meta_tag()
{
global $nome;
global $descr;
global $file;
global... | [
{
"answer_id": 103815,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>That code must run before the <code>wp_head</code> hook fires or nothing will happen, and when tested in a mu... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33591/"
] | I have a big problem.
In a Wordpress page I've a function that generate og meta tags. I want to "append" that generated meta in the head section. So, I write this code:
```
add_action('wp_head', '_set_meta_tag');
function _set_meta_tag()
{
global $nome;
global $descr;
global $file;
global $path_meta;
... | That code must run before the `wp_head` hook fires or nothing will happen, and when tested in a mu-plugin file it does work.
I suspect that you are trying to hook that function too late-- perhaps from inside a theme template file after [`get_header`](http://codex.wordpress.org/Function_Reference/get_header) (in most ... |
103,827 | <p>I filter my <code>WP_Query</code> by this script:</p>
<pre><code>$args = array (
'posts_per_page' => $posts_per_page,
'post_type' => $post_type,
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
'showposts' => 160,
'order' => 'DESC',
... | [
{
"answer_id": 103829,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the <code>posts_where</code> filter to adjust the<code>WHERE</code> part of your query:</p>\n\n<p... | 2013/06/21 | [
"https://wordpress.stackexchange.com/questions/103827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34406/"
] | I filter my `WP_Query` by this script:
```
$args = array (
'posts_per_page' => $posts_per_page,
'post_type' => $post_type,
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
'showposts' => 160,
'order' => 'DESC',
'paged' => $paged,
'tax_... | To restrict to letter `X` dynamically, the following should work. It depends upon the fact that `WP_Query` will let *ad hoc* parameters pass through. That lets you send your own data to the filters. I do not know if this is intentional behavior so *caveat emptor*, but it is very useful behavior.
Simply send your lette... |
103,839 | <p>I created a custom checkbox that when I check, I wish it to display slightly different content (specially special css styling). For some reason it is not functioning properly.</p>
<p>In my functions:</p>
<pre><code>add_action( 'add_meta_boxes', 'add_special_checkbox' );
function add_special_checkbox()
{
add_me... | [
{
"answer_id": 103840,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>You're setting a value whether it's checked or not with this line:</p>\n\n<pre><code>$chk = ( isset( $_POST['specia... | 2013/06/22 | [
"https://wordpress.stackexchange.com/questions/103839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32290/"
] | I created a custom checkbox that when I check, I wish it to display slightly different content (specially special css styling). For some reason it is not functioning properly.
In my functions:
```
add_action( 'add_meta_boxes', 'add_special_checkbox' );
function add_special_checkbox()
{
add_meta_box( 'special-chec... | You're setting a value whether it's checked or not with this line:
```
$chk = ( isset( $_POST['special_box_check'] ) && $_POST['special_box_check'] ) ? 'on' : 'off';
```
The value is going to be either `on` or `off`, so your `if` condition is always true, since it always has a value.
You could change it to save onl... |
103,845 | <p>I am trying to sort posts based on rating (using wp-postrating plugin) and numbers of comments. I have made this using wpdb, but i kinda wish to make it easier and use it with wp_query. Seems that I can not find any way to achieve this because I do not know any method to orderby two items in $args.</p>
<p>My wpdb c... | [
{
"answer_id": 103840,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>You're setting a value whether it's checked or not with this line:</p>\n\n<pre><code>$chk = ( isset( $_POST['specia... | 2013/06/22 | [
"https://wordpress.stackexchange.com/questions/103845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26178/"
] | I am trying to sort posts based on rating (using wp-postrating plugin) and numbers of comments. I have made this using wpdb, but i kinda wish to make it easier and use it with wp\_query. Seems that I can not find any way to achieve this because I do not know any method to orderby two items in $args.
My wpdb code looks... | You're setting a value whether it's checked or not with this line:
```
$chk = ( isset( $_POST['special_box_check'] ) && $_POST['special_box_check'] ) ? 'on' : 'off';
```
The value is going to be either `on` or `off`, so your `if` condition is always true, since it always has a value.
You could change it to save onl... |
103,849 | <p>I am writing a plugin in which I need to list post/page/attachment by each type.</p>
<p>First I get all post type:</p>
<pre><code>$post_types = get_post_types (array('public'=>true));
</code></pre>
<p>Then I create a loop and query posts for each post type, and print out:</p>
<pre><code>foreach ($post_types a... | [
{
"answer_id": 103840,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>You're setting a value whether it's checked or not with this line:</p>\n\n<pre><code>$chk = ( isset( $_POST['specia... | 2013/06/22 | [
"https://wordpress.stackexchange.com/questions/103849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34319/"
] | I am writing a plugin in which I need to list post/page/attachment by each type.
First I get all post type:
```
$post_types = get_post_types (array('public'=>true));
```
Then I create a loop and query posts for each post type, and print out:
```
foreach ($post_types as $type_name => $post_type) :
$args = arra... | You're setting a value whether it's checked or not with this line:
```
$chk = ( isset( $_POST['special_box_check'] ) && $_POST['special_box_check'] ) ? 'on' : 'off';
```
The value is going to be either `on` or `off`, so your `if` condition is always true, since it always has a value.
You could change it to save onl... |
103,866 | <p>I'm trying to upload a XML file through Wordpress Importer</p>
<p>It shows this error, no matter what the size of the file is.</p>
<p>Even 10kb file throws up this error.</p>
<p>My php.ini settings were set to 100MB, still no change. Back to defaults, wich is 8MB.</p>
<p>I'm starting to think it's permission rel... | [
{
"answer_id": 103869,
"author": "tacudtap",
"author_id": 33561,
"author_profile": "https://wordpress.stackexchange.com/users/33561",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>phpinfo()</code> to verify what the setting is. Some hosts do not allow you to change the PHP sett... | 2013/06/22 | [
"https://wordpress.stackexchange.com/questions/103866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27278/"
] | I'm trying to upload a XML file through Wordpress Importer
It shows this error, no matter what the size of the file is.
Even 10kb file throws up this error.
My php.ini settings were set to 100MB, still no change. Back to defaults, wich is 8MB.
I'm starting to think it's permission related.
Any ideas? | You need to make the following changes in php.ini file on your server.
```
upload_max_filesize = 100M
post_max_size = 100M
```
If still it's same then update value of memory\_limit. |
103,876 | <p>I've been trying to get this query to work but it keeps failing to return any rows</p>
<pre><code>SELECT a.ID
FROM wp_users a, wp_usermeta b
WHERE b.user_id=a.ID
AND (
(b.meta_key='firstname-groom' AND b.meta_value LIKE 'Darren')
OR (b.meta_key='firstname-bride' AND b.meta_value LIKE 'Someone')
OR (b.m... | [
{
"answer_id": 103878,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>SQL</code> does not trigger an error, so you do not have data in your database that matches all of... | 2013/06/22 | [
"https://wordpress.stackexchange.com/questions/103876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25290/"
] | I've been trying to get this query to work but it keeps failing to return any rows
```
SELECT a.ID
FROM wp_users a, wp_usermeta b
WHERE b.user_id=a.ID
AND (
(b.meta_key='firstname-groom' AND b.meta_value LIKE 'Darren')
OR (b.meta_key='firstname-bride' AND b.meta_value LIKE 'Someone')
OR (b.meta_key='lastn... | Actually i figured it out now using join
```
SELECT a.ID FROM wp_users a INNER JOIN wp_usermeta b ON b.user_id = a.ID AND
(
( b.meta_key = 'firstname-groom' AND b.meta_value LIKE 'Darren' )
OR ( b.meta_key = 'firstname-bride' AND b.meta_value LIKE 'Someone' )
OR ( b.meta_key = 'lastname-bride' AND b.meta_value LIKE '... |
103,886 | <p>I have installed <a href="http://en.wikipedia.org/wiki/WAMP" rel="nofollow noreferrer">WAMP</a> server on Windows 8 and am trying to install WordPress on it, but while installing it, I could not complete it. It's showing me the error like</p>
<pre><code>http://localhost/wordpress/wp-admin/install.php?step=2
</code>... | [
{
"answer_id": 103895,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>That isn't an error. It is an URL, and it suggests that the problem is here: </p>\n\n<blockquote>\n<pre><cod... | 2013/06/22 | [
"https://wordpress.stackexchange.com/questions/103886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34423/"
] | I have installed [WAMP](http://en.wikipedia.org/wiki/WAMP) server on Windows 8 and am trying to install WordPress on it, but while installing it, I could not complete it. It's showing me the error like
```
http://localhost/wordpress/wp-admin/install.php?step=2
```
After that, the process stops.
I referred to the qu... | I hope that what solved my problem will help you, in php.ini, I set the `max_execution_time` configuration to `90` instead of the default value `30`.
```
max_execution_time = 90
``` |
103,896 | <p>In a plugin, I use ajax to <code>get_option()</code> which takes much longer than it has to because entire wp gets loaded.</p>
<p>How do I set things up so that it (my ajax) loads only what is needed? (<code>get_option()</code>)</p>
<p><a href="https://wordpress.stackexchange.com/questions/41808/ajax-takes-10x-as-... | [
{
"answer_id": 103897,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 4,
"selected": true,
"text": "<p>If you're building something for public consumption (a plugin, a theme, etc) use <a href=\"http://codex.w... | 2013/06/23 | [
"https://wordpress.stackexchange.com/questions/103896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15816/"
] | In a plugin, I use ajax to `get_option()` which takes much longer than it has to because entire wp gets loaded.
How do I set things up so that it (my ajax) loads only what is needed? (`get_option()`) | If you're building something for public consumption (a plugin, a theme, etc) use [`admin-ajax.php` like you should](http://codex.wordpress.org/AJAX_in_Plugins) because that is the appropriate and accepted way to do things and gives your end users the power they need to change and modify things if they so choose.
Beyon... |
103,903 | <p>When an article is posted it comes out like this:<br/>
Where the title is on top, then the picture, then the image.</p>
<p><img src="https://i.stack.imgur.com/Xiyf5.png" alt="enter image description here"></p>
<p>But what I would like to do is how technobuffalo.com has it:</p>
<p><img src="https://i.stack.imgur.c... | [
{
"answer_id": 103906,
"author": "Greeso",
"author_id": 34253,
"author_profile": "https://wordpress.stackexchange.com/users/34253",
"pm_score": -1,
"selected": false,
"text": "<p>Look into your archive.php and single.php files in your template. Then modify the html output of those files,... | 2013/06/23 | [
"https://wordpress.stackexchange.com/questions/103903",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5919/"
] | When an article is posted it comes out like this:
Where the title is on top, then the picture, then the image.

But what I would like to do is how technobuffalo.com has it:

How... | In TwentyTwelve index.php:
```
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
```
the line in the middle is loading the `content.php` to show the posts on the homepage.
a. In `content.php`, `the_post_thumbnail()` in *line 18* is respon... |
103,909 | <p>I'm using <code>previous_post_link('%link','Previous Post');</code> and <code>next_post_link('%link','Next Post');</code> for post navigation but I want to add text domain to that similar to <code>_e('Next Post' , 'ft');</code> </p>
<p>How can I do that?</p>
| [
{
"answer_id": 103911,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<pre><code>previous_post_link( '%link', __( '&larr; Previous Post', 'my_domain' ) );\n</code></pre>\n\n<p... | 2013/06/23 | [
"https://wordpress.stackexchange.com/questions/103909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34434/"
] | I'm using `previous_post_link('%link','Previous Post');` and `next_post_link('%link','Next Post');` for post navigation but I want to add text domain to that similar to `_e('Next Post' , 'ft');`
How can I do that? | ```
previous_post_link( '%link', __( '← Previous Post', 'my_domain' ) );
```
Check out [an explanation of the translator functions](http://wpengineer.com/2237/whats-the-difference-between-__-_e-_x-and-_ex/). |
103,917 | <p>I need to remove the link to the Jetpack settings, but not the links to Omnisearch and Site Stats from the admin menu for everyone not having an administrator role:</p>
<p><img src="https://i.stack.imgur.com/5mMAM.png" alt="enter image description here"></p>
<p>For this, I came up with this code:</p>
<pre><code>f... | [
{
"answer_id": 103921,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": true,
"text": "<p>Try this instead:</p>\n\n<pre><code>function remove_posts_menu() {\n if ( ! current_user_can( 'manage_optio... | 2013/06/23 | [
"https://wordpress.stackexchange.com/questions/103917",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I need to remove the link to the Jetpack settings, but not the links to Omnisearch and Site Stats from the admin menu for everyone not having an administrator role:

For this, I came up with this code:
```
function remove_posts_menu() {
if (!cur... | Try this instead:
```
function remove_posts_menu() {
if ( ! current_user_can( 'manage_options' ) )
remove_submenu_page( 'jetpack', 'jetpack' );
}
add_action( 'admin_init', 'remove_posts_menu' );
```
where the *menu slug* and *submenu slug* are `jetpack`. |
103,930 | <p>I was tasked with rebuilding works website as my first project for the job, and decided to go down the wpalchemy class route to help make meta boxes for my custom post type (I'm not going to use plugins).</p>
<p>I'm currently using (inside my theme page)</p>
<pre><code> $sidebar_excerpt = $sidebar_excerpt_meta-... | [
{
"answer_id": 103921,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": true,
"text": "<p>Try this instead:</p>\n\n<pre><code>function remove_posts_menu() {\n if ( ! current_user_can( 'manage_optio... | 2013/06/23 | [
"https://wordpress.stackexchange.com/questions/103930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34442/"
] | I was tasked with rebuilding works website as my first project for the job, and decided to go down the wpalchemy class route to help make meta boxes for my custom post type (I'm not going to use plugins).
I'm currently using (inside my theme page)
```
$sidebar_excerpt = $sidebar_excerpt_meta->the_meta();
```
to... | Try this instead:
```
function remove_posts_menu() {
if ( ! current_user_can( 'manage_options' ) )
remove_submenu_page( 'jetpack', 'jetpack' );
}
add_action( 'admin_init', 'remove_posts_menu' );
```
where the *menu slug* and *submenu slug* are `jetpack`. |
103,932 | <p>I am trying to put <code>the_content()</code> inside <code><meta itemprop="articleBody" content="</code>(content here)<code>"></code>.</p>
<p>But if I just put <code><?php the_content() ?></code> in there, it doesn't work, image goes, structure gets mis-aligned, and <code>"></code> appears after the ... | [
{
"answer_id": 103921,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": true,
"text": "<p>Try this instead:</p>\n\n<pre><code>function remove_posts_menu() {\n if ( ! current_user_can( 'manage_optio... | 2013/06/23 | [
"https://wordpress.stackexchange.com/questions/103932",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32366/"
] | I am trying to put `the_content()` inside `<meta itemprop="articleBody" content="`(content here)`">`.
But if I just put `<?php the_content() ?>` in there, it doesn't work, image goes, structure gets mis-aligned, and `">` appears after the content.
Any ideas?
Edit:
I don't know why this was put on hold for not fittin... | Try this instead:
```
function remove_posts_menu() {
if ( ! current_user_can( 'manage_options' ) )
remove_submenu_page( 'jetpack', 'jetpack' );
}
add_action( 'admin_init', 'remove_posts_menu' );
```
where the *menu slug* and *submenu slug* are `jetpack`. |
103,965 | <p>I've been working on my first widget, Everything works perfectly except it doesn't save anything I add to the textarea box. It will output the input on the website however.</p>
<p>From research I think its something to do with the form function and update, but can't quite get my head around which part.</p>
<p>Here... | [
{
"answer_id": 103921,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": true,
"text": "<p>Try this instead:</p>\n\n<pre><code>function remove_posts_menu() {\n if ( ! current_user_can( 'manage_optio... | 2013/06/23 | [
"https://wordpress.stackexchange.com/questions/103965",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32672/"
] | I've been working on my first widget, Everything works perfectly except it doesn't save anything I add to the textarea box. It will output the input on the website however.
From research I think its something to do with the form function and update, but can't quite get my head around which part.
Here is my widget cod... | Try this instead:
```
function remove_posts_menu() {
if ( ! current_user_can( 'manage_options' ) )
remove_submenu_page( 'jetpack', 'jetpack' );
}
add_action( 'admin_init', 'remove_posts_menu' );
```
where the *menu slug* and *submenu slug* are `jetpack`. |
103,970 | <p>I'm working on a plugin which needs a custom Preview page. In this page i call the neccessary wp functions(wp-load.php & wp-admin/includes/admin.php).</p>
<p>The problem is, that the admin bar is not visible. So my question is, how to display the admin bar on this page? Here is the preview.php file:</p>
<pre><... | [
{
"answer_id": 103921,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": true,
"text": "<p>Try this instead:</p>\n\n<pre><code>function remove_posts_menu() {\n if ( ! current_user_can( 'manage_optio... | 2013/06/23 | [
"https://wordpress.stackexchange.com/questions/103970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8038/"
] | I'm working on a plugin which needs a custom Preview page. In this page i call the neccessary wp functions(wp-load.php & wp-admin/includes/admin.php).
The problem is, that the admin bar is not visible. So my question is, how to display the admin bar on this page? Here is the preview.php file:
```
<?php
//Include wor... | Try this instead:
```
function remove_posts_menu() {
if ( ! current_user_can( 'manage_options' ) )
remove_submenu_page( 'jetpack', 'jetpack' );
}
add_action( 'admin_init', 'remove_posts_menu' );
```
where the *menu slug* and *submenu slug* are `jetpack`. |
104,002 | <p>I have a custom post (it's called "items") and 2 categories there.<br>
1. on category page, I need to get posts which belong to 2 categories.</p>
<p>get posts from category1="Food" and category2="featured"</p>
<p>How can I get these posts from 2 categories?</p>
<p>This is what I have been doing is....</p>
<p>I j... | [
{
"answer_id": 104004,
"author": "ksr89",
"author_id": 31368,
"author_profile": "https://wordpress.stackexchange.com/users/31368",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>AND</code> relation between <code>tax_query</code></p>\n\n<pre><code>$posts = get_posts( arr... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104002",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34463/"
] | I have a custom post (it's called "items") and 2 categories there.
1. on category page, I need to get posts which belong to 2 categories.
get posts from category1="Food" and category2="featured"
How can I get these posts from 2 categories?
This is what I have been doing is....
I just got posts from "FOOD" like t... | Now try this, surely it will work
query\_posts("cat=1, 2&showposts=5&post\_type=item");
while(have\_posts()) : the\_post();
```
echo $title = get_the_title();
echo $content = get_the_content();
```
endwhile; |
104,011 | <p>I have a custom post type with tags included as a taxonomy, I am trying to display a list of all the tags that are in the custom post type only. I initially used:</p>
<pre><code>wp_tag_cloud();
</code></pre>
<p>which generates the list of tags with links fine but it shows the tags of the normal posts with it. I tr... | [
{
"answer_id": 104023,
"author": "S kumar",
"author_id": 10725,
"author_profile": "https://wordpress.stackexchange.com/users/10725",
"pm_score": -1,
"selected": false,
"text": "<pre> \n query_posts( 'post_type'=> 'custom_post_type_name' );\n if ( have_posts() ) : while ( have_pos... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104011",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34466/"
] | I have a custom post type with tags included as a taxonomy, I am trying to display a list of all the tags that are in the custom post type only. I initially used:
```
wp_tag_cloud();
```
which generates the list of tags with links fine but it shows the tags of the normal posts with it. I tried to query the posts lik... | The above solutions work correctly but aren't exactly optimized. Here's a method that queries that database ONCE for the data you're looking for, and gives you a list of term objects. It can accept a post\_type argument, and if one is not supplied, will use the post\_type of the current global $post object.
```
functi... |
104,015 | <p>This might be very basic question, but I can't really get the category ID on category page (actually a category page of custom type post).</p>
<p>Filename is <code>taxonomy-item-category.php</code> & URL is <code>http://www.abc.com/cat/food/</code></p>
<p>I have tried some of the following but not working...</... | [
{
"answer_id": 104018,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p><code>$cat_id = get_queried_object_id();</code> - it's that simple!</p>\n"
},
{
"answer_id": 116080... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34463/"
] | This might be very basic question, but I can't really get the category ID on category page (actually a category page of custom type post).
Filename is `taxonomy-item-category.php` & URL is `http://www.abc.com/cat/food/`
I have tried some of the following but not working...
```
$cur_cat_id = get_cat_id( single_cat_ti... | `$cat_id = get_queried_object_id();` - it's that simple! |
104,025 | <p>Im baffled on why this is not showing the correct results, when selecting the month alone and say 100 posts are on the site, only 3 show up, then if you select the category and month the proper show up.</p>
<p>here is the archives template</p>
<pre><code><div id="archive-browser">
<div>
<h4>Month... | [
{
"answer_id": 104054,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>It is going to be difficult to debug something like this since I don't have your data on my server but you a... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104025",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70/"
] | Im baffled on why this is not showing the correct results, when selecting the month alone and say 100 posts are on the site, only 3 show up, then if you select the category and month the proper show up.
here is the archives template
```
<div id="archive-browser">
<div>
<h4>Month</h4>
<select id="month-choice">
<opti... | this is what i ended up with which works nicely.
functions.php part
```
<?php
function scripts_enqueue() {
if(is_page('archives')) {
wp_enqueue_script('ajax_dropdown', get_stylesheet_directory_uri() . '/js/loadposts.js',array('jquery'));
wp_localize_script( 'ajax_dropdown', 'myajax', array('custom_nonce' => ... |
104,044 | <p>I have found this code here.</p>
<pre><code>$args = array(
'hide_empty' => FALSE,
'title_li'=> __( '' ),
'show_count'=> 1,
'echo' => 0
);
$links = wp_list_categories($args);
$links = str_replace('</a> (', '<... | [
{
"answer_id": 104054,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>It is going to be difficult to debug something like this since I don't have your data on my server but you a... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104044",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30937/"
] | I have found this code here.
```
$args = array(
'hide_empty' => FALSE,
'title_li'=> __( '' ),
'show_count'=> 1,
'echo' => 0
);
$links = wp_list_categories($args);
$links = str_replace('</a> (', '</a> <span>(', $links);
$links = ... | this is what i ended up with which works nicely.
functions.php part
```
<?php
function scripts_enqueue() {
if(is_page('archives')) {
wp_enqueue_script('ajax_dropdown', get_stylesheet_directory_uri() . '/js/loadposts.js',array('jquery'));
wp_localize_script( 'ajax_dropdown', 'myajax', array('custom_nonce' => ... |
104,053 | <p>I use a code like the one shown below to insert ads after the first paragraph.</p>
<p>The problem is that this code requires the content to be displayed within paragraph tags and I would like to use this code to insert a DIV.<br>
When I simply replace the tags with div tags the code no longer works.</p>
<p>How do ... | [
{
"answer_id": 104058,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>I need to stress that I think this is going to be very unstable and you may not always get the results you wa... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104053",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I use a code like the one shown below to insert ads after the first paragraph.
The problem is that this code requires the content to be displayed within paragraph tags and I would like to use this code to insert a DIV.
When I simply replace the tags with div tags the code no longer works.
How do I remove the parag... | I need to stress that I think this is going to be very unstable and you may not always get the results you want, but in simple cases this should work.
```
$content = apply_filters('the_content', get_the_content());
$content = explode("</p>", $content, 2);
// var_dump($content); // debug
echo $content[0].'</p>';
echo '... |
104,060 | <p>I have searched high and low for this but I cant seem to locate anything.</p>
<p>I am trying to filter some results and when I make an args array like this and pass it to query_posts I noticed that the generated SQL uses AND instead of OR for the 'class_1_days' value. I would like to make than an OR. How would I ... | [
{
"answer_id": 104062,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>Use <code>'relation' => 'OR'</code> <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_F... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34480/"
] | I have searched high and low for this but I cant seem to locate anything.
I am trying to filter some results and when I make an args array like this and pass it to query\_posts I noticed that the generated SQL uses AND instead of OR for the 'class\_1\_days' value. I would like to make than an OR. How would I go about ... | Use `'relation' => 'OR'` [as in the Codex example](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) below:
```
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'OR', /* <-- here */
array(
'key' => 'color',
'value' ... |
104,088 | <p>I have a post type with the slug 'open-tour', so all its pages are under www.domain.com/open-tour/. <strong>I need all the pages under this "directory" to go to HTTPS (for credit card payments).</strong></p>
<p>I can redirect a single URL okay, but the dynamic stuff goes a bit over my head. Maybe it's also because ... | [
{
"answer_id": 104062,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>Use <code>'relation' => 'OR'</code> <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_F... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34484/"
] | I have a post type with the slug 'open-tour', so all its pages are under www.domain.com/open-tour/. **I need all the pages under this "directory" to go to HTTPS (for credit card payments).**
I can redirect a single URL okay, but the dynamic stuff goes a bit over my head. Maybe it's also because I don't know how/where ... | Use `'relation' => 'OR'` [as in the Codex example](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) below:
```
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'OR', /* <-- here */
array(
'key' => 'color',
'value' ... |
104,094 | <p>I'm a WP beginner.</p>
<p>So I'm using a plugin called breadcrumb-trail. I'm about to upgrade it, but I noticed that I had tweaked <code>/breadcrumb-trail/breadcrumb-trail.php</code> a little bit in the past. How would I extract these changes to another file so that they won't be deleted when I upgrade breadcrumb-t... | [
{
"answer_id": 104096,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Unless it is a plugin you've created or maintain you <em>don't</em> edit it or you end up with these issues,... | 2013/06/24 | [
"https://wordpress.stackexchange.com/questions/104094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34348/"
] | I'm a WP beginner.
So I'm using a plugin called breadcrumb-trail. I'm about to upgrade it, but I noticed that I had tweaked `/breadcrumb-trail/breadcrumb-trail.php` a little bit in the past. How would I extract these changes to another file so that they won't be deleted when I upgrade breadcrumb-trail?
here's an exam... | If you look a little further down in the source of [Breadcrumb Trail](http://wordpress.org/plugins/breadcrumb-trail/), you'll notice this line:
```
/* Apply filters to the arguments. */
$args = apply_filters( 'breadcrumb_trail_args', $args );
```
The author has made it possible for you to do exactly what you need, *... |
104,112 | <p>I already used <code>Limit Login Attempts</code> wordpress plugin. Are there other ways to prevent brute force attacks?</p>
<p>I'm worried because I saw a lot of locked out.</p>
| [
{
"answer_id": 104115,
"author": "Andrew",
"author_id": 34501,
"author_profile": "https://wordpress.stackexchange.com/users/34501",
"pm_score": 1,
"selected": false,
"text": "<p>What is your concern with the lockouts? Are there particular features you're looking for? I like Limit Logins ... | 2013/06/25 | [
"https://wordpress.stackexchange.com/questions/104112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26267/"
] | I already used `Limit Login Attempts` wordpress plugin. Are there other ways to prevent brute force attacks?
I'm worried because I saw a lot of locked out. | Brute force attacks run with heavily *automated* scripts. These scripts focus on regular installations; most of them cannot handle changes to the normal login process ([example](http://www.metasploit.com/modules/auxiliary/scanner/http/wordpress_login_enum "Wordpress Brute Force and User Enumeration Utility")).
You can... |
104,113 | <p>I've been getting a 404 error on a CPT archive page, and am not sure why. I can go to the page set for the custom post type archive, but the next page <code>/mycustomposttype/page/2</code> gets a 404 error. </p>
<p>I don't think that there's anything wrong with my code and I've flushed my permalink rules and I thin... | [
{
"answer_id": 104208,
"author": "tnog",
"author_id": 34098,
"author_profile": "https://wordpress.stackexchange.com/users/34098",
"pm_score": 1,
"selected": false,
"text": "<p>While <code>pre_get_posts</code> is a much better solution for modifying the parameters for the archive main que... | 2013/06/25 | [
"https://wordpress.stackexchange.com/questions/104113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34098/"
] | I've been getting a 404 error on a CPT archive page, and am not sure why. I can go to the page set for the custom post type archive, but the next page `/mycustomposttype/page/2` gets a 404 error.
I don't think that there's anything wrong with my code and I've flushed my permalink rules and I think that the CPT is reg... | While `pre_get_posts` is a much better solution for modifying the parameters for the archive main query for specific conditions like Custom Post Types, as Milo and helgatheviking mentioned, trying to use a custom query to override the main query for an archive is overcomplicating the issue.
Since I'm building a custom... |
104,168 | <p>I'm new to WordPress and the WooCommerce plugin. I'm creating a plugin to change the add to cart button link if it hits a desired stock quantity.</p>
<p>For example if stock qty is above 50, I would like to change the link for special payment. </p>
<p>I've searched for hours in the internet and found no solution o... | [
{
"answer_id": 104245,
"author": "Faison Zutavern",
"author_id": 19651,
"author_profile": "https://wordpress.stackexchange.com/users/19651",
"pm_score": 1,
"selected": false,
"text": "<p>I honestly just figured out how to do most of this today.</p>\n\n<p>To accomplish your goal, you will... | 2013/06/25 | [
"https://wordpress.stackexchange.com/questions/104168",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34527/"
] | I'm new to WordPress and the WooCommerce plugin. I'm creating a plugin to change the add to cart button link if it hits a desired stock quantity.
For example if stock qty is above 50, I would like to change the link for special payment.
I've searched for hours in the internet and found no solution or idea on how to ... | I honestly just figured out how to do most of this today.
To accomplish your goal, you will need to hook into one of the url filters found in **woocommerce/templates/loop/add-to-cart.php** between **lines 30 - 53**, take advantage of the global **$product** variable, and the [**get\_stock\_quantity**](http://docs.woot... |
104,202 | <p>Certain themes don't use the default post class structure in the loop ie</p>
<pre><code><div class="post-100 post type-post status-publish format-standard hentry category-uncategorized">
</code></pre>
<p>Spacing.ca, for example, doesn't use this structure. The posts in their loop use the following tag struct... | [
{
"answer_id": 104203,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 2,
"selected": false,
"text": "<p>We're not magicians ;)</p>\n\n<p>If there is no function call or hook, then there is no way to do thi... | 2013/06/25 | [
"https://wordpress.stackexchange.com/questions/104202",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31714/"
] | Certain themes don't use the default post class structure in the loop ie
```
<div class="post-100 post type-post status-publish format-standard hentry category-uncategorized">
```
Spacing.ca, for example, doesn't use this structure. The posts in their loop use the following tag structure:
```
<div class="post-listi... | We're not magicians ;)
If there is no function call or hook, then there is no way to do this.
(Well, you always can buffer the output and then `preg_replace` it, but I wouldn't use plugin which do something like that). |
104,211 | <p>here is the request : get all post from category=11 (get 21 post), and then in the 21 post got from this category, refilter it, and show only post from category=10. So the request should be : cat=11&10. i what post that are from BOTH category at the same time, because my category are job and active. i what the l... | [
{
"answer_id": 104212,
"author": "tnog",
"author_id": 34098,
"author_profile": "https://wordpress.stackexchange.com/users/34098",
"pm_score": 2,
"selected": true,
"text": "<p>Have you looked up the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters\" rel=\"... | 2013/06/25 | [
"https://wordpress.stackexchange.com/questions/104211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3969/"
] | here is the request : get all post from category=11 (get 21 post), and then in the 21 post got from this category, refilter it, and show only post from category=10. So the request should be : cat=11&10. i what post that are from BOTH category at the same time, because my category are job and active. i what the listing ... | Have you looked up the [WP Codex on WP\_Query for categories](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters)?
They provide an example here. Also your category variable should probably only have one `$`. The way you've written your custom query also looks wrong, are you using WP\_Query?
`$qu... |
104,216 | <p>Like others, I'm having issues with WP adding unwanted p tags in my code. I have a shortcode I created that is to simply just spit out my javascript and html when I use it. Everything works fine except WP is wraping each in p tags. Adding many lines of blank unwanted space.
I have tried the solution here: <a hre... | [
{
"answer_id": 104212,
"author": "tnog",
"author_id": 34098,
"author_profile": "https://wordpress.stackexchange.com/users/34098",
"pm_score": 2,
"selected": true,
"text": "<p>Have you looked up the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters\" rel=\"... | 2013/06/25 | [
"https://wordpress.stackexchange.com/questions/104216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34548/"
] | Like others, I'm having issues with WP adding unwanted p tags in my code. I have a shortcode I created that is to simply just spit out my javascript and html when I use it. Everything works fine except WP is wraping each in p tags. Adding many lines of blank unwanted space.
I have tried the solution here: [Automaticall... | Have you looked up the [WP Codex on WP\_Query for categories](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters)?
They provide an example here. Also your category variable should probably only have one `$`. The way you've written your custom query also looks wrong, are you using WP\_Query?
`$qu... |
104,232 | <p>My question is very simple but I haven't found this answer yet. Here's an example:</p>
<pre><code>class MyClass {
public function __construct(){
add_action('init', array($this, 'init'));
add_action('wp_footer', array($this, 'footer'));
}
public function init(){
add_action('init', array($this, 're... | [
{
"answer_id": 104235,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>You have to use a later (higher) priority. So use <code>current_filter()</code> to get the current hook and priority, ... | 2013/06/25 | [
"https://wordpress.stackexchange.com/questions/104232",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34364/"
] | My question is very simple but I haven't found this answer yet. Here's an example:
```
class MyClass {
public function __construct(){
add_action('init', array($this, 'init'));
add_action('wp_footer', array($this, 'footer'));
}
public function init(){
add_action('init', array($this, 'register_scripts... | You have to use a later (higher) priority. So use `current_filter()` to get the current hook and priority, add 1 to that priority, and register the next action:
```
add_action( 'init', 'func_1' );
function func_1()
{
global $wp_filter;
$hook = current_filter();
add_action( $hook, 'func_2', key( $wp_filte... |
104,248 | <p>I am trying to show a list of custom post types on a page template. When I view the page, instead of seeing the different posts, I see the actual page repeated. For example, If I have 5 posts, the actual page (head content footer) will be display five times. It seems like the query is working...in some way but I am ... | [
{
"answer_id": 104251,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>Refer to the Codex page for <a href=\"https://codex.wordpress.org/Function_Reference/setup_postdata\" rel=\"nofoll... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13096/"
] | I am trying to show a list of custom post types on a page template. When I view the page, instead of seeing the different posts, I see the actual page repeated. For example, If I have 5 posts, the actual page (head content footer) will be display five times. It seems like the query is working...in some way but I am not... | Refer to the Codex page for [`setup_postdata()`](https://codex.wordpress.org/Function_Reference/setup_postdata):
>
> Important: You must make use of the global $post variable to pass the post details into this function, otherwise functions like the\_title() don't work properly...
>
>
>
Also note that you can use ... |
104,278 | <p>Like for example, I have 5 users I want to give permission to comment, but no one else.</p>
<p>But everyone needs to be able to read them. (Publicly viewable)</p>
<p>Like a blog about a show with 5 actors and I only want them to be able to comment on this specific page. This is for a custom page template.</p>
<p>... | [
{
"answer_id": 104293,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 2,
"selected": false,
"text": "<p>If you know the ID of the users who are allowed to comment I don't see why you can't do something like this. </... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104278",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18605/"
] | Like for example, I have 5 users I want to give permission to comment, but no one else.
But everyone needs to be able to read them. (Publicly viewable)
Like a blog about a show with 5 actors and I only want them to be able to comment on this specific page. This is for a custom page template.
I think I could use this... | You can check for a user role. This should work when you put the code into the template above the call to `comments.php`:
```
if ( current_user_can( 'actor' ) ) // or use 'publish_posts'
add_filter( 'comments_open', '__return_true' );
``` |
104,283 | <p>I am using <a href="http://pro.weavertheme.com/" rel="nofollow">Weaver II Pro</a> theme 1.3.8 with WordPress 3.5.2</p>
<p>The theme is very flexible and provides many templates. On individual pages, I can even choose which template to use, which is cool and handy.</p>
<p>Is there a way to assign a particular templ... | [
{
"answer_id": 104293,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 2,
"selected": false,
"text": "<p>If you know the ID of the users who are allowed to comment I don't see why you can't do something like this. </... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104283",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32723/"
] | I am using [Weaver II Pro](http://pro.weavertheme.com/) theme 1.3.8 with WordPress 3.5.2
The theme is very flexible and provides many templates. On individual pages, I can even choose which template to use, which is cool and handy.
Is there a way to assign a particular template for a particular custom post type, e.g.... | You can check for a user role. This should work when you put the code into the template above the call to `comments.php`:
```
if ( current_user_can( 'actor' ) ) // or use 'publish_posts'
add_filter( 'comments_open', '__return_true' );
``` |
104,289 | <p>I cannot get the image from one of my fields into a shortcode.<br>
(it works with <code>get_the_post_thumbnail($post->ID, 'thumbnail')</code> but I need the value from the field <code>udstiller logo</code>.</p>
<pre><code>function logo_shortcode( $atts ) {
extract( shortcode_atts( array(
'limit' =>... | [
{
"answer_id": 104287,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 2,
"selected": false,
"text": "<p>A friend of mine (John Eckman) wrote <a href=\"http://wordpress.org/plugins/wpgplus/\" rel=\"nofollow\">WPGPlus... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34569/"
] | I cannot get the image from one of my fields into a shortcode.
(it works with `get_the_post_thumbnail($post->ID, 'thumbnail')` but I need the value from the field `udstiller logo`.
```
function logo_shortcode( $atts ) {
extract( shortcode_atts( array(
'limit' => '50',
'orderby' => 'name',
),... | Google does not currently have a public API to allow posting to G+ from anywhere other than their web interface. The scripts that currently do so are using the "mobile" interface to do so, and as such are fragile at best. Additionally, they don't work with 2-step verification (which you should enable on your Google acc... |
104,294 | <p>I have a custom loop:</p>
<pre><code>$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$works = new WP_Query('category_name=work&posts_per_page=9&paged=' . $paged);
</code></pre>
<p>Pagination outputs 3 pages, on first there are 9 posts, which is also total number of posts, and on pages 2 an... | [
{
"answer_id": 104296,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>You use your custom <code>WP_Query</code> to query posts, but then in pagination you use global <code>... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34571/"
] | I have a custom loop:
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$works = new WP_Query('category_name=work&posts_per_page=9&paged=' . $paged);
```
Pagination outputs 3 pages, on first there are 9 posts, which is also total number of posts, and on pages 2 and 3 there are no posts (there shou... | You use your custom `WP_Query` to query posts, but then in pagination you use global `$wp_query` variable, which contains different query.
You should use your custom query variable `$works` in your pagination, or change global `$wp_query` variable before your pagination function call.
Since you use universal function... |
104,301 | <p>I have a menu name <code>Social Network</code>. I want to get the menus ID. I tried the following, but didn't succeed.</p>
<pre><code> global $wpdb;
$menu_slug = 'social-network';
$menu_id = $wpdb->get_results(
"
SELECT TERM_ID
FROM $wpdb->wp_terms
WHERE name = ".$menu_slug."
"
);
echo $m... | [
{
"answer_id": 104314,
"author": "Balas",
"author_id": 17849,
"author_profile": "https://wordpress.stackexchange.com/users/17849",
"pm_score": 1,
"selected": false,
"text": "<p>You don't use the right code, use this instead:</p>\n\n<pre><code>global $wpdb;\n\n$tablename = $wpdb->prefi... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33289/"
] | I have a menu name `Social Network`. I want to get the menus ID. I tried the following, but didn't succeed.
```
global $wpdb;
$menu_slug = 'social-network';
$menu_id = $wpdb->get_results(
"
SELECT TERM_ID
FROM $wpdb->wp_terms
WHERE name = ".$menu_slug."
"
);
echo $menu_id;
``` | You can use the function get\_term\_by and use 'name' in the field param.
```
<?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?>
```
Example:
```
$term = get_term_by('name', 'Social Network', 'nav_menu');
$menu_id = $term->term_id;
```
Here is the link to the codex page:
<http://codex.wordpress.... |
104,316 | <p>WordPress doesn't add <code>parent</code> class to menu items that have submenus. Therefore this is required to extend this:</p>
<pre><code>function add_parent_css( $classes, $item ) {
global $have_children;
if( $have_children ) {
$classes[] = 'parent';
}
return $classes;
}
add_filter( 'nav_... | [
{
"answer_id": 104318,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<pre><code>function wpse_104316_nav_menu_css_class( $classes, $item ) {\n if ( ! empty( $item->current_... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104316",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | WordPress doesn't add `parent` class to menu items that have submenus. Therefore this is required to extend this:
```
function add_parent_css( $classes, $item ) {
global $have_children;
if( $have_children ) {
$classes[] = 'parent';
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'add_par... | I'm using the following code to achieve this. Doesn't need any walkers or anything else, just insert this into your functions.php and the items with sub-menu will get "menu-parent-item" added as class.
```
add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
function add_menu_parent_class( $items ) {
$par... |
104,319 | <p>Thank you in advance for your time.</p>
<p>I want to perform the following conditonal <code>if</code>:</p>
<pre><code>if (current user didnt log out and is in the same login session )
{
Do_something;
}
</code></pre>
<p>How to express it using Codex functions? I want to add it to the following <code>if</code> but... | [
{
"answer_id": 104320,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<pre><code>if ( is_user_logged_in() ) {\n echo 'Hello ' . wp_get_current_user()->display_name;\n}\n</co... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104319",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | Thank you in advance for your time.
I want to perform the following conditonal `if`:
```
if (current user didnt log out and is in the same login session )
{
Do_something;
}
```
How to express it using Codex functions? I want to add it to the following `if` but in vain.
```
if (
is_single()
&& !empty($cur... | ```
if ( is_user_logged_in() ) {
echo 'Hello ' . wp_get_current_user()->display_name;
}
``` |
104,324 | <p>I am using <a href="http://wordpress.org/plugins/wp-postviews/" rel="nofollow">WP Post Views</a> plugin to display the post number of views. To do so, I use:</p>
<pre><code><?php if(function_exists('the_views')) { the_views(); } ?>
</code></pre>
<p><strong>The problem is:</strong> The plugin increments the n... | [
{
"answer_id": 104331,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": true,
"text": "<p>Since the plugin author does not offer any actions or filters for us to hook onto, we'll have to settle for... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | I am using [WP Post Views](http://wordpress.org/plugins/wp-postviews/) plugin to display the post number of views. To do so, I use:
```
<?php if(function_exists('the_views')) { the_views(); } ?>
```
**The problem is:** The plugin increments the number of a post views if the user just refreshes the post page. It will... | Since the plugin author does not offer any actions or filters for us to hook onto, we'll have to settle for "listening" to changes to the `views` meta field instead.
```
function wpse_104324_prevent_multiple_views( $meta_id, $object_id, $meta_key, $meta_value ) {
if ( $meta_key === 'views' ) {
if ( ! empty... |
104,327 | <p>I've been looking into wpse archives to solve my problem but I can't manage to do such a thing. I built this code :</p>
<pre><code>$args = array('fields' => 'all_with_meta');
$users = get_users($args);
foreach ($users as $user) {
echo esc_html( translate_user_role( ucfirst ( $user->roles[0] ) ) );
}
</... | [
{
"answer_id": 104332,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p><strike>I think your function nesting is slightly muddled; call <code>ucfirst</code> <em>after</em> transl... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31376/"
] | I've been looking into wpse archives to solve my problem but I can't manage to do such a thing. I built this code :
```
$args = array('fields' => 'all_with_meta');
$users = get_users($args);
foreach ($users as $user) {
echo esc_html( translate_user_role( ucfirst ( $user->roles[0] ) ) );
}
```
I made a `print_... | I think your function nesting is slightly muddled; call `ucfirst` *after* translating, like so:
```
esc_html( ucfirst( translate_user_role( $user->roles[0] ) ) );
```
My bad, completely skipped a beat there. You should instead be using:
```
translate_user_role( $GLOBALS['wp_roles']->role_names[ $user->roles[0] ] );... |
104,335 | <p>I am trying to update the value of an option in the DB for all sites within my multisite, but no success here is the code, been pulling my hair out for the last 2 hours:</p>
<pre><code>function simplifyit_upload_folder($blog_id){
switch_to_blog($blog_id);
update_option('uploads_use_yearmonth_folders', f... | [
{
"answer_id": 104338,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>The field just ends up with an empty value :-(</p>\n</blockquote>\n\n<p>If what you want to ... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34546/"
] | I am trying to update the value of an option in the DB for all sites within my multisite, but no success here is the code, been pulling my hair out for the last 2 hours:
```
function simplifyit_upload_folder($blog_id){
switch_to_blog($blog_id);
update_option('uploads_use_yearmonth_folders', false);
... | Well, "update\_wpmu\_options" is certainly the wrong hook. It doesn't send the blog\_id as a parameter, so your code won't ever work with that hook and use of the blog\_id parameter.
If you just wanted to update the value on each site, then I would just put `update_option('uploads_use_yearmonth_folders', 0);` on the `... |
104,347 | <p>I have just started to read on OAuth as I need to integrate it within a WordPress web app. As per my understanding of OAuth, signed requests are sent between the client and the server. These signed requests are what authenticates a user/client with the server.</p>
<p>WordPress being a stateless application handles ... | [
{
"answer_id": 104374,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": false,
"text": "<p>Okay, after your comments, I think I see what you're asking but I'm not sure, so I'll make it as generic as possib... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9094/"
] | I have just started to read on OAuth as I need to integrate it within a WordPress web app. As per my understanding of OAuth, signed requests are sent between the client and the server. These signed requests are what authenticates a user/client with the server.
WordPress being a stateless application handles authentica... | Okay, after your comments, I think I see what you're asking but I'm not sure, so I'll make it as generic as possible.
WordPress uses the `authenticate` filter hook to perform authentication. You can add additional authentication methods by connecting your own functions to this filter.
This is an example of an authent... |
104,349 | <p>I am pretty new in WordPress world (I came from Joomla)</p>
<p>I am finding some difficulties to insert a logo into this WordPress test site: <a href="http://onofri.org/example/">http://onofri.org/example/</a></p>
<p>I want put my logo in the header of the website, instead the "EXAMPLE" text.</p>
<p>Looking into ... | [
{
"answer_id": 104351,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>If there is a \"logo\" functionality, it will be part of the theme. Perhaps a <a href=\"http://codex.wordpre... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104349",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am pretty new in WordPress world (I came from Joomla)
I am finding some difficulties to insert a logo into this WordPress test site: <http://onofri.org/example/>
I want put my logo in the header of the website, instead the "EXAMPLE" text.
Looking into the WordPress configuration panel I am not finding where I can ... | Try modifying the header section a bit to comply with the standards. Here is what your code right now:
```
<div id="header-image">
<img width="1102" height="350" alt="" class="header-image" src="http://onofri.org/example/wp-content/uploads/2013/06/header1.jpg">
</div>
```
Here is how you can modify the things:
`... |
104,384 | <p>I'm Trying to completely disable WordPress Comments. I have manually disabled comments via the WordPress back-end setting and I also created a new blank file called "no-comments-please.php" and then I added the below to my functions.php. Yet the comments show up in their numbers.</p>
<pre><code>add_filter( 'comment... | [
{
"answer_id": 104388,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 0,
"selected": false,
"text": "<p>Comments can be enabled or disabled for each individual page and post.</p>\n\n<p>The comments setting you've toggl... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104384",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22594/"
] | I'm Trying to completely disable WordPress Comments. I have manually disabled comments via the WordPress back-end setting and I also created a new blank file called "no-comments-please.php" and then I added the below to my functions.php. Yet the comments show up in their numbers.
```
add_filter( 'comments_template', '... | You might as well go the whole nine yards & use [Disable Comments](http://wordpress.org/plugins/disable-comments/). In addition to a complete lock down, the plugin will remove any comment related sections in the admin. |
104,394 | <p>I'm having a difficult time trying to get my custom post types URLs to work correctly. Every solution I find has crippled another part that needs to work. What I am trying to accomplish is <code>domain.com/post_type/post_id/post_name</code>.</p>
<p>What I have that works for everything except archives is:</p>
<pre... | [
{
"answer_id": 104420,
"author": "Chris Wiegman",
"author_id": 34454,
"author_profile": "https://wordpress.stackexchange.com/users/34454",
"pm_score": 0,
"selected": false,
"text": "<p>Have you reset your permalink settings after saving the template file? Before you can use a new permali... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2832/"
] | I'm having a difficult time trying to get my custom post types URLs to work correctly. Every solution I find has crippled another part that needs to work. What I am trying to accomplish is `domain.com/post_type/post_id/post_name`.
What I have that works for everything except archives is:
```
register_post_type('post-... | Your code/solutions is pretty good. You use `slug` param in a very smart way, so WordPress automatically creates correct `permastruct` for this CPT.
The only thing you're missing, I guess, is `has_archive` param. It's default value is `false` and you don't set it to true. So WordPress doesn't create archive links/page... |
104,403 | <p>Does current_time('timestamp') have an issue?</p>
<p>I am trying to get the current_time('timestamp'), and instead of giving me my <strong>current time</strong>: </p>
<pre><code>Jun 26 2013 14:30
</code></pre>
<p>It gives me:</p>
<pre><code>Jun 26 2013 21:30
</code></pre>
<p>I tried to check the seconds, and it... | [
{
"answer_id": 104407,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>The output of <code>current_time('timestamp')</code> should be </p>\n\n<pre><code>time() + ( get_option( 'gmt... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33828/"
] | Does current\_time('timestamp') have an issue?
I am trying to get the current\_time('timestamp'), and instead of giving me my **current time**:
```
Jun 26 2013 14:30
```
It gives me:
```
Jun 26 2013 21:30
```
I tried to check the seconds, and it gives me:
```
1372282238
```
Which is correct for the time giv... | It's a WP non-code programming thinking error.
Under General Settings > Timezone
It should be **set to your own timezone**. |
104,412 | <p>Is it possible to find out which post_type a term_id belongs to? </p>
<p>I have this bit of code to try and collect all possible categories into an array, but I would like to add the post type each category belongs to into the array.</p>
<pre><code>$post_catgegories_objects = get_categories(
array(
'ty... | [
{
"answer_id": 104416,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>You can get the post type that a term's taxonomy is attached to, if that's what you mean.</p>\n\n<pre><code... | 2013/06/26 | [
"https://wordpress.stackexchange.com/questions/104412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2798/"
] | Is it possible to find out which post\_type a term\_id belongs to?
I have this bit of code to try and collect all possible categories into an array, but I would like to add the post type each category belongs to into the array.
```
$post_catgegories_objects = get_categories(
array(
'type' => 'post'... | You can get the post type that a term's taxonomy is attached to, if that's what you mean.
```
$post_type = get_taxonomy( $term->taxonomy )->object_type[0];
``` |
104,419 | <p>I have this little bit of code that sends me an email whenever a new posts is published by an author, but I want to be alerted to posts in 'pending' status by contributors too.</p>
<pre><code>add_action('publish_post', 'send_admin_email');
function send_admin_email($post_id){
$to = 'myemail@email.com';
$sub... | [
{
"answer_id": 104421,
"author": "Chris Wiegman",
"author_id": 34454,
"author_profile": "https://wordpress.stackexchange.com/users/34454",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress has a hook transition_post_status that might help. Take a look at <a href=\"http://blog.joshs... | 2013/06/27 | [
"https://wordpress.stackexchange.com/questions/104419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22450/"
] | I have this little bit of code that sends me an email whenever a new posts is published by an author, but I want to be alerted to posts in 'pending' status by contributors too.
```
add_action('publish_post', 'send_admin_email');
function send_admin_email($post_id){
$to = 'myemail@email.com';
$subject = 'New Po... | There a couple of ways you can go about it depending on your use case and although example number 1 is perfectly valid, it might make more sense to employ the use of example number 2.
Example #1:
-----------
This will send you an email each time a post is updated/published with the status of "pending". This will also... |
104,442 | <p>I want to get option to change logo within my option theme. I use this code:</p>
<pre><code> array("name" => "Upload Logo",
"desc" => "Choose an image",
"id" => $shortname."_logo_img",
"type" => "upload",
"std" => "",
),
</code></pre>
<p>when I execute on my theme option page, not... | [
{
"answer_id": 104448,
"author": "Adi",
"author_id": 27912,
"author_profile": "https://wordpress.stackexchange.com/users/27912",
"pm_score": 0,
"selected": false,
"text": "<p>If using image radio buttons, define a directory path here is code. I hope its going work.</p>\n\n<pre><code>$ima... | 2013/06/27 | [
"https://wordpress.stackexchange.com/questions/104442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34615/"
] | I want to get option to change logo within my option theme. I use this code:
```
array("name" => "Upload Logo",
"desc" => "Choose an image",
"id" => $shortname."_logo_img",
"type" => "upload",
"std" => "",
),
```
when I execute on my theme option page, nothing appear. I change that type to "file"... | If using image radio buttons, define a directory path here is code. I hope its going work.
```
$imagepath = get_template_directory_uri() . '/images/';
$options = array();
$options[] = array( "name" => __('Logo', 'prothemeus'),
"desc" => __('Upload your logo', 'prothemeus'),
... |
104,456 | <p>I have a filter that filters posts from the main loop depending on a user role (handled externally)</p>
<p>The meta data is entered when adding a post/page.</p>
<p>This is the filter - it works for filtering posts from the main page loops and the search pages but <strong>sticky posts</strong> are ignored and will ... | [
{
"answer_id": 104463,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": true,
"text": "<p>You might try</p>\n\n<pre><code>$query->set( 'ignore_sticky_posts', 1 );\n</code></pre>\n\n<p>to stop the s... | 2013/06/27 | [
"https://wordpress.stackexchange.com/questions/104456",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33888/"
] | I have a filter that filters posts from the main loop depending on a user role (handled externally)
The meta data is entered when adding a post/page.
This is the filter - it works for filtering posts from the main page loops and the search pages but **sticky posts** are ignored and will show regardless of user role. ... | You might try
```
$query->set( 'ignore_sticky_posts', 1 );
```
to stop the sticky posts from being prepended. |