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
41,588
<p>When I use <code>the_permalink</code> or <code>get_the_permalink</code> in a draft or scheduled post, the URL provided is not the "final" permalink—it is the unpretty <code>?p=xxxxx</code> version.</p> <p>How can I get the final, "clean" permalink to show up in a draft or scheduled post? </p> <p>I could do somethi...
[ { "answer_id": 42988, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 4, "selected": true, "text": "<p>This is a little \"hacky\", but when you call <code>get_permalink</code> and you need the permalink for ...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41588", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
When I use `the_permalink` or `get_the_permalink` in a draft or scheduled post, the URL provided is not the "final" permalink—it is the unpretty `?p=xxxxx` version. How can I get the final, "clean" permalink to show up in a draft or scheduled post? I could do something involving `$post->post_name`, but I'd need the ...
This is a little "hacky", but when you call `get_permalink` and you need the permalink for a draft, provide a clone of your post object with the details filled in: ``` global $post; if ( in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) { $my_post = clone $post; $my_post->post_status ...
41,592
<p>I have created a plugin which will create a table in database on plugin activation.</p> <p>When I enabled the plugin and check the database, there was no new table which I want to create. Here is my plugin file code.</p> <pre><code>&lt;?php /* Plugin Name: wp_course_management Description: Wordpress plugin for cou...
[ { "answer_id": 41594, "author": "Arvind Pal", "author_id": 12858, "author_profile": "https://wordpress.stackexchange.com/users/12858", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;?php\n/*\nPlugin Name: wp_course_management\nDescription: Wordpress plugin for course managemen...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41592", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11985/" ]
I have created a plugin which will create a table in database on plugin activation. When I enabled the plugin and check the database, there was no new table which I want to create. Here is my plugin file code. ``` <?php /* Plugin Name: wp_course_management Description: Wordpress plugin for course management for an ed...
Instead of this code ``` $sql = $wpdb->prepare( "CREATE TABLE %s ( id mediumint(9) NOT NULL AUTO_INCREMENT, time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, name tinytext NOT NULL, text text NOT NULL, url VARCHAR(55) DEFAULT '' NOT NULL, UNIQUE KEY id (id) );", $table_name ...
41,596
<p>Can anyone help me develop a wordpress script that [IF] will get first image post and if it doesn't exist it will [ELSE] get first attached (uploaded) image.</p> <p><strong>Theoretically:</strong> [IF exists]</p> <pre><code>&lt;img src="&lt;?php echo catch_that_image() ?&gt;" /&gt; </code></pre> <p>[or ELSE]</p> ...
[ { "answer_id": 41599, "author": "turbonerd", "author_id": 6344, "author_profile": "https://wordpress.stackexchange.com/users/6344", "pm_score": 0, "selected": false, "text": "<p><strong>Updated answer</strong></p>\n\n<p>Updated the code from dan's comment on this post.</p>\n\n<pre><code>...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41596", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12897/" ]
Can anyone help me develop a wordpress script that [IF] will get first image post and if it doesn't exist it will [ELSE] get first attached (uploaded) image. **Theoretically:** [IF exists] ``` <img src="<?php echo catch_that_image() ?>" /> ``` [or ELSE] ``` <img src="'. wp_get_attachment_url($attachment->ID) . '" ...
Check the [Get The Image][1] plugin by Justin Tadlock, it offer many options and fallbacks for getting images.
41,610
<p>As far as I understand (from the <a href="http://codex.wordpress.org/Function_Reference/get_template_part#Using_loop.php_in_child_themes" rel="nofollow">get_template_part codex</a>) <code>get_template_part</code> is just a wrapper round the PHP require function.</p> <p>So if I have a variable that I have create in ...
[ { "answer_id": 41611, "author": "icc97", "author_id": 5433, "author_profile": "https://wordpress.stackexchange.com/users/5433", "pm_score": 4, "selected": true, "text": "<p>D'oh, it just needs a <code>global</code> as its inside a function.</p>\n\n<p>messages.php:</p>\n\n<pre><code>&lt;?...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41610", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5433/" ]
As far as I understand (from the [get\_template\_part codex](http://codex.wordpress.org/Function_Reference/get_template_part#Using_loop.php_in_child_themes)) `get_template_part` is just a wrapper round the PHP require function. So if I have a variable that I have create in a page template file e.g. `$message`, I would...
D'oh, it just needs a `global` as its inside a function. messages.php: ``` <?php global $message; echo $message; ?> ```
41,629
<p>I'm having trouble uploading a custom image into Wordpress' dashboard. It says that it needs to be a custom 1000x288 image. When I upload it, I get the error of:</p> <pre><code>Warning: copy(/var/sites/zeldezine/wordpress/wp-content/uploads/2012/02/header.jpg) [function.copy]: failed to open stream: Permission deni...
[ { "answer_id": 41645, "author": "Sufiyan Ghori", "author_id": 12276, "author_profile": "https://wordpress.stackexchange.com/users/12276", "pm_score": -1, "selected": false, "text": "<p>whenever you upload something , wordpress will automatically generate sub-folders inside 'uploads' base...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm having trouble uploading a custom image into Wordpress' dashboard. It says that it needs to be a custom 1000x288 image. When I upload it, I get the error of: ``` Warning: copy(/var/sites/zeldezine/wordpress/wp-content/uploads/2012/02/header.jpg) [function.copy]: failed to open stream: Permission denied in /var/sit...
Please Give the permission to Folder uploads to 755 and its subfolders.
41,643
<p>I don't want to show the permalink if the user is subscriber. Can anyone help me to achieve that?</p> <p>PS: I'm talking about the permalink which appears <code>below title</code> while creating new post.</p> <p>PPS: I modified the rules for subscriber. They can able to submit the post for review </p>
[ { "answer_id": 41644, "author": "Yoav Aner", "author_id": 4741, "author_profile": "https://wordpress.stackexchange.com/users/4741", "pm_score": 2, "selected": false, "text": "<p>maybe this can do the trick? (untested). Note I used contributor role (Thanks to Brian Fegter for pointing thi...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41643", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5074/" ]
I don't want to show the permalink if the user is subscriber. Can anyone help me to achieve that? PS: I'm talking about the permalink which appears `below title` while creating new post. PPS: I modified the rules for subscriber. They can able to submit the post for review
``` function hide_slug_box() { global $post; global $pagenow; if (is_admin() && $pagenow=='post-new.php' OR $pagenow=='post.php') { echo "<script type='text/javascript'> jQuery(document).ready(function($) { jQuery('#edit-slug-box').hide(); }); </sc...
41,651
<p>I'm working on my admin area theme and I wanted to make some modifications on the way the thickbox and tinyMCE looks. I could make most of the changes through adding custom stylesheets and JS to my admin area using <code>wp_enqueue_script()</code> and <code>wp_enqueue_style()</code>, but I have had a hard time makin...
[ { "answer_id": 41652, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 2, "selected": false, "text": "<p>You could over-ride the CSS by using the <strike>admin_print_scripts</strike> <code>admin_head-media-upload...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41651", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13489/" ]
I'm working on my admin area theme and I wanted to make some modifications on the way the thickbox and tinyMCE looks. I could make most of the changes through adding custom stylesheets and JS to my admin area using `wp_enqueue_script()` and `wp_enqueue_style()`, but I have had a hard time making some others changes. Th...
You could over-ride the CSS by using the admin\_print\_scripts `admin_head-media-upload-popup` and add css to match your needs. This can be done via the functions.php file or by creating a plugin. Here is the code in a plugin format to begin adding style: ``` <?php /* Plugin Name: Some Name Description: Custom Thickbo...
41,653
<p>I'm using <a href="http://codex.wordpress.org/Settings_API" rel="noreferrer">Settings API</a> and wondering if there's any way of editing default output of <a href="http://codex.wordpress.org/Function_Reference/add_settings_field" rel="noreferrer">add_settings_field()</a> function?</p> <pre><code>add_settings_field...
[ { "answer_id": 41657, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 4, "selected": true, "text": "<p>If you look at <code>do_settings_fields()</code> (line 1125, <code>/wp-admin/includes/template.php</code>), yo...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I'm using [Settings API](http://codex.wordpress.org/Settings_API) and wondering if there's any way of editing default output of [add\_settings\_field()](http://codex.wordpress.org/Function_Reference/add_settings_field) function? ``` add_settings_field('the_field', 'bar', 'foo', 'page', 'section'); function foo(...
If you look at `do_settings_fields()` (line 1125, `/wp-admin/includes/template.php`), you can see that the table information is hardcoded into the the settings API. If you wish to not use the table, you will need to develop your own settings functions.
41,654
<p>in my wordpress plugin file I have this code that includes a javascript</p> <pre><code>function javascript_file-exmp() { $src = plugins_url('test.js', __FILE__); wp_register_script( 'links', $src ); wp_enqueue_script( 'links' ); wp_enqueue_script( 'jquery' ); } add_action('init','javascript_...
[ { "answer_id": 41658, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>A .js file should ONLY contain javascript. You should also have you javascript separated from your HTML (...a...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41654", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12918/" ]
in my wordpress plugin file I have this code that includes a javascript ``` function javascript_file-exmp() { $src = plugins_url('test.js', __FILE__); wp_register_script( 'links', $src ); wp_enqueue_script( 'links' ); wp_enqueue_script( 'jquery' ); } add_action('init','javascript_file-exmp'); ...
First you should use the wp\_enqueue\_scripts to load your scripts. ``` add_action( 'wp_enqueue_scripts' , 'javascript_file-exmp' ); ``` Second, be sure to both register and then enqueue your script **Register:** ``` wp_register_script( 'links', plugins_url( 'test.js', __FILE__ ), array( 'jquery' ), '1.0', true )...
41,660
<p>I am working on a website that is using posts as a way to manage glossary articles similar to the example website below. I would like to find a way to display articles alphabetically and grouped by a selected letter (such as the letter 'F' in the example). I would like the process to be automatic.</p> <p>Example of...
[ { "answer_id": 41748, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 5, "selected": true, "text": "<p>once up a time i did a client project where i had to have archives by first letter. thinking back i'm won...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41660", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2469/" ]
I am working on a website that is using posts as a way to manage glossary articles similar to the example website below. I would like to find a way to display articles alphabetically and grouped by a selected letter (such as the letter 'F' in the example). I would like the process to be automatic. Example of desired o...
once up a time i did a client project where i had to have archives by first letter. thinking back i'm wondering if shouldn't have just created a hidden taxonomy and then saved the first letter as a term in that taxonomy. **anyway, here's what i actually did:** ``` /* * Function Create Array of Letters that have pos...
41,667
<p>I have a Glossary CPT. Title, editor, slug and featured image.</p> <p>I would like to add a filter to Post content (and content of my other CPT "species") which looks through all of the content in each post and replaces any words found in the Glossary with a link to the glossary entry.</p> <p>For example...</p> <...
[ { "answer_id": 41999, "author": "Ian Dunn", "author_id": 3898, "author_profile": "https://wordpress.stackexchange.com/users/3898", "pm_score": 0, "selected": false, "text": "<p>Take a look at the <a href=\"http://wordpress.org/extend/plugins/linkify-text/\" rel=\"nofollow\">Linkify Text<...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41667", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
I have a Glossary CPT. Title, editor, slug and featured image. I would like to add a filter to Post content (and content of my other CPT "species") which looks through all of the content in each post and replaces any words found in the Glossary with a link to the glossary entry. For example... *Glossary entry*: test...
This was a fun project. I think I could write an entire chapter in a book on this (in fact, I practically did below). Anyway, I messed around with a bunch of ways to do this, and here's the simplest way I came up with: ``` function add_glossary_links($content) { global $wpdb, $wordlist; if ( !$wordlist && !$wo...
41,670
<p>I am trying to incorporate author avatars into my posts by doing <code>&lt;?php echo get_avatar( get_the_author_meta('ID'), 150 ); ?&gt;</code> but I can't go larger than 50x50px without it getting stretched (since the image is only 50x50px). It is using the BuddyPress thumbnail of the avatar. </p> <p>How can I get...
[ { "answer_id": 41685, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I am not an expert on BuddyPress specifically, but I believe that BP has a specified function :</p>\n\n<pre><code>...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12476/" ]
I am trying to incorporate author avatars into my posts by doing `<?php echo get_avatar( get_the_author_meta('ID'), 150 ); ?>` but I can't go larger than 50x50px without it getting stretched (since the image is only 50x50px). It is using the BuddyPress thumbnail of the avatar. How can I get it to use a larger thumbna...
I found the function that makes up bp\_post\_author\_avatar() and then changed the type to full. Place this funtion in functions.php and use the new function to call the post author avatar in the template. ``` function fod_post_author_avatar() { global $post; if ( function_exists('bp_core_fetch_avatar') ) { echo ...
41,674
<p>I am trying to figure out how to have a user bio in the user profile using BuddyPress.</p> <p>For example, on this page <a href="http://buddypress.org/community/members/johnjamesjacoby/activity/just-me/" rel="nofollow">http://buddypress.org/community/members/johnjamesjacoby/activity/just-me/</a> where it says "I he...
[ { "answer_id": 41696, "author": "Aces", "author_id": 7401, "author_profile": "https://wordpress.stackexchange.com/users/7401", "pm_score": 1, "selected": false, "text": "<p>If you enable Extended Profiles on the Buddypress > Components page, you can add new questions to the profile form ...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41674", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12476/" ]
I am trying to figure out how to have a user bio in the user profile using BuddyPress. For example, on this page <http://buddypress.org/community/members/johnjamesjacoby/activity/just-me/> where it says "I help lead the BuddyPress and bbPress projects. I also like puppies, potato chips, and a good nap." I'm assuming ...
I ended up adding a User Bio Profile Field and then displayed it by inserting the following into member-header.php in the BuddyPress theme files: ``` <?php if ( bp_get_profile_field_data( 'field=User Bio' ) ) : ?> <div class="user-bio"><?php bp_profile_field_data( 'field=User Bio' );?></div> <?php endif ?> ```
41,678
<p>I currently have episodes from a TV Show that feature bands playing, so for example I have:</p> <ul> <li>Moby </li> <li>The Dandy Warhols</li> <li>The Kooks</li> </ul> <p>My wp_query looks like this:</p> <pre><code>$loop = new WP_Query(array('post_type' =&gt; 'episodio', 'cat' =&gt; '9', 'posts_per_page' =&gt; 90...
[ { "answer_id": 41680, "author": "Kyle", "author_id": 12476, "author_profile": "https://wordpress.stackexchange.com/users/12476", "pm_score": 1, "selected": false, "text": "<p>If you're using the plugin SEO Ultimate (it's popular and I recommend using it), it has a component called Slug O...
2012/02/08
[ "https://wordpress.stackexchange.com/questions/41678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12183/" ]
I currently have episodes from a TV Show that feature bands playing, so for example I have: * Moby * The Dandy Warhols * The Kooks My wp\_query looks like this: ``` $loop = new WP_Query(array('post_type' => 'episodio', 'cat' => '9', 'posts_per_page' => 90, 'orderby' => 'title','order' => 'ASC' )); ``` But I want ...
If you're using the plugin SEO Ultimate (it's popular and I recommend using it), it has a component called Slug Optimizer that strips those types of words out of the post-slug, so if the post title is "The Dandy Warhols", the slug would just be "dandy-warhols". Perhaps just order by the post-slug?
41,692
<p>I have Genesis framework installed with a child theme. My client wants their themes "shopping cart" shortcode to be the last menu item, in their primary nav, no matter how many menu items there is.</p> <p><em>The shortcode:</em></p> <pre><code>echo do_shortcode('[shopping_cart]'); </code></pre> <p><em>Current cod...
[ { "answer_id": 41693, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<pre><code>add_filter('wp_nav_menu_items','my_item', 10, 2);\nfunction my_item($items, $args) {\n $items .= '&lt;l...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11333/" ]
I have Genesis framework installed with a child theme. My client wants their themes "shopping cart" shortcode to be the last menu item, in their primary nav, no matter how many menu items there is. *The shortcode:* ``` echo do_shortcode('[shopping_cart]'); ``` *Current code:* ``` $nav_output = sprintf ( '<...
``` add_filter('wp_nav_menu_items','my_item', 10, 2); function my_item($items, $args) { $items .= '<li class="myclass">whatever</li>'; return $items; } ``` If you have a specific theme location for menu you can target it with : ``` if( $args->theme_location == 'mylocation' ) ``` **EDIT I** you can try ...
41,695
<p>i want insert a dropdown menu with list of menus, that i've created in nav-menu.php, to post-admin...</p> <p>For example, when i'm creating a post, i want insert a menu "Paul" in a post (only a post that i want) selecting a menu at right sidebar of Admin-Post.</p> <p>I've copied the rows: </p> <pre><code>add_acti...
[ { "answer_id": 41716, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>To see how such a list can be created look at the code in <code>wp-admin/includes/nav-menu.php</code>. Unfortunately, ...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41695", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12932/" ]
i want insert a dropdown menu with list of menus, that i've created in nav-menu.php, to post-admin... For example, when i'm creating a post, i want insert a menu "Paul" in a post (only a post that i want) selecting a menu at right sidebar of Admin-Post. I've copied the rows: ``` add_action( 'init', 'register_my_men...
To see how such a list can be created look at the code in `wp-admin/includes/nav-menu.php`. Unfortunately, it is hard coded there, so you have to re-create the code. First, let’s create [two menus](https://i.stack.imgur.com/bNTme.jpg): ![enter image description here](https://i.stack.imgur.com/bNTme.jpg) We can get t...
41,698
<p>There are a good plugin, that allows user to make several galleries in one post not using manually "include" attribute.</p> <p><a href="http://wordpress.org/extend/plugins/multiple-galleries/" rel="nofollow">http://wordpress.org/extend/plugins/multiple-galleries/</a></p> <p>But after upgrading on 3.3.1 core versio...
[ { "answer_id": 41716, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>To see how such a list can be created look at the code in <code>wp-admin/includes/nav-menu.php</code>. Unfortunately, ...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41698", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12934/" ]
There are a good plugin, that allows user to make several galleries in one post not using manually "include" attribute. <http://wordpress.org/extend/plugins/multiple-galleries/> But after upgrading on 3.3.1 core version of WordPress this plugin don't work anymore. (I suggest this is because of changes in file post ma...
To see how such a list can be created look at the code in `wp-admin/includes/nav-menu.php`. Unfortunately, it is hard coded there, so you have to re-create the code. First, let’s create [two menus](https://i.stack.imgur.com/bNTme.jpg): ![enter image description here](https://i.stack.imgur.com/bNTme.jpg) We can get t...
41,699
<p><em><strong>In my application, users have to login first before accessing the website.</em></strong></p> <p>So now what I am doing, I have created one custom login page.</p> <p>How can I redirect a user to the login page if he/she is not logged in yet.</p> <p>Should i customize wp-login.php for login? Which is b...
[ { "answer_id": 41702, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": true, "text": "<p>You can use the following action to redirect all traffic to that login page. You will need to specify the pa...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41699", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12261/" ]
***In my application, users have to login first before accessing the website.*** So now what I am doing, I have created one custom login page. How can I redirect a user to the login page if he/she is not logged in yet. Should i customize wp-login.php for login? Which is better way, **1.** Redirect user to login pag...
You can use the following action to redirect all traffic to that login page. You will need to specify the page name and the page slug. ``` add_action('wp', 'wpse_41699_wp', 0); function wpse_41699_wp(){ if(is_page('Login')) return; if(!is_user_logged_in()){ $url = get_bloginfo('home').'/login';...
41,725
<p>I have a list of subcategories in a sidebar (children of top level category) and I also get a list of posts underneath each category. I only want to show those posts when we are under that subcategory or when we are viewing one of the posts. Each post comes under top level category and subcategory and I don't know h...
[ { "answer_id": 41728, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>You can filter for the subcategory by checking what the category parent is as so: <code>$category_object-&gt;...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41725", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12679/" ]
I have a list of subcategories in a sidebar (children of top level category) and I also get a list of posts underneath each category. I only want to show those posts when we are under that subcategory or when we are viewing one of the posts. Each post comes under top level category and subcategory and I don't know how ...
If you use the follow code: ``` <?php $cats = get_categories('child_of=6'); foreach ($cats as $cat) : $this_category = get_category($cat); $args = array( 'category__in' => array($cat->term_id) ); $my_query = new WP_Query($args); if...
41,730
<p>I'm just wondering why wordpress doesn't send confirmation mail every time user change his/her email address.</p> <p>How do we know that email address is not fake or mistyped?</p> <p>So can anyone give me some snippet to implement this function?</p> <h2>Update:</h2> <p>Here is the idea.</p> <ol> <li>user change...
[ { "answer_id": 44827, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 2, "selected": false, "text": "<p>This is a strange 'feature'. The function is actually available inside WordPress (WordPress.com has it enabl...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41730", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5074/" ]
I'm just wondering why wordpress doesn't send confirmation mail every time user change his/her email address. How do we know that email address is not fake or mistyped? So can anyone give me some snippet to implement this function? Update: ------- Here is the idea. 1. user changes his/her mail 2. We send confirmat...
Like SickHippie posted this functionality is native to WordPress but only for a multisite setup so here is the two functions you need to get this to work on a single site setup which are mostly code one for one from the core `/wp-admin/user-edit.php file` ``` function custom_send_confirmation_on_profile_email() { ...
41,755
<p>I have a bit of a problem/issue what is freaking me out a bit. I hope you can help me. If i do site:www.somesitename.com search in Google i see that Google is indexing my attachment pages. I want to redirect attachment URL's to parent post and stop google from indexing them. </p> <p>I have used different redirect p...
[ { "answer_id": 41770, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>If the page is reachable by a human, then an bot can and will index it, even though Google will follow a robots.txt...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12951/" ]
I have a bit of a problem/issue what is freaking me out a bit. I hope you can help me. If i do site:www.somesitename.com search in Google i see that Google is indexing my attachment pages. I want to redirect attachment URL's to parent post and stop google from indexing them. I have used different redirect plugins in ...
Just add this to your `functions.php` or plugin. ``` add_action( 'template_redirect', 'attachment_redirect', 1 ); /** * Redirect any attachment page to their parent with 301 redirection */ function attachment_redirect() { global $post; if ( is_attachment() AND isset( $post->post_parent) AND is_numeric( $post->po...
41,760
<p>Why does the jquery below not fire? Its going to the "else" every time.</p> <pre><code>if ( is_admin() &amp;&amp; $pagenow == 'theme-install.php' &amp;&amp; $_GET['tab']=="upload"){ add_action('admin_print_scripts', 'theme_upgrade_alert'); function theme_upgrade_alert(){ wp_enqueue_script('jquery');...
[ { "answer_id": 41765, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>First, check for syntax errors. The syntax highlighting seems to indicate that you have syntax errors.</p>\n...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41760", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
Why does the jquery below not fire? Its going to the "else" every time. ``` if ( is_admin() && $pagenow == 'theme-install.php' && $_GET['tab']=="upload"){ add_action('admin_print_scripts', 'theme_upgrade_alert'); function theme_upgrade_alert(){ wp_enqueue_script('jquery'); echo ' <scrip...
First, check for syntax errors. The syntax highlighting seems to indicate that you have syntax errors. Second, don't wrap your `add_action()` calls inside conditionals; rather, wrap your *callback function content* inside the conditionals, e.g.: ``` <?php function theme_upgrade_alernt() { if ( is_admin() && $page...
41,767
<p>Actualy the question says it all. I integrated a media upload box to my admin page and a button with the text 'Insert into post' makes no sense. I rather like to change it to something like 'Use this image'. Anyone got a clue on how you are able to do so?</p>
[ { "answer_id": 41772, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 3, "selected": true, "text": "<pre><code>add_filter(\"attribute_escape\", \"myfunction\", 10, 2);\nfunction myfunction($safe_text, $text) {\n ret...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41767", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8757/" ]
Actualy the question says it all. I integrated a media upload box to my admin page and a button with the text 'Insert into post' makes no sense. I rather like to change it to something like 'Use this image'. Anyone got a clue on how you are able to do so?
``` add_filter("attribute_escape", "myfunction", 10, 2); function myfunction($safe_text, $text) { return str_replace("Insert into Post", "Use this image", $text); } ``` Place in your theme functions file of in a plugin file. The first usable filter that this button hits is on the function `esc_attr()`. So what t...
41,776
<p>The code below allows me to retrieve the image string, when <code>Insert to Post</code> has been pressed, but what would be the correct way to retrieve the ID of the image? So I can retrieve all information through <code>wp_get_attachment_image_src</code>?</p> <pre><code>jQuery(document).ready(function() { var...
[ { "answer_id": 41782, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;input type=\"submit\" name=\"send[79]\" id=\"send[79]\" class=\"button\" value=\"Insert into Post\"&gt...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8757/" ]
The code below allows me to retrieve the image string, when `Insert to Post` has been pressed, but what would be the correct way to retrieve the ID of the image? So I can retrieve all information through `wp_get_attachment_image_src`? ``` jQuery(document).ready(function() { var form_field; var upload_field_ID...
You can also add in a filter that can add the ID as a html5 data attribute to the returned HTML fragment from send\_to\_editor. ``` public function image_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt){ $dom = new DOMDocument(); @$dom->loadHTML($html); $x = new DOMXPath($dom...
41,787
<p>I´m developing a theme that include plugins. One of this plugins is a contact form. And this plugin have an asociate code to validate input data. Because I don´t know in what pages contact form was been added... I want to find a right way to detect if a plugin is included in a current page. </p> <p>Sample: page.php...
[ { "answer_id": 41793, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>If I understand correctly you want to include a php file that validates the form input, but only when you ...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41787", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7023/" ]
I´m developing a theme that include plugins. One of this plugins is a contact form. And this plugin have an asociate code to validate input data. Because I don´t know in what pages contact form was been added... I want to find a right way to detect if a plugin is included in a current page. Sample: page.php ``` <?ph...
If I understand correctly you want to include a php file that validates the form input, but only when you need to actually validate something? In this case, you don't need to check if the contact form exists on some page - you just need to check if the form data has been posted. All you need to do is add a hidden fiel...
41,790
<p>Can I list all the blogs in my network on one page?</p>
[ { "answer_id": 41792, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>This will print out an unordered list of all public sites in a multisite network:</p>\n\n<pre><code>// $bcoun...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41790", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12727/" ]
Can I list all the blogs in my network on one page?
yes, small source for an template. ``` <ul class='postlist no-mp'> <?php /** * Old version, change on 07/23/2013 * $blogs = $wpdb->get_results( "SELECT blog_id,path FROM {$wpdb->blogs} WHERE blog_id != {$wpdb->blogid} AND site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AN...
41,797
<p>I've been working on building a theme for the past couple days now, and I've run into a wall. While I originally included foundation.js as an enqueued script, I couldn't remember why I had added it. Today, when I tried removing it (to improve page-load speed) from my functions.php file, it messed up all of my jQuery...
[ { "answer_id": 41798, "author": "turbonerd", "author_id": 6344, "author_profile": "https://wordpress.stackexchange.com/users/6344", "pm_score": 4, "selected": true, "text": "<p>Try changing the first line of your custom JS file.</p>\n\n<p><code>jQuery(document).ready(function($) {</code>...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41797", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11575/" ]
I've been working on building a theme for the past couple days now, and I've run into a wall. While I originally included foundation.js as an enqueued script, I couldn't remember why I had added it. Today, when I tried removing it (to improve page-load speed) from my functions.php file, it messed up all of my jQuery pl...
Try changing the first line of your custom JS file. `jQuery(document).ready(function($) {` jQuery operated within WordPress should be run in compatibility mode. That line allows this to happen, as per point #5 [here](http://www.ericmmartin.com/5-tips-for-using-jquery-with-wordpress/).
41,805
<p>If I use is_front_page() in my front-page.php file it works as expected. However if I use the same function in my theme functions.php file it does not work. Is this normal behavior? If not can it be trouble shot somehow? </p> <p>In settings->reading I have my front page set to a page called "front page" so I think ...
[ { "answer_id": 41806, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 4, "selected": true, "text": "<p>That may be normal behavior, depending on how exactly you're using <code>is_front_page</code> in your func...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41805", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6811/" ]
If I use is\_front\_page() in my front-page.php file it works as expected. However if I use the same function in my theme functions.php file it does not work. Is this normal behavior? If not can it be trouble shot somehow? In settings->reading I have my front page set to a page called "front page" so I think that is ...
That may be normal behavior, depending on how exactly you're using `is_front_page` in your functions file. If you use it inside the global scope of `functions.php`, it will not work. Why? Because WordPress loads `functions.php` before the `$wp_query object` has been set up with the current page. `is_front_page` is a...
41,808
<p>I have just hit my first serious issue with WordPress and for someone that enjoys Ajax this is a biggy.</p> <p>I have an Ajax request that is taking 1.5 seconds to complete while using the Ajax API. </p> <p>If I take the same exact code and run it with a custom script(no WordPress) the Ajax request takes merely 15...
[ { "answer_id": 41812, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 7, "selected": true, "text": "<p>Yep, this is nasty issue that to have full WordPress environment you need to spend considerable time loading it.</p>\...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41808", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6811/" ]
I have just hit my first serious issue with WordPress and for someone that enjoys Ajax this is a biggy. I have an Ajax request that is taking 1.5 seconds to complete while using the Ajax API. If I take the same exact code and run it with a custom script(no WordPress) the Ajax request takes merely 150 milliseconds. *...
Yep, this is nasty issue that to have full WordPress environment you need to spend considerable time loading it. I've needed much better performance (for very dynamic incremental search feature) for work and what I went with is: 1. Custom file as Ajax handler. 2. [SHORTINIT constant](http://core.trac.wordpress.org/br...
41,820
<p>I created a new category with the ID of 57, how do I exclude this category from the homepage/blog and then list the posts from this category on its own page?</p> <p>this is what my index.php looks like</p> <pre><code>&lt;?php $popular_count = 1; query_posts( array( 'orderby' =&gt; 'comment_...
[ { "answer_id": 41823, "author": "Kyle", "author_id": 12476, "author_profile": "https://wordpress.stackexchange.com/users/12476", "pm_score": 0, "selected": false, "text": "<p>Use a custom query for both.</p>\n\n<pre><code> &lt;?php if (have_posts()) : \n\n $args = array(\n ...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41820", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12965/" ]
I created a new category with the ID of 57, how do I exclude this category from the homepage/blog and then list the posts from this category on its own page? this is what my index.php looks like ``` <?php $popular_count = 1; query_posts( array( 'orderby' => 'comment_count','posts_per_page' => ...
Rather than performing a separate query, to exclude a category (or any other taxonomy) term, you can hook into `pre_get_posts`: ``` add_action('pre_get_posts', 'wpse41820_exclude_cat_from_front_page'); function wpse41820_exclude_cat_from_front_page( $query ){ if( $query->is_main_query() && is_front_page() ){ ...
41,821
<p>I'm trying to add a line to my functions.php that does a behind-the-scenes HTTP request submitting some user information to a mailing list URL I have. I'm trying to test the code at the moment, but nothing seems to be working.</p> <p>I have tried the following:</p> <pre><code>$url = 'blabla.org/mailinglist/add?' ....
[ { "answer_id": 41825, "author": "Yoav Aner", "author_id": 4741, "author_profile": "https://wordpress.stackexchange.com/users/4741", "pm_score": 0, "selected": false, "text": "<p>perhaps you're just missing <code>http://</code> ?</p>\n\n<p>i.e. </p>\n\n<p><code>$url = 'http://blabla.org/m...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41821", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12203/" ]
I'm trying to add a line to my functions.php that does a behind-the-scenes HTTP request submitting some user information to a mailing list URL I have. I'm trying to test the code at the moment, but nothing seems to be working. I have tried the following: ``` $url = 'blabla.org/mailinglist/add?' . $user_email; $reques...
Only use `wp_remote_post()` if you are actually posting something. Try using `wp_remote_get()` with a full url ``` $url = 'http://blabla.org/mailinglist/add?' . $user_email; $results = wp_remote_get( $url ); // var_dump( $results ); ```
41,827
<p>I am trying to create a custom meta box for multiple custom post types in WordPress without creating duplicate code.</p> <p>Currently I have:</p> <pre><code>add_meta_box('adv_form_box1', 'Advanced Form', 'adv_form1', 'custom-post-type1', 'side', 'high'); add_meta_box('adv_form_box2', 'Advanced Form', 'adv_form2', ...
[ { "answer_id": 41828, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>You are creating a bunch of extra work.</p>\n\n<p>Rather than creating a separate callback function for each post typ...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41827", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12972/" ]
I am trying to create a custom meta box for multiple custom post types in WordPress without creating duplicate code. Currently I have: ``` add_meta_box('adv_form_box1', 'Advanced Form', 'adv_form1', 'custom-post-type1', 'side', 'high'); add_meta_box('adv_form_box2', 'Advanced Form', 'adv_form2', 'custom-post-type2', ...
In addition to the other answers, you can further improve it by looping through an array of types instead of manually adding a new add\_meta\_box() line each time you add a new type. ``` $postTypes = array( 'custom-post-type1', 'custom-post-type2', 'custom-post-type3' ); foreach( $postTypes as $pt ) add_meta_box( ...
41,833
<p>Does anyone know how I can set a limit on the char length for posts when using the "content=yes" function?</p> <p>I need something like excerpt_size but for the content, not excerpt. Before someone suggests using excerpt, it strips out the formatting and line breaks so I want to use the content output function but...
[ { "answer_id": 41836, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 0, "selected": false, "text": "<p>You cannot just cut off the content on any position: The break may occur inside of an element like <code>table</code>,...
2012/02/09
[ "https://wordpress.stackexchange.com/questions/41833", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12974/" ]
Does anyone know how I can set a limit on the char length for posts when using the "content=yes" function? I need something like excerpt\_size but for the content, not excerpt. Before someone suggests using excerpt, it strips out the formatting and line breaks so I want to use the content output function but set a li...
You could enable links, images and other tags for use with the\_excerpt. This might be the most simple solution, but it will apply to **all excerpts**: ``` <?php function my_excerpt_custom($text) { $raw_excerpt = $text; if ( '' == $text ) { $text = get_the_content(''); $text = strip_shortcodes( $text ); $...
41,839
<p>In my theme directory I have the following structure:</p> <p>/includes/functions-custom.php<br> /includes/avatax/AvaTax.php<br> /includes/classes/gmaps.class.php</p> <p>I'm making a call from the functions-custom.php to include the second file within the WordPress admin using this code</p> <pre><code>require_once...
[ { "answer_id": 41845, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>It looks like the require is being called from within <code>AvaTax.php</code>, so if you change the call to <...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41839", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/947/" ]
In my theme directory I have the following structure: /includes/functions-custom.php /includes/avatax/AvaTax.php /includes/classes/gmaps.class.php I'm making a call from the functions-custom.php to include the second file within the WordPress admin using this code ``` require_once('avatax/AvaTax.php'); //Avala...
So after a night of sleep, and confirmation from the above users that I was including files properly, I've managed to resolve the issue. In the AvaTax.php file, there was an \_\_autoload() function: ``` <?php function __autoload($class_name) { if ( $class_name != 'WP_User_Search' ) { //WORDPRESS HACK $path=d...
41,841
<p>I'm working on a plugin that interacts with Gravity Forms, and under certain conditions I want to prevent a form from being deleted. Here's the method in Gravity Forms that handles deleting a form:</p> <pre><code>public static function delete_form($form_id){ global $wpdb; if(!GFCommon::current_user_can_any...
[ { "answer_id": 41853, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 3, "selected": true, "text": "<p>Short answer: no.</p>\n\n<p>Long answer: also no. Actions don't work that way.</p>\n\n<p><strong>Edit:</strong></p>\...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3898/" ]
I'm working on a plugin that interacts with Gravity Forms, and under certain conditions I want to prevent a form from being deleted. Here's the method in Gravity Forms that handles deleting a form: ``` public static function delete_form($form_id){ global $wpdb; if(!GFCommon::current_user_can_any("gravityforms...
Short answer: no. Long answer: also no. Actions don't work that way. **Edit:** To elaborate and make your question totally generic: ``` function foo() { bar(); return 1; } function bar() { // stuff } ``` There is nothing you can put in stuff that will prevent a call to `foo()` from returning 1, other than ...
41,873
<p>I would like to use the url <code>http://site.com/post/title-of-the-post</code> for my posts and I've saw in my admin page I have the current url <code>http://site.com/%slug%/title-of-the-post</code> obiouvsly incorrect.</p> <p>How can I define the slug for my default posts? I'm using various custom post types so I...
[ { "answer_id": 41875, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>Take a look at the <a href=\"http://codex.wordpress.org/Using_Permalinks#Structure_Tags\" rel=\"nofollow\">Structur...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41873", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5287/" ]
I would like to use the url `http://site.com/post/title-of-the-post` for my posts and I've saw in my admin page I have the current url `http://site.com/%slug%/title-of-the-post` obiouvsly incorrect. How can I define the slug for my default posts? I'm using various custom post types so I would like to name the default ...
Set your permalink structure to custom and use: ``` /post/%postname%/ ``` Then when registering your custom post types use something like this: ``` 'rewrite' => array( 'slug' => 'something', 'with_front' => false ), ``` Using `with_front` set to false will make sure that your new custom post types don't s...
41,900
<p>The wordpress function wp_insert_user doesn't seem to set (overwrite) the input I give. (documentation shows you can't) Trying to use: wp_insert_user using the returned userID also doesn't work. </p> <p>Of course I could just make my own query but maybe I'm forgetting an option to insert this data using a existin...
[ { "answer_id": 41903, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": false, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_user\">codex page for <code>wp_insert_u...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41900", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12998/" ]
The wordpress function wp\_insert\_user doesn't seem to set (overwrite) the input I give. (documentation shows you can't) Trying to use: wp\_insert\_user using the returned userID also doesn't work. Of course I could just make my own query but maybe I'm forgetting an option to insert this data using a existing functi...
What you are best off doing is hooking into `user_register` and from there updating the user options you want them set to. Below is an example of disabling the admin bar for new users: ``` add_action("user_register", "sc_set_user_admin_bar_false_by_default", 10, 1); function sc_set_user_admin_bar_false_by_default($use...
41,905
<p>I'm trying to edit the loop so if its on category ID 60 it displays "Photos" instead of "Blog".. how do I do this?</p> blog <pre><code> &lt;?php if(is_archive()&amp;&amp;!is_category()&amp;&amp;!is_tag()&amp;&amp;!is_search()){ ?&gt; &lt;!-- BEGIN .archive-title --&gt; &lt;h1 ...
[ { "answer_id": 41903, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": false, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_user\">codex page for <code>wp_insert_u...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12965/" ]
I'm trying to edit the loop so if its on category ID 60 it displays "Photos" instead of "Blog".. how do I do this? blog ``` <?php if(is_archive()&&!is_category()&&!is_tag()&&!is_search()){ ?> <!-- BEGIN .archive-title --> <h1 class="page-title"> <?php if ( is_day() ) : ?> ...
What you are best off doing is hooking into `user_register` and from there updating the user options you want them set to. Below is an example of disabling the admin bar for new users: ``` add_action("user_register", "sc_set_user_admin_bar_false_by_default", 10, 1); function sc_set_user_admin_bar_false_by_default($use...
41,912
<p>I'd like to run a custom query using some meta data whenever a post is updated or published.</p> <p>Is there something I can put in functions.php to fire when those events occur?</p>
[ { "answer_id": 41914, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 2, "selected": false, "text": "<p>the edit_post hook is probably the best hook... as it fires whenever a post/page is published or updated....
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41912", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12476/" ]
I'd like to run a custom query using some meta data whenever a post is updated or published. Is there something I can put in functions.php to fire when those events occur?
The `save_post` action fires When a post is updated and/or published -- including when a new post is inserted. ``` <?php add_action( 'save_post', 'wpse41912_save_post' ); function wpse41912_save_post() { // do stuff } ``` If you want your functions to fire only when a post is being edited, you can hook into `edi...
41,917
<p>I set up my site on a PreviewDNS, I have since pointed my Domain to the correct place and changed all the links to non-previewDNS links.</p> <p>However I can see (using Jetpack) that visitors to my site are somehow able to click on some images (I have the no right click plugin as well as no urls on images)</p> <p>...
[ { "answer_id": 41918, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 0, "selected": false, "text": "<p><strong>Described Behavior:</strong> User clicks on a link and is taken away to see the image by itself in a browser ...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41917", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11682/" ]
I set up my site on a PreviewDNS, I have since pointed my Domain to the correct place and changed all the links to non-previewDNS links. However I can see (using Jetpack) that visitors to my site are somehow able to click on some images (I have the no right click plugin as well as no urls on images) I do not want peo...
It appears that you have content (pages, posts or widgets) that contain old URL information. An example of a URL that is correct: ``` http://www.hutchisonhaines.co.uk/wp-content/themes/FactoryWP/style.css ``` An example of a URL that is incorrect: ``` http://hutchisonhaines.co.uk.previewdns.com/wp-content/uploads/...
41,925
<p>I'm trying to find a way to selectively disable qTranslate - I would like to be able to show certain static content on my site in 4 languages, but to then only have a single language (and a simplified editor) for posts and also custom post types.</p> <p>I would also need to disable the output on selective pages in ...
[ { "answer_id": 41945, "author": "englebip", "author_id": 10406, "author_profile": "https://wordpress.stackexchange.com/users/10406", "pm_score": 1, "selected": false, "text": "<p>There is an answer in the <a href=\"http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&amp;t=2288&amp;p...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41925", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7968/" ]
I'm trying to find a way to selectively disable qTranslate - I would like to be able to show certain static content on my site in 4 languages, but to then only have a single language (and a simplified editor) for posts and also custom post types. I would also need to disable the output on selective pages in the front-...
Following snippet will disable it for post\_type `post` (modify array below to affect other post\_types): ``` function qtrans_disable() { global $typenow, $pagenow; if (in_array($typenow, array('post')) && // post_types where qTranslate should be disabled in_array($pagenow, array('post-new.php', 'post...
41,927
<p>I'm working on a plugin which we'll call "my-plugin" for the purposes of this question. The my-plugin directory looks like this:</p> <pre class="lang-none prettyprint-override"><code>my-plugin/ |- image.jpg |- script.js |- script.php |- plugin.php |- ajax.php </code></pre> <p>In script.php I have a section of...
[ { "answer_id": 41945, "author": "englebip", "author_id": 10406, "author_profile": "https://wordpress.stackexchange.com/users/10406", "pm_score": 1, "selected": false, "text": "<p>There is an answer in the <a href=\"http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&amp;t=2288&amp;p...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/483/" ]
I'm working on a plugin which we'll call "my-plugin" for the purposes of this question. The my-plugin directory looks like this: ```none my-plugin/ |- image.jpg |- script.js |- script.php |- plugin.php |- ajax.php ``` In script.php I have a section of code that specifies some JS. In it, I need a URL for ajax.ph...
Following snippet will disable it for post\_type `post` (modify array below to affect other post\_types): ``` function qtrans_disable() { global $typenow, $pagenow; if (in_array($typenow, array('post')) && // post_types where qTranslate should be disabled in_array($pagenow, array('post-new.php', 'post...
41,940
<p>I'm using post formats heavily on a project, but have no current need for the standard option. Beyond being an unnecessary bit of UI, it actually causes broken behavior if it does get mistakenly selected. I might, with some convoluted logic, be able to set up a template for Standard that properly handles the incomin...
[ { "answer_id": 42073, "author": "GavinR", "author_id": 2001, "author_profile": "https://wordpress.stackexchange.com/users/2001", "pm_score": 1, "selected": false, "text": "<p>This is a semi-hacky workaround, but I think it meets all your needs. First, implement the template logic to hand...
2012/02/10
[ "https://wordpress.stackexchange.com/questions/41940", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3370/" ]
I'm using post formats heavily on a project, but have no current need for the standard option. Beyond being an unnecessary bit of UI, it actually causes broken behavior if it does get mistakenly selected. I might, with some convoluted logic, be able to set up a template for Standard that properly handles the incoming c...
The first thing to remember about the post editing screen is that everything (except for the post title, editors, permalink, etc.) is a meta box. Since you can easily add and remove meta boxes, there's no need for CSS and JS hacking. Don't want the standard post format to show up? Remove the default meta box and roll y...
41,979
<p>I'm using this code.</p> <pre><code>$blog_list = $wpdb-&gt;get_results( "SELECT " . $extra . "blog_id, last_updated FROM " . $wpdb-&gt;blogs. " WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted ='0' AND UPPER(blog_name) LIKE 'A%'" . $order . " " . $limit . "", ARRAY_A ); </code></pre...
[ { "answer_id": 41982, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<h1>Prepare your Queries!</h1>\n\n<pre><code>global $wpdb;\n$wpdb-&gt;get_results( \n $wpdb-&gt;prepare( \n \...
2012/02/11
[ "https://wordpress.stackexchange.com/questions/41979", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5074/" ]
I'm using this code. ``` $blog_list = $wpdb->get_results( "SELECT " . $extra . "blog_id, last_updated FROM " . $wpdb->blogs. " WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted ='0' AND UPPER(blog_name) LIKE 'A%'" . $order . " " . $limit . "", ARRAY_A ); ``` But that LIKE statement `A...
Prepare your Queries! ===================== ``` global $wpdb; $wpdb->get_results( $wpdb->prepare( "SELECT %s blog_id, last_updated FROM %s WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted ='0' AND UPPER(blog_name) LIKE '%s' %s %s ", ARRAY_A ), $extra, $wpdb->...
41,988
<p>Is it possible to redeclare/change the slug of a plugin's existing custom post type (without simply editing the plugin)?</p> <p>That is, if Plugin X creates a custom post type with the slug /uncookedtoast/, is it possible to add a filter to functions.php (or something similar) that changes the slug to /bread/?</p>
[ { "answer_id": 42164, "author": "Tom", "author_id": 1014, "author_profile": "https://wordpress.stackexchange.com/users/1014", "pm_score": 6, "selected": true, "text": "<p>Yes, this is possible, but if the plugin is creating a custom post type using the <code>rewrite =&gt; array('slug' =&...
2012/02/11
[ "https://wordpress.stackexchange.com/questions/41988", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13027/" ]
Is it possible to redeclare/change the slug of a plugin's existing custom post type (without simply editing the plugin)? That is, if Plugin X creates a custom post type with the slug /uncookedtoast/, is it possible to add a filter to functions.php (or something similar) that changes the slug to /bread/?
Yes, this is possible, but if the plugin is creating a custom post type using the `rewrite => array('slug' => 'post_type')` parameter, then it's not likely that you're going to be able to *replace* the slug. Whenever custom post types are created, URL rewrite rules are written to the database. Depending on which actio...
41,989
<p>Here is my wp_enqueue_script and wp_localize_script - which i am using to run an Ajax call.</p> <pre><code>wp_enqueue_script( 'function', plugin_dir_url( __FILE__ ) . 'function.js', array( 'jquery', 'json2' ) ); wp_localize_script( 'function', 'MyAjax', array( 'ajaxurl' =&gt; admin_url( 'admin-ajax.php' ) ) ); </co...
[ { "answer_id": 41995, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 4, "selected": true, "text": "<p><code>wp_localize_script()</code> now uses <code>json_encode()</code> which means a multidimensional array will now...
2012/02/11
[ "https://wordpress.stackexchange.com/questions/41989", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12364/" ]
Here is my wp\_enqueue\_script and wp\_localize\_script - which i am using to run an Ajax call. ``` wp_enqueue_script( 'function', plugin_dir_url( __FILE__ ) . 'function.js', array( 'jquery', 'json2' ) ); wp_localize_script( 'function', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); ``` While debug...
`wp_localize_script()` now uses `json_encode()` which means a multidimensional array will now work for the passed data. And, HTML entity decoding only applies to the first level of the array. Better is an way to use json and default js possibilities from WP. At first, i add the options from the database via script an...
41,991
<p>I am using the latest default Twenty Eleven on WordPress 3.3.1</p> <p><img src="https://i.stack.imgur.com/Z26LL.png" alt="My Site Currently"></p> <p>My post has a featured image (the smaller one, which 1 is pointing to), and I would like it not to appear in my post. It has already appeared in my outer post before ...
[ { "answer_id": 41996, "author": "Ian Dunn", "author_id": 3898, "author_profile": "https://wordpress.stackexchange.com/users/3898", "pm_score": 1, "selected": false, "text": "<p>TwentyEleven includes the featured image from header.php, rather than a template part like most themes. If you ...
2012/02/11
[ "https://wordpress.stackexchange.com/questions/41991", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10787/" ]
I am using the latest default Twenty Eleven on WordPress 3.3.1 ![My Site Currently](https://i.stack.imgur.com/Z26LL.png) My post has a featured image (the smaller one, which 1 is pointing to), and I would like it not to appear in my post. It has already appeared in my outer post before someone clicks in. In the pict...
TwentyEleven includes the featured image from header.php, rather than a template part like most themes. If you comment out line 92 that should remove it, e.g. ``` <?php // The header image // Check if this is a post or page, if it has a thumbnail, and if it's a big one if ( is_singular() && has...
42,003
<p>I want to give a group of user types (Editor + a custom role) the add_users /create_users capability. The only catch is that I wanted to limit that capability to adding 'subscriber' type users only, and nothing above that. Is there a way to do this?</p>
[ { "answer_id": 42007, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 4, "selected": true, "text": "<p>This first step to making this happen is add the capability to <code>create_users</code> to a given role. ...
2012/02/11
[ "https://wordpress.stackexchange.com/questions/42003", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5552/" ]
I want to give a group of user types (Editor + a custom role) the add\_users /create\_users capability. The only catch is that I wanted to limit that capability to adding 'subscriber' type users only, and nothing above that. Is there a way to do this?
This first step to making this happen is add the capability to `create_users` to a given role. You do this be calling `get_role`, then using the `add_cap` method. This only needs to be done once. Here's an example that does it on plugin activation. ``` <?php register_activation_hook( __FILE__, 'wpse42003_activation' )...
42,013
<p>I have a custom post type <code>Event</code> that contains a starting and ending date/times custom fields (as metaboxes in the post edit screen). </p> <p>I would like to make sure that an Event cannot get published (or scheduled) without the dates being filled, as that will cause problems with the templates display...
[ { "answer_id": 42015, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 2, "selected": false, "text": "<p>I think that the best way to go about this is not to PREVENT the status change from happening so much as it i...
2012/02/11
[ "https://wordpress.stackexchange.com/questions/42013", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10406/" ]
I have a custom post type `Event` that contains a starting and ending date/times custom fields (as metaboxes in the post edit screen). I would like to make sure that an Event cannot get published (or scheduled) without the dates being filled, as that will cause problems with the templates displaying the Event data (b...
OK, this is finally how I ended up doing it: an Ajax call to a PHP function that does the checking, sort of inspired by [this answer](https://wordpress.stackexchange.com/a/15627/10406) and using a clever tip from a [question I asked on StackOverflow](https://stackoverflow.com/a/9331201/519210). Importantly, I make sure...
42,018
<p>I'm already running a WordPress installation just fine under a mapped domain. The current setup points <code>(www).sample.com</code> to <code>/sample/</code> within <code>domain.com</code>, and it works fine. In the Create A Network section of the WP Codex, it states <em>"Domain mapping, however, will not work"</em...
[ { "answer_id": 42023, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 2, "selected": false, "text": "<p>This is possible, and it actually should be very easy for you to do.</p>\n\n<p>There are lots of ways t...
2012/02/12
[ "https://wordpress.stackexchange.com/questions/42018", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13043/" ]
I'm already running a WordPress installation just fine under a mapped domain. The current setup points `(www).sample.com` to `/sample/` within `domain.com`, and it works fine. In the Create A Network section of the WP Codex, it states *"Domain mapping, however, will not work"* but I would like to know if it is possible...
This is possible, and it actually should be very easy for you to do. There are lots of ways that you could have this setup, depending on if your server is using cPanel, Plesk, etc. At its most basic, right now, your Apache virtual host points to your main web directory, maybe something like `/var/www/`, and you have y...
42,041
<p>I have a situation where the Wordpress 3 Admin Bar (which is cool and I do want to have) obscures some important information on my page.</p> <p>Before I start fiddling with the CSS myself (which I'm sure will break stuff): Is there an existing patch to change this so the Admin Bar starts "above" the actual page? I ...
[ { "answer_id": 42042, "author": "Pekka", "author_id": 2161, "author_profile": "https://wordpress.stackexchange.com/users/2161", "pm_score": 3, "selected": true, "text": "<p>Upon closer inspection, I found out that Wordpress already <em>does</em> try to move everything that would be obscu...
2012/02/12
[ "https://wordpress.stackexchange.com/questions/42041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2161/" ]
I have a situation where the Wordpress 3 Admin Bar (which is cool and I do want to have) obscures some important information on my page. Before I start fiddling with the CSS myself (which I'm sure will break stuff): Is there an existing patch to change this so the Admin Bar starts "above" the actual page? I realize th...
Upon closer inspection, I found out that Wordpress already *does* try to move everything that would be obscured further down. The problem is elements that have been positioned using `position: fixed` or `position: absolute`. What I ended up doing is adding separate CSS rules for those that apply only when the `admin-...
42,048
<p>I'm making a directory for half a dozen sorts of venues that are located in innumerable cities in all 50 US states. My plan has been to use a custom post type for each venue type and then assign a hierarchical "location" taxonomy to all of them.</p> <p>When I create my "location" taxonomy archives, I'd like to sta...
[ { "answer_id": 42072, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 1, "selected": false, "text": "<p>I am not sure off-hand if custom taxonomies have this (I'm almost positive they do) but Tags and Categories alread...
2012/02/12
[ "https://wordpress.stackexchange.com/questions/42048", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12392/" ]
I'm making a directory for half a dozen sorts of venues that are located in innumerable cities in all 50 US states. My plan has been to use a custom post type for each venue type and then assign a hierarchical "location" taxonomy to all of them. When I create my "location" taxonomy archives, I'd like to start plugging...
I am not sure off-hand if custom taxonomies have this (I'm almost positive they do) but Tags and Categories already have a Description field you can fill out, and then display on any page. It would take some modification of your template files but what you can do is something like this: 1. Enter the description in the...
42,067
<p>I am working with WordPress 3.3.1 and cannot resize the image I am trying to add to the page as the thumbnail, small, medium and large options are greyed out. the size of the image in question is 276x354.</p> <p>I have created my own theme and have added <code>&lt;?php the_post_thumbnail(); ?&gt;</code> template ta...
[ { "answer_id": 42080, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 3, "selected": true, "text": "<p>it can be caused by multiple reasons , some of which may be :</p>\n\n<ul>\n<li>theme disabling this function</...
2012/02/12
[ "https://wordpress.stackexchange.com/questions/42067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11465/" ]
I am working with WordPress 3.3.1 and cannot resize the image I am trying to add to the page as the thumbnail, small, medium and large options are greyed out. the size of the image in question is 276x354. I have created my own theme and have added `<?php the_post_thumbnail(); ?>` template tag but to no avail. Does dea...
it can be caused by multiple reasons , some of which may be : * theme disabling this function => switch to default theme and check function again * GD library not installed on server => check your PHP server settings . * the image you are inserting is smaller than the thumbnail image size set in Admin/Settings/Med...
42,068
<p>I'm looking to adapt an existing forum-like plugin which has no facility for attaching media.</p> <p>The plugin works as a Custom Post Type, so it would be as "simple" as attaching an image to a post.</p> <p>I am only concerned about attaching images rather than any file type, but the plugin does use <code>wp_edit...
[ { "answer_id": 42372, "author": "ifdion", "author_id": 6383, "author_profile": "https://wordpress.stackexchange.com/users/6383", "pm_score": 3, "selected": false, "text": "<p>Maybe this is not your ideal solution, but it worth a shot. Got it by googling but unfortunately I forgot the url...
2012/02/12
[ "https://wordpress.stackexchange.com/questions/42068", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
I'm looking to adapt an existing forum-like plugin which has no facility for attaching media. The plugin works as a Custom Post Type, so it would be as "simple" as attaching an image to a post. I am only concerned about attaching images rather than any file type, but the plugin does use `wp_editor` and as such the so...
I think the easiest way, since you're already using the `wp_editor` function is going to be to just include the media buttons in the WP\_Editor instance - this way you'll have the native functions, including the "Insert into post" button, built in for free. How you do this obviously depends on the plugin you're trying...
42,089
<p>So I managed to loop my posts in a page template, ordering the posts by most viewed.</p> <p>The query posts string looks like this</p> <pre><code>$wplover_home = new WP_Query('posts_per_page=18&amp;v_sortby=views&amp;v_orderby=desc&amp;paged=' . $paged); while ($wplover_home-&gt;have_posts()) : $wplover_home-&gt;...
[ { "answer_id": 42091, "author": "tollmanz", "author_id": 4850, "author_profile": "https://wordpress.stackexchange.com/users/4850", "pm_score": 1, "selected": false, "text": "<p>Not sure exactly what you mean by \"x days or months\", but I'm assuming you want to set a time interval for th...
2012/02/12
[ "https://wordpress.stackexchange.com/questions/42089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13057/" ]
So I managed to loop my posts in a page template, ordering the posts by most viewed. The query posts string looks like this ``` $wplover_home = new WP_Query('posts_per_page=18&v_sortby=views&v_orderby=desc&paged=' . $paged); while ($wplover_home->have_posts()) : $wplover_home->the_post(); ?> ``` Now to my question...
Not sure exactly what you mean by "x days or months", but I'm assuming you want to set a time interval for the posts that you are querying. I would recommend that you take a look at the ["Time Parameters" section in the Codex article on WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters). It...
42,093
<p>I don't think there is, but I was wondering whether anyone ran into this issue before.</p> <p>Is there a function (or variable) call to get all registered WP Actions and all registered WP Filters?</p> <p>My current way of doing so would be to have something like this:</p> <pre><code>static private $wp_actions = a...
[ { "answer_id": 42097, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 4, "selected": true, "text": "<p>I'd just like to point out that that is, by no means, anywhere NEAR a complete list. According to <a href=\"ht...
2012/02/12
[ "https://wordpress.stackexchange.com/questions/42093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2322/" ]
I don't think there is, but I was wondering whether anyone ran into this issue before. Is there a function (or variable) call to get all registered WP Actions and all registered WP Filters? My current way of doing so would be to have something like this: ``` static private $wp_actions = array( 'muplugins_loaded'...
I'd just like to point out that that is, by no means, anywhere NEAR a complete list. According to [adambrown.info](http://adambrown.info/p/wp_hooks/version/3.3), there are 595 actions and 970 filters in wordpress 3.3...and that's just by default, not including hooks added by your plugins. You might be able to do somet...
42,108
<p>Hopefully it's OK asking a second question pretty much directly after the first one...</p> <p>I'm currently having some difficulties accomplishing this:</p> <p><img src="https://i.stack.imgur.com/DsLsT.png" alt=""></p> <p>I've been able to remove the 'Attachment Post URL' button using</p> <pre><code>function med...
[ { "answer_id": 42141, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 5, "selected": false, "text": "<p>The answer for this might be complicated and very long, as far as I know, there will also be some differences...
2012/02/12
[ "https://wordpress.stackexchange.com/questions/42108", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Hopefully it's OK asking a second question pretty much directly after the first one... I'm currently having some difficulties accomplishing this: ![](https://i.stack.imgur.com/DsLsT.png) I've been able to remove the 'Attachment Post URL' button using ``` function medium_attachment_fields_to_edit($form_fields) { $...
I gave this some more thought and given size of WP code base (including bundled libraries) it doesn't seem very realistic to compile such list by hand (and repeat it for every new version - meh). I looked up appropriate static code analysis tool - [PHP\_CompatInfo](http://php5.laurent-laville.org/compatinfo/) and afte...
42,116
<p>I've been looking around for the past couple hours for a way to create a custom page template from within a plugin but haven't had any luck yet.</p> <p>What I am specifically trying to do is add an option to the list of available page templates when editing a page, and <strong>not</strong> using some other method l...
[ { "answer_id": 42122, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 1, "selected": false, "text": "<p>I took a browse through the source, and quite shockingly there doesn't look to be a way to do this! My ...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42116", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2415/" ]
I've been looking around for the past couple hours for a way to create a custom page template from within a plugin but haven't had any luck yet. What I am specifically trying to do is add an option to the list of available page templates when editing a page, and **not** using some other method like `if( is_page( 'page...
### Filters? Anyone? There's *no* filter there to help: `page_template_dropdown($template);` is used to build the drop down and it's not filterable. ### Sneaking into the Templates Array? To build the drop downs contents, the core meta box uses `get_page_templates()`. From inside, the function looks like the followi...
42,117
<p>I am trying to retrieve the slug of the current WordPress page outside the loop. The title of the page returns with <code>wp_title ()</code>, but how can I get the slug? </p> <pre><code>&lt;li&gt; &lt;a href="/slug-of-current-page/"&gt; &lt;?php wp_title('', true); ?&gt; &lt;/a&gt; &lt;/li&gt; </code></pre>...
[ { "answer_id": 42119, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 3, "selected": false, "text": "<p>Given the code example, it looks like what you really need is a link. In that case, you can use <a href...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42117", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11022/" ]
I am trying to retrieve the slug of the current WordPress page outside the loop. The title of the page returns with `wp_title ()`, but how can I get the slug? ``` <li> <a href="/slug-of-current-page/"> <?php wp_title('', true); ?> </a> </li> ```
Use the global variable [`$post`](https://codex.wordpress.org/Global_Variables#Inside_the_Loop_variables): ``` <?php global $post; $post_slug = $post->post_name; ?> ```
42,120
<p>Just wondering, how can remove slugs from some URLS. I'm using a custom post type called exhibitors, and some taxonomies to define those exhibitors (eg: featured-guests, publishers etc.): </p> <p>Right now I have this: <code>http://thisurl.com/exhibitor_filters/featured-guests/</code></p> <p>I would like this: <co...
[ { "answer_id": 42121, "author": "Evan Yeung", "author_id": 1878, "author_profile": "https://wordpress.stackexchange.com/users/1878", "pm_score": -1, "selected": false, "text": "<p>Have you done:</p>\n\n<pre><code>'rewrite' = &gt; array(\n 'slug' =&gt; 'featured-guests',\n 'with_fro...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42120", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8574/" ]
Just wondering, how can remove slugs from some URLS. I'm using a custom post type called exhibitors, and some taxonomies to define those exhibitors (eg: featured-guests, publishers etc.): Right now I have this: `http://thisurl.com/exhibitor_filters/featured-guests/` I would like this: `http://thisurl.com/featured-gu...
This by default is not possible, and using the CPT and Custom Tax registration APIs, is not possible. **And for good reason.** It's all to do with permalink and slug clashes, and removing ambiguity. Admittedly there are cases where unique URLs that never overlap are not allowed by the system for this reason ( false n...
42,184
<p>What is correct way to send HTML back to an AJAX request in WordPress?</p> <p>I currently have this:</p> <pre><code>add_action( 'wp_ajax_nopriv_get-location-info', 'sc_locations_get_location_info' ); add_action( 'wp_ajax_get-location-info', 'sc_locations_get_location_info' ); function sc_locations_get_location_inf...
[ { "answer_id": 42186, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>If the HTML is fully trusted, I'd say no additional processing needs to be done, though theoretically it migh...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
What is correct way to send HTML back to an AJAX request in WordPress? I currently have this: ``` add_action( 'wp_ajax_nopriv_get-location-info', 'sc_locations_get_location_info' ); add_action( 'wp_ajax_get-location-info', 'sc_locations_get_location_info' ); function sc_locations_get_location_info() { $nonce = $_...
Depending on what kind of HTML you're expecting, there are different tools you can use: * [`esc_html()`](http://codex.wordpress.org/Function_Reference/esc_html) escapes entire HTML blocks so you don't end up with breaking characters in your JSON object literals. * [`esc_html_e()`](http://codex.wordpress.org/Function_R...
42,193
<p>It's possible to move wp-config.php up one directory level for security, i.e. into the directory above public_html (sometimes called home or a user name, depending on the web host).</p> <p>"You can move the wp-config.php file to the directory above your WordPress install", according to <a href="http://codex.wordpre...
[ { "answer_id": 42225, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 0, "selected": false, "text": "<p>There are two ways to do this. From your question, it sounds like you have this structure currently:</p>\n\n<pre><co...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
It's possible to move wp-config.php up one directory level for security, i.e. into the directory above public\_html (sometimes called home or a user name, depending on the web host). "You can move the wp-config.php file to the directory above your WordPress install", according to <http://codex.wordpress.org/Hardening_...
Use one main `wp-config.php` and name the others according to the name of the host: * example.com.config.php * example.net.config.php * and so on. In your main `wp-config.php` write: ``` $current_config = __DIR__ . '/' . $_SERVER['HTTP_HOST'] . '.config.php'; if ( file_exists( $current_config ) ) require_once $c...
42,196
<p>I'm editing this site <a href="http://www.millermusicproductions.com/" rel="nofollow">http://www.millermusicproductions.com/</a> currently and I updated WP 3.0.1 to 3.3.1. After updating, the page now is zoomed in compared to how it had been and I have no idea why. Here's another site with the same template that is ...
[ { "answer_id": 42225, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 0, "selected": false, "text": "<p>There are two ways to do this. From your question, it sounds like you have this structure currently:</p>\n\n<pre><co...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42196", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10181/" ]
I'm editing this site <http://www.millermusicproductions.com/> currently and I updated WP 3.0.1 to 3.3.1. After updating, the page now is zoomed in compared to how it had been and I have no idea why. Here's another site with the same template that is sort of zoomed out in comparison. I want it to end up looking like th...
Use one main `wp-config.php` and name the others according to the name of the host: * example.com.config.php * example.net.config.php * and so on. In your main `wp-config.php` write: ``` $current_config = __DIR__ . '/' . $_SERVER['HTTP_HOST'] . '.config.php'; if ( file_exists( $current_config ) ) require_once $c...
42,209
<p>As stated in one of the answers in <a href="https://wordpress.stackexchange.com/questions/21341/alternative-to-query-posts-for-main-loop/21378#21378">this</a> question and in the codex entry for the <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference/request" rel="nofollow noreferrer"><code>request</code...
[ { "answer_id": 42225, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 0, "selected": false, "text": "<p>There are two ways to do this. From your question, it sounds like you have this structure currently:</p>\n\n<pre><co...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42209", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2234/" ]
As stated in one of the answers in [this](https://wordpress.stackexchange.com/questions/21341/alternative-to-query-posts-for-main-loop/21378#21378) question and in the codex entry for the [`request`](http://codex.wordpress.org/Plugin_API/Filter_Reference/request) filter, said filter gets called only in a default query,...
Use one main `wp-config.php` and name the others according to the name of the host: * example.com.config.php * example.net.config.php * and so on. In your main `wp-config.php` write: ``` $current_config = __DIR__ . '/' . $_SERVER['HTTP_HOST'] . '.config.php'; if ( file_exists( $current_config ) ) require_once $c...
42,216
<p>I need to call the WordPress options table and pull some data. However, the table name may be different (typically wp_options) depending on whether the default table prefix was used on installation.</p> <p>How can I obtain a reference to the site's table prefix in order to properly access the site's options table v...
[ { "answer_id": 42217, "author": "Pippin", "author_id": 2418, "author_profile": "https://wordpress.stackexchange.com/users/2418", "pm_score": 4, "selected": true, "text": "<pre><code>global $wpdb;\n$prefix = $wpdb-&gt;prefix;\n</code></pre>\n" }, { "answer_id": 42879, "author"...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42216", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
I need to call the WordPress options table and pull some data. However, the table name may be different (typically wp\_options) depending on whether the default table prefix was used on installation. How can I obtain a reference to the site's table prefix in order to properly access the site's options table via $wpdb?...
``` global $wpdb; $prefix = $wpdb->prefix; ```
42,227
<p>I am working on a plugin that creates an inventory list page using an XML data file. For the sake of this example, let us say the inventory items are antique motorcycles or contemporary area rugs.</p> <p>User activates my plugin and adds a short code to a page in order to display the inventory on a page called "Inv...
[ { "answer_id": 42217, "author": "Pippin", "author_id": 2418, "author_profile": "https://wordpress.stackexchange.com/users/2418", "pm_score": 4, "selected": true, "text": "<pre><code>global $wpdb;\n$prefix = $wpdb-&gt;prefix;\n</code></pre>\n" }, { "answer_id": 42879, "author"...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42227", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13090/" ]
I am working on a plugin that creates an inventory list page using an XML data file. For the sake of this example, let us say the inventory items are antique motorcycles or contemporary area rugs. User activates my plugin and adds a short code to a page in order to display the inventory on a page called "Inventory." ...
``` global $wpdb; $prefix = $wpdb->prefix; ```
42,230
<p>The WordPress function wp_get_nav_menu_items returns my whole site's navigation nested and all. Now if i want to get the nav menu for one "level" of that nested navigation only, how do I do that?</p>
[ { "answer_id": 42327, "author": "Vlad Ionescu", "author_id": 12205, "author_profile": "https://wordpress.stackexchange.com/users/12205", "pm_score": 3, "selected": true, "text": "<p>Are you trying to display the posts from the top down a certain number of levels?</p>\n\n<p>If so, use wp_...
2012/02/13
[ "https://wordpress.stackexchange.com/questions/42230", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13121/" ]
The WordPress function wp\_get\_nav\_menu\_items returns my whole site's navigation nested and all. Now if i want to get the nav menu for one "level" of that nested navigation only, how do I do that?
Are you trying to display the posts from the top down a certain number of levels? If so, use wp\_nav\_menu. It has an argument "depth" built just for this and it works painelssly. ``` wp_nav_menu(array('depth' => 2)); ``` Also, <http://codex.wordpress.org/Function_Reference/wp_nav_menu>
42,242
<p>I just set up a custom post type, mostly following <a href="http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/" rel="nofollow">this tutorial</a>.</p> <p>I'm setting up things on my site now, doing a lot of CSS modifications and such, and every few minutes the post just forgets everything tha...
[ { "answer_id": 42243, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>In the function hooked onto <code>save_posts</code> you should make sure that you check that the action wa...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42242", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13097/" ]
I just set up a custom post type, mostly following [this tutorial](http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/). I'm setting up things on my site now, doing a lot of CSS modifications and such, and every few minutes the post just forgets everything that's in the custom meta boxes. I'm s...
In the function hooked onto `save_posts` you should make sure that you check that the action wasn't triggered by an auto-save routine. I suspect that the reason why the post 'forgets' the data is that the post auto-saves, and updates the post-meta with blank data. To do this: ``` function save_details($post_id){ ...
42,252
<p>In my plugin, I am trying to get the current date/time of the blog into the code but it seems to be returning a odd date/time. If i put a new post on the blog it does show the correct date/time so I am not sure what the issue is. Am I handling the code incorrectly? (Post Time: Published on: Feb 13, 2012 @ 22:45)</p>...
[ { "answer_id": 42255, "author": "Alex Older", "author_id": 3365, "author_profile": "https://wordpress.stackexchange.com/users/3365", "pm_score": 4, "selected": true, "text": "<p>There is a function in WordPress called <code>current_time();</code> which you pass either 'timestamp' or 'mys...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42252", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13101/" ]
In my plugin, I am trying to get the current date/time of the blog into the code but it seems to be returning a odd date/time. If i put a new post on the blog it does show the correct date/time so I am not sure what the issue is. Am I handling the code incorrectly? (Post Time: Published on: Feb 13, 2012 @ 22:45) PHP C...
There is a function in WordPress called `current_time();` which you pass either 'timestamp' or 'mysql' to and it returns a time. For more information: <https://developer.wordpress.org/reference/functions/current_time/>
42,301
<p>I just moved servers.</p> <p>When calling <code>wp_get_attachment_image()</code> or any of its sister functions the image returned is always the full-size image, scaled down, instead of the requested thumbnail size. This has a pretty nasty impact on load times.</p> <p>Both AJAX thumbnail rebuild and Regenerate Thu...
[ { "answer_id": 42317, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 1, "selected": false, "text": "<p>I'd be sure that the new server has the same php config as the last, mainly GD library or ImageMagick. Use ph...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42301", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7905/" ]
I just moved servers. When calling `wp_get_attachment_image()` or any of its sister functions the image returned is always the full-size image, scaled down, instead of the requested thumbnail size. This has a pretty nasty impact on load times. Both AJAX thumbnail rebuild and Regenerate Thumbnails those have happily c...
Found the problem. It turns out somebody had done a slightly rough search and replace on the DB, breaking the delicately serialized data in wp\_postmeta. thankfully I had a backup.
42,305
<p>How can i remove the whole menu in the admin?</p> <p>I have this code:</p> <pre><code>function remove_menu_items() { global $menu; end( $menu ); while ( prev($menu) ) { $value = explode( ' ', $menu[ key($menu) ][0] ); if ( $value[0] != NULL ? $value[0] : "" ) { unset( $men...
[ { "answer_id": 42306, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<pre><code>add_action('admin_head', 't5_hide_menu');\nfunction t5_hide_menu()\n{\n $GLOBALS['menu'] = array();\n ?&g...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42305", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6224/" ]
How can i remove the whole menu in the admin? I have this code: ``` function remove_menu_items() { global $menu; end( $menu ); while ( prev($menu) ) { $value = explode( ' ', $menu[ key($menu) ][0] ); if ( $value[0] != NULL ? $value[0] : "" ) { unset( $menu[ key($menu) ] ); ...
``` add_action('admin_head', 't5_hide_menu'); function t5_hide_menu() { $GLOBALS['menu'] = array(); ?> <style>#adminmenuback,#adminmenuwrap{display:none !important} #wpcontent, #footer{margin-left:0 !important}</style> <?php } ``` Now I want to know: *why?* :)
42,311
<p>I am experiencing an issue where terms with a parent are not being displayed in the category admin screen. The screen gives the total number of terms that should be there (i.e., 32), but only displays parent terms (i.e., 9). </p> <p>Interestingly, if run:</p> <pre><code>var_dump( get_terms( 'category' ) ); </code>...
[ { "answer_id": 42328, "author": "tollmanz", "author_id": 4850, "author_profile": "https://wordpress.stackexchange.com/users/4850", "pm_score": 3, "selected": true, "text": "<p>The issue was that somehow the \"category_children\" value in \"wp_options\" was reset to a blank, serialized ar...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42311", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4850/" ]
I am experiencing an issue where terms with a parent are not being displayed in the category admin screen. The screen gives the total number of terms that should be there (i.e., 32), but only displays parent terms (i.e., 9). Interestingly, if run: ``` var_dump( get_terms( 'category' ) ); ``` all 32 terms are retur...
The issue was that somehow the "category\_children" value in "wp\_options" was reset to a blank, serialized array. In certain contexts, WordPress uses this value to determine the parent child relationship. The value in my DB suggested no such relationships exist. The fix for the issue was to add/edit/delete a category ...
42,330
<p>I'm trying to set up a new local development server and instead of Apache I've decided to go with nginx.</p> <p>What I'd like to do is have each WordPress site live within its own directory inside <code>/usr/share/nginx/www</code>. The sites are only going to available on our local network. So for example:</p> <p>...
[ { "answer_id": 42688, "author": "Pothi Kalimuthu", "author_id": 9584, "author_profile": "https://wordpress.stackexchange.com/users/9584", "pm_score": 0, "selected": false, "text": "<p>On your \"location /\" block</p>\n\n<pre><code>try_files $uri $uri/ /index.html;\n</code></pre>\n\n<p>Th...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13129/" ]
I'm trying to set up a new local development server and instead of Apache I've decided to go with nginx. What I'd like to do is have each WordPress site live within its own directory inside `/usr/share/nginx/www`. The sites are only going to available on our local network. So for example: `/usr/share/nginx/www/ourcom...
For the multiple sites to work you need to give each a separate server entry. Think of it the same way Apache vhosts work. You need to specify a document root and server name for each domain or use the $host alias. It is also a good idea to create a hosts file entry on your local machine to correspond with each domai...
42,341
<p>I have a pretty basic 'featured-list - image slider' implemented above my content in my custom WordPress theme. How do I integrate WordPress content into the slider so that the slide content is pulled via 'Recent-Posts' or via a 'Category'? Also, how can I set the 'Featured Imgs' to display as the photo within the s...
[ { "answer_id": 42688, "author": "Pothi Kalimuthu", "author_id": 9584, "author_profile": "https://wordpress.stackexchange.com/users/9584", "pm_score": 0, "selected": false, "text": "<p>On your \"location /\" block</p>\n\n<pre><code>try_files $uri $uri/ /index.html;\n</code></pre>\n\n<p>Th...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9594/" ]
I have a pretty basic 'featured-list - image slider' implemented above my content in my custom WordPress theme. How do I integrate WordPress content into the slider so that the slide content is pulled via 'Recent-Posts' or via a 'Category'? Also, how can I set the 'Featured Imgs' to display as the photo within the slid...
For the multiple sites to work you need to give each a separate server entry. Think of it the same way Apache vhosts work. You need to specify a document root and server name for each domain or use the $host alias. It is also a good idea to create a hosts file entry on your local machine to correspond with each domai...
42,346
<p>I'm trying to generate thumbnails on my server that are being uploaded by a plugin. It uploads all images to a directory. I'm trying to target these files and then create a thumbnail with them based on img_resize, but I am not having any lucky. Eventually I'll be inserting the thumbs into the media gallery and into ...
[ { "answer_id": 42356, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 2, "selected": true, "text": "<p>Looking at your code, it looks like the file wil be looked for in <code>.../wp-content/uploads/bill.jpeg...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42346", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12203/" ]
I'm trying to generate thumbnails on my server that are being uploaded by a plugin. It uploads all images to a directory. I'm trying to target these files and then create a thumbnail with them based on img\_resize, but I am not having any lucky. Eventually I'll be inserting the thumbs into the media gallery and into us...
Looking at your code, it looks like the file wil be looked for in `.../wp-content/uploads/bill.jpeg`. You'll need to include the yyyy/mm as well. I would use this: ``` require_once(ABSPATH . '/wp-admin/includes/media.php'); require_once(ABSPATH . '/wp-admin/includes/image.php'); $file = 'http://www.mysite.org/uploads...
42,352
<p>Wondered if anyone knew an easy way around this.</p> <p>The code behind my local dev version of a WordPress instance and the live version are in sync (as they should be). Problem is this means the "Jetpack" plugin is working on the live version (since it's a live blog that can connect to WordPress.com) but not on t...
[ { "answer_id": 42354, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 2, "selected": false, "text": "<p>If you want <em>full</em> Jetpack functionality, your development environment will need to be publicly ...
2012/02/14
[ "https://wordpress.stackexchange.com/questions/42352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13142/" ]
Wondered if anyone knew an easy way around this. The code behind my local dev version of a WordPress instance and the live version are in sync (as they should be). Problem is this means the "Jetpack" plugin is working on the live version (since it's a live blog that can connect to WordPress.com) but not on the local d...
As of JetPack 2.2.1 there is now a local development/debug mode. <http://jetpack.me/2013/03/28/jetpack-dev-mode-release/> use: ``` define ('JETPACK_DEV_DEBUG', true); ``` in your wp-config and you should have access to any modules that don't require a connection to function. Update, since around v3.3 another local...
42,394
<p>if I add this code in my theme function.php</p> <pre><code>add_image_size('thumb' , 130, 65, true ); // Thumb add_image_size('max' , 610, 305, true ); // Maximum add_image_size('min' , 270, 135, true ); // Minimum </code></pre> <p>&hellip;the file names of uploaded images is:</p> <blockquote> <ul> <li>phot...
[ { "answer_id": 42595, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 1, "selected": false, "text": "<p>when you change themes or adjust the media sizes you could just use the <a href=\"http://wordpress.org/ex...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12508/" ]
if I add this code in my theme function.php ``` add_image_size('thumb' , 130, 65, true ); // Thumb add_image_size('max' , 610, 305, true ); // Maximum add_image_size('min' , 270, 135, true ); // Minimum ``` …the file names of uploaded images is: > > * photo-name-130x65.jpg > * photo-name-610x305.jpg > * photo-n...
If you want to ensure your image sizes remain available when switching themes, then you should place them into a plugin. Create a .php file (name it what you want) and place it in wp-content/plugins/, then paste the following: ``` <?php /* Plugin Name: My Custom Image Sizes Plugin URI: http://pippinsplugins.com/ Desc...
42,396
<p>A third party developer made a text widget with title, body and thumbnail. This accompany widget plugin has not been internationalized and therefore the strings do not appear in WPML's string translation management. I need them to be loaded. So I am trying to register the plugings domain as indicated <a href="http:...
[ { "answer_id": 42398, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 0, "selected": false, "text": "<p>You will need to add the following</p>\n\n<pre><code>$plugin_dir = basename(dirname(__FILE__)); \nload_pl...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42396", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12260/" ]
A third party developer made a text widget with title, body and thumbnail. This accompany widget plugin has not been internationalized and therefore the strings do not appear in WPML's string translation management. I need them to be loaded. So I am trying to register the plugings domain as indicated [here](http://cod...
After some great help - even though a bit late - from the guys at [WPML](http://wpml.org/), especially @Brooks I managed to ge the code fixed. The icl\_register\_strings() function was in the wrong place so WPML I shifted it to the update() Method from where one can sanitize the instance variables before they are used ...
42,406
<p>Suppose that I have a blog with few posts per month, and no comments, and I don't want to show posts in single post pages, but always "in context" (say, together with the posts in its month - or perhaps a week?). To accomplish this, I'd need to use permalinks with fragment identifiers (#), among other things. I wond...
[ { "answer_id": 42409, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>There are two hooks named <code>'pre_post_link'</code> and <code>'post_link'</code>. Their first argument – which you c...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42406", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12768/" ]
Suppose that I have a blog with few posts per month, and no comments, and I don't want to show posts in single post pages, but always "in context" (say, together with the posts in its month - or perhaps a week?). To accomplish this, I'd need to use permalinks with fragment identifiers (#), among other things. I wonder ...
There are two hooks named `'pre_post_link'` and `'post_link'`. Their first argument – which you can change – is the permalink. So … ``` add_filter( 'pre_post_link', 'wpse_42406_change_permalink', 10, 2 ); function wpse_42406_change_permalink( $permalink, $post ) { // change the permalink, let it point to an archi...
42,418
<p>I am trying to sort the posts using GD Star Rating in the last 24 hours. I have two separate queries, but I don't know how to merge them.</p> <pre><code> function filter_where($where = '') { //posts in the last 24 Hours $where .= "AND post_date &gt; '" . date('Y-m-d H:i:s', strtotim...
[ { "answer_id": 42420, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p>The <code>posts_where</code> filters the 'WHERE' part of the SQL statement, and not the query string. So<...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42418", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13115/" ]
I am trying to sort the posts using GD Star Rating in the last 24 hours. I have two separate queries, but I don't know how to merge them. ``` function filter_where($where = '') { //posts in the last 24 Hours $where .= "AND post_date > '" . date('Y-m-d H:i:s', strtotime('-24 hours')) ....
The `posts_where` filters the 'WHERE' part of the SQL statement, and not the query string. So ``` $where .= "&post_date > '".date('Y-m-d H:i:s', strtotime('-24 hours'))."'"; ``` should be ``` $where .= " AND post_date > '".date('Y-m-d H:i:s', strtotime('-24 hours'))."'"; ``` Also as this hook is fired for *every*...
42,430
<p>I'm currently using the following code in order to get subcategories in a category page and getting the posts foreach subcategory. In the part where it echos "span-12" (line 14) i want it to echo "span-12 last" for every other subcategory. </p> <p>my code: </p> <pre><code>&lt;?php $cats = get_categories('child_of...
[ { "answer_id": 42431, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 2, "selected": false, "text": "<p>I wrote a function to help with this to functionally mimic Ruby on Rails' <code>cycle</code> helper:</p...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42430", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13114/" ]
I'm currently using the following code in order to get subcategories in a category page and getting the posts foreach subcategory. In the part where it echos "span-12" (line 14) i want it to echo "span-12 last" for every other subcategory. my code: ``` <?php $cats = get_categories('child_of='.get_query_var('cat'))...
I wrote a function to help with this to functionally mimic Ruby on Rails' `cycle` helper: ``` /** * Cycle/alternate unlimited values of a given array. * * For instance, if you call this function five times with * `cycle_it( 'three', 'two', 'one' )`, you will in return get: * three two one three two * * Thi...
42,433
<p>I have created a meta box and it's storing the post data successfully but I am having trouble outputting the content and displaying it in a sensible fashion - beyond my limited knowledge of PHP. I am a bee-keeper and want to record inspections of my beehives - so for each hive there is a record with a set number of ...
[ { "answer_id": 42439, "author": "rg89", "author_id": 13090, "author_profile": "https://wordpress.stackexchange.com/users/13090", "pm_score": 1, "selected": false, "text": "<p>You could try something like this...</p>\n\n<pre><code>// need a loop here until all instances colony are reached...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42433", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13162/" ]
I have created a meta box and it's storing the post data successfully but I am having trouble outputting the content and displaying it in a sensible fashion - beyond my limited knowledge of PHP. I am a bee-keeper and want to record inspections of my beehives - so for each hive there is a record with a set number of fie...
Add meta data as "flat" data to the post ---------------------------------------- The actual problem is, that your meta data comes back as array (with a single entry), when calling `get_post_custom( $id );` for your post. Here's a simple function, that adds all meta data attached to a post to your post object. ``` /*...
42,444
<p>First time poster. I'm trying to export a bunch of custom posts out to a csv file so I can easily import them into a new database. I've ran the native export to xml, but it's not the correct format I need. I need a column based format (ie. name, height, weight, etc.).</p> <p>I have a custom post that has several cu...
[ { "answer_id": 42509, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Use <a href=\"http://codex.wordpress.org/Template_Tags/get_posts\" rel=\"nofollow\"><code>get_posts()</code></a> and i...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13165/" ]
First time poster. I'm trying to export a bunch of custom posts out to a csv file so I can easily import them into a new database. I've ran the native export to xml, but it's not the correct format I need. I need a column based format (ie. name, height, weight, etc.). I have a custom post that has several custom field...
With the help of @toscho pointing out `get_post();`, I was able to spit out a .csv with a blank template. At first, I had memory limit issues b/c of the amount of data, so I moved the site locally and was able to get everything I need with the `get_post();` This is the gist of it: ``` <ol> <?php global $post; $args =...
42,445
<p>Do I need to use the Simple Facebook Connect plugin? or can I just use some facebook api code? Any help appreciated.</p> <p>The example i'm trying to replicate is the interface at lookbook.nu. Once you login with facebook, there is a nice page to invite your FB friends. </p>
[ { "answer_id": 42450, "author": "rexposadas", "author_id": 413, "author_profile": "https://wordpress.stackexchange.com/users/413", "pm_score": 2, "selected": true, "text": "<p>An easy way would be to include the Facebook Javascript code:</p>\n\n<pre><code> wp_deregister_script('facebook'...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4229/" ]
Do I need to use the Simple Facebook Connect plugin? or can I just use some facebook api code? Any help appreciated. The example i'm trying to replicate is the interface at lookbook.nu. Once you login with facebook, there is a nice page to invite your FB friends.
An easy way would be to include the Facebook Javascript code: ``` wp_deregister_script('facebook'); wp_enqueue_script( 'facebook', 'https://connect.facebook.net/en_US/all.js' ); ``` Then use the default Facebook invite page. ``` <script> function facebookInvite(){ var r...
42,451
<p>I'm trying to explore new ways of embedding videos on to my site as a few of my contributors are having trouble viewing flash embeds when they use the preview function.</p> <p>Ideally it would be easiest to use oEmbed via the [embed] shortcode but i'm running into a problem that I don't seem to be able to find a so...
[ { "answer_id": 42455, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 0, "selected": false, "text": "<p>If you are trying to embed flash videos you should try <a href=\"http://wordpress.org/extend/plugins/kimili-flash...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42451", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4488/" ]
I'm trying to explore new ways of embedding videos on to my site as a few of my contributors are having trouble viewing flash embeds when they use the preview function. Ideally it would be easiest to use oEmbed via the [embed] shortcode but i'm running into a problem that I don't seem to be able to find a solution for...
When you're referring to using oEmbed codes, I'm assuming that you're referring to WordPress' ability to take a URL to media (such as one from YouTube) and [automatically embed](http://codex.wordpress.org/Embeds#oEmbed) that into a post. If that's the case, then you can take advantage of the [`embed_oembed_html`](http...
42,457
<p>I have a site with about 1,000 posts spread out over 70 or 80 categories. Some of these categories require the posts be sorted by a custom field, others not. </p> <p>I've got a working solution by having 60+ category template files defined (e.g. category-123.php, category-124.php) and each of those calls a separa...
[ { "answer_id": 42462, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>How about this, create an option in the options table (in the database) with an array of categories ids that ...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6146/" ]
I have a site with about 1,000 posts spread out over 70 or 80 categories. Some of these categories require the posts be sorted by a custom field, others not. I've got a working solution by having 60+ category template files defined (e.g. category-123.php, category-124.php) and each of those calls a separate loop file...
I would suggest to hook onto `pre_get_posts` and alter the query, rather than firing off your own in the template (it keeps your template tidy, and you'll avoid doubling your database queries!). Below demonstrates this, plus a bonus settings field in the admin (under "Reading") to select the categories that "special s...
42,461
<p>I know I can set a static page as the homepage but is it possible to set a single custom post as the site front page?</p> <p>I created a custom post type called "portfolio" where users can add all the work they have done as posts and I need one of those posts to display as the homepage, exactly as if you would set ...
[ { "answer_id": 42464, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>There are many ways to accomplish this, though some are more advanced than others:</p>\n\n<ol>\n<li>Mark th...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3893/" ]
I know I can set a static page as the homepage but is it possible to set a single custom post as the site front page? I created a custom post type called "portfolio" where users can add all the work they have done as posts and I need one of those posts to display as the homepage, exactly as if you would set a static f...
You don't want a *post* to be the front page, you want a *custom post type* entry to be the front page. Now that we have the terminology right, *yes* it's possible. A client once asked me to do the exact same thing. They had a custom post type they needed displayed on the front page. Doing so was as simple as adding a...
42,471
<p>I have an options page for my plugin. I want the user to be able to click a button to execute a member function of my plugin's class. I found this page: </p> <p><a href="https://stackoverflow.com/questions/8597846/wordpress-plugin-call-function-on-button-click-in-admin-panel">https://stackoverflow.com/questions/859...
[ { "answer_id": 42499, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 0, "selected": false, "text": "<p>Yes, that method <em>should</em> be fine. Adding a nonce is always a positive thing to do as well.</p>\n\n<p><stro...
2012/02/15
[ "https://wordpress.stackexchange.com/questions/42471", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13090/" ]
I have an options page for my plugin. I want the user to be able to click a button to execute a member function of my plugin's class. I found this page: <https://stackoverflow.com/questions/8597846/wordpress-plugin-call-function-on-button-click-in-admin-panel> But I'm not sure if I am interpreting the instructions c...
Try using ['init'](http://codex.wordpress.org/Plugin_API/Action_Reference/init) action hook to handle the submit trigger. Create a new object of your class in the hooked function and call the member function.
42,488
<p>I can't seem to get drafts to show up with WP_Query, even when post_status is set to 'any' or 'draft'</p> <pre><code> $args = array( 'p' =&gt; 1234, 'post_type' =&gt; 'any', 'post_status' =&gt; 'any' ); $query = new WP_Q...
[ { "answer_id": 42491, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 3, "selected": false, "text": "<p>Try passing it as an array.</p>\n\n<p><strong>For example</strong></p>\n\n<pre><code>$args = array(\n 'p' =&gt;...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42488", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
I can't seem to get drafts to show up with WP\_Query, even when post\_status is set to 'any' or 'draft' ``` $args = array( 'p' => 1234, 'post_type' => 'any', 'post_status' => 'any' ); $query = new WP_Query( $args ); ...
Try passing it as an array. **For example** ``` $args = array( 'p' => 1234, 'post_type' => 'any', 'post_status' => array('draft') ); ``` **Or for all types** ``` $args = array( 'p' => 1234, 'post_type' => 'any', 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future',...
42,494
<p>I am a rookie theme developer (3 months in) and I am trying to figure out how to implement the following functionality:</p> <ol> <li>The theme I am building has a logo which I would like for users <strong>to be able to change</strong>.</li> <li>I'd like for them to NOT have to do so in the code. </li> <li>Rather I'...
[ { "answer_id": 42495, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>I just finished posting this <a href=\"http://en.bainternet.info/2012/my-options-panel\" rel=\"nofollow\"><st...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42494", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12116/" ]
I am a rookie theme developer (3 months in) and I am trying to figure out how to implement the following functionality: 1. The theme I am building has a logo which I would like for users **to be able to change**. 2. I'd like for them to NOT have to do so in the code. 3. Rather I'd like to develop some type of low-tech...
You can create a basic theme options page using the [WordPress settings api](http://codex.wordpress.org/Settings_API) Here is a simple example that will create an input field for the user to enter a path to the custom logo. ``` // Add a menu for our option page add_action('admin_menu', 'prefix_myplugin_add_page'); fu...
42,521
<p>All</p> <p>I am using <a href="http://wordpress.org/extend/plugins/formidable/" rel="nofollow">formidable</a> plugin and on one page i need to use 5 shortcodes.</p> <pre><code>[frm-entry-delete-link id=9 page_id=25 field_key=hsn108] [frm-entry-delete-link id=12 page_id=25 field_key=cp7pi] [frm-entry-delete-link id...
[ { "answer_id": 42523, "author": "Chris", "author_id": 11460, "author_profile": "https://wordpress.stackexchange.com/users/11460", "pm_score": 0, "selected": false, "text": "<p>Have a read of the shortcode API which explains everything you need to know about using and developing shortcode...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42521", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12261/" ]
All I am using [formidable](http://wordpress.org/extend/plugins/formidable/) plugin and on one page i need to use 5 shortcodes. ``` [frm-entry-delete-link id=9 page_id=25 field_key=hsn108] [frm-entry-delete-link id=12 page_id=25 field_key=cp7pi] [frm-entry-delete-link id=13 page_id=25 field_key=ksa9qv] [frm-entry-del...
You can create your own shortcode which will hold all of that for you hardcoded: ``` add_shortcode("my_five_forms","my_five_forms_handler"); function my_five_forms_handler($atts,$content =null){ $con = "[frm-entry-delete-link id=9 page_id=25 field_key=hsn108] [frm-entry-delete-link id=12 page_id=25 field_...
42,529
<p>Has anyone seen a way to add a new header_image to a theme? I need to add two configurable images in a theme. It doesn't really matter if it gets added as a new "Header" admin theme menu or if it's added to the existing Apperance->Header menu. </p> <p>I'm a bit new to plugin development so any help in the right dir...
[ { "answer_id": 42523, "author": "Chris", "author_id": 11460, "author_profile": "https://wordpress.stackexchange.com/users/11460", "pm_score": 0, "selected": false, "text": "<p>Have a read of the shortcode API which explains everything you need to know about using and developing shortcode...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88/" ]
Has anyone seen a way to add a new header\_image to a theme? I need to add two configurable images in a theme. It doesn't really matter if it gets added as a new "Header" admin theme menu or if it's added to the existing Apperance->Header menu. I'm a bit new to plugin development so any help in the right direction is...
You can create your own shortcode which will hold all of that for you hardcoded: ``` add_shortcode("my_five_forms","my_five_forms_handler"); function my_five_forms_handler($atts,$content =null){ $con = "[frm-entry-delete-link id=9 page_id=25 field_key=hsn108] [frm-entry-delete-link id=12 page_id=25 field_...
42,538
<p>I have a live WordPress installation and a local one for development purposes. I just exported the live database, replaced all occurences of the live siteurl with the local one, and imported on my dev machine.</p> <p>Problem is that on my dev machine all users have lost any permissions. When logging in I get:</p> ...
[ { "answer_id": 42523, "author": "Chris", "author_id": 11460, "author_profile": "https://wordpress.stackexchange.com/users/11460", "pm_score": 0, "selected": false, "text": "<p>Have a read of the shortcode API which explains everything you need to know about using and developing shortcode...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42538", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3701/" ]
I have a live WordPress installation and a local one for development purposes. I just exported the live database, replaced all occurences of the live siteurl with the local one, and imported on my dev machine. Problem is that on my dev machine all users have lost any permissions. When logging in I get: ``` Notice: Un...
You can create your own shortcode which will hold all of that for you hardcoded: ``` add_shortcode("my_five_forms","my_five_forms_handler"); function my_five_forms_handler($atts,$content =null){ $con = "[frm-entry-delete-link id=9 page_id=25 field_key=hsn108] [frm-entry-delete-link id=12 page_id=25 field_...
42,545
<p>I'm simply typing wp_list_comments() in page.php but nothing is shown. But if I put the comments_template() tag there, then the comment form, comments and pings are shown. Why is that, why can't I use wp_list_comments() in page.php? What could I have done wrong?</p>
[ { "answer_id": 42563, "author": "rexposadas", "author_id": 413, "author_profile": "https://wordpress.stackexchange.com/users/413", "pm_score": 0, "selected": false, "text": "<p>Try enclosing wp_list_comments() like this: </p>\n\n<pre><code>&lt;ol class=\"commentlist\"&gt;\n&lt;?php wp_li...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42545", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1936/" ]
I'm simply typing wp\_list\_comments() in page.php but nothing is shown. But if I put the comments\_template() tag there, then the comment form, comments and pings are shown. Why is that, why can't I use wp\_list\_comments() in page.php? What could I have done wrong?
You need to include comments functionality via `comments_template()`, because this function doesn't merely include the `comments.php`, file, but also handles all of the querying and functions required for displaying comments. While [the Codex doesn't really get into details](http://codex.wordpress.org/Function_Referen...
42,553
<p>I have a custom post type with custom metaboxes <a href="http://wptheming.com/2011/11/event-posts-in-wordpress/comment-page-1/#comment-17038" rel="nofollow">(as seen on wptheming.com)</a> and would like to make a query to show upcoming events, say in the sidebar, where past dates are left out.</p> <p>But I need a v...
[ { "answer_id": 42582, "author": "Matth_eu", "author_id": 13202, "author_profile": "https://wordpress.stackexchange.com/users/13202", "pm_score": 1, "selected": false, "text": "<p>Looks like a unix timestamp is being stored in the post meta - so you should compare with a unix timestimp, n...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42553", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13197/" ]
I have a custom post type with custom metaboxes [(as seen on wptheming.com)](http://wptheming.com/2011/11/event-posts-in-wordpress/comment-page-1/#comment-17038) and would like to make a query to show upcoming events, say in the sidebar, where past dates are left out. But I need a value of the current time to compare ...
Looks like a unix timestamp is being stored in the post meta - so you should compare with a unix timestimp, not a MySQL's timestamp. To get the current time as a timestamp you should use the following code: current\_time( 'timestamp' );
42,556
<p>Just a question : I want to use <code>get_category_parents()</code> to display a breadcrumb on a category archive page, but with no link on the current displayed category (SEO purposes, because they say that's a link to itself. I'm not sure search engines are <em>that</em> stupid, but anyway).</p> <p>Like this : </...
[ { "answer_id": 42557, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<h3>Use native php functions</h3>\n\n<p>It's not that hard, if you take a in-depth look at string/array handling on ph...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42556", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9458/" ]
Just a question : I want to use `get_category_parents()` to display a breadcrumb on a category archive page, but with no link on the current displayed category (SEO purposes, because they say that's a link to itself. I'm not sure search engines are *that* stupid, but anyway). Like this : > > link\_home » link\_cat1...
I wouldn't consider this any better/worse than Kaiser's option, but just different. Why not use `get_category_parents` on the parent category and then (optionally) append the current category? I haven't tested this, but something like the following should work: ``` $cat_id=7;//current category's ID (e.g. 7) $separato...
42,559
<p>I am USING the wordpress Import/Export and have done exporting the XML file from my wordpress site. And now i am moving my site from a local server to a host, after copying the files i noticed that on the new HOST there is no DATABASE connection, since i am not using a fresh install, I am just copying my files from ...
[ { "answer_id": 42557, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<h3>Use native php functions</h3>\n\n<p>It's not that hard, if you take a in-depth look at string/array handling on ph...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42559", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13126/" ]
I am USING the wordpress Import/Export and have done exporting the XML file from my wordpress site. And now i am moving my site from a local server to a host, after copying the files i noticed that on the new HOST there is no DATABASE connection, since i am not using a fresh install, I am just copying my files from the...
I wouldn't consider this any better/worse than Kaiser's option, but just different. Why not use `get_category_parents` on the parent category and then (optionally) append the current category? I haven't tested this, but something like the following should work: ``` $cat_id=7;//current category's ID (e.g. 7) $separato...
42,561
<p>I try to make template that has Page content in the main div but in the same page there is category base post loop whit title, day, content and read more link.</p> <p>What i had now is like this</p> <pre><code>&lt;?php if(have_posts()): while(have_posts()): the_post(); ?&gt; &lt;?php //Post thumbnails nee...
[ { "answer_id": 42562, "author": "Chris Cox", "author_id": 1718, "author_profile": "https://wordpress.stackexchange.com/users/1718", "pm_score": 1, "selected": false, "text": "<p>Use the_excerpt() instead of the_content() - the_content() will only cut off if you do it manually.</p>\n" }...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42561", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12857/" ]
I try to make template that has Page content in the main div but in the same page there is category base post loop whit title, day, content and read more link. What i had now is like this ``` <?php if(have_posts()): while(have_posts()): the_post(); ?> <?php //Post thumbnails need this in functions.php: `add_...
Use the\_excerpt() instead of the\_content() - the\_content() will only cut off if you do it manually.
42,604
<p>I have the following code in my functions.php file.</p> <pre><code>&lt;?php add_action('init', 'flush_rewrite_rules'); function custom_add_rewrite_rules( $wp_rewrite ) { $new_rules = array( 'insurance-leads-types/auto-insurance-leads/([^/\.]+)/?$' =&gt; 'index.php?pagename=auto-insurance-leads&amp;sta...
[ { "answer_id": 42562, "author": "Chris Cox", "author_id": 1718, "author_profile": "https://wordpress.stackexchange.com/users/1718", "pm_score": 1, "selected": false, "text": "<p>Use the_excerpt() instead of the_content() - the_content() will only cut off if you do it manually.</p>\n" }...
2012/02/16
[ "https://wordpress.stackexchange.com/questions/42604", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13210/" ]
I have the following code in my functions.php file. ``` <?php add_action('init', 'flush_rewrite_rules'); function custom_add_rewrite_rules( $wp_rewrite ) { $new_rules = array( 'insurance-leads-types/auto-insurance-leads/([^/\.]+)/?$' => 'index.php?pagename=auto-insurance-leads&state=' . $wp_rewrite->preg...
Use the\_excerpt() instead of the\_content() - the\_content() will only cut off if you do it manually.
42,631
<p>Ok I have this jQuery that I have tested in a static html page and it works fine.</p> <p>How would I include jQuery to work on wordpress in a plugin?</p> <p>So this is the html page.</p> <pre><code>&lt;head&gt; &lt;title&gt; Welcome to my page&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="css/styl...
[ { "answer_id": 42634, "author": "Zack", "author_id": 2322, "author_profile": "https://wordpress.stackexchange.com/users/2322", "pm_score": 1, "selected": false, "text": "<p>You may want to look at <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script\" rel=\"nofollow\...
2012/02/17
[ "https://wordpress.stackexchange.com/questions/42631", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12918/" ]
Ok I have this jQuery that I have tested in a static html page and it works fine. How would I include jQuery to work on wordpress in a plugin? So this is the html page. ``` <head> <title> Welcome to my page</title> <link rel="stylesheet" type="text/css" href="css/style.css"> <link rel="stylesheet" type="text/css" hr...
You should be using `wp_register_script()` and `wp_enqueue_script()`, so, for example: ``` add_action( 'wp_enquque_scripts', 'my_script_enqueue' ); function my_script_enqueue() { wp_enqueue_script( 'my-jquery', 'URL TO THE FILE', array( 'jquery' ) ); } ``` Also, as mentioned by Zack, you should be registering y...