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
164,059
<p>I just created a child theme but every change I make in the style.css does not overwrite the parent style.css - other files work. I just did it like that:</p> <ol> <li>Making new Childtheme Folder in the Theme Directory</li> <li>Copy original style.css to it.</li> <li>Add to its header "Template: orion"</li> <li>Se...
[ { "answer_id": 164063, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 0, "selected": false, "text": "<p>Make sure your parent theme does not use wp_enqueue_style() in its functions.php file.</p>\n\n<p>If it does...
2014/10/10
[ "https://wordpress.stackexchange.com/questions/164059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60938/" ]
I just created a child theme but every change I make in the style.css does not overwrite the parent style.css - other files work. I just did it like that: 1. Making new Childtheme Folder in the Theme Directory 2. Copy original style.css to it. 3. Add to its header "Template: orion" 4. Selected and activated my childth...
It should be noted that the child stylesheet loads **after** the parent theme's styles, so this should not be a problem. I think what is happening here is that you are trying to change styles that is not in the the parent stylesheet, but in other custom stylesheets. If that is the case, then your changes won't work as ...
164,064
<p>I found some instructions on encrypting an options field for a plugin <a href="https://wordpress.stackexchange.com/questions/25062/how-to-store-username-and-password-to-api-in-wordpress-option-db">here</a>, using:</p> <pre><code>encrypt($input_string, $key){ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT...
[ { "answer_id": 164063, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 0, "selected": false, "text": "<p>Make sure your parent theme does not use wp_enqueue_style() in its functions.php file.</p>\n\n<p>If it does...
2014/10/10
[ "https://wordpress.stackexchange.com/questions/164064", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48604/" ]
I found some instructions on encrypting an options field for a plugin [here](https://wordpress.stackexchange.com/questions/25062/how-to-store-username-and-password-to-api-in-wordpress-option-db), using: ``` encrypt($input_string, $key){ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_...
It should be noted that the child stylesheet loads **after** the parent theme's styles, so this should not be a problem. I think what is happening here is that you are trying to change styles that is not in the the parent stylesheet, but in other custom stylesheets. If that is the case, then your changes won't work as ...
164,087
<p><strong>Here's a brief outline of the set-up:</strong></p> <p>"The Art" CPT is where all the art and art descriptions are uploaded. In this CPT you can choose the category (custom taxonomy) of the art--painting, jewelry, sculpture, etc. This allows me to have a page that displays all the art that's filterable with ...
[ { "answer_id": 164063, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 0, "selected": false, "text": "<p>Make sure your parent theme does not use wp_enqueue_style() in its functions.php file.</p>\n\n<p>If it does...
2014/10/10
[ "https://wordpress.stackexchange.com/questions/164087", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7662/" ]
**Here's a brief outline of the set-up:** "The Art" CPT is where all the art and art descriptions are uploaded. In this CPT you can choose the category (custom taxonomy) of the art--painting, jewelry, sculpture, etc. This allows me to have a page that displays all the art that's filterable with Isotope. I'm also shari...
It should be noted that the child stylesheet loads **after** the parent theme's styles, so this should not be a problem. I think what is happening here is that you are trying to change styles that is not in the the parent stylesheet, but in other custom stylesheets. If that is the case, then your changes won't work as ...
164,089
<p>I am trying to rebuild my inline posts counting to a function. What would be the best way to do that? Here is my inline code: </p> <pre><code>$posts = get_posts('post_type=myposttype&amp;customtaxonomy=mytax&amp;posts_per_page=-1'); $posts_count = count($posts); echo $posts_count; </code></pre> <p>In my <code>...
[ { "answer_id": 164094, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 1, "selected": false, "text": "<p>In your function, you have this line:</p>\n\n<pre><code>$mytaxonomy = get_posts('post_type=myposttype&amp;$cu...
2014/10/10
[ "https://wordpress.stackexchange.com/questions/164089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48915/" ]
I am trying to rebuild my inline posts counting to a function. What would be the best way to do that? Here is my inline code: ``` $posts = get_posts('post_type=myposttype&customtaxonomy=mytax&posts_per_page=-1'); $posts_count = count($posts); echo $posts_count; ``` In my `functions.php` I tried this: ``` func...
You have a couple of problems with your code * `customtaxonomy=$mytaxonomy` is incorrect. First of all, there is no parameter called `customtaxonomy` in `get_posts`. Secondly, your syntaxing is wrong. If you make use of a varaible, your syntaxing should look like this ``` 'post_type=myposttype&customtaxonomy=' . $my...
164,096
<p>I am using woocommerce as a shopping cart on a wordpress site. Products and Product Variations are each stored as records in the wp_posts table. Each of these Variations have aprox. 15-20 associated records in wp_postmeta (to store various details about that product, such as SKU or price).</p> <p>What I've discov...
[ { "answer_id": 190882, "author": "Ben G", "author_id": 35979, "author_profile": "https://wordpress.stackexchange.com/users/35979", "pm_score": -1, "selected": false, "text": "<p>You just need to do a <code>RIGHT JOIN</code> to query the rows that have <code>NULL</code> values</p>\n" },...
2014/10/10
[ "https://wordpress.stackexchange.com/questions/164096", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60959/" ]
I am using woocommerce as a shopping cart on a wordpress site. Products and Product Variations are each stored as records in the wp\_posts table. Each of these Variations have aprox. 15-20 associated records in wp\_postmeta (to store various details about that product, such as SKU or price). What I've discovered is ...
A different way of doing this (not better, but easier to follow) would be: ``` DELETE * FROM wp_postmeta WHERE post_id NOT IN (SELECT ID FROM wp_posts) ``` Obviously changing the prefixes from 'wp\_' to whatever your setup uses
164,098
<p>I'm working on an integration between an outside app (which needs to pull user names and some taxonomy data, and create new posts) and a WordPress site. I'm running the latest build of WP (4.0).</p> <p>The XML-RPC documentation being as spare as it is, I'm hoping someone out there can just pastebin a recent (2014?)...
[ { "answer_id": 164101, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<p>How complex do you want the example to be?</p>\n\n<p>This outputs \"Hello\".</p>\n\n<pre><code>$client = new WP_HT...
2014/10/10
[ "https://wordpress.stackexchange.com/questions/164098", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60961/" ]
I'm working on an integration between an outside app (which needs to pull user names and some taxonomy data, and create new posts) and a WordPress site. I'm running the latest build of WP (4.0). The XML-RPC documentation being as spare as it is, I'm hoping someone out there can just pastebin a recent (2014?) working e...
Okay, I was being stupid, so I stopped that. I'd assumed that a) any answer older than two years would be out-of-date; b) I'd need a special WP flavor of the base IXR library; I was confused, and took the sparseness of the wp.org documentation as "they're not telling the whole story" instead of "the tool is very basic...
164,131
<p>I'm trying to create a simple contact form using jQuery to validate the form and AJAX to pass it to PHP and WP <code>wp_mail()</code> to send it.</p> <p>I have a simple form like this.</p> <pre><code> &lt;form role="form"&gt; &lt;div class="form-group"&gt; &lt;label class=""&gt;Name&lt;/labe...
[ { "answer_id": 164133, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>From quick look at your code you seem to be omitting <em>where</em> you are submitting request to. By default it is...
2014/10/11
[ "https://wordpress.stackexchange.com/questions/164131", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17373/" ]
I'm trying to create a simple contact form using jQuery to validate the form and AJAX to pass it to PHP and WP `wp_mail()` to send it. I have a simple form like this. ``` <form role="form"> <div class="form-group"> <label class="">Name</label> <input type="text" id="name" class="fo...
From quick look at your code you seem to be omitting *where* you are submitting request to. By default it is just current page, which isn't typically equipped to receive the request. Since you are using `wp_ajax_` hook you need to point request at `admin-ajax.php` endpoint. On admin side the URL is provided in `ajaxur...
164,143
<p>I have this function to set the title of a wordpress post which works properly for saving / updating posts. The major issue is that the function stops posts being deleted (it removes the title but the post still exists).</p> <p>Is there a way to identify if the action is a delete post rather than save / update post...
[ { "answer_id": 164144, "author": "Philip Light", "author_id": 28338, "author_profile": "https://wordpress.stackexchange.com/users/28338", "pm_score": 1, "selected": false, "text": "<p>Not sure, but seems maybe $data['post_status'] would be set to 'trash' at that point. If so, then you c...
2014/10/11
[ "https://wordpress.stackexchange.com/questions/164143", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57534/" ]
I have this function to set the title of a wordpress post which works properly for saving / updating posts. The major issue is that the function stops posts being deleted (it removes the title but the post still exists). Is there a way to identify if the action is a delete post rather than save / update post and obvio...
Not sure, but seems maybe $data['post\_status'] would be set to 'trash' at that point. If so, then you could just do something like... ``` if ($data['post_status'] == 'trash') { return $data; } ``` ...before the other manipulations. **EDIT** That code should work then - but needs to be at top of the function, like...
164,147
<p>I followed <a href="http://efeqdev.com/website-development/this-is-how-we-version-control-and-deploy-our-wordpress-websites-with-git/" rel="nofollow">this</a> guide on how to set up a WordPress installation that is optimized for git deployment.</p> <p>Basically, WordPress is moved into a subfolder called <code>word...
[ { "answer_id": 192227, "author": "Nouniz", "author_id": 75043, "author_profile": "https://wordpress.stackexchange.com/users/75043", "pm_score": 0, "selected": false, "text": "<p>you must define path to current site like this : </p>\n\n<pre><code>define('PATH_CURRENT_SITE', '/wordpress/')...
2014/10/11
[ "https://wordpress.stackexchange.com/questions/164147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12580/" ]
I followed [this](http://efeqdev.com/website-development/this-is-how-we-version-control-and-deploy-our-wordpress-websites-with-git/) guide on how to set up a WordPress installation that is optimized for git deployment. Basically, WordPress is moved into a subfolder called `wordpress`, `index.php` and `wp-config.php` a...
`network admin_url` filter can rewrite network admin url. But i don't know it is a best way or not. ```js // wp-config.php /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php'); // add code // define('__WORDPRESS_CORE_DIR__', '/wordpress'); add_filter('network_admin_url', 're...
164,153
<p>At this point I have tried everything I know to fix the issue.</p> <p>Issue: preview only works right after a custom posts is loaded or updated. If you make any changes or hit preview twice without updating the preview 404s. Pages and blog post do not 404 the previews.</p> <p>We were using the ACF and CPUI plugins...
[ { "answer_id": 290154, "author": "Mario Melchor", "author_id": 118793, "author_profile": "https://wordpress.stackexchange.com/users/118793", "pm_score": 0, "selected": false, "text": "<p>I had the same issue. I was using CPT UI and ACF. To resolve the issue i went into CPT UI > Edit Post...
2014/10/11
[ "https://wordpress.stackexchange.com/questions/164153", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45947/" ]
At this point I have tried everything I know to fix the issue. Issue: preview only works right after a custom posts is loaded or updated. If you make any changes or hit preview twice without updating the preview 404s. Pages and blog post do not 404 the previews. We were using the ACF and CPUI plugins and roots theme....
One of the parameter that you can pass to the `supports` argument is `post_formats`, removing this argument will fix the problem with the preview redirecting to a wrong or non-existing url. Code sample: ``` if ( ! function_exists('custom_post_type') ) { // Register Custom Post Type function custom_post_ty...
165,184
<p>When trying to upload media to my Wordpress 4.0 running on a shared Apache 2.2.14, PHP 5.3.2 host, I get the error message "Missing a temporary folder". I have no influence over the <code>php.ini</code> which is globally managed by the host and outside my <code>html</code> folder.</p> <p>I set the <code>WP_TEMP_DIR...
[ { "answer_id": 165195, "author": "angoru", "author_id": 60927, "author_profile": "https://wordpress.stackexchange.com/users/60927", "pm_score": 3, "selected": false, "text": "<p>try to use </p>\n\n<pre><code>get_temp_dir() \n</code></pre>\n\n<p>to see if wordpress is using your WP_TEMP_D...
2014/10/12
[ "https://wordpress.stackexchange.com/questions/165184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29065/" ]
When trying to upload media to my Wordpress 4.0 running on a shared Apache 2.2.14, PHP 5.3.2 host, I get the error message "Missing a temporary folder". I have no influence over the `php.ini` which is globally managed by the host and outside my `html` folder. I set the `WP_TEMP_DIR` in `wp-config.php`. Here is the rel...
try to use ``` get_temp_dir() ``` to see if wordpress is using your WP\_TEMP\_DIR constant. i've tried this code in wp-config.php and it works ``` define('WP_TEMP_DIR', dirname(__FILE__) . '/wp-content/temp/'); ``` but you have to put it before the ``` /* That's all, stop editing! Happy blogging. */ ``` in...
165,192
<p>The canonical link element isn't set for all pages. For example, if I look at the source code for a post, I can see the following in the <code>&lt;head&gt;</code>:</p> <pre><code>&lt;link rel='canonical' href='http://example.com/post-name/' /&gt; </code></pre> <p>However, if I look at the source code for an author...
[ { "answer_id": 165195, "author": "angoru", "author_id": 60927, "author_profile": "https://wordpress.stackexchange.com/users/60927", "pm_score": 3, "selected": false, "text": "<p>try to use </p>\n\n<pre><code>get_temp_dir() \n</code></pre>\n\n<p>to see if wordpress is using your WP_TEMP_D...
2014/10/12
[ "https://wordpress.stackexchange.com/questions/165192", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22599/" ]
The canonical link element isn't set for all pages. For example, if I look at the source code for a post, I can see the following in the `<head>`: ``` <link rel='canonical' href='http://example.com/post-name/' /> ``` However, if I look at the source code for an author archive page, I don't see the link element. Why...
try to use ``` get_temp_dir() ``` to see if wordpress is using your WP\_TEMP\_DIR constant. i've tried this code in wp-config.php and it works ``` define('WP_TEMP_DIR', dirname(__FILE__) . '/wp-content/temp/'); ``` but you have to put it before the ``` /* That's all, stop editing! Happy blogging. */ ``` in...
165,197
<p>Inside my plugin I'm adding the Advanced Custom Fields files. Part of including it in the plugin is changing the default directories using <code>dirname(__FILE__)</code>. </p> <p>In step 3, <code>include_once</code> works fine. So, ACF works, but without stylesheets or scripts, because in steps 1 and 2, I get the f...
[ { "answer_id": 165255, "author": "Mark Rummel", "author_id": 14190, "author_profile": "https://wordpress.stackexchange.com/users/14190", "pm_score": 2, "selected": true, "text": "<p>I resolved the issue by using <code>$dir = plugins_url() . '/simple/acf/';</code> in step 2. I kept everyt...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165197", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14190/" ]
Inside my plugin I'm adding the Advanced Custom Fields files. Part of including it in the plugin is changing the default directories using `dirname(__FILE__)`. In step 3, `include_once` works fine. So, ACF works, but without stylesheets or scripts, because in steps 1 and 2, I get the following for the stylesheets and...
I resolved the issue by using `$dir = plugins_url() . '/simple/acf/';` in step 2. I kept everything else the same. ``` // 2. Customize ACF dir add_filter('acf/settings/dir', 'my_acf_settings_dir'); function my_acf_settings_dir( $dir ) { // update path $dir = plugins_url() . '/simple/acf/'; // return return ...
165,203
<pre><code>query_posts($query_string . '&amp;meta_value=pro&amp;orderby=rand'); </code></pre> <p>I get pro list with random, but I want <code>pro</code> as well as free, but with <code>pro</code> list first, then <code>meta_value</code> <code>free</code> list. </p> <p>I also set <code>orderby</code> <code>meta_value<...
[ { "answer_id": 165211, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>You need to query by the <code>meta_key</code> instead of <code>meta_value</code>:</p>\n\n<pre><code> $que...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62017/" ]
``` query_posts($query_string . '&meta_value=pro&orderby=rand'); ``` I get pro list with random, but I want `pro` as well as free, but with `pro` list first, then `meta_value` `free` list. I also set `orderby` `meta_value` ``` query_posts($query_string . '&orderby=meta_value_num'); ``` This does not work, an...
Before I fire away, just one note, **NEVER** (my emphasis) make use of [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) to create custom queries > > **Note:** This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the...
165,228
<p>I used the custom Structure <code>/blog/%category%/%postname%/</code> for blog. also i have a custom post type named 'FAQ' while viewing the faq posts, it is showing the <code>/blog/faq/%faq_category%/%postname%/</code>. When I'm using the <code>['with_front' =&gt; false]</code> the paged URLs ('Old entries' and 'Ne...
[ { "answer_id": 165229, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>This can be set in a plugins' options if you're using a plugin to generate a Custom Post Type (such as CPT UI).</...
2014/09/22
[ "https://wordpress.stackexchange.com/questions/165228", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64365/" ]
I used the custom Structure `/blog/%category%/%postname%/` for blog. also i have a custom post type named 'FAQ' while viewing the faq posts, it is showing the `/blog/faq/%faq_category%/%postname%/`. When I'm using the `['with_front' => false]` the paged URLs ('Old entries' and 'New entries' links) `http://www.example.c...
This can be set in a plugins' options if you're using a plugin to generate a Custom Post Type (such as CPT UI). Otherwise if you've created this post type in the functions.php file you should amend or add to your your code as follows: ``` 'with_front' => false ``` i.e. if your permalink structure appears as: ``` y...
165,233
<p>I want to get list of 5 recent posts from a subdomain (not multisite) to show on our main domain. Following is the code am trying to execute, but is giving the error - Invalid arguments supplied in foreach()</p> <pre><code>global $wpdb; $second_db = new wpdb('user','pass','db','localhost'); $rows = $second_db-&gt;g...
[ { "answer_id": 165254, "author": "Justin Bell", "author_id": 60176, "author_profile": "https://wordpress.stackexchange.com/users/60176", "pm_score": 2, "selected": false, "text": "<p>I'm looking at <a href=\"https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/wp-db.php#L0\" ...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165233", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19409/" ]
I want to get list of 5 recent posts from a subdomain (not multisite) to show on our main domain. Following is the code am trying to execute, but is giving the error - Invalid arguments supplied in foreach() ``` global $wpdb; $second_db = new wpdb('user','pass','db','localhost'); $rows = $second_db->get_results('SELEC...
I'm looking at [wp-db.php](https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/wp-db.php#L0) and see: ``` 1384 if ( $this->dbh->connect_errno ) { 1385 $this->dbh = null; ``` This is in the class function `db_connect()`, which is called by the...
165,239
<p>I am struggling with this little problem. I have a user profile page and I want to change some of the content based on whether it is my own profile og someone elses. This is my code to add a shortcode which eventually will call other shortcodes.</p> <pre><code>function is_mine_func() { if (is_author() ) { echo ...
[ { "answer_id": 165254, "author": "Justin Bell", "author_id": 60176, "author_profile": "https://wordpress.stackexchange.com/users/60176", "pm_score": 2, "selected": false, "text": "<p>I'm looking at <a href=\"https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/wp-db.php#L0\" ...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165239", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62046/" ]
I am struggling with this little problem. I have a user profile page and I want to change some of the content based on whether it is my own profile og someone elses. This is my code to add a shortcode which eventually will call other shortcodes. ``` function is_mine_func() { if (is_author() ) { echo 'it is my site...
I'm looking at [wp-db.php](https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/wp-db.php#L0) and see: ``` 1384 if ( $this->dbh->connect_errno ) { 1385 $this->dbh = null; ``` This is in the class function `db_connect()`, which is called by the...
165,249
<p>I use wordpress a lot, i develop for it a lot too!</p> <p>I have a client website that i have added 10 custom meta boxes to the post edit screen in functions.php . All the meta boxes have an editor using wp_editor()</p> <p>This all worked find in wordpress 3.8 and 3.9 but now the site has been upgraded to wordpres...
[ { "answer_id": 167171, "author": "Ambulare", "author_id": 62901, "author_profile": "https://wordpress.stackexchange.com/users/62901", "pm_score": 0, "selected": false, "text": "<p>Just in case anyone else is having this problem, I've found that a pretty reliable way to get your visual ed...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62051/" ]
I use wordpress a lot, i develop for it a lot too! I have a client website that i have added 10 custom meta boxes to the post edit screen in functions.php . All the meta boxes have an editor using wp\_editor() This all worked find in wordpress 3.8 and 3.9 but now the site has been upgraded to wordpress 4 the editor i...
Yes as per @Nibbr Web Development, TinyMCE editor IDs cannot have brackets. Which is the html field ID, so what we will do is create a different but similiar name for the ID attribute and still use our desired name in for the text area field name, like so. ``` $content = $options['textareafield']; // editor_id cannot ...
165,251
<p>I have a form which does</p> <pre><code>&lt;form method="post" action="options.php"&gt; ......... &lt;input type="submit" class="button-primary" value="&lt;?php _e( 'Save changes', 'bsp_style_settings' ); ?&gt;" /&gt; </code></pre> <p>I have all the register settings/admin_init's etc. and it all works fine and sav...
[ { "answer_id": 167171, "author": "Ambulare", "author_id": 62901, "author_profile": "https://wordpress.stackexchange.com/users/62901", "pm_score": 0, "selected": false, "text": "<p>Just in case anyone else is having this problem, I've found that a pretty reliable way to get your visual ed...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165251", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62054/" ]
I have a form which does ``` <form method="post" action="options.php"> ......... <input type="submit" class="button-primary" value="<?php _e( 'Save changes', 'bsp_style_settings' ); ?>" /> ``` I have all the register settings/admin\_init's etc. and it all works fine and saves the data to WP\_Options part of the data...
Yes as per @Nibbr Web Development, TinyMCE editor IDs cannot have brackets. Which is the html field ID, so what we will do is create a different but similiar name for the ID attribute and still use our desired name in for the text area field name, like so. ``` $content = $options['textareafield']; // editor_id cannot ...
165,259
<p>I am attempting to delete a row from my DB.I am using inputs from the user and I need to be able to sanitize using the prepared statement.</p> <p>The query itself looks like - </p> <pre><code>DELETE FROM wp_thing_assignment WHERE (account_number,user) values (1, 'DudeDev') </code></pre> <p>I am using the followin...
[ { "answer_id": 167171, "author": "Ambulare", "author_id": 62901, "author_profile": "https://wordpress.stackexchange.com/users/62901", "pm_score": 0, "selected": false, "text": "<p>Just in case anyone else is having this problem, I've found that a pretty reliable way to get your visual ed...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165259", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26841/" ]
I am attempting to delete a row from my DB.I am using inputs from the user and I need to be able to sanitize using the prepared statement. The query itself looks like - ``` DELETE FROM wp_thing_assignment WHERE (account_number,user) values (1, 'DudeDev') ``` I am using the following code - ``` $success = $th...
Yes as per @Nibbr Web Development, TinyMCE editor IDs cannot have brackets. Which is the html field ID, so what we will do is create a different but similiar name for the ID attribute and still use our desired name in for the text area field name, like so. ``` $content = $options['textareafield']; // editor_id cannot ...
165,263
<p>So, on my wordpress site I have page called "Books" and sub-pages, each containing info about some book. </p> <p>It looks something like this:</p> <ul> <li>Books <ul> <li>Harry Potter, J.K.Rowling</li> <li>Some Other Book, Who WroteIt</li> <li>Some Other Book, Who WroteIt</li> <li>Some Other Book, Who WroteIt</li...
[ { "answer_id": 165269, "author": "RachieVee", "author_id": 42783, "author_profile": "https://wordpress.stackexchange.com/users/42783", "pm_score": 1, "selected": false, "text": "<p>Assuming that you're on a page template or a custom page template, the first thing you want to do is grab t...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165263", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62060/" ]
So, on my wordpress site I have page called "Books" and sub-pages, each containing info about some book. It looks something like this: * Books + Harry Potter, J.K.Rowling + Some Other Book, Who WroteIt + Some Other Book, Who WroteIt + Some Other Book, Who WroteIt What I want to do is create custom page template...
Assuming that you're on a page template or a custom page template, the first thing you want to do is grab the current page ID, then use that ID to grab the children. Once you have the children, display the content for those children. Try using [get\_children();](http://codex.wordpress.org/Function_Reference/get_childr...
165,265
<p>I am using wordpress 3.9.1 for one of the website. I am getting slow response around 35 seconds. I did investigation &amp; found that <code>wp_head</code> is taking too much time. Further, I debug &amp; found that a function inside wp-includes/plugin.php is causing it:</p> <pre><code>function do_action($tag, $arg =...
[ { "answer_id": 165278, "author": "Radley Sustaire", "author_id": 19105, "author_profile": "https://wordpress.stackexchange.com/users/19105", "pm_score": 3, "selected": true, "text": "<p>Well, <code>do_action()</code> is in plugin.php for a reason. It's intended for use by plugins, just l...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165265", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60532/" ]
I am using wordpress 3.9.1 for one of the website. I am getting slow response around 35 seconds. I did investigation & found that `wp_head` is taking too much time. Further, I debug & found that a function inside wp-includes/plugin.php is causing it: ``` function do_action($tag, $arg = '') { global $wp_filter, $wp...
Well, `do_action()` is in plugin.php for a reason. It's intended for use by plugins, just like `apply_filters()`. This function is not the cause, it is just the middleman. It's like saying your pizza tastes bad because of the delivery guy - instead of the restaurant itself. This is almost certainly caused by a plugin....
165,277
<p>When trying to create a new blog post, Wordpress is showing a Database error:</p> <pre><code> WordPress database error Duplicate entry '0' for key 'PRIMARY' for query INSERT INTO `wp_posts` (`post_author`,`post_date`,`post_date_gmt`,`post_content`,`post_content_filtered`,`post_title`,`post_excerpt`,`post_status`,`p...
[ { "answer_id": 165280, "author": "Radley Sustaire", "author_id": 19105, "author_profile": "https://wordpress.stackexchange.com/users/19105", "pm_score": 3, "selected": true, "text": "<p>This is only my best guess. I can't see a definitive answer with the information provided.</p>\n\n<hr>...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165277", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62057/" ]
When trying to create a new blog post, Wordpress is showing a Database error: ``` WordPress database error Duplicate entry '0' for key 'PRIMARY' for query INSERT INTO `wp_posts` (`post_author`,`post_date`,`post_date_gmt`,`post_content`,`post_content_filtered`,`post_title`,`post_excerpt`,`post_status`,`post_type`,`com...
This is only my best guess. I can't see a definitive answer with the information provided. --- The primary key for `wp_posts` should be set to `ID`. The primary key is giving the error. Since `ID` is not defined in the query, it is likely that the `AUTO_INCREMENT` value has been set to 0, or is no longer incrementing...
165,286
<p>I use AngularJS to build an AJAX form which is then processed on a server running Wordpress.</p> <p>Server-side handler is simple:</p> <pre><code>function rnr_contact_callback() { $name = $_POST['firstName'] . ' ' . $_POST['lastName']; wp_mail( 'myname@gmail.com', 'Contact form submitted',...
[ { "answer_id": 165287, "author": "rishat", "author_id": 62059, "author_profile": "https://wordpress.stackexchange.com/users/62059", "pm_score": 3, "selected": true, "text": "<p>I got it. I just should have used <code>$_REQUEST</code> instead of <code>$_POST</code> within every function w...
2014/10/13
[ "https://wordpress.stackexchange.com/questions/165286", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62059/" ]
I use AngularJS to build an AJAX form which is then processed on a server running Wordpress. Server-side handler is simple: ``` function rnr_contact_callback() { $name = $_POST['firstName'] . ' ' . $_POST['lastName']; wp_mail( 'myname@gmail.com', 'Contact form submitted', $name . '(' ...
I got it. I just should have used `$_REQUEST` instead of `$_POST` within every function which handles AJAX requests.
165,324
<p>I'm trying to fix a theme which has the following setup: on each page the user can select to list posts instead of the page content. The problem is that the pagination doesn't work on this page even thou the same functions works fine on the main query (on homepage). When I say that the pagination doesn't work I mean...
[ { "answer_id": 165373, "author": "George Grigorita", "author_id": 13214, "author_profile": "https://wordpress.stackexchange.com/users/13214", "pm_score": 0, "selected": false, "text": "<p>The solution: </p>\n\n<pre><code>&lt;?php // building query\n $zephyr_cat = get_post_meta($post-&...
2014/10/14
[ "https://wordpress.stackexchange.com/questions/165324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13214/" ]
I'm trying to fix a theme which has the following setup: on each page the user can select to list posts instead of the page content. The problem is that the pagination doesn't work on this page even thou the same functions works fine on the main query (on homepage). When I say that the pagination doesn't work I mean th...
The solution: ``` <?php // building query $zephyr_cat = get_post_meta($post->ID, 'zephyr_category', true); $paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' ); if ( $zephyr_cat == 0 ) { $zephyr_q = new WP_query('posts_per_page='.get_option('posts_per_page') . '&paged=' ....
165,357
<p>I've seen different ways of doing making a text with a hyperlink translatable. However, I have been unable to find a single best practice.</p> <p>So, here are some of the solutions I found:</p> <pre><code>// METHOD 1 sprintf( __( 'Please read %1$sthis%2$s.', 'tacoverdo-example-domain' ), '&lt;a target="_blank" hre...
[ { "answer_id": 165361, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>You have to keep the markup in the translatable string, because the translators have to <strong>know</strong> there i...
2014/10/14
[ "https://wordpress.stackexchange.com/questions/165357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62095/" ]
I've seen different ways of doing making a text with a hyperlink translatable. However, I have been unable to find a single best practice. So, here are some of the solutions I found: ``` // METHOD 1 sprintf( __( 'Please read %1$sthis%2$s.', 'tacoverdo-example-domain' ), '<a target="_blank" href="' . esc_url( 'https:/...
This is a very faceted issue. It combines inherent HTML content issues with whole new load of translation challenges, such as scanning for strings, translation process itself, and its verification. So we have to combine: 1. Text (in translatable form) 2. HTML markup (in hard to break, but preferably flexible form) 3....
165,367
<p>I have been teetering back and forth on this question for a while and after a recent battle with TinyMCE, I wanted to get some input.</p> <p>If I am creating very different pages with unique javascript interactions, css, and markup/content is it best to create a single "blank" base template to use as a canvas with ...
[ { "answer_id": 165361, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>You have to keep the markup in the translatable string, because the translators have to <strong>know</strong> there i...
2014/10/14
[ "https://wordpress.stackexchange.com/questions/165367", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62104/" ]
I have been teetering back and forth on this question for a while and after a recent battle with TinyMCE, I wanted to get some input. If I am creating very different pages with unique javascript interactions, css, and markup/content is it best to create a single "blank" base template to use as a canvas with which I ca...
This is a very faceted issue. It combines inherent HTML content issues with whole new load of translation challenges, such as scanning for strings, translation process itself, and its verification. So we have to combine: 1. Text (in translatable form) 2. HTML markup (in hard to break, but preferably flexible form) 3....
165,374
<p>I'm trying to use the front page as a default of sorts for featured images (if no featured image is set, I want to use the front page's, for example)</p> <p>But I'm having trouble finding out how to get the post ID of the front page in a safe manner (so that my code still works when the front page is inevitably cha...
[ { "answer_id": 165375, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 4, "selected": false, "text": "<p>You should be able to use <code>$front_page_id = get_option( 'page_on_front' );</code></p>\n\n<p>It'll return t...
2014/10/14
[ "https://wordpress.stackexchange.com/questions/165374", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62107/" ]
I'm trying to use the front page as a default of sorts for featured images (if no featured image is set, I want to use the front page's, for example) But I'm having trouble finding out how to get the post ID of the front page in a safe manner (so that my code still works when the front page is inevitably changed by so...
WordPress has a few useful options. You can get the homepage ID by using the following: ``` $frontpage_id = get_option( 'page_on_front' ); ``` or the blog ID by using: ``` $blog_id = get_option( 'page_for_posts' ); ``` [Here's a list of many useful `get_option` parameters](http://codex.wordpress.org/Option_Refere...
165,392
<p>I have a custom page template with the following query. Isotope filers my categories and all this works fine. I want now to make this page only viewable by a few <strong>specific</strong>, <strong>currently logged in authors</strong>. <em>Example: Posts are only visible to an author with one of these ID's (1,2 or 3...
[ { "answer_id": 165375, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 4, "selected": false, "text": "<p>You should be able to use <code>$front_page_id = get_option( 'page_on_front' );</code></p>\n\n<p>It'll return t...
2014/10/14
[ "https://wordpress.stackexchange.com/questions/165392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41410/" ]
I have a custom page template with the following query. Isotope filers my categories and all this works fine. I want now to make this page only viewable by a few **specific**, **currently logged in authors**. *Example: Posts are only visible to an author with one of these ID's (1,2 or 3) and are logged in.* ``` <u...
WordPress has a few useful options. You can get the homepage ID by using the following: ``` $frontpage_id = get_option( 'page_on_front' ); ``` or the blog ID by using: ``` $blog_id = get_option( 'page_for_posts' ); ``` [Here's a list of many useful `get_option` parameters](http://codex.wordpress.org/Option_Refere...
165,401
<p>I am trying to figure out how to display the categories in a specific order. Let's say my category IDs are in the following order: 1,3,4,2,5</p> <p>I want to display the categories in that sequence. Here is the following code I have so far but it isn't working:</p> <pre><code>$args = array( 'type' ...
[ { "answer_id": 165402, "author": "bysanchy", "author_id": 13010, "author_profile": "https://wordpress.stackexchange.com/users/13010", "pm_score": 0, "selected": false, "text": "<p>Can you show what you're getting? </p>\n\n<p>If you're not getting anything, this is probably why:</p>\n\n<p...
2014/10/14
[ "https://wordpress.stackexchange.com/questions/165401", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56940/" ]
I am trying to figure out how to display the categories in a specific order. Let's say my category IDs are in the following order: 1,3,4,2,5 I want to display the categories in that sequence. Here is the following code I have so far but it isn't working: ``` $args = array( 'type' => 'post', ...
**EDIT** I don't really know of a solution within Wordpress to sort the way you need. I think the best is to make use of php sorting to sort your returned array as needed Here is how: ============ 1. Get the array of category info as you normally do ``` $categories = get_categories($args); ``` `$categories` will ...
165,404
<p>I'm developing a real estate site for a client and I'm struggling a bit with it. I created a custom post type called "Property". A property can be on sale and/or on rent. Two different menu items in the site, "Properties on Sale" and "Properties on Rent", show a list of properties either on sale or on rent.</p> <p>...
[ { "answer_id": 165406, "author": "bysanchy", "author_id": 13010, "author_profile": "https://wordpress.stackexchange.com/users/13010", "pm_score": 2, "selected": true, "text": "<p>Add categories to your custom posts. Ex:</p>\n\n<pre><code>add_action( 'init', 'create_gallery_taxonomies', 0...
2014/10/14
[ "https://wordpress.stackexchange.com/questions/165404", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33049/" ]
I'm developing a real estate site for a client and I'm struggling a bit with it. I created a custom post type called "Property". A property can be on sale and/or on rent. Two different menu items in the site, "Properties on Sale" and "Properties on Rent", show a list of properties either on sale or on rent. When a use...
Add categories to your custom posts. Ex: ``` add_action( 'init', 'create_gallery_taxonomies', 0 ); function create_gallery_taxonomies() { $labels = array( 'name' => _x( 'B&A Categories', 'taxonomy general name' ), 'singular_name' => _x( 'B&A', 'taxonomy singular name' ), 'search_items' =>...
165,414
<p>I have created a custom post type called "portfolio" and I use a static page to list my portfolio posts because I need to add content using the content editor.</p> <p>My problem is that I would like this structure:</p> <p><a href="http://www.example.com/portfolio/" rel="nofollow">http://www.example.com/portfolio/<...
[ { "answer_id": 165406, "author": "bysanchy", "author_id": 13010, "author_profile": "https://wordpress.stackexchange.com/users/13010", "pm_score": 2, "selected": true, "text": "<p>Add categories to your custom posts. Ex:</p>\n\n<pre><code>add_action( 'init', 'create_gallery_taxonomies', 0...
2014/10/14
[ "https://wordpress.stackexchange.com/questions/165414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16871/" ]
I have created a custom post type called "portfolio" and I use a static page to list my portfolio posts because I need to add content using the content editor. My problem is that I would like this structure: <http://www.example.com/portfolio/> (It is a static page) <http://www.example.com/portfolio/photography> (tax...
Add categories to your custom posts. Ex: ``` add_action( 'init', 'create_gallery_taxonomies', 0 ); function create_gallery_taxonomies() { $labels = array( 'name' => _x( 'B&A Categories', 'taxonomy general name' ), 'singular_name' => _x( 'B&A', 'taxonomy singular name' ), 'search_items' =>...
165,422
<p>I have attempted to move a Wordpress site from a subdirectory on my root domain to a subdomain.</p> <p>I changed the site options in Wordpress settings > general first, and then copied over the contents from the subdirectory to the subdomain.</p> <p>Nothing is available on the new subdomain, however. Is there a wa...
[ { "answer_id": 165406, "author": "bysanchy", "author_id": 13010, "author_profile": "https://wordpress.stackexchange.com/users/13010", "pm_score": 2, "selected": true, "text": "<p>Add categories to your custom posts. Ex:</p>\n\n<pre><code>add_action( 'init', 'create_gallery_taxonomies', 0...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27120/" ]
I have attempted to move a Wordpress site from a subdirectory on my root domain to a subdomain. I changed the site options in Wordpress settings > general first, and then copied over the contents from the subdirectory to the subdomain. Nothing is available on the new subdomain, however. Is there a way to save this mi...
Add categories to your custom posts. Ex: ``` add_action( 'init', 'create_gallery_taxonomies', 0 ); function create_gallery_taxonomies() { $labels = array( 'name' => _x( 'B&A Categories', 'taxonomy general name' ), 'singular_name' => _x( 'B&A', 'taxonomy singular name' ), 'search_items' =>...
165,425
<p>I'm working on a major WordPress site and ran into a problem where I need to use multiple custom post types, but I only want to use one template for all of them.</p> <p>I found a code by Brad Dalton of WPSites that works with a single CPT name. Looking for a solution that allows multiple CPTs. Source: <a href="http...
[ { "answer_id": 165427, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>Each CPT should have its own templates. If there is common code then you should write it as a function in...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62132/" ]
I'm working on a major WordPress site and ran into a problem where I need to use multiple custom post types, but I only want to use one template for all of them. I found a code by Brad Dalton of WPSites that works with a single CPT name. Looking for a solution that allows multiple CPTs. Source: <http://wpsites.net/web...
Doesn't exist any `is_post_type_single` function, because there is no need for it. [`is_singular()`](https://developer.wordpress.org/reference/functions/is_singular/) fit perfectly your purpose. Example code using [`'template_include'`](https://developer.wordpress.org/reference/hooks/template_include/) filter: ``` a...
165,441
<p>I have managed to update post meta using update_post_meta(). However, the more posts I have, the more time it takes. I would like to minimize the time it takes to process say about 400 posts (although I am not too sure how long this will take). Currently my code looks like this:</p> <pre><code> $numbers = range(...
[ { "answer_id": 165427, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>Each CPT should have its own templates. If there is common code then you should write it as a function in...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165441", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58665/" ]
I have managed to update post meta using update\_post\_meta(). However, the more posts I have, the more time it takes. I would like to minimize the time it takes to process say about 400 posts (although I am not too sure how long this will take). Currently my code looks like this: ``` $numbers = range(1,100000); ...
Doesn't exist any `is_post_type_single` function, because there is no need for it. [`is_singular()`](https://developer.wordpress.org/reference/functions/is_singular/) fit perfectly your purpose. Example code using [`'template_include'`](https://developer.wordpress.org/reference/hooks/template_include/) filter: ``` a...
165,444
<p>I have created a custom template page for every one of my categories. I am using a <code>foreach</code> loop in order to fetch the posts of this specific category in my page.</p> <pre><code>if (is_page()) { $cat=get_cat_ID($post-&gt;post_title); //use page title to get a category ID $posts = get_posts ("cat...
[ { "answer_id": 165449, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 0, "selected": false, "text": "<p>It's far easier to use built-in loop functions such as pagination when you use a category template base...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62138/" ]
I have created a custom template page for every one of my categories. I am using a `foreach` loop in order to fetch the posts of this specific category in my page. ``` if (is_page()) { $cat=get_cat_ID($post->post_title); //use page title to get a category ID $posts = get_posts ("cat=$cat"); if ($posts) { ...
It's far easier to use built-in loop functions such as pagination when you use a category template based on the template hierarchy. You mentioned using the category ID to load posts into your custom template page, but if you instead name the template file based on the category ID, you can simply use the default WP lo...
165,448
<p>I want to make a different front-page and show it to the mobile user, instead of the one used on desktop. </p> <p>In detail, right now we have set our site to show desktop-front-page to user, when he lands on www.domain.com. Now, I want to make a different front-page (mobile-front-page) which can be served to the u...
[ { "answer_id": 165453, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 1, "selected": false, "text": "<p>I believe you're on the right track with <code>wp_is_mobile()</code>.</p>\n\n<p>Have you tried creating...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19409/" ]
I want to make a different front-page and show it to the mobile user, instead of the one used on desktop. In detail, right now we have set our site to show desktop-front-page to user, when he lands on www.domain.com. Now, I want to make a different front-page (mobile-front-page) which can be served to the user coming...
Switching the actual template file could work in the same way as above using `get_template_part()`. For example... ``` <?php if ( wp_is_mobile() ) { // If it is a mobile device get_template_part( 'mobile-front', 'page' ); } else { // If it is not a mobile device get_template_part( 'desktop-front', 'page' ); } // ...
165,457
<p>I need to fetch all the posts with a specific tag, but I'm getting all the posts instead. My query works if I publish a post with the tag that I need and list all the posts with that tag, but when I publish a post with another tag, it's fetching the newly published post. </p> <p>This is my query:</p> <pre><code>$o...
[ { "answer_id": 165459, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 4, "selected": true, "text": "<p>It's a lot easier to create a new WP_Query than it is to try clearing or overwriting the original.</p>\n...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60864/" ]
I need to fetch all the posts with a specific tag, but I'm getting all the posts instead. My query works if I publish a post with the tag that I need and list all the posts with that tag, but when I publish a post with another tag, it's fetching the newly published post. This is my query: ``` $original_query = $wp_q...
It's a lot easier to create a new WP\_Query than it is to try clearing or overwriting the original. If $post\_tag is a tag slug, you could simply use: ``` <?php $the_query = new WP_Query( 'tag='.$post_tag ); if ( $the_query->have_posts() ) { echo '<ul>'; while ( $the_query->have_posts() ) { $the_quer...
165,462
<p>I was pleasantly surprised to see that CloudFlare had started providing a free SSL certificate to all its users, <a href="https://historyofrappelz.com" rel="nofollow">my site</a> included. </p> <p>I use a WordPress plugin to force HTTPS SSL on my pages, but the site is still accessible by HTTP, which leads to displ...
[ { "answer_id": 213803, "author": "Mahesh Patel", "author_id": 86278, "author_profile": "https://wordpress.stackexchange.com/users/86278", "pm_score": -1, "selected": false, "text": "<p>Put this code in <code>.htaccess</code> file: </p>\n\n<pre><code>RewriteEngine On\nRewriteCond %{HTTPS...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165462", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62142/" ]
I was pleasantly surprised to see that CloudFlare had started providing a free SSL certificate to all its users, [my site](https://historyofrappelz.com) included. I use a WordPress plugin to force HTTPS SSL on my pages, but the site is still accessible by HTTP, which leads to display issues. I want to force the nativ...
I am answering this old question, as it still remains unanswered. Instead of using the plugin, you should use cPanel to redirect HTTP to HTTPS. It will help you to get rid of the infinite redirection loop issue. Follow these steps: 1. Login to your cPanel account. 2. Click on the **File Manager**. 3. Ensure that publi...
165,463
<p>I want to check if excerpt is not empty, then echo the excerpt link, if not the echo permalink, like this:</p> <p><code>if(the_excerpt()!='') echo the_excerpt(); else echo get_permalink()</code> but how can I check if the excerpt field is empty without using the content when empty?</p> <p>Any help will be apprecia...
[ { "answer_id": 213803, "author": "Mahesh Patel", "author_id": 86278, "author_profile": "https://wordpress.stackexchange.com/users/86278", "pm_score": -1, "selected": false, "text": "<p>Put this code in <code>.htaccess</code> file: </p>\n\n<pre><code>RewriteEngine On\nRewriteCond %{HTTPS...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62143/" ]
I want to check if excerpt is not empty, then echo the excerpt link, if not the echo permalink, like this: `if(the_excerpt()!='') echo the_excerpt(); else echo get_permalink()` but how can I check if the excerpt field is empty without using the content when empty? Any help will be appreciated.
I am answering this old question, as it still remains unanswered. Instead of using the plugin, you should use cPanel to redirect HTTP to HTTPS. It will help you to get rid of the infinite redirection loop issue. Follow these steps: 1. Login to your cPanel account. 2. Click on the **File Manager**. 3. Ensure that publi...
165,472
<p>I have a template that has a dedicated page for STAFF. The only problem is, I can't rearrange the entries. In other words, all the entries are automatically sorted based on time when the data was entered. Is there a way to manually change the order of these entries. For example, if I want to move my secretary on...
[ { "answer_id": 213803, "author": "Mahesh Patel", "author_id": 86278, "author_profile": "https://wordpress.stackexchange.com/users/86278", "pm_score": -1, "selected": false, "text": "<p>Put this code in <code>.htaccess</code> file: </p>\n\n<pre><code>RewriteEngine On\nRewriteCond %{HTTPS...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165472", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62149/" ]
I have a template that has a dedicated page for STAFF. The only problem is, I can't rearrange the entries. In other words, all the entries are automatically sorted based on time when the data was entered. Is there a way to manually change the order of these entries. For example, if I want to move my secretary on spot u...
I am answering this old question, as it still remains unanswered. Instead of using the plugin, you should use cPanel to redirect HTTP to HTTPS. It will help you to get rid of the infinite redirection loop issue. Follow these steps: 1. Login to your cPanel account. 2. Click on the **File Manager**. 3. Ensure that publi...
165,478
<p>I have built a theme for a car dealership. Each car is a custom post type ("vehicle"), and has about 12 custom fields with things such as Make, Model, Mileage, Fuel Type etc. etc.</p> <p>So basically on the home page I want a search form which has drop down lists for Make &amp; Model and contains any available Make...
[ { "answer_id": 165494, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 5, "selected": true, "text": "<blockquote>\n <p><strong>______UPDATE_______</strong><br>\n Though I'm getting more and more votes, and...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165478", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62152/" ]
I have built a theme for a car dealership. Each car is a custom post type ("vehicle"), and has about 12 custom fields with things such as Make, Model, Mileage, Fuel Type etc. etc. So basically on the home page I want a search form which has drop down lists for Make & Model and contains any available Makes or Models. ...
> > **\_\_\_\_\_\_UPDATE\_\_\_\_\_\_\_** > > Though I'm getting more and more votes, and the solution works, but [cybmeta's answer](https://wordpress.stackexchange.com/a/176805/22728) is actually the answer that is nice and WordPress' way. You should definitely try that. > > > ### Step 1 Start by making an Ad...
165,498
<p>I have created a custom WordPress theme and need to be able to include the sidebar with widgets. I have the sidebar.php file, functions code and three widgets waiting to see the light of day. But alas, no dice.</p> <p>Here is the sidebar.php code:</p> <pre><code>&lt;?php /** * The sidebar containing the main widg...
[ { "answer_id": 165494, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 5, "selected": true, "text": "<blockquote>\n <p><strong>______UPDATE_______</strong><br>\n Though I'm getting more and more votes, and...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48611/" ]
I have created a custom WordPress theme and need to be able to include the sidebar with widgets. I have the sidebar.php file, functions code and three widgets waiting to see the light of day. But alas, no dice. Here is the sidebar.php code: ``` <?php /** * The sidebar containing the main widget area * * If no acti...
> > **\_\_\_\_\_\_UPDATE\_\_\_\_\_\_\_** > > Though I'm getting more and more votes, and the solution works, but [cybmeta's answer](https://wordpress.stackexchange.com/a/176805/22728) is actually the answer that is nice and WordPress' way. You should definitely try that. > > > ### Step 1 Start by making an Ad...
165,507
<p>I migrated content from our production server to our dev server in an attempt to sync all environments. I used the All-In-One WP Migration plugin. </p> <p>Now, when I access dev.domain.com I am forwarded to <a href="http://dev.domain.com/wp-signup.php?new=dev.domain.com" rel="noreferrer">http://dev.domain.com/wp-si...
[ { "answer_id": 165509, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 3, "selected": false, "text": "<p>You'll want to add these to your wp-config.php file:</p>\n\n<pre><code>define( 'NOBLOGREDIRECT', '' ); ...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58198/" ]
I migrated content from our production server to our dev server in an attempt to sync all environments. I used the All-In-One WP Migration plugin. Now, when I access dev.domain.com I am forwarded to <http://dev.domain.com/wp-signup.php?new=dev.domain.com> It sounds like one of the database values must be incorrect a...
For me it was changing old domain entries in database tables `wp_blogs` and `wp_site` to the new domain of the multisite's main domain. I haven't done this after the migration to a new domain.
165,510
<p>I'm going to get crazy with the problem:</p> <p>I want to add a specific css class to the menu items, depending on a custom taxonomy. This is my code so far.</p> <pre><code>add_filter('nav_menu_css_class', 'auto_custom_type_class', 10, 2 ); function auto_custom_type_class($classes, $item) { if($item-&gt;object ==...
[ { "answer_id": 165509, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 3, "selected": false, "text": "<p>You'll want to add these to your wp-config.php file:</p>\n\n<pre><code>define( 'NOBLOGREDIRECT', '' ); ...
2014/10/15
[ "https://wordpress.stackexchange.com/questions/165510", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62165/" ]
I'm going to get crazy with the problem: I want to add a specific css class to the menu items, depending on a custom taxonomy. This is my code so far. ``` add_filter('nav_menu_css_class', 'auto_custom_type_class', 10, 2 ); function auto_custom_type_class($classes, $item) { if($item->object == "marke") { if( has_t...
For me it was changing old domain entries in database tables `wp_blogs` and `wp_site` to the new domain of the multisite's main domain. I haven't done this after the migration to a new domain.
165,551
<p><strong>DESCRIPTION</strong></p> <p>I want to get the name of the slug of the last child of the post's category. My categories of my posts represents cities and I am assigning them 3-4 level categories as <code>continent</code>, <code>country</code>, <code>region</code>, and finaly most important category <code>cit...
[ { "answer_id": 165552, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 1, "selected": false, "text": "<p>Create a custom taxonomy for cities, and then use <code>get_the_terms()</code> to display the term slug...
2014/10/16
[ "https://wordpress.stackexchange.com/questions/165551", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33517/" ]
**DESCRIPTION** I want to get the name of the slug of the last child of the post's category. My categories of my posts represents cities and I am assigning them 3-4 level categories as `continent`, `country`, `region`, and finaly most important category `city` as you can see here: **Example** ``` Europe Italy ...
Create a custom taxonomy for cities, and then use `get_the_terms()` to display the term slug in the image URL. ALTERNATIVE If you're only wanting the last slug, you can use PHP for that. Place this at the very top of the file just after `get_header()` : ``` <?php /* Grab the link. */ $link = $_SERVER['PHP_SE...
165,583
<p>I'm trying to retrieve the post content of a specific post:</p> <pre><code>$post = get_post(/* id */); $content = $post-&gt;post_content; </code></pre> <p>However, this retrieves the content with no line-breaks and omits all <code>&lt;p&gt;</code> tags.</p> <p>What is the proper way to retrieve the post content w...
[ { "answer_id": 165585, "author": "Lisandro Vaccaro", "author_id": 2488, "author_profile": "https://wordpress.stackexchange.com/users/2488", "pm_score": 3, "selected": false, "text": "<p>Found the solution:</p>\n\n<pre><code>$content = apply_filters('the_content', $post-&gt;post_content);...
2014/10/16
[ "https://wordpress.stackexchange.com/questions/165583", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2488/" ]
I'm trying to retrieve the post content of a specific post: ``` $post = get_post(/* id */); $content = $post->post_content; ``` However, this retrieves the content with no line-breaks and omits all `<p>` tags. What is the proper way to retrieve the post content without stripping the `<p>` tags (as it is shown on th...
Both answers so far are correct but a more thorough answer seems warranted. If you use this: ``` $content = wpautop( $post->post_content ); ``` you're applying the one function that adds paragraph tags to post content. `wpautop()` is one of many functions (including plugin functions at times) that hooks onto `the_c...
165,587
<p>I have a pretty simple child theme of Twenty Twelve active, but the mobile menu does not expand when pressed. </p> <p>Here is header.php:</p> <pre><code>&lt;?php/** * The Header for our theme. * * Displays all of the &lt;head&gt; section and everything up till &lt;div id="main"&gt; * * @package WordPress * @subpa...
[ { "answer_id": 166345, "author": "Mithun Sarker Shuvro", "author_id": 56654, "author_profile": "https://wordpress.stackexchange.com/users/56654", "pm_score": 1, "selected": false, "text": "<pre><code>wp_nav_menu(\n array(\n 'theme_location' =&gt; 'primary',\n 'menu_class' =&gt; 'nav-menu...
2014/10/16
[ "https://wordpress.stackexchange.com/questions/165587", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I have a pretty simple child theme of Twenty Twelve active, but the mobile menu does not expand when pressed. Here is header.php: ``` <?php/** * The Header for our theme. * * Displays all of the <head> section and everything up till <div id="main"> * * @package WordPress * @subpackage Twenty_Twelve * @since Twenty T...
I had exactly the same problem. In the base TwentyTwelve theme there has been a code change so that the site navigation changed from `h3` to `button`. You need to update header.php file in the child theme to use ``` <button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button> ``` See WordPress [TRAC ...
165,598
<p>I'm wondering if there is some sort of equivalent to Drupal's <a href="https://api.drupal.org/api/drupal/includes!form.inc/group/batch/7" rel="nofollow">Batch API</a> in WordPress?</p> <p>Basically, the API allows you to register a batch request and Drupal will call your function over and over again (with Ajax requ...
[ { "answer_id": 166345, "author": "Mithun Sarker Shuvro", "author_id": 56654, "author_profile": "https://wordpress.stackexchange.com/users/56654", "pm_score": 1, "selected": false, "text": "<pre><code>wp_nav_menu(\n array(\n 'theme_location' =&gt; 'primary',\n 'menu_class' =&gt; 'nav-menu...
2014/10/16
[ "https://wordpress.stackexchange.com/questions/165598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62196/" ]
I'm wondering if there is some sort of equivalent to Drupal's [Batch API](https://api.drupal.org/api/drupal/includes!form.inc/group/batch/7) in WordPress? Basically, the API allows you to register a batch request and Drupal will call your function over and over again (with Ajax requests) until your batch is finished. ...
I had exactly the same problem. In the base TwentyTwelve theme there has been a code change so that the site navigation changed from `h3` to `button`. You need to update header.php file in the child theme to use ``` <button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button> ``` See WordPress [TRAC ...
165,601
<pre><code>add_action( 'wp_enqueue_scripts', function ( ) { global $post,$pageparent; if(in_array($pageparent, array($post-&gt;ID,$post-&gt;post_parent))){ wp_enqueue_style( 'products_pages', urlto.'products_pages.css' ); wp_enqueue_script('tooltipster', urlto.'js/jquery.tooltipster.min.js',...
[ { "answer_id": 165607, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>I cant figure out where to hook so that A. The $post is set up and 2.\n the style and script get ...
2014/10/16
[ "https://wordpress.stackexchange.com/questions/165601", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17881/" ]
``` add_action( 'wp_enqueue_scripts', function ( ) { global $post,$pageparent; if(in_array($pageparent, array($post->ID,$post->post_parent))){ wp_enqueue_style( 'products_pages', urlto.'products_pages.css' ); wp_enqueue_script('tooltipster', urlto.'js/jquery.tooltipster.min.js', array( 'jq...
It seems that you need to add styles and scripts to a single post. The best way to achieve this is to make use of the conditional tag [`is_single()`](http://codex.wordpress.org/Function_Reference/is_single) With that you target specific single posts or all single posts. Styles should always be loaded in the header. `<...
165,610
<p>I am not getting the posts under custom taxonomy(<code>fabric_building_types</code>). I am getting <code>cat_id</code> and <code>cat-&gt;name</code> also but not able to get the posts.</p> <pre><code>$args = array( 'type' =&gt; 'post', 'child_of' =&gt; 0, 'parent' ...
[ { "answer_id": 165613, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 3, "selected": false, "text": "<p>You should use <code>get_terms()</code> for taxonomies when you can.</p>\n<pre><code>&lt;?php \n/* Add ...
2014/10/16
[ "https://wordpress.stackexchange.com/questions/165610", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43572/" ]
I am not getting the posts under custom taxonomy(`fabric_building_types`). I am getting `cat_id` and `cat->name` also but not able to get the posts. ``` $args = array( 'type' => 'post', 'child_of' => 0, 'parent' => '', 'orderby' => ...
Your tax query is incorrect, `field` should be the field you want to query on: `term_id`, `name`, or `slug` - ``` $posts_array = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'fabric_building', 'tax_query' => array( array( 'taxonomy' => 'fabric_buildin...
165,614
<p>I just started playing with Wordpress and I have a question about the AJAX side of things.</p> <p>I think that I understand how the AJAX front-end to server side processing, back to font-end works.</p> <p>But, I am not that clear on how I could get front-end data into the back-end and then use that data for someth...
[ { "answer_id": 165613, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 3, "selected": false, "text": "<p>You should use <code>get_terms()</code> for taxonomies when you can.</p>\n<pre><code>&lt;?php \n/* Add ...
2014/10/16
[ "https://wordpress.stackexchange.com/questions/165614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62201/" ]
I just started playing with Wordpress and I have a question about the AJAX side of things. I think that I understand how the AJAX front-end to server side processing, back to font-end works. But, I am not that clear on how I could get front-end data into the back-end and then use that data for something else (not ret...
Your tax query is incorrect, `field` should be the field you want to query on: `term_id`, `name`, or `slug` - ``` $posts_array = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'fabric_building', 'tax_query' => array( array( 'taxonomy' => 'fabric_buildin...
165,644
<p>I have a query inside a function that is returning matches that i don't want, for example when the $id=116 it is also returning results where the meta_key 'funds_id' is 11687. </p> <pre><code> public function list_related_docs($id){ $docs_args = array( 'post_type' =&gt; 'publication', 'post...
[ { "answer_id": 165650, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 1, "selected": false, "text": "<p>Well, you need to include the type comparison, or alphanumeric comparison is applied here.</p>\n\n<p>In...
2014/10/16
[ "https://wordpress.stackexchange.com/questions/165644", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45255/" ]
I have a query inside a function that is returning matches that i don't want, for example when the $id=116 it is also returning results where the meta\_key 'funds\_id' is 11687. ``` public function list_related_docs($id){ $docs_args = array( 'post_type' => 'publication', 'post_status' => '...
Well, you need to include the type comparison, or alphanumeric comparison is applied here. In this case, you should add `'type' => 'numeric'`. **Using Your Class Function** ``` <?php public function list_related_docs($id){ $docs_args = array( 'post_type' => 'publication', ...
165,691
<p>Is there any way to check if a user id exists? I want to create a function similar to <code>username_exists()</code> but which returns if the id exists or not.</p>
[ { "answer_id": 165693, "author": "Dan", "author_id": 42582, "author_profile": "https://wordpress.stackexchange.com/users/42582", "pm_score": 3, "selected": true, "text": "<p>Use this function:</p>\n\n<pre><code>function user_id_exists($user){\n\n global $wpdb;\n\n $count = $wpdb-&g...
2014/10/17
[ "https://wordpress.stackexchange.com/questions/165691", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44378/" ]
Is there any way to check if a user id exists? I want to create a function similar to `username_exists()` but which returns if the id exists or not.
Use this function: ``` function user_id_exists($user){ global $wpdb; $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->users WHERE ID = %d", $user)); if($count == 1){ return true; }else{ return false; } } ``` Usage: ``` if(user_id_exists(1)){ //it does exists } else { //it...
165,706
<p>I know since WP 3.6 we've been able to upload and embed various file formats and that the 'Add Media' button effectively implements the correct media embed shortcode for us.</p> <p>I'm having a problem in WP4.0 using 'Add Media' to embed quicktime (.mov) files. The embed works fine for the other supported video MIM...
[ { "answer_id": 165762, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<p>You can try the following:</p>\n\n<pre><code>/**\n * Add support for the QuickTime (.mov) video format.\n */\...
2014/10/17
[ "https://wordpress.stackexchange.com/questions/165706", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58528/" ]
I know since WP 3.6 we've been able to upload and embed various file formats and that the 'Add Media' button effectively implements the correct media embed shortcode for us. I'm having a problem in WP4.0 using 'Add Media' to embed quicktime (.mov) files. The embed works fine for the other supported video MIME types bu...
You can try the following: ``` /** * Add support for the QuickTime (.mov) video format. */ add_filter( 'wp_video_extensions', function( $exts ) { $exts[] = 'mov'; return $exts; } ); ``` to add the *Embed Media Player* support for the QuickTime video files. The [default](https://core.trac...
165,728
<p>I'm not sure if it's a database or template issue, but on this template <a href="http://krieger.jhu.edu/museums-society/exhibitions/" rel="nofollow">page</a> only one post of my Custom Post Types are appearing. There should be at least two.</p> <p>The page uses an isotope.js script, but disabling it does not allevi...
[ { "answer_id": 165762, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<p>You can try the following:</p>\n\n<pre><code>/**\n * Add support for the QuickTime (.mov) video format.\n */\...
2014/10/17
[ "https://wordpress.stackexchange.com/questions/165728", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54745/" ]
I'm not sure if it's a database or template issue, but on this template [page](http://krieger.jhu.edu/museums-society/exhibitions/) only one post of my Custom Post Types are appearing. There should be at least two. The page uses an isotope.js script, but disabling it does not alleviate the problem. The plugin code ca...
You can try the following: ``` /** * Add support for the QuickTime (.mov) video format. */ add_filter( 'wp_video_extensions', function( $exts ) { $exts[] = 'mov'; return $exts; } ); ``` to add the *Embed Media Player* support for the QuickTime video files. The [default](https://core.trac...
165,737
<p>I'm trying to get my Meta Box to display at the bottom of my post excerpt on the blog index. I've been working on the site for the last 10 hours so I think I'm being blind or have I done it wrong? Would someone please take a look and tell me what I'm doing wrong?</p> <p>Here is my meta box data:</p> <pre><code> f...
[ { "answer_id": 165762, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<p>You can try the following:</p>\n\n<pre><code>/**\n * Add support for the QuickTime (.mov) video format.\n */\...
2014/10/17
[ "https://wordpress.stackexchange.com/questions/165737", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62261/" ]
I'm trying to get my Meta Box to display at the bottom of my post excerpt on the blog index. I've been working on the site for the last 10 hours so I think I'm being blind or have I done it wrong? Would someone please take a look and tell me what I'm doing wrong? Here is my meta box data: ``` function true_add_a_met...
You can try the following: ``` /** * Add support for the QuickTime (.mov) video format. */ add_filter( 'wp_video_extensions', function( $exts ) { $exts[] = 'mov'; return $exts; } ); ``` to add the *Embed Media Player* support for the QuickTime video files. The [default](https://core.trac...
165,747
<p>On <a href="http://codex.wordpress.org/Child_Themes" rel="nofollow">child themes</a>: It is stated: </p> <blockquote> <p>... create a file called style.css. This is the <strong>only</strong> file required to make a child theme.</p> </blockquote> <p>Then, it states:</p> <blockquote> <p>The correct method to im...
[ { "answer_id": 165748, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 1, "selected": false, "text": "<p>Yes you will need to enqueue parent theme styles into child theme. Adding style.css in child theme will no...
2014/10/18
[ "https://wordpress.stackexchange.com/questions/165747", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62269/" ]
On [child themes](http://codex.wordpress.org/Child_Themes): It is stated: > > ... create a file called style.css. This is the **only** file required to make a child theme. > > > Then, it states: > > The correct method to import the parent themes stylesheet into the child theme is to use `wp_enqueue_style()` in...
Yes you will need to enqueue parent theme styles into child theme. Adding style.css in child theme will not automatically add parent theme's styles too. You can enqueue parent theme's styles like this. Create a new `functions.php` in child theme and paste this. ``` function enqueue_child_theme_styles() { wp_enque...
165,754
<p><strong>What is the idea way to register/enqueue scripts and/or styles for use in plugins?</strong></p> <p>I recently made a plugin <a href="https://wordpress.org/plugins/avatar-shortcode/">simple plugin</a> to add the user avatar/gravatar with a shortcode. I have different style options for displaying the avatar (...
[ { "answer_id": 165759, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 5, "selected": false, "text": "<p>Before starting answer I have to say that regarding this topic css and js are not the same. </p>\n\n<p>The re...
2014/10/18
[ "https://wordpress.stackexchange.com/questions/165754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38123/" ]
**What is the idea way to register/enqueue scripts and/or styles for use in plugins?** I recently made a plugin [simple plugin](https://wordpress.org/plugins/avatar-shortcode/) to add the user avatar/gravatar with a shortcode. I have different style options for displaying the avatar (square, round, etc.) and decided t...
I found an other way that works well for me: * When initializing the plugin, do not enqueue your scripts and styles, but register them with [`wp_register_style`](https://developer.wordpress.org/reference/functions/wp_register_style/) and [`wp_register_script`](https://developer.wordpress.org/reference/functions/wp_reg...
165,766
<p>I really want to try and add an overlay and "loading" notice to the wordpress customizer when a change is made. </p> <p>For some of my larger theme changes that are made through the customizer, I am using the refresh (default) transport mode. However, to increase my user experience, I think some kind of notice to s...
[ { "answer_id": 165994, "author": "Ashok Kumar Nath", "author_id": 43284, "author_profile": "https://wordpress.stackexchange.com/users/43284", "pm_score": 0, "selected": false, "text": "<p>I use this simple process:</p>\n\n<pre><code>add_action( 'customize_controls_print_footer_scripts', ...
2014/10/18
[ "https://wordpress.stackexchange.com/questions/165766", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32864/" ]
I really want to try and add an overlay and "loading" notice to the wordpress customizer when a change is made. For some of my larger theme changes that are made through the customizer, I am using the refresh (default) transport mode. However, to increase my user experience, I think some kind of notice to say that th...
While this might not a be the perfect solution but this should work. You can set an interval to check against the preview iframe, like this: ``` var previewDiv = $('#customize-preview'); previewDiv.prepend('<div class="loading-overlay"></div>'); var loadingOverlay = previewDiv.find('.loading-overlay'); setInterval(fu...
165,771
<p>I want to extend my image field in my widget with an 'edit image details' button. Is it possible in some way to re-use the popup from the tinyMCE editor?</p> <p><img src="https://i.stack.imgur.com/sA0ya.png" alt="enter image description here"></p> <p>So i can use the size settings for example. </p>
[ { "answer_id": 177754, "author": "Chief Alchemist", "author_id": 18343, "author_profile": "https://wordpress.stackexchange.com/users/18343", "pm_score": 0, "selected": false, "text": "<p>The CMB2 plugin lets you add images, take a look at that?</p>\n\n<p>There are a couple plugins for ad...
2014/10/18
[ "https://wordpress.stackexchange.com/questions/165771", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56398/" ]
I want to extend my image field in my widget with an 'edit image details' button. Is it possible in some way to re-use the popup from the tinyMCE editor? ![enter image description here](https://i.stack.imgur.com/sA0ya.png) So i can use the size settings for example.
Let me answer in the most simple way. It depends on the situation and sometimes you might want to create your own MediaFrame, but i think this would be slightly out of the questions scope and would need much more explanation: Assuming all there is is an ID of the attachment to edit, following code will open the detail...
165,780
<p>I have a main wordpress installed on the root and now due to a long story about incompatible plugins I need to install a second full instance of wordpress in a subdirectory.</p> <p>The main site works fine, as does the site in the subdirectory. As long as I don't activate pretty permalinks on the subsite</p> <p>On...
[ { "answer_id": 177754, "author": "Chief Alchemist", "author_id": 18343, "author_profile": "https://wordpress.stackexchange.com/users/18343", "pm_score": 0, "selected": false, "text": "<p>The CMB2 plugin lets you add images, take a look at that?</p>\n\n<p>There are a couple plugins for ad...
2014/10/18
[ "https://wordpress.stackexchange.com/questions/165780", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62287/" ]
I have a main wordpress installed on the root and now due to a long story about incompatible plugins I need to install a second full instance of wordpress in a subdirectory. The main site works fine, as does the site in the subdirectory. As long as I don't activate pretty permalinks on the subsite Once the subsite ha...
Let me answer in the most simple way. It depends on the situation and sometimes you might want to create your own MediaFrame, but i think this would be slightly out of the questions scope and would need much more explanation: Assuming all there is is an ID of the attachment to edit, following code will open the detail...
165,785
<p>Is it possible to symlink a directory from my project folder to my wp-content/themes folder which is in a Vagrant setup called chassis: <a href="https://github.com/Chassis/Chassis" rel="nofollow">https://github.com/Chassis/Chassis</a> ?</p> <p>I tried to symlink already using ln -s, but my wordpress installation di...
[ { "answer_id": 165811, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p>Yes, symlinks are also possible. But maybe you have a problem with the rights of the WP install. Often have the u...
2014/10/18
[ "https://wordpress.stackexchange.com/questions/165785", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2776/" ]
Is it possible to symlink a directory from my project folder to my wp-content/themes folder which is in a Vagrant setup called chassis: <https://github.com/Chassis/Chassis> ? I tried to symlink already using ln -s, but my wordpress installation did not recognize it as I did not see it in the Appearance > Themes admin ...
You can add this to your VagrantFile for "shared folders:" ``` config.vm.synced_folder "/path/to/your/host/projectfolder/theme", "/path/to/your/vagrant/wp-content/theme", owner: 'www-data', group: 'www-data', mount_options: ["dmode=775", "fmode=664"] ``` <http://docs.vagrantup.com/v2/synced-folde...
165,791
<p>I have been searching for hours. I need a code that allows me to display a Login &amp; Register link and when logged in display the users avatar along with name and logout button.</p> <p>I'm not exactly great at writing php or putting them together, although I am still learning. Can anyone help me with this issue.<...
[ { "answer_id": 165794, "author": "shachar", "author_id": 61996, "author_profile": "https://wordpress.stackexchange.com/users/61996", "pm_score": 2, "selected": true, "text": "<p>Try this code:</p>\n\n<pre><code>if(is_user_logged_in() ) {\n global $current_user;\n get_currentuse...
2014/10/18
[ "https://wordpress.stackexchange.com/questions/165791", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32447/" ]
I have been searching for hours. I need a code that allows me to display a Login & Register link and when logged in display the users avatar along with name and logout button. I'm not exactly great at writing php or putting them together, although I am still learning. Can anyone help me with this issue. ![enter image...
Try this code: ``` if(is_user_logged_in() ) { global $current_user; get_currentuserinfo(); echo get_avatar($current_user->user_email); echo 'Hello, '. $current_user->display_name; echo '<a href="/wp-login.php?action=logout">logout</a>'; } else { echo '<a href="/wp-login.php?action=login">log...
165,796
<p>I tried to use <a href="https://developer.wordpress.org/reference/functions/deactivate_plugins/" rel="nofollow"><code>deactivate_plugins</code></a> function to deactivate a plugin only for mobile devices.</p> <p>It worked: when I enter site on mobile phone the plugin is deactivated, but when I enter site on PC the ...
[ { "answer_id": 165812, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 4, "selected": true, "text": "<p>If you deactivate a plugin, the change is stored in database, so in all subsequent access the plugin is deacti...
2014/10/19
[ "https://wordpress.stackexchange.com/questions/165796", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45743/" ]
I tried to use [`deactivate_plugins`](https://developer.wordpress.org/reference/functions/deactivate_plugins/) function to deactivate a plugin only for mobile devices. It worked: when I enter site on mobile phone the plugin is deactivated, but when I enter site on PC the plugin is deactivated too. Is there a way to n...
If you deactivate a plugin, the change is stored in database, so in all subsequent access the plugin is deactivated, no matter the device used to access the site. Filtering the option -------------------- Active plugin in WordPress are retrieved using [**`wp_get_active_and_valid_plugins()`**](https://developer.wordp...
165,839
<p>I'm just getting to grips with metaboxes for the first time and after reading up on them one of the main question i have is do you need to specify fields in the DB to store the data got input. i.e. if you had a metabox with :</p> <ul> <li>Title <code>&lt;input&gt;</code></li> <li>Description <code>&lt;textfeild&gt;...
[ { "answer_id": 165843, "author": "matr07", "author_id": 20829, "author_profile": "https://wordpress.stackexchange.com/users/20829", "pm_score": 2, "selected": false, "text": "<p>When adding a metabox, the metabox itself isn't saved in the database. It's loaded from the plugin code that i...
2014/10/19
[ "https://wordpress.stackexchange.com/questions/165839", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31688/" ]
I'm just getting to grips with metaboxes for the first time and after reading up on them one of the main question i have is do you need to specify fields in the DB to store the data got input. i.e. if you had a metabox with : * Title `<input>` * Description `<textfeild>` * For Sale `<boolean>` Are they added to an ex...
When adding a metabox, the metabox itself isn't saved in the database. It's loaded from the plugin code that is written, then it's up to you to fill it with appropriate values. You don't have to create additional fields in the DB. There is a function: ``` update_post_meta($post_id, $meta_key, $meta_value); ``` In ...
165,846
<p>I'm trying to get the title and content from the global $post variable when a user publishes a new post (to submit to an external web service, which in turn needs to pass back additional data to add to the post).</p> <p>The hooks I tried using so far ('transition_post_status' and 'publish_post') all seem to run <st...
[ { "answer_id": 165847, "author": "matr07", "author_id": 20829, "author_profile": "https://wordpress.stackexchange.com/users/20829", "pm_score": 0, "selected": false, "text": "<p>I'm unable to comment yet, as I feel it may be a more suitable spot than to post an actual answer, in case you...
2014/10/19
[ "https://wordpress.stackexchange.com/questions/165846", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62317/" ]
I'm trying to get the title and content from the global $post variable when a user publishes a new post (to submit to an external web service, which in turn needs to pass back additional data to add to the post). The hooks I tried using so far ('transition\_post\_status' and 'publish\_post') all seem to run **before**...
The third parameter for `transition_post_status` is the post object. Use it. ``` add_action( 'transition_post_status', 'dostuff', 10, 3 ); function dostuff( $new_status, $old_status, $post ) { } ``` When in doubt, do not use globals. They are not reliable, they make your code hard to test and to read.
165,850
<p>I'm using the Settings API on an admin page and it's marvelously simple and all that.</p> <pre><code>public function on_show_page(){ ?&gt; &lt;div id="admin-bar-button-page" class="wrap admin-bar-button"&gt; &lt;h2&gt;&lt;?php _e('Admin Bar Button Settings', 'djg-admin-bar-button'); ?&gt;&lt;/h2&gt; ...
[ { "answer_id": 165851, "author": "David Gard", "author_id": 10097, "author_profile": "https://wordpress.stackexchange.com/users/10097", "pm_score": 3, "selected": true, "text": "<p>So because I couldn't find an out of the box way, I created this. Don't forget to enqueue the <code>jquery...
2014/10/19
[ "https://wordpress.stackexchange.com/questions/165850", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10097/" ]
I'm using the Settings API on an admin page and it's marvelously simple and all that. ``` public function on_show_page(){ ?> <div id="admin-bar-button-page" class="wrap admin-bar-button"> <h2><?php _e('Admin Bar Button Settings', 'djg-admin-bar-button'); ?></h2> <form action="options.php" method...
So because I couldn't find an out of the box way, I created this. Don't forget to enqueue the `jquery-ui-tabs` script - ``` /** Replace the call to 'do_settings_sections()' with a call to this function */ function do_settings_sections_tabs($page){ global $wp_settings_sections, $wp_settings_fields; if(!isset(...
165,855
<p>I would like to create 2 lists of pages and include and exclude some of them depending on their category. In the following example, I have my 2 lists. A list of promoted pages and a list for the rest.</p> <pre><code> &lt;ul class="promoted"&gt; &lt;?php wp_list_pages('include=4');?&gt; &lt;/ul&gt; ...
[ { "answer_id": 165851, "author": "David Gard", "author_id": 10097, "author_profile": "https://wordpress.stackexchange.com/users/10097", "pm_score": 3, "selected": true, "text": "<p>So because I couldn't find an out of the box way, I created this. Don't forget to enqueue the <code>jquery...
2014/10/20
[ "https://wordpress.stackexchange.com/questions/165855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7838/" ]
I would like to create 2 lists of pages and include and exclude some of them depending on their category. In the following example, I have my 2 lists. A list of promoted pages and a list for the rest. ``` <ul class="promoted"> <?php wp_list_pages('include=4');?> </ul> <ul> <?php wp_list_pag...
So because I couldn't find an out of the box way, I created this. Don't forget to enqueue the `jquery-ui-tabs` script - ``` /** Replace the call to 'do_settings_sections()' with a call to this function */ function do_settings_sections_tabs($page){ global $wp_settings_sections, $wp_settings_fields; if(!isset(...
165,857
<p>I'm creating a Wordpress portfolio site using the Simone theme. I have three menu items that link to the same page but with different hashes:</p> <p><code>tovly.com/work/#work-all-work</code></p> <p><code>tovly.com/work/#work-photos</code></p> <p><code>tovly.com/work/#work-videos</code></p> <p>The problem is all...
[ { "answer_id": 165875, "author": "Ashok Kumar Nath", "author_id": 43284, "author_profile": "https://wordpress.stackexchange.com/users/43284", "pm_score": 0, "selected": false, "text": "<p>Try combination of setInterval method and window.location.hash. This is not tested, but something li...
2014/10/20
[ "https://wordpress.stackexchange.com/questions/165857", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62321/" ]
I'm creating a Wordpress portfolio site using the Simone theme. I have three menu items that link to the same page but with different hashes: `tovly.com/work/#work-all-work` `tovly.com/work/#work-photos` `tovly.com/work/#work-videos` The problem is all three menu items are set as active no matter what hash is in th...
This can be accomplised fairly easy by checking the URL then setting the appropriate link to active. That can be accomplished by the following... ``` var hash = window.location.hash.substr(1); // Get the text after the hash $('a[href="#' + hash + '"]').addClass('active'); // Set the correct link to active ``` Howe...
165,870
<p>I have searched and cannot find anything regarding this.</p> <p>What I want to do is only show part of the users logged in name or username when they leave a comment (it is actually a product review but it uses the comments system).</p> <p>I need something like what eBay does where is shows something like a*******...
[ { "answer_id": 165875, "author": "Ashok Kumar Nath", "author_id": 43284, "author_profile": "https://wordpress.stackexchange.com/users/43284", "pm_score": 0, "selected": false, "text": "<p>Try combination of setInterval method and window.location.hash. This is not tested, but something li...
2014/10/20
[ "https://wordpress.stackexchange.com/questions/165870", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62305/" ]
I have searched and cannot find anything regarding this. What I want to do is only show part of the users logged in name or username when they leave a comment (it is actually a product review but it uses the comments system). I need something like what eBay does where is shows something like a\*\*\*\*\*\*\*z. Is the...
This can be accomplised fairly easy by checking the URL then setting the appropriate link to active. That can be accomplished by the following... ``` var hash = window.location.hash.substr(1); // Get the text after the hash $('a[href="#' + hash + '"]').addClass('active'); // Set the correct link to active ``` Howe...
165,883
<p>When I click "read more" at the bottom of one of my website posts, it just loads the rest of the text in the same page and the same section, thus overflowing elements with text and spoiling my layout. I noticed there is a tag at the end of every Wordpress post when Read More is added from the toolbar. How can I ove...
[ { "answer_id": 165886, "author": "Hakkim", "author_id": 62335, "author_profile": "https://wordpress.stackexchange.com/users/62335", "pm_score": 0, "selected": false, "text": "<p>It might be because you have left excerpt field blank. If you've out some texts (normally summary of each post...
2014/10/20
[ "https://wordpress.stackexchange.com/questions/165883", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62333/" ]
When I click "read more" at the bottom of one of my website posts, it just loads the rest of the text in the same page and the same section, thus overflowing elements with text and spoiling my layout. I noticed there is a tag at the end of every Wordpress post when Read More is added from the toolbar. How can I overrid...
It sounds like this is a problem with the way your theme is setup, since what you describe isn't the usual behaviour of the more tag. The first part of your post suggests there's some built-in Javascript in your theme causing the read more to expand the post text rather than take you to the single post page, removing t...
165,900
<p>I have made a custom post 'case studies' which has a number of posts.</p> <p>I wish to get the IDs of each of these posts to manipulate the data, but despite looking at similar threads, I cannot piece together a way to achieve this. Something like;</p> <pre><code>foreach post oftype custom, get the id </code></pre...
[ { "answer_id": 165886, "author": "Hakkim", "author_id": 62335, "author_profile": "https://wordpress.stackexchange.com/users/62335", "pm_score": 0, "selected": false, "text": "<p>It might be because you have left excerpt field blank. If you've out some texts (normally summary of each post...
2014/10/20
[ "https://wordpress.stackexchange.com/questions/165900", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51823/" ]
I have made a custom post 'case studies' which has a number of posts. I wish to get the IDs of each of these posts to manipulate the data, but despite looking at similar threads, I cannot piece together a way to achieve this. Something like; ``` foreach post oftype custom, get the id ``` I am making a function to d...
It sounds like this is a problem with the way your theme is setup, since what you describe isn't the usual behaviour of the more tag. The first part of your post suggests there's some built-in Javascript in your theme causing the read more to expand the post text rather than take you to the single post page, removing t...
165,952
<p>In order to highlight menu item when viewing single post (not blog), am trying to add special classes to single, (regular, not custom) posts from different categories. this is the basic code:</p> <pre><code>function my_special_nav_class( $classes, $item ) { if ( is_single() &amp;&amp; (in_category('workshops') )...
[ { "answer_id": 165968, "author": "iyrin", "author_id": 33393, "author_profile": "https://wordpress.stackexchange.com/users/33393", "pm_score": 0, "selected": false, "text": "<p>Use <code>in_category( $category )</code> and <code>is_category( $category )</code> in your conditional stateme...
2014/10/20
[ "https://wordpress.stackexchange.com/questions/165952", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62358/" ]
In order to highlight menu item when viewing single post (not blog), am trying to add special classes to single, (regular, not custom) posts from different categories. this is the basic code: ``` function my_special_nav_class( $classes, $item ) { if ( is_single() && (in_category('workshops') ) { $classes[] = 's...
I found the correct syntax is: ``` if ( is_single() && in_category ( '5' ) ) { ``` However, I solved the problem using this code: ``` //add category classes to single.php add_filter('body_class','add_category_to_single'); function add_category_to_single($classes, $class) { if (is_single() ) { glob...
165,966
<p>Im trying to set up a taxonomy to hide a post_format on a particular page.</p> <p>I have created the below which stops that post_format from displaying on the page but it also hides it in the 'Posts' page on the CMS. Is there a way to get around this?</p> <pre><code> function exclude_campaigns( $query ) { ...
[ { "answer_id": 165968, "author": "iyrin", "author_id": 33393, "author_profile": "https://wordpress.stackexchange.com/users/33393", "pm_score": 0, "selected": false, "text": "<p>Use <code>in_category( $category )</code> and <code>is_category( $category )</code> in your conditional stateme...
2014/10/20
[ "https://wordpress.stackexchange.com/questions/165966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37852/" ]
Im trying to set up a taxonomy to hide a post\_format on a particular page. I have created the below which stops that post\_format from displaying on the page but it also hides it in the 'Posts' page on the CMS. Is there a way to get around this? ``` function exclude_campaigns( $query ) { if( $query->is_m...
I found the correct syntax is: ``` if ( is_single() && in_category ( '5' ) ) { ``` However, I solved the problem using this code: ``` //add category classes to single.php add_filter('body_class','add_category_to_single'); function add_category_to_single($classes, $class) { if (is_single() ) { glob...
166,010
<p>I'm trying to create a new home page with two columns for latest post of specific category. This the page code:</p> <pre><code> &lt;div id="left-column"&gt; &lt;div class="bloccorosso"&gt;News &amp; Blog&lt;/div&gt; &lt;?php $catquery = new WP_Query( 'cat=5&amp;posts_per_page=3' ); while($catquery-&gt;hav...
[ { "answer_id": 165980, "author": "Hakkim", "author_id": 62335, "author_profile": "https://wordpress.stackexchange.com/users/62335", "pm_score": 0, "selected": false, "text": "<p>I'm not sure whether its possible to download an external file directly to WordPress. But you can simply embed...
2014/10/21
[ "https://wordpress.stackexchange.com/questions/166010", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51160/" ]
I'm trying to create a new home page with two columns for latest post of specific category. This the page code: ``` <div id="left-column"> <div class="bloccorosso">News & Blog</div> <?php $catquery = new WP_Query( 'cat=5&posts_per_page=3' ); while($catquery->have_posts()) : $catquery->the_post(); ?> <ul> <l...
@Amirreza Nasiri - Yes that is possible. I have used following plugin to import large size files into WordPress Media library. Please take a look at this: <https://wordpress.org/plugins/add-from-server/> I have no affiliation with plugin. I had used it for one of my client project and just found it as suitable suggest...
166,024
<p>I'm trying to sort my posts by a custom field value, called price. Only using numbers in the custom field value. I want that the visitors of the website can sort the posts on price by using a dropdown. I searched for a plugin, but couldn't found that. Now u found the code below:</p> <pre><code>&lt;?php $order = "...
[ { "answer_id": 166036, "author": "Ashok Kumar Nath", "author_id": 43284, "author_profile": "https://wordpress.stackexchange.com/users/43284", "pm_score": 1, "selected": false, "text": "<p>Instead of <code>query_posts</code> try using <code>WP_Query</code> class. <a href=\"http://codex.wo...
2014/10/21
[ "https://wordpress.stackexchange.com/questions/166024", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62393/" ]
I'm trying to sort my posts by a custom field value, called price. Only using numbers in the custom field value. I want that the visitors of the website can sort the posts on price by using a dropdown. I searched for a plugin, but couldn't found that. Now u found the code below: ``` <?php $order = "&order=DESC"; i...
Instead of `query_posts` try using `WP_Query` class. <http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters> This is example from codex: ``` $args = array( 'post_type' => 'my_custom_post_type', 'meta_key' => 'age', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_query' => ...
166,029
<p>Is there a way I can retrieve an array of post ids queried from the following:</p> <pre><code>$latest = new WP_Query( array ( 'orderby' =&gt; 'rand', 'posts_per_page' =&gt; 3 )); if ( $latest -&gt; have_posts() ) : while ( $latest -&gt; have_posts() ) : $latest -&gt; the_post(); g...
[ { "answer_id": 166033, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 7, "selected": true, "text": "<p>Try</p>\n\n<pre><code>$post_ids = wp_list_pluck( $latest-&gt;posts, 'ID' );\n</code></pre>\n\n<p>Read <a href=...
2014/10/21
[ "https://wordpress.stackexchange.com/questions/166029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27716/" ]
Is there a way I can retrieve an array of post ids queried from the following: ``` $latest = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => 3 )); if ( $latest -> have_posts() ) : while ( $latest -> have_posts() ) : $latest -> the_post(); get_template_part( 'templates/...
Try ``` $post_ids = wp_list_pluck( $latest->posts, 'ID' ); ``` Read [`wp_list_pluck`](http://codex.wordpress.org/Function_Reference/wp_list_pluck)
166,056
<p>I am working on a theme that requires a piece of dynamic content nested in the navigation. I'm using a custom walker to generate the menu. I need a way to add markup to the code that will be editable on the back end (probably ACF, not important). </p> <p>The content will nest inside a specific section of the menu...
[ { "answer_id": 166033, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 7, "selected": true, "text": "<p>Try</p>\n\n<pre><code>$post_ids = wp_list_pluck( $latest-&gt;posts, 'ID' );\n</code></pre>\n\n<p>Read <a href=...
2014/10/21
[ "https://wordpress.stackexchange.com/questions/166056", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62402/" ]
I am working on a theme that requires a piece of dynamic content nested in the navigation. I'm using a custom walker to generate the menu. I need a way to add markup to the code that will be editable on the back end (probably ACF, not important). The content will nest inside a specific section of the menu ("Products"...
Try ``` $post_ids = wp_list_pluck( $latest->posts, 'ID' ); ``` Read [`wp_list_pluck`](http://codex.wordpress.org/Function_Reference/wp_list_pluck)
166,081
<p>I was creating my application to automate all of my blogs from my desktop. Target, I'll post blog. That's all. I used <strong>XMLRPC</strong> service, as you know "xmlrpc.php".</p> <p>I built many of parts, near to done... But stucked at custom fields which are starting with (_) an underscore. I would like to save ...
[ { "answer_id": 166085, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<h2>Playing with XML-RPC and underscored custom fields:</h2>\n\n<p>Let's say we want to set the featured image t...
2014/10/22
[ "https://wordpress.stackexchange.com/questions/166081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62414/" ]
I was creating my application to automate all of my blogs from my desktop. Target, I'll post blog. That's all. I used **XMLRPC** service, as you know "xmlrpc.php". I built many of parts, near to done... But stucked at custom fields which are starting with (\_) an underscore. I would like to save as "\_thumbnail\_id" =...
Playing with XML-RPC and underscored custom fields: --------------------------------------------------- Let's say we want to set the featured image to a given post with `$remote_post_id`. We want it to be the attachment with ID equal to `300`, so we want `_thumbnail_id` to be `300`. Here are three methods how one co...
166,106
<p>I'm trying hard to get the post ID of the current post/page inside a widget class but doesn't work, I know there's get_the_ID() and some other options but not a single works inside a widget. Here's my code:</p> <pre><code>public function widget( $args, $instance ) { global $wp_query; $thePostID = $wp_query...
[ { "answer_id": 166112, "author": "Ram Ratan Maurya", "author_id": 24756, "author_profile": "https://wordpress.stackexchange.com/users/24756", "pm_score": 4, "selected": true, "text": "<p>You can make use of <a href=\"https://codex.wordpress.org/Function_Reference/get_queried_object\" rel...
2014/10/22
[ "https://wordpress.stackexchange.com/questions/166106", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48736/" ]
I'm trying hard to get the post ID of the current post/page inside a widget class but doesn't work, I know there's get\_the\_ID() and some other options but not a single works inside a widget. Here's my code: ``` public function widget( $args, $instance ) { global $wp_query; $thePostID = $wp_query->post->ID; ...
You can make use of [`get_queried_object()`](https://codex.wordpress.org/Function_Reference/get_queried_object) here, which is a wrapper for `$wp_query` and returns the whole post metadata. Here's a sample code: ``` $queried_object = get_queried_object(); if ( $queried_object ) { $post_id = $queried_object->ID; ...
166,124
<p>I am intergrating WordPress with a non WordPress site. I have installed WordPress at my <a href="http://www.evercam.io/wordpress" rel="nofollow">evercam.io/wordpress</a> and I have followed the <a href="http://codex.wordpress.org/Integrating_WordPress_with_Your_Website" rel="nofollow">codex</a> and I have been able ...
[ { "answer_id": 166130, "author": "Brendonwbrown", "author_id": 54675, "author_profile": "https://wordpress.stackexchange.com/users/54675", "pm_score": 1, "selected": false, "text": "<p>If I understand your needs correctly, you would like to have your /blog page and post items aggregated ...
2014/10/22
[ "https://wordpress.stackexchange.com/questions/166124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43113/" ]
I am intergrating WordPress with a non WordPress site. I have installed WordPress at my [evercam.io/wordpress](http://www.evercam.io/wordpress) and I have followed the [codex](http://codex.wordpress.org/Integrating_WordPress_with_Your_Website) and I have been able to display a list of posts on a static page that I have...
If I understand your needs correctly, you would like to have your /blog page and post items aggregated and driven by WordPress without exposing the user to anything WordPress. To solve the problem with "wordpress" being in the url, you should actually be putting the entire *contents* of the WordPress install into the ...
166,161
<p>I've inherited a site built with a theme by Highgrade (<a href="http://www.highgradelab.com/themes/southcentral/" rel="nofollow">southcentral</a>) which is built using the Redux framework.</p> <p>I'm seeing the following error in the frontend and admin panel:</p> <pre><code>Warning: Invalid argument supplied for f...
[ { "answer_id": 166172, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<p>It is not necessary to use the WP_Filesystem for every little thing, and in this case, the correct solution is to ...
2014/10/22
[ "https://wordpress.stackexchange.com/questions/166161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/500/" ]
I've inherited a site built with a theme by Highgrade ([southcentral](http://www.highgradelab.com/themes/southcentral/)) which is built using the Redux framework. I'm seeing the following error in the frontend and admin panel: ``` Warning: Invalid argument supplied for foreach() in /Volumes/Data/Users/me/Sites/refere...
It is not necessary to use the WP\_Filesystem for every little thing, and in this case, the correct solution is to use the normal `file_get_contents`. The WP\_Filesystem is a wrapper around various ways to interact with the filesystem in a safe manner... but it's not meant for everything. Fundamentally, the WP\_Files...
166,165
<p>I have multiple custom posts types that use the same category taxonomy. Let's call the CPT's 'venue' and 'story', and say we have categorised each of them as 'foo'. </p> <p>I already have the following code to ensure they're part of the taxonomy loops:</p> <pre><code>//make sure these custom post types are registe...
[ { "answer_id": 166170, "author": "indietravel", "author_id": 62442, "author_profile": "https://wordpress.stackexchange.com/users/62442", "pm_score": 2, "selected": false, "text": "<p>Solution: </p>\n\n<pre><code>//make sure these custom post types are registered for taxonomy queries\n\na...
2014/10/22
[ "https://wordpress.stackexchange.com/questions/166165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62442/" ]
I have multiple custom posts types that use the same category taxonomy. Let's call the CPT's 'venue' and 'story', and say we have categorised each of them as 'foo'. I already have the following code to ensure they're part of the taxonomy loops: ``` //make sure these custom post types are registered for taxonomy quer...
Solution: ``` //make sure these custom post types are registered for taxonomy queries add_filter('pre_get_posts', 'query_post_type'); function query_post_type($query) { if(is_category() || is_tag()) { $post_type = get_query_var('post_type'); if($post_type) $post_type = $post_type; else ...
166,181
<p>After a server move, I'm unable to log in to my site. I get the "ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress." error when I try submitting the login form.</p> <p>I'm positive that my browser supports cookies and that they're not blocked.</p> <p>I've researc...
[ { "answer_id": 166384, "author": "Sarah German", "author_id": 62361, "author_profile": "https://wordpress.stackexchange.com/users/62361", "pm_score": 4, "selected": true, "text": "<p>It was Varnish.</p>\n\n<p>Our web host had Varnish set up in a Drupal-specific manner, and it was filteri...
2014/10/22
[ "https://wordpress.stackexchange.com/questions/166181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62361/" ]
After a server move, I'm unable to log in to my site. I get the "ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress." error when I try submitting the login form. I'm positive that my browser supports cookies and that they're not blocked. I've researched this pretty t...
It was Varnish. Our web host had Varnish set up in a Drupal-specific manner, and it was filtering out the cookies that WordPress uses to handle logins.
166,185
<p>I am building a Bootstrap site on WordPress and need to be able include multiple stylesheets. However, when I enqueue them as follows, only the first and third style sheets show up in the page source. I have confirmed that all three files are on the server.</p> <pre><code>wp_enqueue_style( 'mamies-wafers-bootstrap...
[ { "answer_id": 166186, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 5, "selected": true, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_style\" rel=\"noreferrer\"><code>...
2014/10/22
[ "https://wordpress.stackexchange.com/questions/166185", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48611/" ]
I am building a Bootstrap site on WordPress and need to be able include multiple stylesheets. However, when I enqueue them as follows, only the first and third style sheets show up in the page source. I have confirmed that all three files are on the server. ``` wp_enqueue_style( 'mamies-wafers-bootstrap-min', '/wp-co...
The [`wp_enqueue_style()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) function uses the following format and parameters: ``` wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ); ``` In your case, you could try the following: ``` <?php /** * Proper way to e...
166,206
<p>I would like to know is there any way to catch all PHP errors (not only WP Errors) in Wordpress without modifying core?</p> <p>The reason I am asking is that I would like to manually catch all errors and <strike>use third party software as an error aggregator, for example Sentry, but not limited to.</strike> for ex...
[ { "answer_id": 166186, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 5, "selected": true, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_style\" rel=\"noreferrer\"><code>...
2014/10/23
[ "https://wordpress.stackexchange.com/questions/166206", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62468/" ]
I would like to know is there any way to catch all PHP errors (not only WP Errors) in Wordpress without modifying core? The reason I am asking is that I would like to manually catch all errors and use third party software as an error aggregator, for example Sentry, but not limited to. for example email them or log to ...
The [`wp_enqueue_style()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) function uses the following format and parameters: ``` wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ); ``` In your case, you could try the following: ``` <?php /** * Proper way to e...
166,230
<pre><code> &lt;?php require_once("../../../wp-includes/wp-db.php"); wpdb::insert( 'wp_options', array( 'option_name' =&gt; 'data1', 'option_value' =&gt; 'data2' ) ); ?&gt; </code></pre> <p>I have this code not working...It gets the following message</p> <blockquote> <p>Fatal error: Using $this whe...
[ { "answer_id": 166234, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 1, "selected": false, "text": "<p><code>insert</code> is not a static method. So you can't call it like this: <code>wpdb::insert(/*...*/)<...
2014/10/23
[ "https://wordpress.stackexchange.com/questions/166230", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58297/" ]
``` <?php require_once("../../../wp-includes/wp-db.php"); wpdb::insert( 'wp_options', array( 'option_name' => 'data1', 'option_value' => 'data2' ) ); ?> ``` I have this code not working...It gets the following message > > Fatal error: Using $this when not in object context in url/wp-includes/wp-db...
`insert` is not a static method. So you can't call it like this: `wpdb::insert(/*...*/)`. You'll need to do something like: ``` global $wpdb; $wpdb->insert(/*...*/); ``` Or create your own instance: ``` $db = new wpdb('dbuser', 'dbpassword', 'dbname', 'dbhost'); // change these! $db->insert(/*...*/); ```
166,232
<p>I used WP_Query to find posts of a certain criteria and loop through them performing actions. I grabbed the post id in the loop and assigned it to a variable <code>$i</code> to perform functions on.</p> <p>Before the loop I used <code>get_the_id()</code> and it correctly displays the custom post page ID I am on. Af...
[ { "answer_id": 166236, "author": "Hakkim", "author_id": 62335, "author_profile": "https://wordpress.stackexchange.com/users/62335", "pm_score": 0, "selected": false, "text": "<p>Try <code>&lt;?php wp_reset_query(); ?&gt;</code> after the while loop, this will reset your custom query data...
2014/10/23
[ "https://wordpress.stackexchange.com/questions/166232", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51823/" ]
I used WP\_Query to find posts of a certain criteria and loop through them performing actions. I grabbed the post id in the loop and assigned it to a variable `$i` to perform functions on. Before the loop I used `get_the_id()` and it correctly displays the custom post page ID I am on. After the loop I used it again bu...
If you need to get the ID from the current page, you should make use of [`get_queried_object_id()`](http://queryposts.com/function/get_queried_object_id/) which will return the ID of the current queried object. A new instance of `WP_Query` alters the `$post` global variable, that is why after your loop you'll see the...
166,266
<p>My default media setting in WordPress blog is <strong>150x150</strong>, <strong>300x300</strong>, <strong>1024x1024</strong> respectively for <strong>thumbnail</strong>, <strong>medium</strong>, <strong>large</strong> images. Now I am designing a theme that need different size thumbnail images to show in theme. For ...
[ { "answer_id": 166278, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": true, "text": "<p>A quick and easy fix for this is to make use of a plugin called <a href=\"https://wordpress.org/plugins/...
2014/10/23
[ "https://wordpress.stackexchange.com/questions/166266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52859/" ]
My default media setting in WordPress blog is **150x150**, **300x300**, **1024x1024** respectively for **thumbnail**, **medium**, **large** images. Now I am designing a theme that need different size thumbnail images to show in theme. For this, I go to the media setting again and changed the setting with my news sizes ...
A quick and easy fix for this is to make use of a plugin called [Force Regenerate Thumbnails](https://wordpress.org/plugins/force-regenerate-thumbnails/) (*to which I don't have any affiliation to*) Unlike a plugin like Regenerating Thumbnails, Force Regenerate Thumbnails creates all your new custom sizes and delete a...
166,287
<p>I have made a custom post type "projects" with custom taxonomy "tag", here's the snippet from code:</p> <pre><code>$args = array( 'post_type'=&gt; 'projects', ); $qry = new WP_Query( $args ); ?&gt; &lt;section id="primary" class="site-content"&gt; &lt;div id="content" role="main"&gt; &lt;?ph...
[ { "answer_id": 166288, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>You want <a href=\"http://codex.wordpress.org/Function_Reference/single_term_title#Description\" rel=\"nofol...
2014/10/23
[ "https://wordpress.stackexchange.com/questions/166287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48736/" ]
I have made a custom post type "projects" with custom taxonomy "tag", here's the snippet from code: ``` $args = array( 'post_type'=> 'projects', ); $qry = new WP_Query( $args ); ?> <section id="primary" class="site-content"> <div id="content" role="main"> <?php if ( $qry->have_posts() ) : ?> ...
For custom taxonomy terms, use [`single_term_title`](http://codex.wordpress.org/Function_Reference/single_term_title) > > Displays or returns the term title for the current page. > > > Alternatively you can make use of `echo get_queried_object()->name`
166,355
<p>According to <a href="https://stackoverflow.com/questions/14521488/apis-available-to-pull-wordpress-blog-posts-into-jquery-mobile-app">this post</a> there is no built-in JavaScript API for Wordpress. Therefore developers who want to build on AJAX seem to come up all with their own solution which doesn't seem right t...
[ { "answer_id": 166357, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 2, "selected": false, "text": "<p>There has been quite a bit of development around the JSON REST API that is supposed to be <a href=\"http:/...
2014/10/24
[ "https://wordpress.stackexchange.com/questions/166355", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54967/" ]
According to [this post](https://stackoverflow.com/questions/14521488/apis-available-to-pull-wordpress-blog-posts-into-jquery-mobile-app) there is no built-in JavaScript API for Wordpress. Therefore developers who want to build on AJAX seem to come up all with their own solution which doesn't seem right to me. What I...
TL;DR ===== There is no JavaScript API in the WordPress core and no one is planned, but actually, there is no need of it. Backend ======= First of all let's say that, regarding the backend, some useful information can be fetched from already present JavaScript global variables (WordPress loves all global flavors). ...
166,363
<p>I'm using WP_User_Query to bring back a list of users. According to <a href="http://codex.wordpress.org/Class_Reference/WP_User_Query#Search_Parameters" rel="nofollow">this article</a>, I can focus the query on particular columns (I'm assuming in the wp_users table) using the search_columns param. </p> <p>My query:...
[ { "answer_id": 166368, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 2, "selected": false, "text": "<p>According to the <a href=\"http://codex.wordpress.org/Class_Reference/WP_User_Query#Search_Parameters\" rel=\...
2014/10/24
[ "https://wordpress.stackexchange.com/questions/166363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22599/" ]
I'm using WP\_User\_Query to bring back a list of users. According to [this article](http://codex.wordpress.org/Class_Reference/WP_User_Query#Search_Parameters), I can focus the query on particular columns (I'm assuming in the wp\_users table) using the search\_columns param. My query: ``` $args = array( 'search...
You can try this: ``` /** * Add support for the "display_name" search column in WP_User_Query * * @see http://wordpress.stackexchange.com/a/166369/26350 */ add_filter( 'user_search_columns', function( $search_columns ) { $search_columns[] = 'display_name'; return $search_columns; } ); ``` where we use t...
166,380
<p>I have a post type with 7 (count it SEVEN!) taxonomy tag boxes. By default, the only options to display these metaboxes are - 7 small metaboxes on the right side stacking or turn these tag metaboxes into Long metaboxes and stack them below the main editor.</p> <p>What I'd rather do is bring all the metaboxes into 1...
[ { "answer_id": 166368, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 2, "selected": false, "text": "<p>According to the <a href=\"http://codex.wordpress.org/Class_Reference/WP_User_Query#Search_Parameters\" rel=\...
2014/10/24
[ "https://wordpress.stackexchange.com/questions/166380", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
I have a post type with 7 (count it SEVEN!) taxonomy tag boxes. By default, the only options to display these metaboxes are - 7 small metaboxes on the right side stacking or turn these tag metaboxes into Long metaboxes and stack them below the main editor. What I'd rather do is bring all the metaboxes into 1 big metab...
You can try this: ``` /** * Add support for the "display_name" search column in WP_User_Query * * @see http://wordpress.stackexchange.com/a/166369/26350 */ add_filter( 'user_search_columns', function( $search_columns ) { $search_columns[] = 'display_name'; return $search_columns; } ); ``` where we use t...
166,382
<p>In a page of posts, how do I show their date, instead of the page date? I have no php knowledge.</p> <p>Let's say I want to show the single posts date here, instead to the single posts title.</p> <pre><code>&lt;?php if($block === 'title'): ?&gt; &lt;h2 class="post-title"&gt; &lt;?php echo empty($...
[ { "answer_id": 166388, "author": "jetlej", "author_id": 9862, "author_profile": "https://wordpress.stackexchange.com/users/9862", "pm_score": 0, "selected": false, "text": "<p>Not sure what kind of plugin you're using there, but my guess would be: </p>\n\n<pre><code>&lt;?php if($block ==...
2014/10/24
[ "https://wordpress.stackexchange.com/questions/166382", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62535/" ]
In a page of posts, how do I show their date, instead of the page date? I have no php knowledge. Let's say I want to show the single posts date here, instead to the single posts title. ``` <?php if($block === 'title'): ?> <h2 class="post-title"> <?php echo empty($link_setting) || $link_sett...
Use [`get_the_date()`](http://codex.wordpress.org/Function_Reference/get_the_date) if you want to change the [date format](http://codex.wordpress.org/Formatting_Date_and_Time). ``` get_the_date( 'S F Y', $post ); ``` The 2nd argument is optional and only needed outside the loop.
166,392
<p>WordPress provides a helpful function called <code>is_email()</code> which checks if a given email address is valid. Is there a similar function available to check if a URL is valid?</p> <p>I tried <code>is_url()</code> but that was just wishful thinking on my part.</p> <p>Ref: <a href="http://codex.wordpress.org/...
[ { "answer_id": 166394, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 5, "selected": true, "text": "<p>Use the native php function <a href=\"http://php.net/manual/ref.filter.php\" rel=\"noreferrer\">Filter Validat...
2014/10/24
[ "https://wordpress.stackexchange.com/questions/166392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22599/" ]
WordPress provides a helpful function called `is_email()` which checks if a given email address is valid. Is there a similar function available to check if a URL is valid? I tried `is_url()` but that was just wishful thinking on my part. Ref: <http://codex.wordpress.org/Function_Reference/is_email>
Use the native php function [Filter Validator](http://php.net/manual/ref.filter.php) ``` if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { die('Not a valid URL'); } ```
166,410
<p>I'm working with a custom post type / custom taxonomy combo and I can't seem to get pagination to work properly. I'm wanting to add an infinite scroll to the page, however I can't even get pagination to even show up in order to get the infinite scroll piece working.</p> <p>Below is my loop:</p> <pre><code>&lt;?ph...
[ { "answer_id": 166394, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 5, "selected": true, "text": "<p>Use the native php function <a href=\"http://php.net/manual/ref.filter.php\" rel=\"noreferrer\">Filter Validat...
2014/10/24
[ "https://wordpress.stackexchange.com/questions/166410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62557/" ]
I'm working with a custom post type / custom taxonomy combo and I can't seem to get pagination to work properly. I'm wanting to add an infinite scroll to the page, however I can't even get pagination to even show up in order to get the infinite scroll piece working. Below is my loop: ``` <?php $paged = (get_query...
Use the native php function [Filter Validator](http://php.net/manual/ref.filter.php) ``` if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { die('Not a valid URL'); } ```
166,448
<p>I'm working on a website for a company that will very likely be creating millions of posts via a custom post type. They're prayers, so basically the user on the front end just submits a short phrase via a form. All the company cares about is the post content and the date posted. The site hasn't even launched yet and...
[ { "answer_id": 166699, "author": "iyrin", "author_id": 33393, "author_profile": "https://wordpress.stackexchange.com/users/33393", "pm_score": 6, "selected": true, "text": "<h2>1. Set the query <em>before</em> WP_Query is run</h2>\n\n<p>This seems to be the most important thing to keep i...
2014/10/25
[ "https://wordpress.stackexchange.com/questions/166448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25029/" ]
I'm working on a website for a company that will very likely be creating millions of posts via a custom post type. They're prayers, so basically the user on the front end just submits a short phrase via a form. All the company cares about is the post content and the date posted. The site hasn't even launched yet and th...
1. Set the query *before* WP\_Query is run ------------------------------------------ This seems to be the most important thing to keep in mind when trying to keep database queries to a minimum since the only opportunity to alter the query is, of course, before it is run in the SQL database. **Normal Queries** For...
166,449
<p>I'm creating a plugin that needs to replace <code>the_content</code> of only two specific pages that it created upon activation. </p> <p>Here is my code:</p> <pre><code>add_filter('the_content', 'emd_content'); function emd_content() { if ( is_page('Member Directory') ) { include dirname( __FILE__ ) . '...
[ { "answer_id": 166699, "author": "iyrin", "author_id": 33393, "author_profile": "https://wordpress.stackexchange.com/users/33393", "pm_score": 6, "selected": true, "text": "<h2>1. Set the query <em>before</em> WP_Query is run</h2>\n\n<p>This seems to be the most important thing to keep i...
2014/10/25
[ "https://wordpress.stackexchange.com/questions/166449", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14190/" ]
I'm creating a plugin that needs to replace `the_content` of only two specific pages that it created upon activation. Here is my code: ``` add_filter('the_content', 'emd_content'); function emd_content() { if ( is_page('Member Directory') ) { include dirname( __FILE__ ) . '/content-members.php'; } ...
1. Set the query *before* WP\_Query is run ------------------------------------------ This seems to be the most important thing to keep in mind when trying to keep database queries to a minimum since the only opportunity to alter the query is, of course, before it is run in the SQL database. **Normal Queries** For...
166,465
<p>I'm using the default twentythirteen on a wordpress 4.0 site. I have one site in the network right now. I may be adding one or two next year or so. Both blogs are using twentythirteen. Right now the "main" blog only loops out its own posts. I want it to include the child blog. Is there a good way to do this? Doesn't...
[ { "answer_id": 166482, "author": "Bordoni", "author_id": 12166, "author_profile": "https://wordpress.stackexchange.com/users/12166", "pm_score": -1, "selected": false, "text": "<p>On the Database the Taxonomies should be less intensive for sure, meta table gets crowded fast!</p>\n\n<p>I ...
2014/10/26
[ "https://wordpress.stackexchange.com/questions/166465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16567/" ]
I'm using the default twentythirteen on a wordpress 4.0 site. I have one site in the network right now. I may be adding one or two next year or so. Both blogs are using twentythirteen. Right now the "main" blog only loops out its own posts. I want it to include the child blog. Is there a good way to do this? Doesn't ma...
I had the same question [here](http://ottopress.com/2011/when-to-not-use-a-custom-taxonomy/) and it came down to this... It depends! (yep that's it). This is what Otto said... > > Your question cannot be answered because you don’t give a proper > scenario or framework by which to answer it. > > > Searching by meta...