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
71,992
<p>I’d like to make a tiny change in one of my custom taxonomy admin panels: rename the label "Description" to "Title".</p>
[ { "answer_id": 72004, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 0, "selected": false, "text": "<pre><code>function my_gettext_with_context($translated, $text, $context, $domain) {\n if (is_admin() AND $text...
2012/11/08
[ "https://wordpress.stackexchange.com/questions/71992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21110/" ]
I’d like to make a tiny change in one of my custom taxonomy admin panels: rename the label "Description" to "Title".
Checking the file `/wp-admin/edit-tags.php`, we see that it's using the function [`_ex()`](http://codex.wordpress.org/Function_Reference/_ex) to translate the string `Description`. Following `_ex` path, we find that it finally uses the filter `gettext_with_context` to translate the text. So, it is possible to hook int...
71,997
<p>I'm just getting started with wordpress development. I'm trying to create a simple plugin that show results from a db in a table. I can do this, but I'm having trouble with the plugin showing at the top of the admin pages. I'm not sure why it does this.</p> <p>my plugin function:</p> <pre><code>add_action('init','...
[ { "answer_id": 71998, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>You have hooked your function to <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/init\" rel=...
2012/11/08
[ "https://wordpress.stackexchange.com/questions/71997", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13952/" ]
I'm just getting started with wordpress development. I'm trying to create a simple plugin that show results from a db in a table. I can do this, but I'm having trouble with the plugin showing at the top of the admin pages. I'm not sure why it does this. my plugin function: ``` add_action('init','hello_world'); fu...
To complement @s\_ha\_dum’s answer: If you just want to offer a function to be used in a theme, make it a custom action. Sample: ``` add_action( 'call_hello_world', 'hello_world' ); ``` Now, in a theme, the author can call your function with … ``` do_action( 'call_hello_world' ); ``` … and the function will prin...
72,017
<p>I'm making a travel site and for each page/post I want to display a google map and an image of the place referenced in the post/page</p> <p>the image is kind of banner-size so I dont think that the post thumbnail would do (unless I can get the high-res image of which the thumbnail comes from)</p> <p>I thought of g...
[ { "answer_id": 72018, "author": "Jen", "author_id": 13810, "author_profile": "https://wordpress.stackexchange.com/users/13810", "pm_score": 1, "selected": true, "text": "<p>You can use the featured image (or featured thumbnail) for this type of functionality. You can control which size o...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72017", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20696/" ]
I'm making a travel site and for each page/post I want to display a google map and an image of the place referenced in the post/page the image is kind of banner-size so I dont think that the post thumbnail would do (unless I can get the high-res image of which the thumbnail comes from) I thought of getting the first ...
You can use the featured image (or featured thumbnail) for this type of functionality. You can control which size of the image you use... it doesn't have to be the "thumbnail" size. From the [codex](http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail#Thumbnail_Sizes): ``` get_the_post_thumbnail(get_t...
72,040
<p>I'm trying to update <code>user_login</code> in the <code>wp_users</code> table, to force update a user's username to their email address on submission of a front end edit profile form.</p> <p>I know WordPress forbids this via the <code>wp_update_user</code> function so I am trying to use SQL with wpdb functions.</...
[ { "answer_id": 72041, "author": "mattberridge", "author_id": 9244, "author_profile": "https://wordpress.stackexchange.com/users/9244", "pm_score": 2, "selected": false, "text": "<p>Fixed it! There are two methods:</p>\n\n<pre><code>// Force update our username (user_login)\nglobal $wpdb;...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72040", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9244/" ]
I'm trying to update `user_login` in the `wp_users` table, to force update a user's username to their email address on submission of a front end edit profile form. I know WordPress forbids this via the `wp_update_user` function so I am trying to use SQL with wpdb functions. Here is what I have, and it is not working ...
Fixed it! There are two methods: ``` // Force update our username (user_login) global $wpdb; $tablename = $wpdb->prefix . "users"; // method 1 //$sql = $wpdb->prepare("UPDATE {$tablename} SET user_login=%s WHERE ID=%d", $user_email, $user_id); //$wpdb->query($sql); // method 2 $wpdb->update( $tablename, array( 'user...
72,043
<h3>Situation</h3> <p>I've just setup a new installation of WordPress (running on XAMPP/Win7). As I had a port conflict on <code>:80/:443</code>, I switched to <code>:187/4430</code>.</p> <h3>Error</h3> <p>When I'm now trying to access <code>http://vanilla-mu.dev:187/index.php</code> (or any other request), then I r...
[ { "answer_id": 72041, "author": "mattberridge", "author_id": 9244, "author_profile": "https://wordpress.stackexchange.com/users/9244", "pm_score": 2, "selected": false, "text": "<p>Fixed it! There are two methods:</p>\n\n<pre><code>// Force update our username (user_login)\nglobal $wpdb;...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72043", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/385/" ]
### Situation I've just setup a new installation of WordPress (running on XAMPP/Win7). As I had a port conflict on `:80/:443`, I switched to `:187/4430`. ### Error When I'm now trying to access `http://vanilla-mu.dev:187/index.php` (or any other request), then I run into the following WordPress Error inside a `wp_di...
Fixed it! There are two methods: ``` // Force update our username (user_login) global $wpdb; $tablename = $wpdb->prefix . "users"; // method 1 //$sql = $wpdb->prepare("UPDATE {$tablename} SET user_login=%s WHERE ID=%d", $user_email, $user_id); //$wpdb->query($sql); // method 2 $wpdb->update( $tablename, array( 'user...
72,050
<p>My lovely colleagues have once again designed something that gives me a hard time getting it in Wordpress. Surprisingly it's something that I have done multiple times before; having recent posts and page content on one page.</p> <p>The homepage is a page. Just above the page's content there are three recent posts. ...
[ { "answer_id": 72065, "author": "Alex Lane", "author_id": 16016, "author_profile": "https://wordpress.stackexchange.com/users/16016", "pm_score": 1, "selected": false, "text": "<p>At the end of your news.php, use <code>wp_reset_query()</code>. This will revert to the default query for th...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72050", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20639/" ]
My lovely colleagues have once again designed something that gives me a hard time getting it in Wordpress. Surprisingly it's something that I have done multiple times before; having recent posts and page content on one page. The homepage is a page. Just above the page's content there are three recent posts. For the po...
never, ever use the variable `posts` in Wordpress for custom loops. After changing the variable name to `items` in `news.php` everything worked excellent. When I changed the variable `post` to `item`, it stopped working again... ``` <?php foreach($items as $post): setup_postdata($post); ?> <!-- post --> <?php end...
72,055
<p>I'm currently trying to layer a post title on top of the posts featured image but all I see at the moment is "<strong>);"></strong>" instead of the image.</p> <p>The code I'm using is as follows:</p> <pre><code>&lt;div style="width:609px;height:364px;background-image:url(&lt;?php the_post_thumbnail(); ?&gt;);"&gt;...
[ { "answer_id": 72056, "author": "Daniel", "author_id": 12865, "author_profile": "https://wordpress.stackexchange.com/users/12865", "pm_score": 3, "selected": true, "text": "<p><code>the_post_thumbnail()</code> does not return the path of your image. Instead, it returns the complete HTML ...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11945/" ]
I'm currently trying to layer a post title on top of the posts featured image but all I see at the moment is "**);">**" instead of the image. The code I'm using is as follows: ``` <div style="width:609px;height:364px;background-image:url(<?php the_post_thumbnail(); ?>);"><h2><a href="<?php the_permalink() ?>"><?php t...
`the_post_thumbnail()` does not return the path of your image. Instead, it returns the complete HTML markup for that image. You can use this instead: `$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); echo $image[0];` If you want a specific size you can pass an additional parameter: `$imag...
72,064
<p>I am using the "Types" wordpress plugin for the first time. I created a custom post type, as well as some custom fields. </p> <p>How do I dynamically call all the custom posts into a Bootstrap carousel, and also display the fields within that loop?</p> <p>And how do I limit the amount of posts that will cycle thr...
[ { "answer_id": 72068, "author": "Alex Lane", "author_id": 16016, "author_profile": "https://wordpress.stackexchange.com/users/16016", "pm_score": 2, "selected": false, "text": "<p>I've found that for things like this, <code>get_posts</code> is easier.</p>\n\n<pre><code>&lt;?php\n // S...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72064", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23479/" ]
I am using the "Types" wordpress plugin for the first time. I created a custom post type, as well as some custom fields. How do I dynamically call all the custom posts into a Bootstrap carousel, and also display the fields within that loop? And how do I limit the amount of posts that will cycle through the carousel?...
I've found that for things like this, `get_posts` is easier. ``` <?php // Set up your arguments array to include your post type, // order, posts per page, etc. $args = array( 'post_type' => 'testimonial', 'posts_per_page' => 3, 'orderby' => 'date', 'order' => 'DESC' ); ...
72,066
<p>I am wondering if anyone knows the best method for splitting 1 custom menu widget (located in my sites footer) in to 2 columns. There are a total of 8 links, so I would like it to be split in to 2 columns of 4 links. Not sure if there is a function for this or is there some CSS to achieve this? The HTML markup from ...
[ { "answer_id": 72072, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 3, "selected": true, "text": "<p>Purely with CSS you could set a width for menu items, float them and then set the UL to twice that:</p>\n\n<pre>...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72066", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17502/" ]
I am wondering if anyone knows the best method for splitting 1 custom menu widget (located in my sites footer) in to 2 columns. There are a total of 8 links, so I would like it to be split in to 2 columns of 4 links. Not sure if there is a function for this or is there some CSS to achieve this? The HTML markup from the...
Purely with CSS you could set a width for menu items, float them and then set the UL to twice that: ``` footer ul { width: 200px; } footer .menu-item { float: left; width: 100px } ``` (I don't know what elements you are using to designate your footer, you'll need to update that to match your structure.)
72,076
<p>I'm building a CRM-Theme for Wordpress. So i post, edit and delete posts from the Frontend. I'm on a good way to resolve all problems, i think. But there is one failure. At the index there is a "edit" and "delete" button. If i click on "edit" I'm getting to a form. I can change the post_tags there. Changes will be s...
[ { "answer_id": 72137, "author": "Mario Peshev", "author_id": 11506, "author_profile": "https://wordpress.stackexchange.com/users/11506", "pm_score": 1, "selected": false, "text": "<p>When you're trying to insert <code>$_POST['post_tags']</code> it's actually persisting one long string. W...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23477/" ]
I'm building a CRM-Theme for Wordpress. So i post, edit and delete posts from the Frontend. I'm on a good way to resolve all problems, i think. But there is one failure. At the index there is a "edit" and "delete" button. If i click on "edit" I'm getting to a form. I can change the post\_tags there. Changes will be sav...
Ok, found a solution by myself. In the past i saved post\_tags with ``` wp_set_post_terms($pid, array($_POST['post_tags']),'post_tag',false); ``` Now i save the post\_tags with ``` wp_set_post_tags($pid, $_POST['post_tags']); ``` and it works. This way is the same method, i use to publish a new post from the fron...
72,084
<p>I have a blog network (Multisite), with domain mapping plugin installed, and some of my sites are under development, so I want to lock them from not registered users.</p> <p>I tested a few plugins designed for this purpose (<em>Private Only</em>, <em>Private WP suite</em>, <em>Private WP</em>, <em>Members Only</em>...
[ { "answer_id": 72088, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>I don’t have the domain mapping on a test installation at hand currently, but what <em>should work</em> is:</p>\n\n<pre...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17323/" ]
I have a blog network (Multisite), with domain mapping plugin installed, and some of my sites are under development, so I want to lock them from not registered users. I tested a few plugins designed for this purpose (*Private Only*, *Private WP suite*, *Private WP*, *Members Only*, *Registered Users Only*, *Absolute P...
I don’t have the domain mapping on a test installation at hand currently, but what *should work* is: ``` add_action( 'template_redirect', 'auth_redirect' ); ``` As a plugin here: [T5 Force Log In](https://gist.github.com/3521964). [`auth_redirect()`](http://queryposts.com/function/auth_redirect/) is WordPress’ na...
72,099
<p>I see many people prefer to use <code>pre_get_posts</code> hook instead of <code>query_posts</code>. The code below works and shows all posts which have meta key "featured"</p> <pre><code>function show_featured_posts ( $query ) { if ( $query-&gt;is_main_query() ) { $query-&gt;set( 'meta_key', 'featured' ...
[ { "answer_id": 72126, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 6, "selected": false, "text": "<blockquote>\n <p>I see many people prefer to use pre_get_posts hook instead of query_posts</p>\n</blockquo...
2012/11/09
[ "https://wordpress.stackexchange.com/questions/72099", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23491/" ]
I see many people prefer to use `pre_get_posts` hook instead of `query_posts`. The code below works and shows all posts which have meta key "featured" ``` function show_featured_posts ( $query ) { if ( $query->is_main_query() ) { $query->set( 'meta_key', 'featured' ); $query->set( 'meta_value', 'yes'...
> > I see many people prefer to use pre\_get\_posts hook instead of query\_posts > > > Yay! So `pre_get_posts` filters a [`WP_Query` object](http://codex.wordpress.org/Class_Reference/WP_Query) which means *anything* you could do via `query_posts()` you can do via `$query->set()` and `$query->get()`. In particula...
72,103
<p>I'm trying to improve a bookmarks manager/theme I've built (<a href="http://bookmarkie.waterstreetgm.org" rel="nofollow">http://bookmarkie.waterstreetgm.org</a>). </p> <p>Right now, each post is simply a link: </p> <p><code>&lt;a href="http://tumblr.everlane.com/page/4"&gt;Everlane Tumblr&lt;/a&gt;.</code> ie: tha...
[ { "answer_id": 72104, "author": "Abdussamad", "author_id": 12839, "author_profile": "https://wordpress.stackexchange.com/users/12839", "pm_score": 0, "selected": false, "text": "<p>Instead of putting a link in the content area why don't you just put the URL in a custom field. Then you ca...
2012/11/10
[ "https://wordpress.stackexchange.com/questions/72103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3877/" ]
I'm trying to improve a bookmarks manager/theme I've built (<http://bookmarkie.waterstreetgm.org>). Right now, each post is simply a link: `<a href="http://tumblr.everlane.com/page/4">Everlane Tumblr</a>.` ie: that one single link is the entire content of `the_content()`. Easy enough and works great. Next, I want ...
You're just looking in the wrong place: ``` php > $txt = '<a href="http://tumblr.everlane.com/page/4">Everlane Tumblr</a>'; php > $matches = array(); php > echo preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $txt, $matches); 1 php > print_r($matches); Array ( [0] => Array ( ...
72,116
<p>Given the user ID, how can I display all the blogs where this user is administrator?</p> <p>I tried:</p> <pre><code>&lt;?php $user_id = 2; $user_blogs = get_blogs_of_user( $user_id ); echo '&lt;ul&gt;'; foreach ($user_blogs AS $user_blog) { echo '&lt;li&gt;'.$user_blog-&gt;blogname.'&lt;/li&gt;'; } echo '&lt;/...
[ { "answer_id": 72118, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>The capabilities are stored as user meta data in a serialized array for each site.</p>\n\n<p>The key as a regular expre...
2012/11/10
[ "https://wordpress.stackexchange.com/questions/72116", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7749/" ]
Given the user ID, how can I display all the blogs where this user is administrator? I tried: ``` <?php $user_id = 2; $user_blogs = get_blogs_of_user( $user_id ); echo '<ul>'; foreach ($user_blogs AS $user_blog) { echo '<li>'.$user_blog->blogname.'</li>'; } echo '</ul>'; ?> ``` However, it will return all the b...
The capabilities are stored as user meta data in a serialized array for each site. The key as a regular expression would look like that: ``` '~' . $GLOBALS['wpdb']->base_prefix . '(\d+)_capabilities~' ``` So … get the user meta data, find the capability strings (they hold the roles), and compare the unserialized re...
72,131
<p>To get a the path to a plugin you can use <code>plugin_dir_path(__FILE__)</code> - but this obviously has to be called from within the plug-in.</p> <p>How can you <em>reliably</em> get the path to plugin B (<code>pluginb/pluginb.php</code>) from within plug-in A?</p> <p><strong>Edit:</strong> Its assumed you know ...
[ { "answer_id": 72133, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 4, "selected": true, "text": "<p>My best guess would be:</p>\n\n<pre><code>if ( ! is_file( $dir = WPMU_PLUGIN_DIR . '/pluginb/pluginb.php' ) ...
2012/11/10
[ "https://wordpress.stackexchange.com/questions/72131", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9364/" ]
To get a the path to a plugin you can use `plugin_dir_path(__FILE__)` - but this obviously has to be called from within the plug-in. How can you *reliably* get the path to plugin B (`pluginb/pluginb.php`) from within plug-in A? **Edit:** Its assumed you know the slug of the plug-in you're after (actually you can get ...
My best guess would be: ``` if ( ! is_file( $dir = WPMU_PLUGIN_DIR . '/pluginb/pluginb.php' ) ) { if ( ! is_file( $dir = WP_PLUGIN_DIR . '/pluginb/pluginb.php' ) ) $dir = null; } return $dir; ``` However, the danger here is still the assumption of the plugin's "basename" - a well written plugin will sti...
72,157
<p>I have a site with several thousand posts. They all have just a single attached image of varying size. All posts are displayed in full (no thumbnail view). I'd like to be able to change the way the elements display within the posts to be:</p> <ul> <li>date (at the top)</li> <li>image caption</li> <li>the attached i...
[ { "answer_id": 72188, "author": "Mario Peshev", "author_id": 11506, "author_profile": "https://wordpress.stackexchange.com/users/11506", "pm_score": 0, "selected": false, "text": "<p>I was unable to understand if that refers to the frontend or the backend? </p>\n\n<p>The backend could be...
2012/11/10
[ "https://wordpress.stackexchange.com/questions/72157", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23509/" ]
I have a site with several thousand posts. They all have just a single attached image of varying size. All posts are displayed in full (no thumbnail view). I'd like to be able to change the way the elements display within the posts to be: * date (at the top) * image caption * the attached image (actual size) * post ti...
Something like (in your single.php) ``` <?php while (have_posts()): the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <time class="post-time" datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('F j, Y'); ?></time> <?php if (has_post_thumbnail()): ?> <?php $thumbnail_image ...
72,158
<p>What I want to do is display my latest post's content on a custom template page, ONLY if a meta box is filled in with the right word. In other words, if the post has a meta box named, "FEATURED" with a value of "YES", then I would like to show the post on my custom template page. If the "FEATURED" meta box says, "NO...
[ { "answer_id": 72189, "author": "Mario Peshev", "author_id": 11506, "author_profile": "https://wordpress.stackexchange.com/users/11506", "pm_score": 1, "selected": false, "text": "<p>You're speaking about <code>custom field</code> content and not <code>meta box</code> content - the meta ...
2012/11/10
[ "https://wordpress.stackexchange.com/questions/72158", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17837/" ]
What I want to do is display my latest post's content on a custom template page, ONLY if a meta box is filled in with the right word. In other words, if the post has a meta box named, "FEATURED" with a value of "YES", then I would like to show the post on my custom template page. If the "FEATURED" meta box says, "NO", ...
You're speaking about `custom field` content and not `meta box` content - the meta box is the wrapper box where custom fields are displayed. For the custom field display, you can create a WP\_Query with a meta condition, i.e. adding a specific condition whether a custom field is set and with a specific value. [@Rarst...
72,160
<p>Many posts here or somewhere else contain code, but they do not say where to put it.</p> <p>Example:</p> <p>I have found this post: <a href="https://wordpress.stackexchange.com/questions/44740/how-do-i-turn-off-301-redirecting-posts-not-canonical/72136#72136">How do I turn off 301 redirecting posts (not canonical)...
[ { "answer_id": 72179, "author": "andy", "author_id": 23443, "author_profile": "https://wordpress.stackexchange.com/users/23443", "pm_score": 3, "selected": false, "text": "<p>The code referred to in the link is to be placed in the functions.php file of your theme, not in canonical.php. Y...
2012/11/11
[ "https://wordpress.stackexchange.com/questions/72160", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23504/" ]
Many posts here or somewhere else contain code, but they do not say where to put it. Example: I have found this post: [How do I turn off 301 redirecting posts (not canonical)?](https://wordpress.stackexchange.com/questions/44740/how-do-i-turn-off-301-redirecting-posts-not-canonical/72136#72136) I'm a newbie with P...
Whenever you find a piece of code without clear installation instructions it is probably a plugin. The example you gave is a good one, because that is the most common case: ``` add_action('template_redirect', 'remove_404_redirect', 1); function remove_404_redirect() { // do something } ``` To use such a snippet, put...
72,170
<p>I have a custom function which allows users to choose between next/previous links and pagination and I'm attempting to add CSS classes to the next/previous links. I've tried this multiple ways and keep crashing my theme.</p> <p>How do I insert CSS classes into the previous and next link?</p> <pre><code>// Paginat...
[ { "answer_id": 72191, "author": "Mario Peshev", "author_id": 11506, "author_profile": "https://wordpress.stackexchange.com/users/11506", "pm_score": 0, "selected": false, "text": "<p>The <code>paginate_links</code> function doesn't accept parameters for CSS styling itself, and I'm not su...
2012/11/11
[ "https://wordpress.stackexchange.com/questions/72170", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I have a custom function which allows users to choose between next/previous links and pagination and I'm attempting to add CSS classes to the next/previous links. I've tried this multiple ways and keep crashing my theme. How do I insert CSS classes into the previous and next link? ``` // Pagination function my_theme_...
You could do this with jQuery. Like so ... ``` $("a:contains('Newer')").addClass('YourNewerClassHere'); $("a:contains('Older')").addClass('YourOlderClassHere'); ```
72,203
<p>I'm trying to make a page with multiple loops, I need every loop to display a predefined number of posts from the same category (every loop displays X number of posts from Category CATS). But I also need the second loop, the third loop and so on to display the posts from where the last loop stopped, without duplicat...
[ { "answer_id": 72206, "author": "Mario Peshev", "author_id": 11506, "author_profile": "https://wordpress.stackexchange.com/users/11506", "pm_score": 0, "selected": false, "text": "<p>Either use <code>wp_reset_query()</code> after every query in order to clear the results of the previous ...
2012/11/11
[ "https://wordpress.stackexchange.com/questions/72203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23525/" ]
I'm trying to make a page with multiple loops, I need every loop to display a predefined number of posts from the same category (every loop displays X number of posts from Category CATS). But I also need the second loop, the third loop and so on to display the posts from where the last loop stopped, without duplicating...
it is important to read this [Codex chapter](http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action) all the way to the end, as the essential suggestions are after this heading **'Note for Multiple Posts in the First Category'**; repetitive, tedious code: ``` <?php $do_not_duplicate = array(); ?> <?php $mos...
72,204
<p>Related to this question (<a href="https://wordpress.stackexchange.com/questions/67634/use-wp-init-hook-to-call-other-hooks">Use wp init hook to call other hooks?</a>) but not the same.</p> <p>Sometimes, I found that the hook will failed to run when I place inside the init hook, e.g.</p> <p>Not Work:</p> <pre><co...
[ { "answer_id": 72207, "author": "Mario Peshev", "author_id": 11506, "author_profile": "https://wordpress.stackexchange.com/users/11506", "pm_score": 2, "selected": false, "text": "<p>Attaching to a hook inside of a callback of another hook is not a bad practice, contrary, sometimes it's ...
2012/11/11
[ "https://wordpress.stackexchange.com/questions/72204", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16037/" ]
Related to this question ([Use wp init hook to call other hooks?](https://wordpress.stackexchange.com/questions/67634/use-wp-init-hook-to-call-other-hooks)) but not the same. Sometimes, I found that the hook will failed to run when I place inside the init hook, e.g. Not Work: ``` add_action('init','my_init'); functi...
The `locale` hook happens long before `init`. To see when which hook, variable, constant, function, class or file is available install my plugin [T5 WP Load Order](https://gist.github.com/4055044). You get a looong file with a very detailed log. Search for `Hook: locale`, then for `Hook: init`. You will see that you n...
72,242
<p>I like to have folders in my theme folder for scripts and styles, but I can't access these folders in the "Edit Themes" interface. This is problematic for clients that don't give me FTP access. Is there a way to see these folders and the files in them from the Wordpress admin section?</p>
[ { "answer_id": 72243, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>I do the same thing as you and organize things in folders. I never use that editor but I just took a look at ...
2012/11/11
[ "https://wordpress.stackexchange.com/questions/72242", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22912/" ]
I like to have folders in my theme folder for scripts and styles, but I can't access these folders in the "Edit Themes" interface. This is problematic for clients that don't give me FTP access. Is there a way to see these folders and the files in them from the Wordpress admin section?
There is not a way to do this without modifying the core. You should see `.php` files that are in subdirectories, but you won't see anything above the root theme directory for `.css` files, and you won't see any JavaScript files. If you take a look at [`wp-admin/theme-editor.php`](https://github.com/WordPress/WordPr...
72,249
<p>Is it possible to rename the wp-content folder dynamically? I am building a custom framework to use on themes and it would be nice to set it up where it does everything on its own.</p> <p>I am using this following code right now in wp-config</p> <pre><code>define ('WP_CONTENT_DIR','/name_of_new_folder'); define('W...
[ { "answer_id": 72253, "author": "souporserious", "author_id": 18241, "author_profile": "https://wordpress.stackexchange.com/users/18241", "pm_score": 1, "selected": false, "text": "<p>Figured it out!</p>\n\n<pre><code>define('WP_CONTENT_DIR', ABSPATH . 'name_of_new_folder');\ndefine('WP_...
2012/11/11
[ "https://wordpress.stackexchange.com/questions/72249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18241/" ]
Is it possible to rename the wp-content folder dynamically? I am building a custom framework to use on themes and it would be nice to set it up where it does everything on its own. I am using this following code right now in wp-config ``` define ('WP_CONTENT_DIR','/name_of_new_folder'); define('WP_CONTENT_URL','http:...
Don't do what seems to be possible... ------------------------------------- You *can* use the possibility to change the WordPress constants `WP_CONTENT_DIR` and `WP_CONTENT_URL` in your `wp-config.php`. > > **BUT** it really, really, really, really is **not** recommended. > > > Why? not recommended?? -----------...
72,272
<p>I want to embed a social sharing button in the theme. Following is the standard code to embed the twitter button.</p> <pre><code>&lt;a href="https://twitter.com/share" class="twitter-share-button"&gt;Tweet&lt;/a&gt; &lt;script&gt;!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js...
[ { "answer_id": 72253, "author": "souporserious", "author_id": 18241, "author_profile": "https://wordpress.stackexchange.com/users/18241", "pm_score": 1, "selected": false, "text": "<p>Figured it out!</p>\n\n<pre><code>define('WP_CONTENT_DIR', ABSPATH . 'name_of_new_folder');\ndefine('WP_...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23543/" ]
I want to embed a social sharing button in the theme. Following is the standard code to embed the twitter button. ``` <a href="https://twitter.com/share" class="twitter-share-button">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js....
Don't do what seems to be possible... ------------------------------------- You *can* use the possibility to change the WordPress constants `WP_CONTENT_DIR` and `WP_CONTENT_URL` in your `wp-config.php`. > > **BUT** it really, really, really, really is **not** recommended. > > > Why? not recommended?? -----------...
72,287
<p>I'd like to put something like this in searchform.php:</p> <pre><code>&lt;?php if($widget){ ?&gt; //load serach form for sidebar... &lt;?php }else{ ?&gt; //load different search form for page content (404 page) &lt;?php } ?&gt; </code></pre> <p>How can I prepare <code>$widget</code> variable? Or maybe I sh...
[ { "answer_id": 72294, "author": "Paul", "author_id": 21278, "author_profile": "https://wordpress.stackexchange.com/users/21278", "pm_score": 0, "selected": false, "text": "<p>I managed to do this with <code>get_template_part();</code> - you just need searchform.php and searchform-differe...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21278/" ]
I'd like to put something like this in searchform.php: ``` <?php if($widget){ ?> //load serach form for sidebar... <?php }else{ ?> //load different search form for page content (404 page) <?php } ?> ``` How can I prepare `$widget` variable? Or maybe I should use another method? Like filter? Or get template p...
Check if searchform is included? -------------------------------- The [`get_search_form()`](http://queryposts.com/function/get_search_form/) function (that *should* be used) uses [`locate_template('searchform.php');`](http://queryposts.com/function/locate_template/) to display the search form. The later returns (as y...
72,288
<p>I'm trying to get with </p> <pre><code>get_user_meta </code></pre> <p>the meta_key where the meta_value is <code>'ive-read-this'</code></p> <p>But I do not get the value. What should I do?</p>
[ { "answer_id": 72294, "author": "Paul", "author_id": 21278, "author_profile": "https://wordpress.stackexchange.com/users/21278", "pm_score": 0, "selected": false, "text": "<p>I managed to do this with <code>get_template_part();</code> - you just need searchform.php and searchform-differe...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23548/" ]
I'm trying to get with ``` get_user_meta ``` the meta\_key where the meta\_value is `'ive-read-this'` But I do not get the value. What should I do?
Check if searchform is included? -------------------------------- The [`get_search_form()`](http://queryposts.com/function/get_search_form/) function (that *should* be used) uses [`locate_template('searchform.php');`](http://queryposts.com/function/locate_template/) to display the search form. The later returns (as y...
72,303
<p>I'm trying to write a plugin with multiple files. I'm sure I did it before without a problem, but now I have the problem in the subject.</p> <p>In the main plugin file I have included a file name - <code>ydp-includes.php</code>. Inside of <code>ydp-includes.php</code> I have included all the files I wanted like thi...
[ { "answer_id": 72304, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>This happens only if you call a file per HTTP without loading WordPress. That is something you should never do, becaus...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23552/" ]
I'm trying to write a plugin with multiple files. I'm sure I did it before without a problem, but now I have the problem in the subject. In the main plugin file I have included a file name - `ydp-includes.php`. Inside of `ydp-includes.php` I have included all the files I wanted like this: ``` <?php include(dirname( _...
This happens only if you call a file per HTTP without loading WordPress. That is something you should never do, because the plugin URL might be another domains where cookies don’t work anymore.
72,316
<p><strong>I'm trying to get a value from a PHP function through Ajax and save it in a variable in jquery.</strong></p> <p>The PHP;</p> <pre><code>add_action( 'wp_ajax_mark_as_read', array( &amp;$this, 'readen_color' ) ); public function readen_color() { if( isset( $_POST['post_id'] ) &amp;&amp; is_numeric( $_POS...
[ { "answer_id": 72332, "author": "pbd", "author_id": 18968, "author_profile": "https://wordpress.stackexchange.com/users/18968", "pm_score": 3, "selected": true, "text": "<p>You are passing 'readen_color' as the action parameter, but you've defined the ajax action as 'mark_as_read'.</p>\n...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72316", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23548/" ]
**I'm trying to get a value from a PHP function through Ajax and save it in a variable in jquery.** The PHP; ``` add_action( 'wp_ajax_mark_as_read', array( &$this, 'readen_color' ) ); public function readen_color() { if( isset( $_POST['post_id'] ) && is_numeric( $_POST['post_id'] ) ) { echo 'hello'; } } ...
You are passing 'readen\_color' as the action parameter, but you've defined the ajax action as 'mark\_as\_read'. Try this: ``` $.post(ajaxurl, { action:'mark_as_read', post_id: iPostId }, function (response) { console.log(response); }); ``` And as for your PHP: ``` add_action( 'wp_ajax_mark_as_read', a...
72,325
<p>I'm customizing a Woocommerce Wordpress site.</p> <p>In the Woocommerce product class (<code>class-wc-product.php</code>) the <code>get_price</code> function applies a filter as follows:</p> <pre><code>function get_price() { return apply_filters('woocommerce_get_price', $this-&gt;price, $this); } </code></pre>...
[ { "answer_id": 72327, "author": "Steve", "author_id": 23132, "author_profile": "https://wordpress.stackexchange.com/users/23132", "pm_score": 1, "selected": false, "text": "<p>The warning is a result of the second argument in your function custom_price(). The filter provides only one var...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19475/" ]
I'm customizing a Woocommerce Wordpress site. In the Woocommerce product class (`class-wc-product.php`) the `get_price` function applies a filter as follows: ``` function get_price() { return apply_filters('woocommerce_get_price', $this->price, $this); } ``` In my functions.php I want to add a filter as follows...
It's missing the second argument because you didn't tell WordPress you wanted it with your `add_filter` call. By default, actions and filters only get one argument. Try this: ``` <?php add_filter('woocommerce_get_price', 'custom_price', 10, 2); function custom_price($price, $product) { ... } ```
72,345
<p>I've googling for a solution for this issue and found nothing: I have some posts from a Custom Post Type (Restaurants) and its taxonomies ('city' and 'cuisine'). Whenever I create a restaurant post, I can set many 'cuisine' terms as I want, but 'city' is single selected. I've also made a custom search using a html d...
[ { "answer_id": 72357, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 3, "selected": true, "text": "<p>Here's part of the answer... how to query for the terms you're looking for. But it sounds like you'll need so...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72345", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17664/" ]
I've googling for a solution for this issue and found nothing: I have some posts from a Custom Post Type (Restaurants) and its taxonomies ('city' and 'cuisine'). Whenever I create a restaurant post, I can set many 'cuisine' terms as I want, but 'city' is single selected. I've also made a custom search using a html drop...
Here's part of the answer... how to query for the terms you're looking for. But it sounds like you'll need some ajax to re-query for each selection. City and cuisine would be dynamic, but essentially the when the user selects the city populate that data into the `$city` variable, and so on. Someone else will need to ...
72,348
<p>I am trying to create a layout with two different divs alternating vertically. For example the even has to be: picture + content; and the odd has to be: content + picture.</p> <p>Here is my code, at the moment it prints every post doubled, once per div:</p> <pre><code>&lt;div id="content"&gt; &lt;?php if (have_pos...
[ { "answer_id": 72349, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 3, "selected": true, "text": "<p>minimal necessary correction - move <code>the_post();</code> to before the <code>if(($i%2 == 0) :</code></p>\n\n<...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72348", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22715/" ]
I am trying to create a layout with two different divs alternating vertically. For example the even has to be: picture + content; and the odd has to be: content + picture. Here is my code, at the moment it prints every post doubled, once per div: ``` <div id="content"> <?php if (have_posts()) : while(have_posts()) : ...
minimal necessary correction - move `the_post();` to before the `if(($i%2 == 0) :` for instance: ``` <?php if (have_posts()) : while(have_posts()) : the_post(); $i++; if(($i % 2) == 0) : ?> ```
72,361
<p>I am simply trying to print the value of a custom field. I have read all the documentation, tried out other people's suggestions, and nothing works. I can get it to print the ID #, but not the actual value I have in the field. I am using the Types plugin to create the field.</p> <p>this prints the ID:</p> <pre><co...
[ { "answer_id": 72368, "author": "Rachel Baker", "author_id": 8054, "author_profile": "https://wordpress.stackexchange.com/users/8054", "pm_score": 1, "selected": false, "text": "<p>I would try:</p>\n\n<pre><code>echo get_post_meta( $the_query-&gt;post-&gt;ID, 'authorinfo', true);\n</code...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72361", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23479/" ]
I am simply trying to print the value of a custom field. I have read all the documentation, tried out other people's suggestions, and nothing works. I can get it to print the ID #, but not the actual value I have in the field. I am using the Types plugin to create the field. this prints the ID: ``` <?php echo get_the...
The Types plugin is making this about 10x harder than it needs to be, you'll have to look through their documentation on the issue, but from what I can tell they don't store items in the `postmeta` table in a straightforward way. I created a simple field with the plugin in a sandbox env and the `meta_key` for a field I...
72,372
<p>Looking for a way to redirect the user from the dashboard straight to <code>edit.php</code> if <code>wp_is_mobile()</code> is true. </p> <p>This is what I've tried:</p> <pre><code>function redirect_if_mobile() { $screen = get_current_screen(); if($screen-&gt;base == 'dashboard') { if ( wp_is_mobile...
[ { "answer_id": 72375, "author": "INT", "author_id": 2830, "author_profile": "https://wordpress.stackexchange.com/users/2830", "pm_score": 0, "selected": false, "text": "<p>Alright, found one solution, although not that elegant.</p>\n\n<pre><code>function load_if_mobile() {\n if ( wp_i...
2012/11/12
[ "https://wordpress.stackexchange.com/questions/72372", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2830/" ]
Looking for a way to redirect the user from the dashboard straight to `edit.php` if `wp_is_mobile()` is true. This is what I've tried: ``` function redirect_if_mobile() { $screen = get_current_screen(); if($screen->base == 'dashboard') { if ( wp_is_mobile() ) { $url = admin_url( 'edit.php...
The action you're looking for is auth\_redirect, which is before the headers but still recognizes $pagenow to tell which page you're on: ``` add_action('auth_redirect', 'the_mobile_boot'); function the_mobile_boot() { global $pagenow; if ( $pagenow == 'index.php' && wp_is_mobile() ) { header( 'Locatio...
72,394
<p>How to make any plugin icon in wordpress post? The code I want to insert in plugin code and will appear in post bar [wp-admin/post.php].</p> <p>Like this image:</p> <p><img src="https://i.stack.imgur.com/0Qy8r.jpg" alt="enter image description here"></p> <p>Output: If I click the icon it automatically writes <cod...
[ { "answer_id": 72399, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 3, "selected": false, "text": "<p>There's too much to put the whole answer here so checkout this guide: <a href=\"http://wp.smashingmagazine.c...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16683/" ]
How to make any plugin icon in wordpress post? The code I want to insert in plugin code and will appear in post bar [wp-admin/post.php]. Like this image: ![enter image description here](https://i.stack.imgur.com/0Qy8r.jpg) Output: If I click the icon it automatically writes `[plugin]` to the post content like this: ...
To add our button to the TinyMCE editor we need to do several things: 1. Add our button to the toolbar 2. Register a TinyMCE plugin 3. Create that TinyMCE plug-in which tells TinyMCE what to do when our button is clicked. Steps #1 and #2 =============== In these steps we register our TinyMCE plug-in which will live ...
72,405
<p>While creating our portfolio i'd like to make a dynamic header with the latest 5/6 featured images in a row. All these posts come out of the 'apps' custom post type.</p> <pre><code>&lt;div id="header"&gt; &lt;div class="latest_post"&gt; &lt;img src="featured image" class="class-name" /&gt;&lt;/div&gt; ...
[ { "answer_id": 72408, "author": "jzatt", "author_id": 22620, "author_profile": "https://wordpress.stackexchange.com/users/22620", "pm_score": 3, "selected": true, "text": "<p>First setup a WP_Query to fetch the latest 5 posts from your custom post type \"apps\". You also need to update a...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72405", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20548/" ]
While creating our portfolio i'd like to make a dynamic header with the latest 5/6 featured images in a row. All these posts come out of the 'apps' custom post type. ``` <div id="header"> <div class="latest_post"> <img src="featured image" class="class-name" /></div> <div class="second_post"> <img src=...
First setup a WP\_Query to fetch the latest 5 posts from your custom post type "apps". You also need to update a "counter" for each post in the loop. Then simply echo the count in the class for the div. ``` <?php //Query posts $query = new WP_Query(array( 'post_type' => 'apps', 'posts_per_page' => 5 )); //Res...
72,406
<p>I have been struggling for days to figure this one out. I have successfully implemented a form to submit posts from the front end of my site. ButI can't figure out how to make the image uploads work.</p> <p>I want whatever image the user uploads to automatically attach to the post and become its featured image.</p>...
[ { "answer_id": 72411, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 4, "selected": true, "text": "<p>you can do that by running the function</p>\n\n<pre><code>set_post_thumbnail( $my_post_id, $thumbnail_id );\n</c...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72406", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23492/" ]
I have been struggling for days to figure this one out. I have successfully implemented a form to submit posts from the front end of my site. ButI can't figure out how to make the image uploads work. I want whatever image the user uploads to automatically attach to the post and become its featured image. Can someone ...
you can do that by running the function ``` set_post_thumbnail( $my_post_id, $thumbnail_id ); ``` remember, you have to process and insert the image into the library first: ``` $uploaddir = wp_upload_dir(); $file = $_FILES[ ... whatever you have in your POST data ... ]; $uploadfile = $uploaddir['path'] . '/' . base...
72,410
<p>Ok I'm creating a site for a company, this company will have multiple users. In the footer I am trying to include the company name, phone and address but not as a widget. I need to store the information in a place where all users can edit it.</p> <p>In the past I've stored this kind of information in a users profil...
[ { "answer_id": 72411, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 4, "selected": true, "text": "<p>you can do that by running the function</p>\n\n<pre><code>set_post_thumbnail( $my_post_id, $thumbnail_id );\n</c...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23360/" ]
Ok I'm creating a site for a company, this company will have multiple users. In the footer I am trying to include the company name, phone and address but not as a widget. I need to store the information in a place where all users can edit it. In the past I've stored this kind of information in a users profile but that...
you can do that by running the function ``` set_post_thumbnail( $my_post_id, $thumbnail_id ); ``` remember, you have to process and insert the image into the library first: ``` $uploaddir = wp_upload_dir(); $file = $_FILES[ ... whatever you have in your POST data ... ]; $uploadfile = $uploaddir['path'] . '/' . base...
72,425
<p>I have two custom post types, Books and Authors. Now, each book will have its corresponding author(s). I know how to associate books with authors using custom metas.</p> <p>However, over time, there will be a lot of books and corresponding authors. Which would be the best UI control to show a list of authors to sel...
[ { "answer_id": 72411, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 4, "selected": true, "text": "<p>you can do that by running the function</p>\n\n<pre><code>set_post_thumbnail( $my_post_id, $thumbnail_id );\n</c...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17223/" ]
I have two custom post types, Books and Authors. Now, each book will have its corresponding author(s). I know how to associate books with authors using custom metas. However, over time, there will be a lot of books and corresponding authors. Which would be the best UI control to show a list of authors to select from, ...
you can do that by running the function ``` set_post_thumbnail( $my_post_id, $thumbnail_id ); ``` remember, you have to process and insert the image into the library first: ``` $uploaddir = wp_upload_dir(); $file = $_FILES[ ... whatever you have in your POST data ... ]; $uploadfile = $uploaddir['path'] . '/' . base...
72,446
<p>I have created a Wordpress site and titles were working just fine. Then, some time and plugins installed later, I noticed that in SOME pages I get the title repeated 2 times.</p> <p>Example of wrong page title: Contact - NAME | NAME</p> <p>Example of normal title: Our Services | NAME</p> <p>Now, if I go to Genera...
[ { "answer_id": 72447, "author": "Steve", "author_id": 23132, "author_profile": "https://wordpress.stackexchange.com/users/23132", "pm_score": 1, "selected": false, "text": "<p>Yoast has some great documentation on setting up page titles with his plugin. Even clear notes on how to call wp...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72446", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23315/" ]
I have created a Wordpress site and titles were working just fine. Then, some time and plugins installed later, I noticed that in SOME pages I get the title repeated 2 times. Example of wrong page title: Contact - NAME | NAME Example of normal title: Our Services | NAME Now, if I go to General Settings and change ti...
In order to play nicely with Plugins or other code that attempts to modify the HTML document title content (i.e. `wp_title()` output), you should *always and only* output this: ``` <title><?php wp_title( '' ); ?></title> ``` ...and if you want to modify that output yourself, *filter `wp_title`* instead of hard-codin...
72,461
<p>How to hide customize menu and another submenu on wordpress?</p> <p>I already hide some submenu on wordpress like </p> <pre><code>function hiden() { remove_submenu_page( 'themes.php', 'widgets.php' );//widget remove_submenu_page( 'themes.php', 'theme-editor.php' ); //editor remove_submenu_page( 'themes...
[ { "answer_id": 72500, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 3, "selected": true, "text": "<p>If you deal with wp menus you shoudl use admin_menu filter. </p>\n\n<pre><code>add_filter('admin_menu', 'a...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16683/" ]
How to hide customize menu and another submenu on wordpress? I already hide some submenu on wordpress like ``` function hiden() { remove_submenu_page( 'themes.php', 'widgets.php' );//widget remove_submenu_page( 'themes.php', 'theme-editor.php' ); //editor remove_submenu_page( 'themes.php', 'theme_options...
If you deal with wp menus you shoudl use admin\_menu filter. ``` add_filter('admin_menu', 'admin_menu_filter',500); function admin_menu_filter(){ remove_submenu_page( 'themes.php', 'widgets.php' );//widget remove_submenu_page( 'themes.php', 'theme-editor.php'); //editor remove_submenu_page( 'themes.php', ...
72,462
<p>I have 3 custom post formats. One is for image, one for video, and, one for gallery besides the default post and they each have a view comments link on the bottom right corner at the end of the post.</p> <p>Here is the code for that(it's in every formats php file):</p> <pre><code>&lt;div class="post-comments"&gt; ...
[ { "answer_id": 72500, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 3, "selected": true, "text": "<p>If you deal with wp menus you shoudl use admin_menu filter. </p>\n\n<pre><code>add_filter('admin_menu', 'a...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72462", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22873/" ]
I have 3 custom post formats. One is for image, one for video, and, one for gallery besides the default post and they each have a view comments link on the bottom right corner at the end of the post. Here is the code for that(it's in every formats php file): ``` <div class="post-comments"> <p class="postcoments"> <a ...
If you deal with wp menus you shoudl use admin\_menu filter. ``` add_filter('admin_menu', 'admin_menu_filter',500); function admin_menu_filter(){ remove_submenu_page( 'themes.php', 'widgets.php' );//widget remove_submenu_page( 'themes.php', 'theme-editor.php'); //editor remove_submenu_page( 'themes.php', ...
72,466
<p>I would like to make metaboxes as fixed elements, removing the expand function and the drag-and-drop function.</p> <p>Any ideas?</p>
[ { "answer_id": 72470, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_deregister_script\" rel=\"nofollow\">deregister</a...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72466", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23595/" ]
I would like to make metaboxes as fixed elements, removing the expand function and the drag-and-drop function. Any ideas?
Deregistering the postbox script seemed a little bit drastic and as mentioned the "Edit" button for the permalink slug does not work as expected anymore. I actually came up another method which uses filters from Wordpress and the functionality of the jQuery UI sortable plugin allowing to cancel the sort when it is iss...
72,480
<p>I'm getting prompted to enter my FTP information (in this case, SFTP) for installing plugins/themes in Wordpress. Problem is, I keep getting denied with valid SFTP credentials. </p> <p>I have root access to my server as well. RedHat 6.3, MySQL 5.1, PHP 5.3.3</p> <p>For troubleshooting sake, all of Wordpress's d...
[ { "answer_id": 72496, "author": "retomate", "author_id": 22836, "author_profile": "https://wordpress.stackexchange.com/users/22836", "pm_score": 3, "selected": true, "text": "<p>What if you try <a href=\"http://wordpress.org/extend/plugins/ssh-sftp-updater-support/\" rel=\"nofollow\">htt...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12294/" ]
I'm getting prompted to enter my FTP information (in this case, SFTP) for installing plugins/themes in Wordpress. Problem is, I keep getting denied with valid SFTP credentials. I have root access to my server as well. RedHat 6.3, MySQL 5.1, PHP 5.3.3 For troubleshooting sake, all of Wordpress's directories are curre...
What if you try <http://wordpress.org/extend/plugins/ssh-sftp-updater-support/> ? If that doesn't work you can do a quick code change to get the logs with which the developer of that plugin can use do more diagnostics.
72,481
<p>I need to log <strong>fail</strong> and <strong>successful login</strong> actions.</p> <p>What hook is better to use for this?</p>
[ { "answer_id": 72497, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 4, "selected": true, "text": "<p>There are a few different hooks you can use (from <a href=\"http://codex.wordpress.org/Function_Reference/wp_sig...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72481", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15054/" ]
I need to log **fail** and **successful login** actions. What hook is better to use for this?
There are a few different hooks you can use (from [`wp_signon`](http://codex.wordpress.org/Function_Reference/wp_signon)): * [`wp_authenticate`](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/user.php#L41) (action) * [`authenticate`](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/user.php...
72,482
<p>I've been banging my head against my iMac trying to figure out what's wrong. I've also trolled these archives and have tried the following things to fix:</p> <ul> <li>flush permalinks</li> <li>remove possibly conflicting categories/slugs</li> <li><code>flush_rewrite_rules( false );</code></li> <li><code>'has_archiv...
[ { "answer_id": 72497, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 4, "selected": true, "text": "<p>There are a few different hooks you can use (from <a href=\"http://codex.wordpress.org/Function_Reference/wp_sig...
2012/11/13
[ "https://wordpress.stackexchange.com/questions/72482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31938/" ]
I've been banging my head against my iMac trying to figure out what's wrong. I've also trolled these archives and have tried the following things to fix: * flush permalinks * remove possibly conflicting categories/slugs * `flush_rewrite_rules( false );` * `'has_archive' => true`, `'has_archive' => false` (as well as m...
There are a few different hooks you can use (from [`wp_signon`](http://codex.wordpress.org/Function_Reference/wp_signon)): * [`wp_authenticate`](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/user.php#L41) (action) * [`authenticate`](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/user.php...
72,502
<p>When I make a search, if there is an image title within a img tag, it's displayed in a very ugly fashion among the search results (the whole tag is displayed and the picture too). I found this script which is supposed to solve the problem and this is the only thing I found about the subject over the internet.</p> <...
[ { "answer_id": 72507, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 3, "selected": true, "text": "<p><s>I don't know about the code you are trying to use, personally I would never use a solution that excludes resu...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72502", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23404/" ]
When I make a search, if there is an image title within a img tag, it's displayed in a very ugly fashion among the search results (the whole tag is displayed and the picture too). I found this script which is supposed to solve the problem and this is the only thing I found about the subject over the internet. ``` <?ph...
~~I don't know about the code you are trying to use, personally I would never use a solution that excludes results, it's very possible the item being searched for is in those results and excluding them is only a degradation of service.~~ Instead you can use the [`search.php` template file](http://codex.wordpress.org/C...
72,512
<p>Title may not be clear but I'm using <code>update_option($my_option, $new_order);</code> and for some reason it would not work but if instead I change to <code>update_option('my-option-name' $new_order);</code> it works.</p> <p>I check that <code>$my_option</code> has a value and <code>'my-option-name'</code> exist...
[ { "answer_id": 72507, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 3, "selected": true, "text": "<p><s>I don't know about the code you are trying to use, personally I would never use a solution that excludes resu...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72512", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15704/" ]
Title may not be clear but I'm using `update_option($my_option, $new_order);` and for some reason it would not work but if instead I change to `update_option('my-option-name' $new_order);` it works. I check that `$my_option` has a value and `'my-option-name'` exists and has some values on it. Without digging more, is...
~~I don't know about the code you are trying to use, personally I would never use a solution that excludes results, it's very possible the item being searched for is in those results and excluding them is only a degradation of service.~~ Instead you can use the [`search.php` template file](http://codex.wordpress.org/C...
72,529
<p>I want to filter any HTTP request URI done through the HTTP API.</p> <p>Use cases:</p> <ol> <li>The WordPress update check goes to <a href="http://api.wordpress.org/core/version-check/1.6/" rel="nofollow noreferrer">http://api.wordpress.org/core/version-check/1.6/</a>, but <a href="https://api.wordpress.org/core/ver...
[ { "answer_id": 72530, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 2, "selected": false, "text": "<pre><code> add_filter('http_request_args', 'http_request_args_custom', 10,2);\n function http_request...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73/" ]
I want to filter any HTTP request URI done through the HTTP API. Use cases: 1. The WordPress update check goes to <http://api.wordpress.org/core/version-check/1.6/>, but <https://api.wordpress.org/core/version-check/1.6/> works too, and I want to use this always. 2. The new WordPress file is taken from <http://wordpr...
Less than an answer, but just a list of things straight from my experience with it - maybe you've overlooked something. Debugging the request & its results =================================== Without diggin' too deep into the update process, but the WP HTTP API uses the `WP_HTTP` class. It also offers a nice thing: A...
72,569
<p>Is it possible to choose specific categories that will only be displayed to logged in members?</p> <p>I tried to find a plugin or a PHP solution that does that but could not find anything that was still relevant.</p>
[ { "answer_id": 72574, "author": "Nicole", "author_id": 8337, "author_profile": "https://wordpress.stackexchange.com/users/8337", "pm_score": 0, "selected": false, "text": "<p>You could try this if your looking to use it a loop type structure:</p>\n\n<pre><code>&lt;?php\n if ( is_user_lo...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72569", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23632/" ]
Is it possible to choose specific categories that will only be displayed to logged in members? I tried to find a plugin or a PHP solution that does that but could not find anything that was still relevant.
Yes :). The following will effect *all queries for posts on the front-end* including 'secondary loops' (e.g. post lists on the side) but it won't effect custom post types. So this may not be exactly what you're after, but the principle is the same: ``` add_action('pre_get_posts','wpse72569_maybe_filter_out_category')...
72,575
<p>Is there a proper way of exporting and importing a big WordPress MySQL database to a new database?</p> <p>When I tried to do that in the standard way I run into 2 issues:</p> <ol> <li><p>All widgets disappeared and I had to create them from scratch</p></li> <li><p>I had issues with special characters such as <code...
[ { "answer_id": 72577, "author": "Glasnhost", "author_id": 23636, "author_profile": "https://wordpress.stackexchange.com/users/23636", "pm_score": 1, "selected": false, "text": "<p>I normally use mysqldump and sed:</p>\n\n<p>on old server:</p>\n\n<pre><code>mysqldump -u user -p OldWpdatab...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72575", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23634/" ]
Is there a proper way of exporting and importing a big WordPress MySQL database to a new database? When I tried to do that in the standard way I run into 2 issues: 1. All widgets disappeared and I had to create them from scratch 2. I had issues with special characters such as `'` and I had to search and replace the g...
I normally use mysqldump and sed: on old server: ``` mysqldump -u user -p OldWpdatabase > wpdb.sql sed -i 's/oldurl/newurl/g' wpdb.sql ``` on new server: ``` mysql -u user -p NewWpdatabase < wpdb.sql ``` sed is used to search and replace all the hard coded occurrences of the website if needed.
72,578
<p>I've seen plugins and snippets on how to set a new default avatar for a site. I'm wondering if this can be done network-wide, such that every new site on the network will have the network's avatar as its primary default. from there the plugin's that allow the user to upload a new avatar will be sufficient to let ea...
[ { "answer_id": 72583, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Must_Use_Plugins\" rel=\"nofollow\">Must Use Plugins</a> will anable...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72578", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
I've seen plugins and snippets on how to set a new default avatar for a site. I'm wondering if this can be done network-wide, such that every new site on the network will have the network's avatar as its primary default. from there the plugin's that allow the user to upload a new avatar will be sufficient to let each s...
In my mu-plugins folder I now have the following code, which adds a custom avatar as the default network wide, but allows each individual site to change it thereafter. ``` <?php /* Plugin Name: Network Default Avatar Description: This Plugin sets the default avatar network-wide */ class Network_De...
72,581
<p>I have a section on my site that needs a list of pages that are descendents of a particular ID. I need them listed on the child and grandchildren pages. But the page titles are too long, so I need to use the slugs as the titles. I thought I could just use wp_list_pages and specifically call descendents of this ID BU...
[ { "answer_id": 72591, "author": "Prasad Ajinkya", "author_id": 15571, "author_profile": "https://wordpress.stackexchange.com/users/15571", "pm_score": 1, "selected": false, "text": "<p>In case if you are using CF7, then do please use the <a href=\"http://wordpress.org/extend/plugins/cont...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72581", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19794/" ]
I have a section on my site that needs a list of pages that are descendents of a particular ID. I need them listed on the child and grandchildren pages. But the page titles are too long, so I need to use the slugs as the titles. I thought I could just use wp\_list\_pages and specifically call descendents of this ID BUT...
I just checked your site. There is **a javascript error** when you submit the form. It looks like the **issue is caused by the plugin wp-super-heatmap**. Disable that and try it again! If that is not it, start disabling one plugin at a time. I am certain that another plugin causes this issue, and I am pretty sure it i...
72,587
<p>I need to change the meta value of all users at once. Seem there are no api for this,except using custom database query.</p> <p>This is my code:</p> <pre><code>$matches = array('meta_key' =&gt; 'user_token'); $data = array('meta_value' =&gt; '100'); $wpdb-&gt;update( "$wpdb-&gt;usermeta", $data, $matches); </code>...
[ { "answer_id": 72588, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 1, "selected": false, "text": "<p>Your code of wpdb method is correct.\nposible reasons why it fails...</p>\n\n<ol>\n<li>you have only one ...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72587", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
I need to change the meta value of all users at once. Seem there are no api for this,except using custom database query. This is my code: ``` $matches = array('meta_key' => 'user_token'); $data = array('meta_value' => '100'); $wpdb->update( "$wpdb->usermeta", $data, $matches); ``` The problem is this only update on...
Your code of wpdb method is correct. posible reasons why it fails... 1. you have only one user that match's meta\_key = 'user\_token' 2. other functionality change query at **query** hook filter strage. debug the final SQL with ``` add_filter( 'query', 'query_report', 10000 ); function query_report($sql){ var_...
72,590
<p>I've got shortcode that needs to include JS library only once and only there where it's used.</p> <pre><code>function shortcode_function($atts, $content = null) { $class = shortcode_atts( array('something' =&gt; '0'), $atts ); return "&lt;script src=\"http://maps.googleapis.com/maps/api/js?sensor=false\"&g...
[ { "answer_id": 72592, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>Yes, you should use <code>wp_enqueue_script()</code>. The script will be loaded in the footer (action: <code>wp_footer(...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72590", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17167/" ]
I've got shortcode that needs to include JS library only once and only there where it's used. ``` function shortcode_function($atts, $content = null) { $class = shortcode_atts( array('something' => '0'), $atts ); return "<script src=\"http://maps.googleapis.com/maps/api/js?sensor=false\"></script> ...
Yes, you should use `wp_enqueue_script()`. The script will be loaded in the footer (action: `wp_footer()`). Just once. To inspect the order of available hooks, functions etc. per request try my plugin [T5 WP Load Order](https://gist.github.com/4055044).
72,600
<p>I am trying to trigger an action in <em>functions.php</em> with the <code>do_action()</code> function, but I appear to need an attribute.</p> <p>The following</p> <pre><code>do_action( 'really_simple_share button="facebook_like"'); </code></pre> <p>does not work...</p> <p>Can you tell me the proper way to make ...
[ { "answer_id": 72602, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 5, "selected": true, "text": "<p>The correct way is to pass first argument as a unique string which acts as an identifier for the action...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3969/" ]
I am trying to trigger an action in *functions.php* with the `do_action()` function, but I appear to need an attribute. The following ``` do_action( 'really_simple_share button="facebook_like"'); ``` does not work... Can you tell me the proper way to make it work (I have tried many other things that did not work e...
The correct way is to pass first argument as a unique string which acts as an identifier for the action & any additional arguments after that ``` do_action('unique_action_tag', $parameter1, $parameter2,,,, & so on); ``` To attach functions to this action you'll do ``` // 10 is the priority, higher means executed fi...
72,603
<p>I'm trying to write a function to make certain terms of default category always selected.</p> <p>When the user is writing a new post, the term checkbox should be checked and he shouldn't be able to unckeck it. </p> <p>Is it possible?</p>
[ { "answer_id": 72615, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": true, "text": "<p>This can be done with jQuery.</p>\n\n<p>In this example, the modifier is printed when editing an existing pos...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72603", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23644/" ]
I'm trying to write a function to make certain terms of default category always selected. When the user is writing a new post, the term checkbox should be checked and he shouldn't be able to unckeck it. Is it possible?
This can be done with jQuery. In this example, the modifier is printed when editing an existing post (`admin_head-post.php`) and when writing a new one (`admin_head-post-new.php`). There's a condition to check for the correct post type, as this hooks work with posts, pages and custom post types. The "Most used" ta...
72,618
<p>Is there any clean way (not overwriting wp-includes\js\thickbox\thickbox.js file) to translate english next/ prev/ image # of # and Close tooltip in Wordpress native Thickbox script?</p>
[ { "answer_id": 72619, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/WordPress_in_Your_Language\" rel=\"nofollow\">Localize Wordpress</a>...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72618", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23648/" ]
Is there any clean way (not overwriting wp-includes\js\thickbox\thickbox.js file) to translate english next/ prev/ image # of # and Close tooltip in Wordpress native Thickbox script?
[Localize Wordpress](http://codex.wordpress.org/WordPress_in_Your_Language) or write and load special localization for your language specialy for thickbox. Thickbox dialogs support localization provided by WP Update - Let's Check ``` 1. You have uncomented string <code>define('WPLANG', 'pl_PL');</code> in your wp-con...
72,624
<p>I want to add a back button that goes to the parent category of the actual single post that the user is viewing. How can I do that?</p> <pre><code>&lt;h2 class="link"&gt;&lt;a href="#"&gt;Return&lt;/a&gt;&lt;/h2&gt; </code></pre> <p>Thank you.</p>
[ { "answer_id": 72628, "author": "Mario Peshev", "author_id": 11506, "author_profile": "https://wordpress.stackexchange.com/users/11506", "pm_score": 1, "selected": false, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_the_category#Show_the_First_Categ...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22933/" ]
I want to add a back button that goes to the parent category of the actual single post that the user is viewing. How can I do that? ``` <h2 class="link"><a href="#">Return</a></h2> ``` Thank you.
You can use [get\_the\_category()](http://codex.wordpress.org/Function_Reference/get_the_category#Show_the_First_Category_Name_Only) and return the first result as in the example. Technically you could have several parent categories so you need to deal with this separately or expect that the first element of the array ...
72,626
<p>Looking for a way to make the TinyMCE editor always relative to it's content so that the height of the editor changes accordingly to how much text/images it contains.</p> <p>There seem to be plugins for TinyMCE for this already, but I'm not sure on how to apply it for the Wordpress version: <a href="http://www.tiny...
[ { "answer_id": 72690, "author": "INT", "author_id": 2830, "author_profile": "https://wordpress.stackexchange.com/users/2830", "pm_score": 3, "selected": true, "text": "<p>Here's a solution. There's a slight problem as it does not recognize when images are added to the editor.</p>\n\n<p>1...
2012/11/14
[ "https://wordpress.stackexchange.com/questions/72626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2830/" ]
Looking for a way to make the TinyMCE editor always relative to it's content so that the height of the editor changes accordingly to how much text/images it contains. There seem to be plugins for TinyMCE for this already, but I'm not sure on how to apply it for the Wordpress version: <http://www.tinymce.com/wiki.php/P...
Here's a solution. There's a slight problem as it does not recognize when images are added to the editor. 1: Create a folder with the name tinymce-autoresize in the plugins folder. 2. Create a file in tinymce-autoresize named `tinymce_autoresize.php` with this content: ``` function intialize_autoresize_plugin() ...
72,651
<p>I found examples adding a class to top level items, so we can display an arrow in menu items with sub-items, but is seems terrible to cope with the already built in WordPress classes, can't display the arrow with current and css hover, it just ruins all states.</p> <p>The current nav menu is like this <code>&lt;li&...
[ { "answer_id": 72684, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 3, "selected": false, "text": "<p>Have you tried using the <code>before</code> or <code>link_before</code> parameters in your array arguments when ...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72651", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23617/" ]
I found examples adding a class to top level items, so we can display an arrow in menu items with sub-items, but is seems terrible to cope with the already built in WordPress classes, can't display the arrow with current and css hover, it just ruins all states. The current nav menu is like this `<li><a>Text</a></li>` ...
This actually creates two instances where it displays a span class within the tag on the primary and secondary levels so you can add different images to your span class for designing and navigating purposes. This helps for users and developers to show if there is a drop-down to your header menu and also makes it easie...
72,652
<p>I am trying to add a <code>rel=next</code> and <code>rel=prev</code> link tags to the head element of <code>image.php</code> template file. I have Wordpress SEO installed and I like to hook to this plugin <code>wpseo_head</code> action hook to achieve that.</p> <p>What I would like to do is to check if the <code>wp...
[ { "answer_id": 72654, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>You cannot check if an action will be called before that happens. Even if there were already callbacks attached to the ...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12961/" ]
I am trying to add a `rel=next` and `rel=prev` link tags to the head element of `image.php` template file. I have Wordpress SEO installed and I like to hook to this plugin `wpseo_head` action hook to achieve that. What I would like to do is to check if the `wpseo_head` action hook exists before I attach my action to i...
You cannot check if an action will be called before that happens. Even if there were already callbacks attached to the action there would be no guarantee the matching `do_action()` will be used. In your case, test with `is_plugin_active()`: ``` if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) { // do somethi...
72,656
<p>I've recently installed the WordPress SEO plugin by Yoast and it's asking me whether to allow it or not to track my blog? Seems like a stupid question on my part but I'm still new on the blogging arena.</p> <p>What do you guys think? What's the difference if I allow it to track me or not? Is there a mutual benefit ...
[ { "answer_id": 72663, "author": "Nicklas", "author_id": 23657, "author_profile": "https://wordpress.stackexchange.com/users/23657", "pm_score": 1, "selected": false, "text": "<p>As you can read in the settings page your data is used for the future development of the plugin. I don't know ...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72656", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21139/" ]
I've recently installed the WordPress SEO plugin by Yoast and it's asking me whether to allow it or not to track my blog? Seems like a stupid question on my part but I'm still new on the blogging arena. What do you guys think? What's the difference if I allow it to track me or not? Is there a mutual benefit for the tw...
For reference the file that handles the tracking and usage statistics for Yoast SEO is located at, [`path/to/wp-content/plugins/wordpress-seo/admin/class-tracking.php`](https://github.com/crowdfavorite/mirror-wp-wordpress-seo/blob/master/admin/class-tracking.php) I have [linked](https://github.com/crowdfavorite/mirro...
72,662
<p>I am trying to accomplish a thing on WooCommerce that I can not find any information about. It is like the following scenario:</p> <p>I sell screws and have 1500 in stock. I would like the customer to choose between buying 10, 30, 50 and 100 screws in a drop-down list. The price for each screw is lower when you buy...
[ { "answer_id": 72694, "author": "Steve", "author_id": 23132, "author_profile": "https://wordpress.stackexchange.com/users/23132", "pm_score": 1, "selected": false, "text": "<p>You might want to reconsider your approach here, at first glance it seems to me that you could greatly simplify ...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23657/" ]
I am trying to accomplish a thing on WooCommerce that I can not find any information about. It is like the following scenario: I sell screws and have 1500 in stock. I would like the customer to choose between buying 10, 30, 50 and 100 screws in a drop-down list. The price for each screw is lower when you buy 100 compa...
You might want to reconsider your approach here, at first glance it seems to me that you could greatly simplify this but using a hook after the order is processed. If all of your variations are really only quantities then it stands to reason that when an order is completed you'd update the quantities for the parent an...
72,681
<p>I am trying to add an inline style to my paragraph tags which are ouputted using <code>the_content();</code></p> <p>I've tried string replace, see <a href="https://stackoverflow.com/questions/13397348/cant-change-p-tag-in-the-content-using-string-replace#comment18301142_13397348">question</a> I did earlier. But it ...
[ { "answer_id": 72685, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 2, "selected": false, "text": "<p>You can use your custom string replace in a custom \"the_content\" function.</p>\n\n<pre><code>functio...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11327/" ]
I am trying to add an inline style to my paragraph tags which are ouputted using `the_content();` I've tried string replace, see [question](https://stackoverflow.com/questions/13397348/cant-change-p-tag-in-the-content-using-string-replace#comment18301142_13397348) I did earlier. But it won't because the\_content echo'...
Thanks to [@papirtiger](https://stackoverflow.com/users/544825/papirtiger) Came up with this solution just to apply it to a specific content function. I did not explain in my question that I only needed to work on a specific the\_content, instead I think the above solutions are a global solutions, and both are great ...
72,688
<p>I'm writing a plugin that takes an xml feed and posts it into WordPress using wp-cron</p> <p>Everything is working dandy, except it keeps adding the same posts over again.</p> <p>So, I'm working on a system to check to see if a post of that title already exists.</p> <p>I've written this, but its always returning ...
[ { "answer_id": 72691, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>Yes <a href=\"http://codex.wordpress.org/Class_Reference/wpdb\" rel=\"nofollow\"><code>$wpdb</code></a> is bui...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72688", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23669/" ]
I'm writing a plugin that takes an xml feed and posts it into WordPress using wp-cron Everything is working dandy, except it keeps adding the same posts over again. So, I'm working on a system to check to see if a post of that title already exists. I've written this, but its always returning 'already exists' ``` gl...
Yes [`$wpdb`](http://codex.wordpress.org/Class_Reference/wpdb) is built in and is loaded by the WordPress Core on every page load. I don't see any critical problem with your code. I am going to suggest some improvements because I see some places where could go wrong, but mostly that should work. That makes me think th...
72,692
<p>My wordpress blog is set up as <code>de_DE</code>. This means that my login page is also displayed in <code>de_DE</code>.</p> <p>I would like to <strong>only</strong> have the login page in <code>en_US</code>.</p> <p>So, <strong>How would I programmatically change a single page's language?</strong></p> <p><strong...
[ { "answer_id": 72696, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>This will need to go in a plug-in, just put the following inside a file (<code>login-languge.php</code>) i...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15010/" ]
My wordpress blog is set up as `de_DE`. This means that my login page is also displayed in `de_DE`. I would like to **only** have the login page in `en_US`. So, **How would I programmatically change a single page's language?** **Note**: I have WPML but I don't wish to use it, I only want to change one page on the wh...
This will need to go in a plug-in, just put the following inside a file (`login-languge.php`) in `wp-content/plugins/` ``` /* Plugin Name: Log-in Language Plugin URI: http://wordpress.stackexchange.com/questions/72692/how-do-i-change-the-language-of-only-the-login-page Description: Changes the language for log-in/...
72,720
<p>from my header file i can create template path easily for any .js file:</p> <pre><code> &lt;?php $templateDirPath = get_bloginfo( 'template_directory' ) . '/'; ?&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php echo $templateDirPath; ?&gt;js/scripts.js&quot;&gt;&lt;/script&gt; </code></pre> <p>b...
[ { "answer_id": 72722, "author": "Steve", "author_id": 23132, "author_profile": "https://wordpress.stackexchange.com/users/23132", "pm_score": 1, "selected": false, "text": "<p>You need to do a bit of research on the <em>proper</em> way to enqueue JS within WordPress. Your approach is tot...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72720", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23681/" ]
from my header file i can create template path easily for any .js file: ``` <?php $templateDirPath = get_bloginfo( 'template_directory' ) . '/'; ?> <script type="text/javascript" src="<?php echo $templateDirPath; ?>js/scripts.js"></script> ``` but inside the 'scripts.js' file has some include .js files (same dir...
Use [`wp_enqueue_script()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script), hooked in via an appropriate action hook callback. ``` wp_enqueue_script( // Script handle 'someScript', // URL get_template_directory_uri() . '/js/someScript.js', // Dependencies array( 'jquery' ), ...
72,758
<p>I am trying to create a Wordpress plugin that exports each blog post to my dropbox folder. The code is below but I have a problem.</p> <p>If I run this code outside Wordpress, it works perfectly. The table is created and my token is stored. If I use a different browser it works perfectly...no authentication because...
[ { "answer_id": 72787, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 1, "selected": false, "text": "<p>I'm not familiar with the Dropbox API or their libraries, but most likely you'll need to write your own session...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72758", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23688/" ]
I am trying to create a Wordpress plugin that exports each blog post to my dropbox folder. The code is below but I have a problem. If I run this code outside Wordpress, it works perfectly. The table is created and my token is stored. If I use a different browser it works perfectly...no authentication because it reads ...
I'm not familiar with the Dropbox API or their libraries, but most likely you'll need to write your own session handler to store the session data in your WP DB (or wherever you want, safely) and associate it with your user account. Essentially adusting this line: `$storage = new \Dropbox\OAuth\Storage\Session($encrypte...
72,765
<p>I'm trying to find out whether there is more than one page of posts (I've set my posts per blog page to 5 in the reading settings) in a custom category template. </p> <p>I would think the global query would have the total number of pages as a property but I can't find the call to it.</p>
[ { "answer_id": 72769, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 6, "selected": true, "text": "<pre><code>global $wp_query;\necho $wp_query-&gt;max_num_pages;\n</code></pre>\n\n<p>This shows the number...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20557/" ]
I'm trying to find out whether there is more than one page of posts (I've set my posts per blog page to 5 in the reading settings) in a custom category template. I would think the global query would have the total number of pages as a property but I can't find the call to it.
``` global $wp_query; echo $wp_query->max_num_pages; ``` This shows the number of pages for the current query. If you want to determine the actual number of posts found by the current query, you may use `$wp_query->found_posts` Source:- <http://codex.wordpress.org/Class_Reference/WP_Query>
72,768
<p>Stupidly, I truncated my posts table with out thinking about the term relationships. Now I have a bunch of 404s because there are broken term relationships. Is is possible to rebuild the table with the correct pairings?</p>
[ { "answer_id": 72785, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 1, "selected": true, "text": "<p>If your <code>AUTO_INCREMENT</code> value wasn't reset and your new posts will still have unique <code>ID</code>...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72768", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23694/" ]
Stupidly, I truncated my posts table with out thinking about the term relationships. Now I have a bunch of 404s because there are broken term relationships. Is is possible to rebuild the table with the correct pairings?
If your `AUTO_INCREMENT` value wasn't reset and your new posts will still have unique `ID`s and you can do: ``` SELECT tr.*, p.ID FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p ON tr.object_id = p.ID WHERE p.ID is NULL; ``` to see which term relationships are orphans and use a `DELETE FROM` to fix it.
72,772
<p>This is my first project involving WordPress and I've got stuck trying to create a custom walker for a footer menu.</p> <p>I basically want to change the menu from the <code>&lt;ul&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt;</code> structure to a <code>&lt;p&gt; &lt;span&gt;&lt;/span&gt; &lt;/p&gt;</code> structure.</p> ...
[ { "answer_id": 72777, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Ok, not sure what I read wrong when I posted this, but your whole class should be something like this:</p>\n\...
2012/11/15
[ "https://wordpress.stackexchange.com/questions/72772", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23697/" ]
This is my first project involving WordPress and I've got stuck trying to create a custom walker for a footer menu. I basically want to change the menu from the `<ul> <li></li> </ul>` structure to a `<p> <span></span> </p>` structure. The menu and stuff is displaying file and I have been able to adjust the `start_el`...
Your my\_extended\_walker class is OK, but when you call the **wp\_nav\_menu** function use the **items\_wrap** parameter. ``` wp_nav_menu( array( 'items_wrap' => '<p>%3$s</p>', 'walker'=>new my_extended_walker() ) ); ``` The start\_lvl is used for children elements.
72,822
<p>Is there a plugin or something that can help me out with deleting unnecessary elements in my code?</p> <p>I am in charge of fixing a WordPress site and have been asked to remove the following elements that are not necessary, for example, I don't have any pagination in my pages but in my code there is still:</p> <u...
[ { "answer_id": 72823, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": true, "text": "<p>This are default settings fron WordPress.\nThis was set via <code>wp-includes/default_filters.php</code> or the fee...
2012/11/16
[ "https://wordpress.stackexchange.com/questions/72822", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23708/" ]
Is there a plugin or something that can help me out with deleting unnecessary elements in my code? I am in charge of fixing a WordPress site and have been asked to remove the following elements that are not necessary, for example, I don't have any pagination in my pages but in my code there is still: * `<link rel='pr...
This are default settings fron WordPress. This was set via `wp-includes/default_filters.php` or the feed inside your theme. Check the theme, `functions.php` for `add_theme_support( 'automatic-feed-links' );` and remove it. Add this via plugin or `functions.php` in your theme for remove the different defaults, hints ...
72,831
<p>I've run into a strange problem.</p> <p>I have a custom loop built with <code>get_posts</code> that works fine when loading the page normally:</p> <pre><code>&lt;?php $rows = get_posts(array( 'post_type' =&gt; 'drinks', 'numberposts' =&gt; -1 )); ?&gt; &lt;?php foreach ($rows as $po...
[ { "answer_id": 72834, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": false, "text": "<p>You need to delcare <code>$post</code> as global, try:</p>\n\n<pre><code> global $post;\n&lt;?php foreach...
2012/11/16
[ "https://wordpress.stackexchange.com/questions/72831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23714/" ]
I've run into a strange problem. I have a custom loop built with `get_posts` that works fine when loading the page normally: ``` <?php $rows = get_posts(array( 'post_type' => 'drinks', 'numberposts' => -1 )); ?> <?php foreach ($rows as $post) : setup_postdata($post) ?> <?php the_po...
Try this: ``` function h5b_ajax_get_user_drinks() { return get_template_part( 'drinks' ); exit; } ```
72,853
<p>I'm using the following two strips of code to retrieve a list of categories (1st code) then displaying them in a select menu (2nd code), for my theme options page. I was wondering how I could change this code to do the same, but, retrieve custom post types instead??</p> <p><em>Code used to retrieve categories</em>...
[ { "answer_id": 72856, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Use <code>get_post_types()</code> or the global variable <code>$wp_post_types</code>.</p>\n\n<p>From <code>wp-includes...
2012/11/16
[ "https://wordpress.stackexchange.com/questions/72853", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23728/" ]
I'm using the following two strips of code to retrieve a list of categories (1st code) then displaying them in a select menu (2nd code), for my theme options page. I was wondering how I could change this code to do the same, but, retrieve custom post types instead?? *Code used to retrieve categories* ``` $tp_categori...
Use `get_post_types()` or the global variable `$wp_post_types`. From `wp-includes/post.php`: ``` /** * Get a list of all registered post type objects. * * @package WordPress * @subpackage Post * @since 2.9.0 * @uses $wp_post_types * @see register_post_type * * @param array|string $args An array of key => val...
72,860
<p>I've been trying to make wordpress stop adding html tags to my content but leave my own html tags alone? </p> <p>Tried <code>remove_filter( 'the_content', 'wpautop' );</code> and installed PS Disable Auto Formatting but the problem is that it removes my own html tags aswell?</p> <p>I've tried to get_the_content()...
[ { "answer_id": 72862, "author": "Jen", "author_id": 13810, "author_profile": "https://wordpress.stackexchange.com/users/13810", "pm_score": 3, "selected": true, "text": "<p>Try accessing the $post object inside your loop, and echo'ing the content from that. Something like:</p>\n\n<pre><c...
2012/11/16
[ "https://wordpress.stackexchange.com/questions/72860", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19188/" ]
I've been trying to make wordpress stop adding html tags to my content but leave my own html tags alone? Tried `remove_filter( 'the_content', 'wpautop' );` and installed PS Disable Auto Formatting but the problem is that it removes my own html tags aswell? I've tried to get\_the\_content() and the\_content() but the...
Try accessing the $post object inside your loop, and echo'ing the content from that. Something like: ``` <?php echo $post->post_content ?> ``` ### Edit If you need to parse shortcodes, use [**`do_shortcode()`**](http://codex.wordpress.org/Function_Reference/do_shortcode): ``` <?php echo do_shortcode( $post->post_c...
72,865
<p>I dont want to use the WYSIWYG at the top of my Custom Post Type. I want to use a custom field textarea that i can place at bottom of my list of custom fields instead.</p> <p>Is this possible?</p>
[ { "answer_id": 72867, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 6, "selected": true, "text": "<pre><code>add_action('init', 'init_remove_support',100);\nfunction init_remove_support(){\n $post_type = ...
2012/11/16
[ "https://wordpress.stackexchange.com/questions/72865", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22783/" ]
I dont want to use the WYSIWYG at the top of my Custom Post Type. I want to use a custom field textarea that i can place at bottom of my list of custom fields instead. Is this possible?
``` add_action('init', 'init_remove_support',100); function init_remove_support(){ $post_type = 'your post type'; remove_post_type_support( $post_type, 'editor'); } ``` place it to your themes functions.php
72,904
<h2>Problem</h2> <p>Hi everyone, I have a bit of a problem. I have a function that outputs the avatars of users that follow me . It works great, but if the user is deleted the avatars remain visible as a blank image box with a broken hyperlink missing the users username. Is there any way to get rid of the deleted user...
[ { "answer_id": 72906, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>When a user say user A is deleted, you're not cleaning up all traces of that user.</p>\n\n<p>Namely you need t...
2012/11/16
[ "https://wordpress.stackexchange.com/questions/72904", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5499/" ]
Problem ------- Hi everyone, I have a bit of a problem. I have a function that outputs the avatars of users that follow me . It works great, but if the user is deleted the avatars remain visible as a blank image box with a broken hyperlink missing the users username. Is there any way to get rid of the deleted users av...
When a user say user A is deleted, you're not cleaning up all traces of that user. Namely you need to go into each user following A and remove it from their user meta. This is why your function is showing blank users, because its being given stale information that's out of date, and refers to users that no longer exis...
72,914
<p>I am working on a site with several post types - 4 to be exact - and I am trying to setup the search results page to have a filter/sort the results by post types.</p> <p>For example, when a person searches a term they are taking to the page with the results, all posts found from all post types are shown but up top ...
[ { "answer_id": 72952, "author": "Mateusz Hajdziony", "author_id": 15865, "author_profile": "https://wordpress.stackexchange.com/users/15865", "pm_score": 0, "selected": false, "text": "<p>In your second loop you are setting up arguments for posts query but you are not using them anywhere...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72914", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23703/" ]
I am working on a site with several post types - 4 to be exact - and I am trying to setup the search results page to have a filter/sort the results by post types. For example, when a person searches a term they are taking to the page with the results, all posts found from all post types are shown but up top there are ...
You can use filter **posts\_clauses** For example: ``` add_filter( 'posts_clauses', 'post_query_order', 20, 1 ); function post_query_order( $pieces ) { global $wpdb; $pieces['orderby'] = $wpdb->prefix.'posts.post_type ASC'; return $pieces; } ```
72,918
<p>I'm working with a WordPress CMS website that was set up without a blog. I want the site to continue to function as it has, with mostly static pages, including the home page. I want a page called "Blog" to function as a blog. </p> <p>Now I've been asked to add a blog, and what I expected would be extremely easy isn...
[ { "answer_id": 72919, "author": "Mateusz Hajdziony", "author_id": 15865, "author_profile": "https://wordpress.stackexchange.com/users/15865", "pm_score": 1, "selected": false, "text": "<p>So, everything seems to be set up correctly. The setting in your step 2 is everything that needs to ...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72918", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23752/" ]
I'm working with a WordPress CMS website that was set up without a blog. I want the site to continue to function as it has, with mostly static pages, including the home page. I want a page called "Blog" to function as a blog. Now I've been asked to add a blog, and what I expected would be extremely easy isn't turning...
Pogoking's answer helped point me in the right direction, but didn't solve the problem. This is what I ended up doing. I created a new template within the customized theme we are using and edited the blog page to use the new template. ``` .../html/wp-content/themes/[custom theme name]/blogposts.php ``` I added the ...
72,921
<p>I am developing a plugin which displays a wordpress post in a lightbox outside the loop. I noticed that some plugin which modify the contents of the post (like Facebook Like button plugin) use the <code>get_permalink()</code> function to retrieve post urls. When the post is opened normally (single.php) the plugins w...
[ { "answer_id": 72925, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>First, I suggest reading <a href=\"http://codex.wordpress.org/AJAX_in_Plugins\" rel=\"nofollow noreferrer\">AJAX in...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23721/" ]
I am developing a plugin which displays a wordpress post in a lightbox outside the loop. I noticed that some plugin which modify the contents of the post (like Facebook Like button plugin) use the `get_permalink()` function to retrieve post urls. When the post is opened normally (single.php) the plugins work fine. When...
I made an example plugin based on Milo's answer to show how you can use ajax to get a post and display it with colorbox. example.php: ``` <?php /* Plugin Name: example */ function example_ajax_get_post() { $url = $_POST['url']; $post = get_post(url_to_postid($url)); ?> <h2><?php print $post->post_t...
72,923
<p>I am running a wordpress site and I need the correct regex syntax to get a URL from some shortcode that is returned inside the_content(). </p> <p>When I use the_content(), it will return something like this:</p> <pre><code>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nulla enim, euismod ut phar...
[ { "answer_id": 73292, "author": "Mubbashar", "author_id": 23707, "author_profile": "https://wordpress.stackexchange.com/users/23707", "pm_score": 0, "selected": false, "text": "<p>You can use substring and strpos to extract this</p>\n\n<pre><code>$spos = strpos($getContent,\"mp4=\");\nif...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72923", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23869/" ]
I am running a wordpress site and I need the correct regex syntax to get a URL from some shortcode that is returned inside the\_content(). When I use the\_content(), it will return something like this: ``` Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nulla enim, euismod ut pharetra nec, commodo a ...
There's no need to use regex for this. WordPress has a [Shortcode API](http://codex.wordpress.org/Shortcode_API) to do this work for you. That codex page includes one of my favorite codex code snippets: ``` function bartag_func( $atts ) { extract( shortcode_atts( array( 'foo' => 'something', 'bar'...
72,926
<p>I want to ask that how can i dispaly custom field of a post on a web page . I have used get_post_meta but it resulted in just an array .i cant figure out what is the problem</p>
[ { "answer_id": 73292, "author": "Mubbashar", "author_id": 23707, "author_profile": "https://wordpress.stackexchange.com/users/23707", "pm_score": 0, "selected": false, "text": "<p>You can use substring and strpos to extract this</p>\n\n<pre><code>$spos = strpos($getContent,\"mp4=\");\nif...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72926", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23705/" ]
I want to ask that how can i dispaly custom field of a post on a web page . I have used get\_post\_meta but it resulted in just an array .i cant figure out what is the problem
There's no need to use regex for this. WordPress has a [Shortcode API](http://codex.wordpress.org/Shortcode_API) to do this work for you. That codex page includes one of my favorite codex code snippets: ``` function bartag_func( $atts ) { extract( shortcode_atts( array( 'foo' => 'something', 'bar'...
72,928
<p>I have a custom post type named 'tours' and custom taxonomy named 'tourtypes' so i can categorize it into terms like 'cultural tour', 'sports tour' etc.</p> <p>I'm not the original author of this theme and don not know much about dealing with taxonomy. But I want to extend it so that instead of outputting all 'tour...
[ { "answer_id": 139109, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 0, "selected": false, "text": "<p>*<em>Moved comment to answer as suggested by @kaiser *</em></p>\n\n<p>Original comment accepted as answ...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72928", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23756/" ]
I have a custom post type named 'tours' and custom taxonomy named 'tourtypes' so i can categorize it into terms like 'cultural tour', 'sports tour' etc. I'm not the original author of this theme and don not know much about dealing with taxonomy. But I want to extend it so that instead of outputting all 'tours' post, u...
For a custom taxonomy query add the 'tax\_query' => array() ``` $args = array( 'post_type' => 'featured_job', 'post_status' => 'publish', 'posts_per_page' => 9999999, 'orderby' => 'date', 'order' => 'DES', 'tax_query' => array( array( 'taxonomy' => 'job_category', // cust...
72,941
<p>I'm using a Markdown plugin and trying to write a blockquote</p> <blockquote> <p>Like this</p> </blockquote> <p>But Wordpress converts ">" to an html entity, so the result looks</p> <p>&gt; like this</p> <p>Is there a way to avoid this?</p>
[ { "answer_id": 72944, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 3, "selected": true, "text": "<h2>Filtering <code>the_content</code></h2>\n\n<pre><code>function wpse72941_content_filter( $content ) {\n ...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72941", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5135/" ]
I'm using a Markdown plugin and trying to write a blockquote > > Like this > > > But Wordpress converts ">" to an html entity, so the result looks > like this Is there a way to avoid this?
Filtering `the_content` ----------------------- ``` function wpse72941_content_filter( $content ) { $new_content = ''; foreach( preg_split( '/((\r?\n)|(\r\n?))/', $content ) as $line ) { $new_content .= preg_replace( '/^&gt;/', '>', $line ) . '\r\n'; } return $new_content; } add_filter( 'the_co...
72,969
<p>I have some functions into my <code>pre_get_posts</code> filter. So, the problem is that when I set a <code>meta_query</code>, <strong>all the menus disappear from the page</strong>.</p> <pre><code>function propersearchfilter($query) { $taxarray = array(); $metaarray = array(); array_push($metaarray , ...
[ { "answer_id": 72976, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": false, "text": "<p>That happens because <code>pre_get_posts</code> fires on every single instance of <code>WP_Query</code>. ...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72969", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23768/" ]
I have some functions into my `pre_get_posts` filter. So, the problem is that when I set a `meta_query`, **all the menus disappear from the page**. ``` function propersearchfilter($query) { $taxarray = array(); $metaarray = array(); array_push($metaarray , array( 'key' => 'wpcf-market', 'v...
That happens because `pre_get_posts` fires on every single instance of `WP_Query`. Posts get used for a lot of things in WordPress, including nav menus. If you want to only modify the main query (the "loop") you can test for `is_main_query`. ``` <?php add_action('pre_get_posts', 'wpse72969_modify_q'); function wpse72...
72,974
<p>I have the following code to the shortcode to display a random quote. Question: how to make a button display a new random quote? I mean, that would hit the button and show you a new quote (without refreshing the page of course).</p> <pre><code>function random_quote() { // quotes file $array = file("/path ...
[ { "answer_id": 72999, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 3, "selected": true, "text": "<p>First off, this is <em>very borderline</em> within the scope of WPSE, it at all.<br />\nApart from the sho...
2012/11/17
[ "https://wordpress.stackexchange.com/questions/72974", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23769/" ]
I have the following code to the shortcode to display a random quote. Question: how to make a button display a new random quote? I mean, that would hit the button and show you a new quote (without refreshing the page of course). ``` function random_quote() { // quotes file $array = file("/path to txt file");...
First off, this is *very borderline* within the scope of WPSE, it at all. Apart from the shortcode to trigger the initial HTML output, this is really just AJAX. Anyhow, that being said, this is how it's done: The PHP ------- Assuming that the above PHP snippet you supplied is functional, place the following in a ...
73,027
<p>I am trying to run a database query as below:</p> <pre><code>$id = $_GET['id']; $query = 'select * from '; $query .= $wpdb-&gt;get_blog_prefix() . 'fxdescription '; $query .= 'where id= '.$id; $currency = $wpdb-&gt;get_results( $wpdb-&gt;prepare( $query ), ARRAY_A ); </code></pre> <p>The result of doing print_r($c...
[ { "answer_id": 73028, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 1, "selected": false, "text": "<ol>\n<li>its normal for get_results method</li>\n<li>you can use <a href=\"http://codex.wordpress.org/Class...
2012/11/18
[ "https://wordpress.stackexchange.com/questions/73027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23772/" ]
I am trying to run a database query as below: ``` $id = $_GET['id']; $query = 'select * from '; $query .= $wpdb->get_blog_prefix() . 'fxdescription '; $query .= 'where id= '.$id; $currency = $wpdb->get_results( $wpdb->prepare( $query ), ARRAY_A ); ``` The result of doing print\_r($currency) is as below: ``` Array (...
1. its normal for get\_results method 2. you can use [get\_row](http://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Row) method to get only one row.
73,044
<p>Here's the deal: My plugin automatically watermarks images from the WP gallery on the fly using the GD library wherever these images appear. So, I have a physical copy (in wp-uploads) of these attachments, and also a watermarked, dynamic copy of the image which I replace the image source on the page using <a href="h...
[ { "answer_id": 73052, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>I am not sure about complete scope of your requirements, but I would probably:</p>\n\n<ol>\n<li>Register special ima...
2012/11/18
[ "https://wordpress.stackexchange.com/questions/73044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2415/" ]
Here's the deal: My plugin automatically watermarks images from the WP gallery on the fly using the GD library wherever these images appear. So, I have a physical copy (in wp-uploads) of these attachments, and also a watermarked, dynamic copy of the image which I replace the image source on the page using [Simple HTML ...
I ended up changing my code to this, which is what I needed: Hook in: ``` add_action( 'generate_rewrite_rules', array( $this, 'addRewrites' ) ); ``` Create the rules: ``` public function addRewrites( $content ) { global $wp_rewrite; $plugin_path = substr( str_replace( home_url(), '', plugins_url( '', __FI...
73,047
<p>I have created a function in my plugin <code>myplugin</code> with the name <code>foo</code>, how to call it from the frontend?</p> <pre><code> e.g. index.php? </code></pre>
[ { "answer_id": 73048, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Active plugins are loaded (as in technically - their files are <em>included</em> and processed by PHP during WordPre...
2012/11/18
[ "https://wordpress.stackexchange.com/questions/73047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16037/" ]
I have created a function in my plugin `myplugin` with the name `foo`, how to call it from the frontend? ``` e.g. index.php? ```
The same way you would any other: ``` foo(); ``` Active plugins are loaded before the theme files You may want to check that your plugin is activated and the function is available so things dont go pear-shaped if you forget to activate it, like: ``` if(function_exists('foo')){ foo(); } else { echo "oh dear...
73,062
<p>I have a multi-language store running WooCommerce and qTranslate, and am trying to setup multi-language customer emails. The problem is, the "order complete" email gets sent from the admin backend, and it is sent in the language the backend is used in, not in the language that the order was initially made in.</p> <...
[ { "answer_id": 73064, "author": "olex", "author_id": 23417, "author_profile": "https://wordpress.stackexchange.com/users/23417", "pm_score": 3, "selected": false, "text": "<p>And I got it. What was missing was re-loading the text domain for WooCommerce, that was loaded with the current l...
2012/11/18
[ "https://wordpress.stackexchange.com/questions/73062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23417/" ]
I have a multi-language store running WooCommerce and qTranslate, and am trying to setup multi-language customer emails. The problem is, the "order complete" email gets sent from the admin backend, and it is sent in the language the backend is used in, not in the language that the order was initially made in. What I'v...
And I got it. What was missing was re-loading the text domain for WooCommerce, that was loaded with the current locale at initialization: ``` // set the current locale and send email with it active unload_textdomain('woocommerce'); setlocale(LC_ALL, $new_locale); global $q_config, $locale, $woocommerce; $locale = $new...
73,082
<p>The shortcode produced by this function - a list of all sites in a multisite - outputs above the content in the loop, no matter where it is placed in the editor.</p> <p>I've looked at the other related questions and answers on WPSE and realize that it has to do with the function using <code>echo</code> instead of <...
[ { "answer_id": 73083, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>All functions have to <strong>return</strong> a string, you should not use <code>echo</code> anywhere. Rewrite the func...
2012/11/18
[ "https://wordpress.stackexchange.com/questions/73082", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
The shortcode produced by this function - a list of all sites in a multisite - outputs above the content in the loop, no matter where it is placed in the editor. I've looked at the other related questions and answers on WPSE and realize that it has to do with the function using `echo` instead of `return`, but it's not...
All functions have to **return** a string, you should not use `echo` anywhere. Rewrite the functions, use an internal variable to handle the strings and return that: ``` // Output a single menu item function projects_menu_entry($id, $title, $link_self) { global $blog_id; $out = ''; if ($link_self || $id !...
73,087
<p>I am working on a small project for my family to share info, recipes etc. And I added a "@" mention feature. Now that the mention feature works I need to notify the user they were mentioned.</p> <p>I thought that the WP comments already kind of do this and since my family would be getting comment notifications via ...
[ { "answer_id": 73091, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>There is no <code>wp_notify_postauthor</code> filter, a <a href=\"http://codex.wordpress.org/Pluggable_Functions\" ...
2012/11/18
[ "https://wordpress.stackexchange.com/questions/73087", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5391/" ]
I am working on a small project for my family to share info, recipes etc. And I added a "@" mention feature. Now that the mention feature works I need to notify the user they were mentioned. I thought that the WP comments already kind of do this and since my family would be getting comment notifications via email I de...
Turns out the notification email is only sent if the comment\_post\_ID is not 0. I altered my notification comments code to set the comment\_post\_ID and now it all works!
73,099
<p>I've built a site with a custom post type called Testimonials and am using a custom template to display the posts <em>edit: template name is page-testimonials.php</em>. All is working as expected with the default permalink structure, however when I set the permalinks to /%postname%/ the custom template is ignored a...
[ { "answer_id": 73104, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": true, "text": "<p>Custom post types have a different hierarchy than pages or posts.</p>\n\n<p>They'll use <code>single-{{pos...
2012/11/19
[ "https://wordpress.stackexchange.com/questions/73099", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23802/" ]
I've built a site with a custom post type called Testimonials and am using a custom template to display the posts *edit: template name is page-testimonials.php*. All is working as expected with the default permalink structure, however when I set the permalinks to /%postname%/ the custom template is ignored and the pos...
Custom post types have a different hierarchy than pages or posts. They'll use `single-{{post_type}}.php` and fall back to `single.php`. Post type archives will use `archive-{{post_type}}.php` and fall back to `archive.php`. Your question isn't super clear, but if you want your custom post type's singular page to use ...
73,128
<p>I'm having a strange problem: </p> <p>I've build a category page and want to load up all related posts of a custom post type but won't give any results. I'm using the following code:</p> <pre><code> query_posts( array( 'post_type' =&gt; 'blog', 'showposts' =&gt; 3, 'cat' =&gt; 9 ) ); </code></pre> <p>When deleti...
[ { "answer_id": 73140, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": -1, "selected": true, "text": "<blockquote>\n <p>Blockquote</p>\n</blockquote>\n\n<p><strong>Taxonomy</strong> <em>category</em> with a <s...
2012/11/19
[ "https://wordpress.stackexchange.com/questions/73128", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20548/" ]
I'm having a strange problem: I've build a category page and want to load up all related posts of a custom post type but won't give any results. I'm using the following code: ``` query_posts( array( 'post_type' => 'blog', 'showposts' => 3, 'cat' => 9 ) ); ``` When deleting the 'cat' it shows all posts of the cus...
> > Blockquote > > > **Taxonomy** *category* with a **term** with *id* 9 dosen't have a posts with **post type** *blog*. Are you sure that you using native category taxonomy for CPT blogs posts? ``` function query_report($sql){ var_dump($sql); echo '<hr>'; return $sql; } add_filter('query', 'query_re...
73,132
<p>I'm trying to use shortcode in my page, I'm starting with a simple test.</p> <p>In <code>functions.php</code>:</p> <pre><code>function HelloWorldShortcode() { return '&lt;p&gt;Hello World!&lt;/p&gt;'; } add_shortcode('helloworld', 'HelloWorldShortcode'); </code></pre> <p>In <code>index.php</code>:</p> <pre><...
[ { "answer_id": 73136, "author": "stealthyninja", "author_id": 1748, "author_profile": "https://wordpress.stackexchange.com/users/1748", "pm_score": 1, "selected": false, "text": "<p>Use </p>\n\n<pre><code>echo do_shortcode( '[helloworld]' );\n</code></pre>\n\n<p>if you're going to use it...
2012/11/19
[ "https://wordpress.stackexchange.com/questions/73132", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17373/" ]
I'm trying to use shortcode in my page, I'm starting with a simple test. In `functions.php`: ``` function HelloWorldShortcode() { return '<p>Hello World!</p>'; } add_shortcode('helloworld', 'HelloWorldShortcode'); ``` In `index.php`: ``` [helloworld] ``` This doesn't produce `<p>Hello World!</p>`. Instead I ...
Referering to the [Shortcodes API](http://codex.wordpress.org/Shortcode_API) you can do ``` echo do_shortcode('[helloworld]'); ``` if your shortcode not in post. Or you can do ``` echo apply_filters('the_content', '[helloworld]'); ``` but this will also bring other filters to work on your shorcode return html.
73,147
<p>I want to edit this widget to display related posts from the current category. This code below display only posts from a category that I must select manually. What I want to happen is that the widget shows related posts from that category. Thanks for any help</p> <pre><code>add_action( 'widgets_init', 'catposts_loa...
[ { "answer_id": 73151, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 0, "selected": false, "text": "<p>So you want to display posts that are in the 'current category'. This is doable, but you need to think ab...
2012/11/19
[ "https://wordpress.stackexchange.com/questions/73147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23233/" ]
I want to edit this widget to display related posts from the current category. This code below display only posts from a category that I must select manually. What I want to happen is that the widget shows related posts from that category. Thanks for any help ``` add_action( 'widgets_init', 'catposts_load_widgets' ); ...
Change `function widget()` as below ``` global $post; // Get array of category ID's from current Post $post_categories = wp_get_post_categories( $post->ID ); // Get array of post info. if(isset($post_categories) && is_array($post_categories) && count($post_categories) > 0){ $cat_posts = n...
73,165
<p>In my multisite setup I have multiple environments that I want to share the same database, but use different domains.</p> <ul> <li>server1.example.com</li> <li>server2.example.com</li> <li>example.com</li> </ul> <p>... each of those would point to the same database. This works perfectly fine in a standard WP insta...
[ { "answer_id": 73300, "author": "daresayer", "author_id": 23877, "author_profile": "https://wordpress.stackexchange.com/users/23877", "pm_score": 1, "selected": false, "text": "<p>Not sure if this answers your question, but I found this: <a href=\"http://wordpress.org/support/topic/multi...
2012/11/19
[ "https://wordpress.stackexchange.com/questions/73165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3293/" ]
In my multisite setup I have multiple environments that I want to share the same database, but use different domains. * server1.example.com * server2.example.com * example.com ... each of those would point to the same database. This works perfectly fine in a standard WP install using `define( 'WP_HOME', 'http://serve...
When WordPress loads multisite, it includes the relevant MS specific files in `wp-settings.php` The relevant lines: ``` <?php // Initialize multisite if enabled. if ( is_multisite() ) { require( ABSPATH . WPINC . '/ms-blogs.php' ); require( ABSPATH . WPINC . '/ms-settings.php' ); } elseif ( ! defined( 'MULTIS...
73,168
<p>I'm trying to pull the content from a post/page into a template file.</p> <p>I'm using the following code, which works fine HOWEVER the content is pulled in regardless of whether it is set to 'live' or 'draft'.</p> <p>Is there a way of checking to see whether the post is live before pulling in the content?</p> <p...
[ { "answer_id": 73170, "author": "Mubbashar", "author_id": 23707, "author_profile": "https://wordpress.stackexchange.com/users/23707", "pm_score": 1, "selected": false, "text": "<p>I think you should use this function</p>\n\n<pre><code>&lt;?php get_post_status( $ID ) ?&gt;\n</code></pre>\...
2012/11/19
[ "https://wordpress.stackexchange.com/questions/73168", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13998/" ]
I'm trying to pull the content from a post/page into a template file. I'm using the following code, which works fine HOWEVER the content is pulled in regardless of whether it is set to 'live' or 'draft'. Is there a way of checking to see whether the post is live before pulling in the content? ``` <?php show_post('O...
Your custom function `show_post()` uses [`get_page_by_slug()`](http://codex.wordpress.org/Function_Reference/get_page_by_path) to retrieve the specified page. [Looking at source](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/post.php#L3200), it doesn't look like `get_page_by_slug()` uses `post_status`....
73,190
<p>I have a series of posts that are ordered by a meta_key value. They could also be arranged by menu order, if necessary.</p> <p>The next/prev post links (generated by <code>next_post_link</code>, <code>previous_post_link</code>, or <code>posts_nav_link</code> all navigate by chronology. While I understand this defau...
[ { "answer_id": 73194, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 6, "selected": true, "text": "<h1>Understanding the internals</h1>\n\n<p>The \"sort\" order of adjacent (next/prev) posts is not really a sort \"orde...
2012/11/19
[ "https://wordpress.stackexchange.com/questions/73190", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5581/" ]
I have a series of posts that are ordered by a meta\_key value. They could also be arranged by menu order, if necessary. The next/prev post links (generated by `next_post_link`, `previous_post_link`, or `posts_nav_link` all navigate by chronology. While I understand this default behaviour, I don't understand how to ch...
Understanding the internals =========================== The "sort" order of adjacent (next/prev) posts is not really a sort "order". It's a separate query on each request/page, **but** it sorts the query by the `post_date` - or the post parent if you have a hierarchical post as currently displayed object. When you ta...
73,192
<p>I am using the NextGen gallery WordPress plugin for a site. In my gallery.php template I want to retrieve the number of images for each gallery displayed in the loop. I cannot figure out a way to get the data and print it under the thumbnail of each gallery that's called in gallery.php</p> <p>Here is where I want t...
[ { "answer_id": 73194, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 6, "selected": true, "text": "<h1>Understanding the internals</h1>\n\n<p>The \"sort\" order of adjacent (next/prev) posts is not really a sort \"orde...
2012/11/19
[ "https://wordpress.stackexchange.com/questions/73192", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23832/" ]
I am using the NextGen gallery WordPress plugin for a site. In my gallery.php template I want to retrieve the number of images for each gallery displayed in the loop. I cannot figure out a way to get the data and print it under the thumbnail of each gallery that's called in gallery.php Here is where I want to insert t...
Understanding the internals =========================== The "sort" order of adjacent (next/prev) posts is not really a sort "order". It's a separate query on each request/page, **but** it sorts the query by the `post_date` - or the post parent if you have a hierarchical post as currently displayed object. When you ta...