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 |
|---|---|---|---|---|---|---|
130,390 | <p>I've been trawling through forums but can't find a solution to this. If anyone can help, it would be greatly appreciated!
I'm trying to display a link to current users author page (all users have author permissions).
I'm using this at the moment:</p>
<pre><code><a href="<?php echo home_url() . '/author/' . ge... | [
{
"answer_id": 130392,
"author": "Borek",
"author_id": 45286,
"author_profile": "https://wordpress.stackexchange.com/users/45286",
"pm_score": 2,
"selected": false,
"text": "<p>Well if your code is working properly and the only problem is that it displays when no one is logged in then tr... | 2014/01/19 | [
"https://wordpress.stackexchange.com/questions/130390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45381/"
] | I've been trawling through forums but can't find a solution to this. If anyone can help, it would be greatly appreciated!
I'm trying to display a link to current users author page (all users have author permissions).
I'm using this at the moment:
```
<a href="<?php echo home_url() . '/author/' . get_the_author_meta( '... | Well if your code is working properly and the only problem is that it displays when no one is logged in then try the code below. Because right now you are saying "Hey WP just echo out this" - so it does it. You need to change it to: "Hey WP if the user is logged in show the link to his page and if not show the login li... |
130,401 | <p>I'd like to display a random page that:</p>
<ul>
<li>has a parent page of X <em>or</em> Y <em>or</em> Z, etc.</li>
<li>excludes pages with the title "Contributors"</li>
</ul>
<p>The following code works (though without the specific conditions above), but <strong>the_content</strong> isn't displaying anything. I'm ... | [
{
"answer_id": 130405,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": -1,
"selected": false,
"text": "<p>Try adding the page ID into the content e.g.</p>\n\n<pre><code>the_content($post->ID);\n</code></p... | 2014/01/19 | [
"https://wordpress.stackexchange.com/questions/130401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45384/"
] | I'd like to display a random page that:
* has a parent page of X *or* Y *or* Z, etc.
* excludes pages with the title "Contributors"
The following code works (though without the specific conditions above), but **the\_content** isn't displaying anything. I'm not sure what's going wrong there.
fwiw, this is a template ... | The first condition you list is easy. You just need the `post_parent__in` arguments.
```
$args = array(
'post_type' => 'page',
'posts_per_page' => 1,
'orderby' => 'rand',
'post_parent__in' => array(2,169), // replace with your IDs
);
$rand = new WP_Query($args);
if ($rand->have_posts()) {
while ($rand->ha... |
130,428 | <p>I would like to be able to programatically find out what handler is registered to a particular shortcode. I want to be able to find this so I can save it, change it, perform a do_shortcode, then change it back to what it was originally.</p>
<p>I understand WordPress has a gobal variable $wp_filter for registered fi... | [
{
"answer_id": 130429,
"author": "McShaman",
"author_id": 37218,
"author_profile": "https://wordpress.stackexchange.com/users/37218",
"pm_score": 0,
"selected": false,
"text": "<p>Found it $shortcode_tags</p>\n\n<p>If you do printer( $shortcode_tags ) you will get a listing of registered... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130428",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37218/"
] | I would like to be able to programatically find out what handler is registered to a particular shortcode. I want to be able to find this so I can save it, change it, perform a do\_shortcode, then change it back to what it was originally.
I understand WordPress has a gobal variable $wp\_filter for registered filters...... | The below WordPress snippet will give you a list of all the WordPress shortcodes you have available on your blog.
```
<?php
global $shortcode_tags;
echo '<pre>';
print_r($shortcode_tags);
echo '</pre>';
?>
```
Also check the **[`Codex`](http://codex.wordpress.org/Shortcode_API)** fo... |
130,477 | <p>I currently have a menu structure as followed:</p>
<pre><code><ul class="level-1" id="menu-menu1">
<li id="menu-item-411">
<a href="http://www.link.com">Frontpage</a>
</li>
<li id="menu-item-425"></li>
<li id="menu-item-80"></li>
</ul>
</code><... | [
{
"answer_id": 130498,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>You need to do a custom walker on the menu (<a href=\"http://codex.wordpress.org/Function_Reference/wp... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32380/"
] | I currently have a menu structure as followed:
```
<ul class="level-1" id="menu-menu1">
<li id="menu-item-411">
<a href="http://www.link.com">Frontpage</a>
</li>
<li id="menu-item-425"></li>
<li id="menu-item-80"></li>
</ul>
```
**What im looking to do is hardcore a little menu icon image for each differ... | Creating a custom Walker is a valid way to solve this, and is the first thing that crossed my mind, but it is not strictly necessary. It is possible to pull this off with filters, albeit by mildly abusing one of them :)
Proof of concept:
```
function insert_image_wpse_130477($item_output) {
remove_filter('walker... |
130,485 | <p>I want to perform a <code>WP_Query</code> that finds all posts limited to the last 90 days. From my understanding, <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters" rel="nofollow">WP_Query</a> accepts numerical values for months, years, days, etc, but I'm not sure I understand how to pas... | [
{
"answer_id": 130496,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>Not a WP Query but you can do this via a database query using $WPDB, I wrote a <a href=\"https://wordp... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12294/"
] | I want to perform a `WP_Query` that finds all posts limited to the last 90 days. From my understanding, [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters) accepts numerical values for months, years, days, etc, but I'm not sure I understand how to pass an argument that says "get all posts f... | In order to query posts with a [`date_query`](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters), you can pass the argument of column `post_date_gmt` which is the date the post was published, and then pass the argument of `before/after` and a string to represent your request. So for published posts fr... |
130,492 | <p>I need to check if a certain value is true in the post_meta right after the wp fetches a custom post from database, If it's false I need to modify/add some data to the post and then display the modified version, if it's true it should continue as usual. What would be the best hook and approach in general to accompli... | [
{
"answer_id": 130494,
"author": "EHerman",
"author_id": 43000,
"author_profile": "https://wordpress.stackexchange.com/users/43000",
"pm_score": 0,
"selected": false,
"text": "<p>I would do this inside of my <code>single-custon_post_type.php</code>, using the <code>get_meta()</code> func... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45313/"
] | I need to check if a certain value is true in the post\_meta right after the wp fetches a custom post from database, If it's false I need to modify/add some data to the post and then display the modified version, if it's true it should continue as usual. What would be the best hook and approach in general to accomplish... | You can use [`the_content`](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content) filter to modify content before it's output.
```
function my_the_content_filter( $content ) {
// maybe limit to archive or single cpt display?
if( is_post_type_archive( 'your-cpt' )
|| is_singular( 'your-cpt... |
130,501 | <p>In the class <code>WP_Posts_List_Table</code> there is a function named <code>inline_edit()</code> and it is responsible for rendering the entire quick edit table that is used (but initially hidden) on <code>wp-admin/edit.php</code>. </p>
<p>I want to <strong>prevent</strong> that table from being rendered because ... | [
{
"answer_id": 130537,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 0,
"selected": false,
"text": "<p>Had the same issue a while, i solved it by changing the term_list with a filter tho remove all checkboxes when... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45405/"
] | In the class `WP_Posts_List_Table` there is a function named `inline_edit()` and it is responsible for rendering the entire quick edit table that is used (but initially hidden) on `wp-admin/edit.php`.
I want to **prevent** that table from being rendered because the site I'm working on has thousands of category terms ... | I was never able to find a filter either, but there is a check for whether the taxonomy is allowed to show it's UI. So what I used to do in one of my plugins was to tweak the `$wp_taxonomies` global variable on the edit page.
```
/**
* Disable the UI for categories, but only on EDIT screen
* which prevents them fro... |
130,509 | <p>I want to restrict access to certain plugin pages / normal WP Pages. I've found a way to Hide these pages from the menu but currently not restrict them. For instance, I have an editor and I don't want them to have access to <code>Media</code> and <code>Tools</code> - I can hide those pages via this:</p>
<pre><code>... | [
{
"answer_id": 130513,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": -1,
"selected": false,
"text": "<p>Best bet is to use a plugin such as <a href=\"http://wordpress.org/plugins/user-role-editor/\" rel=\"... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | I want to restrict access to certain plugin pages / normal WP Pages. I've found a way to Hide these pages from the menu but currently not restrict them. For instance, I have an editor and I don't want them to have access to `Media` and `Tools` - I can hide those pages via this:
```
function editor_menu() {
global ... | I believe the correct solution here is to just update the $capability component of the admin\_menu items rather than just remove them from the menu structure.
Try this:
```
/** Set 'administrator' cap for particular menu items **/
function update_admin_menu() {
global $menu, $submenu;
$menu[10][1] = 'adminis... |
130,514 | <p>I have the following situation loading a CSS.</p>
<p>I have a WordPress theme that load a <strong>style.css</strong> settings file by this code into my <strong>functions.php</strong> file:</p>
<pre><code>/* Function automatically executed by the hook:
* 1) (OPTIONAL): Register a script (without load it): in this ... | [
{
"answer_id": 130513,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": -1,
"selected": false,
"text": "<p>Best bet is to use a plugin such as <a href=\"http://wordpress.org/plugins/user-role-editor/\" rel=\"... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130514",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I have the following situation loading a CSS.
I have a WordPress theme that load a **style.css** settings file by this code into my **functions.php** file:
```
/* Function automatically executed by the hook:
* 1) (OPTIONAL): Register a script (without load it): in this case register the CSS settings
* 2) Load the C... | I believe the correct solution here is to just update the $capability component of the admin\_menu items rather than just remove them from the menu structure.
Try this:
```
/** Set 'administrator' cap for particular menu items **/
function update_admin_menu() {
global $menu, $submenu;
$menu[10][1] = 'adminis... |
130,516 | <p>I have a query which returns all custom post, I'm trying to split all post into sections of six then wrap them in an list item.</p>
<p>Right now its performing as it should but breaks when it get to the 12 post, their are a total of 40 post. Im not sure what wrong could someone help.</p>
<pre><code><?php
... | [
{
"answer_id": 130517,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>Could you use the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters\... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130516",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13529/"
] | I have a query which returns all custom post, I'm trying to split all post into sections of six then wrap them in an list item.
Right now its performing as it should but breaks when it get to the 12 post, their are a total of 40 post. Im not sure what wrong could someone help.
```
<?php
$args = array(
... | I think your approach is correct but you're running into the "posts\_per\_page" problem.
In your query, use 'posts\_per\_page=-1' to return all posts (assuming that's what you want). I'm guessing your website is currently set to show 12 posts per page in the settings->reading area.
<http://codex.wordpress.org/Class_R... |
130,519 | <p>I am using a ticker jQuery plugin and having trouble loading my script files correctly. If I add the scripts in directly into the theme's <code>header.php</code> file my scripts work correctly.<br>
Example:</p>
<pre><code><script src="<?php bloginfo('template_directory'); ?>/js/jquery-ticker.js"></sc... | [
{
"answer_id": 130520,
"author": "Gareth Gillman",
"author_id": 33936,
"author_profile": "https://wordpress.stackexchange.com/users/33936",
"pm_score": 0,
"selected": false,
"text": "<p>You need to register the scripts but also define them to the jQuery library e.g.</p>\n\n<pre><code> w... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130519",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30937/"
] | I am using a ticker jQuery plugin and having trouble loading my script files correctly. If I add the scripts in directly into the theme's `header.php` file my scripts work correctly.
Example:
```
<script src="<?php bloginfo('template_directory'); ?>/js/jquery-ticker.js"></script>
<script src="<?php bloginfo('templa... | Add the `jquery` script as a dependency for your `jquery-ticker.js` and `site.js` files within the `wp_enqueue_script` function.
Example:
```
function bbc_frontend_script() {
wp_enqueue_script('ticker', plugins_url("/js/jquery-ticker.js", __FILE__), array( 'jquery' ) );
wp_enqueue_script('sitejs', plugins_url("/js/s... |
130,533 | <p>I want to create a page that displays all the blog users ordered by the last login date.</p>
<p>I've tried with the get_users() function and I can succesfully get the users' list, but not in the order I want:</p>
<pre><code>$query = get_users('&offset='.$offset.'&orderby=login&order=DESC&number='.$... | [
{
"answer_id": 130536,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 4,
"selected": true,
"text": "<p>First, you need to store the actual login date, because this is not stored by default. You can use this code to... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22547/"
] | I want to create a page that displays all the blog users ordered by the last login date.
I've tried with the get\_users() function and I can succesfully get the users' list, but not in the order I want:
```
$query = get_users('&offset='.$offset.'&orderby=login&order=DESC&number='.$number);
```
I think that the ord... | First, you need to store the actual login date, because this is not stored by default. You can use this code to do that(use it in your functions.php)
```
add_action('wp_login','user_last_login', 0, 2);
function user_last_login($login, $user) {
$user = get_user_by('login',$login);
$now = time();
update_us... |
130,542 | <p>I have a website with products (shoes), i have some shoes models registered as taxonomy on the function.php file like so:</p>
<pre><code>function add_custom_taxonomies() {
register_taxonomy('mod-nike', 'pompitup_product', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => false,
... | [
{
"answer_id": 130536,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 4,
"selected": true,
"text": "<p>First, you need to store the actual login date, because this is not stored by default. You can use this code to... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45417/"
] | I have a website with products (shoes), i have some shoes models registered as taxonomy on the function.php file like so:
```
function add_custom_taxonomies() {
register_taxonomy('mod-nike', 'pompitup_product', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => false,
// This array of... | First, you need to store the actual login date, because this is not stored by default. You can use this code to do that(use it in your functions.php)
```
add_action('wp_login','user_last_login', 0, 2);
function user_last_login($login, $user) {
$user = get_user_by('login',$login);
$now = time();
update_us... |
130,560 | <p>I have this form in a page template</p>
<pre><code><form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
<div class="formrow requiredRow"><label id="FullName-ariaLabel" for="txt_FullName">Full Name</label>
<input class="required" ... | [
{
"answer_id": 130562,
"author": "akamaozu",
"author_id": 13176,
"author_profile": "https://wordpress.stackexchange.com/users/13176",
"pm_score": -1,
"selected": false,
"text": "<p>What you're looking for is <code>header('Location: url_goes_here')</code>;</p>\n\n<p>Try:</p>\n\n<pre><code... | 2014/01/20 | [
"https://wordpress.stackexchange.com/questions/130560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10413/"
] | I have this form in a page template
```
<form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
<div class="formrow requiredRow"><label id="FullName-ariaLabel" for="txt_FullName">Full Name</label>
<input class="required" id="txt_FullName" title="Full Name. This is a r... | Instead of using home\_url, header(location) you can use [wp\_redirect()](http://codex.wordpress.org/Function_Reference/wp_redirect)
```
function __my_registration_redirect(){
wp_redirect( '/my-page' );
exit;
}
add_filter( 'registration_redirect', '__my_registration_redirect' );
```
This might be helpfull |
130,597 | <p>I'm stuck trying to figure out what seems to be a very common problem, the above mentioned "Allowed memory size of (...) exhausted". After developing my first theme I was moving it (just the theme, not the whole WP installation) from my development computer to my production server. After installing WP everything see... | [
{
"answer_id": 130619,
"author": "Matrix Infologics",
"author_id": 45441,
"author_profile": "https://wordpress.stackexchange.com/users/45441",
"pm_score": -1,
"selected": false,
"text": "<p>Sometime ini_set('memory_limit', '128M');</p>\n\n<p>gives error if you don't have permission to c... | 2014/01/21 | [
"https://wordpress.stackexchange.com/questions/130597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45435/"
] | I'm stuck trying to figure out what seems to be a very common problem, the above mentioned "Allowed memory size of (...) exhausted". After developing my first theme I was moving it (just the theme, not the whole WP installation) from my development computer to my production server. After installing WP everything seemed... | Turns out this issue was caused by bad code (a missing assert) in my theme. More specifically the theme requires a custom navigation menu. As this menu hadn't been created and assigned the site crashed. Why this caused an memory exhaustion error on my production server and not my development computer I unfortunately do... |
130,622 | <p>I am looking for a way to add tag slug as a class.
I can't figure out how to achieve this...</p>
<p>Here is how I display the products tags <br />
<code><?php echo get_the_term_list( $post->id, 'product_tag'); ?></code></p>
<p>The output is<br />
<code><a href="http://myurl.com" rel="tag">My tag<... | [
{
"answer_id": 130623,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": -1,
"selected": false,
"text": "<p>Why can't you wrap the output in an unordered list something like below?</p>\n\n<pre><code>echo '<ul class=\"... | 2014/01/21 | [
"https://wordpress.stackexchange.com/questions/130622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36501/"
] | I am looking for a way to add tag slug as a class.
I can't figure out how to achieve this...
Here is how I display the products tags
`<?php echo get_the_term_list( $post->id, 'product_tag'); ?>`
The output is
`<a href="http://myurl.com" rel="tag">My tag</a>`
And I want
`<a href="http://myurl.com" class="Ta... | I think you should use a custom loop:
```
<?php
$terms = get_the_terms( $post->ID, 'product_tag' );
if ($terms && ! is_wp_error($terms)): ?>
<?php foreach($terms as $term): ?>
<a href="<?php echo get_term_link( $term->slug, 'product_tag'); ?>" rel="tag" class="<?php echo $term->slug; ?>"><?php echo $term->... |
130,634 | <p>How do I insert an image that is in a subfolder into my theme directory?</p>
<p>I have the following situation: Into my custom theme directory I have the following folder that contains a <code>jpg</code> image: <code>/assets/img/flexslider/flex-1.jpg</code></p>
<p>Now in my <code>header.php</code> file, I have som... | [
{
"answer_id": 130636,
"author": "Raja67",
"author_id": 45335,
"author_profile": "https://wordpress.stackexchange.com/users/45335",
"pm_score": 4,
"selected": true,
"text": "<p>You should echo it and also you are closing your php tag improperly. View source the o/p generated to get some ... | 2014/01/21 | [
"https://wordpress.stackexchange.com/questions/130634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | How do I insert an image that is in a subfolder into my theme directory?
I have the following situation: Into my custom theme directory I have the following folder that contains a `jpg` image: `/assets/img/flexslider/flex-1.jpg`
Now in my `header.php` file, I have something like this:
```
<li>
<img src="assets/img... | You should echo it and also you are closing your php tag improperly. View source the o/p generated to get some idea
```
img<src=<?php echo get_template_directory_uri()."/assets/img/flexslider/flex-1.jpg"?> alt="alternative_name">
```
or you can use [bloginfo](http://codex.wordpress.org/Function_Reference/bloginfo) w... |
130,637 | <p>I have searched and found a lot of people asking about how to add a custom rss feed for custom post types/taxonomies. However that's not the problem right now.</p>
<p>I have 2 extra pages on my site that looks like the default index page (with loop and stuff), the only difference is that they have a different order... | [
{
"answer_id": 130636,
"author": "Raja67",
"author_id": 45335,
"author_profile": "https://wordpress.stackexchange.com/users/45335",
"pm_score": 4,
"selected": true,
"text": "<p>You should echo it and also you are closing your php tag improperly. View source the o/p generated to get some ... | 2014/01/21 | [
"https://wordpress.stackexchange.com/questions/130637",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44504/"
] | I have searched and found a lot of people asking about how to add a custom rss feed for custom post types/taxonomies. However that's not the problem right now.
I have 2 extra pages on my site that looks like the default index page (with loop and stuff), the only difference is that they have a different orderby. And I ... | You should echo it and also you are closing your php tag improperly. View source the o/p generated to get some idea
```
img<src=<?php echo get_template_directory_uri()."/assets/img/flexslider/flex-1.jpg"?> alt="alternative_name">
```
or you can use [bloginfo](http://codex.wordpress.org/Function_Reference/bloginfo) w... |
130,664 | <p><strong><em>Updates 6 Feb 14 to make more specific as requested in comments.</em></strong></p>
<p>I have a post type, we'll call it "Projects", with the slug "projects" for which I'd like to offer two views:</p>
<ol>
<li>list view <strong>(default)</strong></li>
<li>map view</li>
</ol>
<p>I'd like those views to ... | [
{
"answer_id": 133698,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 4,
"selected": true,
"text": "<h2>Updated approach</h2>\n\n<p>The first thought/suggestion I made actually - like you said - doesn't ... | 2014/01/21 | [
"https://wordpress.stackexchange.com/questions/130664",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9844/"
] | ***Updates 6 Feb 14 to make more specific as requested in comments.***
I have a post type, we'll call it "Projects", with the slug "projects" for which I'd like to offer two views:
1. list view **(default)**
2. map view
I'd like those views to be at the following permalinks:
1. example.org/projects/ **(default post... | Updated approach
----------------
The first thought/suggestion I made actually - like you said - doesn't work as I understood it. At least I tried it and couldn't figure it out. That said, what you want is still achievable, but not by using a endpoint or at least not by making use of `add_rewrite_endpoint()`.
Howeve... |
130,681 | <p>I am creating a theme framework to use in future wordpress themes that I develop. I would like to include dependant files such as classes inside the parent theme before the child theme functions.php gets loaded. This way the child theme doesn't need to include the classes.</p>
<p>I'll try to show an example:</p>
... | [
{
"answer_id": 130724,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Provide a custom action in your parent theme:</p>\n\n<pre><code>do_action( get_template() . '_loaded', $api_class_ins... | 2014/01/21 | [
"https://wordpress.stackexchange.com/questions/130681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44143/"
] | I am creating a theme framework to use in future wordpress themes that I develop. I would like to include dependant files such as classes inside the parent theme before the child theme functions.php gets loaded. This way the child theme doesn't need to include the classes.
I'll try to show an example:
parent-theme - ... | The `functions.php` file executes at `plugins_loaded`, with the Child Theme `functions.php` executing before the Parent Theme `functions.php`. That means that, in order to load functional sub-files in the Child Theme *after* the Parent Theme `functions.php` executes, you simply need to hook your `include()` calls *afte... |
130,703 | <p>I'm adding a filter for a WordPress query in a widget. I'm adding as following:</p>
<pre><code>function filter_where( $where = '' ) {
}
add_filter( 'posts_where', 'filter_where' );
$query = new WP_Query( $args );
remove_filter( 'posts_where', 'filter_where' );
</code></pre>
<p>It works fine, but if I use the same... | [
{
"answer_id": 130704,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>You must be defining your callback function inside a function that is reused by the widget system-- my guess... | 2014/01/21 | [
"https://wordpress.stackexchange.com/questions/130703",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41290/"
] | I'm adding a filter for a WordPress query in a widget. I'm adding as following:
```
function filter_where( $where = '' ) {
}
add_filter( 'posts_where', 'filter_where' );
$query = new WP_Query( $args );
remove_filter( 'posts_where', 'filter_where' );
```
It works fine, but if I use the same widget more than 1 times ... | Your code should look something like this:
```
class my_Widget extends WP_Widget {
...
function filter_where( $where = '' ) {
...
}
function widget( $options ) {
...
add_filter( 'posts_where', array( $this, 'filter_where' ) );
$query = new WP_Query( $args );
remove_filter( 'posts_where', array( ... |
130,709 | <p>The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at <code>/author/author-name/</code> that only displays a list of posts by that author and a page at something like <code>/author/author-name/profile/</code> that s... | [
{
"answer_id": 130704,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>You must be defining your callback function inside a function that is reused by the widget system-- my guess... | 2014/01/21 | [
"https://wordpress.stackexchange.com/questions/130709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45472/"
] | The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at `/author/author-name/` that only displays a list of posts by that author and a page at something like `/author/author-name/profile/` that shows extended user info b... | Your code should look something like this:
```
class my_Widget extends WP_Widget {
...
function filter_where( $where = '' ) {
...
}
function widget( $options ) {
...
add_filter( 'posts_where', array( $this, 'filter_where' ) );
$query = new WP_Query( $args );
remove_filter( 'posts_where', array( ... |
130,729 | <p>I am trying to add placeholder text to the native WordPress registration form. I am currently using the Register Plus Redux plugin.
How to add this placeholder text into the text input fields on the form?</p>
<p>I need to tell people to use their first and last name as the username.
I'd be stoked if someone could ... | [
{
"answer_id": 130745,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately there are no hooks/filters to modify the input field in the login/registration form to a... | 2014/01/22 | [
"https://wordpress.stackexchange.com/questions/130729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45381/"
] | I am trying to add placeholder text to the native WordPress registration form. I am currently using the Register Plus Redux plugin.
How to add this placeholder text into the text input fields on the form?
I need to tell people to use their first and last name as the username.
I'd be stoked if someone could help me ou... | Another simple way to do this without needing to add another script is using PHP's [str\_replace](http://php.net/manual/en/function.str-replace.php) function.
```
$args = array(
'echo' => false,
);
$form = wp_login_form( $args );
//add the placeholders
$form = str_replace('name="log"', 'name="log" placeholder="... |
130,747 | <p>I'm wondering if I could make a custom <em>Page</em> title for my <a href="https://codex.wordpress.org/Post_Types#Custom_Post_Types" rel="nofollow">Custom Post Type</a> <em>Archive</em> page? Right now I'm using:</p>
<pre><code><title><?php wp_title( '|', true, 'right' ); ?></title>
</code></pre>
... | [
{
"answer_id": 130748,
"author": "Raja67",
"author_id": 45335,
"author_profile": "https://wordpress.stackexchange.com/users/45335",
"pm_score": 2,
"selected": true,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/is_archive\" rel=\"nofollow\">is_archive</a... | 2014/01/22 | [
"https://wordpress.stackexchange.com/questions/130747",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34210/"
] | I'm wondering if I could make a custom *Page* title for my [Custom Post Type](https://codex.wordpress.org/Post_Types#Custom_Post_Types) *Archive* page? Right now I'm using:
```
<title><?php wp_title( '|', true, 'right' ); ?></title>
```
For my regular pages, it display what I want, but on my custom post type archive... | You can use [is\_archive](http://codex.wordpress.org/Function_Reference/is_archive) conditional code in your header.php to control the title
```
<?php if(is_archive()): ?>
<title>Archive page</title>
<?php else: ?>
<title><?php wp_title( '|', true, 'right' ); ?></title>
<?php endif; ?>
``` |
130,770 | <p>I'm using CPT UI to create the post type (books). I am running in debug mode. This is all happening on default, Wordpress 3.8, twenty twelve theme.</p>
<p>I created a field group called Books in ACF and added three fields: book_title, book_author, pub_year. I set the field group to show if post type is books. ... | [
{
"answer_id": 130762,
"author": "Raja67",
"author_id": 45335,
"author_profile": "https://wordpress.stackexchange.com/users/45335",
"pm_score": 2,
"selected": false,
"text": "<p>You need to update the new URL in <strong>the WordPress Address (URL)</strong> and <strong>Site Address (URL)... | 2014/01/22 | [
"https://wordpress.stackexchange.com/questions/130770",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44093/"
] | I'm using CPT UI to create the post type (books). I am running in debug mode. This is all happening on default, Wordpress 3.8, twenty twelve theme.
I created a field group called Books in ACF and added three fields: book\_title, book\_author, pub\_year. I set the field group to show if post type is books. I then copie... | Download and install "Velvet Blues Update URLs". Add your old url in the "Old URL" field, the new one in the "New URL" field, check all the checkboxes and click "Update URLs". Update your permalinks afterwards |
130,781 | <p>I've JUST started using WordPress..i'm trying to add posts to Wordpress using php and i came across this piece of code:</p>
<pre><code>// Create post object
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
... | [
{
"answer_id": 130762,
"author": "Raja67",
"author_id": 45335,
"author_profile": "https://wordpress.stackexchange.com/users/45335",
"pm_score": 2,
"selected": false,
"text": "<p>You need to update the new URL in <strong>the WordPress Address (URL)</strong> and <strong>Site Address (URL)... | 2014/01/22 | [
"https://wordpress.stackexchange.com/questions/130781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45500/"
] | I've JUST started using WordPress..i'm trying to add posts to Wordpress using php and i came across this piece of code:
```
// Create post object
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array... | Download and install "Velvet Blues Update URLs". Add your old url in the "Old URL" field, the new one in the "New URL" field, check all the checkboxes and click "Update URLs". Update your permalinks afterwards |
130,802 | <p>I am pretty new in WP (I came from Joomla) and I have the following problem:</p>
<p>I am carrying this pure HTML theme (that use BootStrap CSS framework) into a WordPress theme.</p>
<p>This is the original pure HTML demo theme (I have the entire source code because it is a downlodable example): <a href="http://www... | [
{
"answer_id": 130804,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": true,
"text": "<p>The simplest and most-common cause for this issue is that you have failed to fire <a href=\"http://codex.wo... | 2014/01/22 | [
"https://wordpress.stackexchange.com/questions/130802",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am pretty new in WP (I came from Joomla) and I have the following problem:
I am carrying this pure HTML theme (that use BootStrap CSS framework) into a WordPress theme.
This is the original pure HTML demo theme (I have the entire source code because it is a downlodable example): <http://www.html.it/guide/img/bootst... | The simplest and most-common cause for this issue is that you have failed to fire [`wp_footer()`](http://codex.wordpress.org/Function_Reference/wp_footer) immediately before the closing `</body>` tag in your `footer.php` file:
```
<?php wp_footer(); ?>
</body>
``` |
130,830 | <p>I have a page that displays a random post every day. In order to change post every 24 hours I use</p>
<p><code>set_transient('totd_trans_post_id', $totd[0]->ID, (60*60*24));</code> </p>
<p>What I'm wondering is this:</p>
<ul>
<li>Does the countdown (60*60*24) start as soon as I have inserted and saved the code... | [
{
"answer_id": 130804,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": true,
"text": "<p>The simplest and most-common cause for this issue is that you have failed to fire <a href=\"http://codex.wo... | 2014/01/22 | [
"https://wordpress.stackexchange.com/questions/130830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44504/"
] | I have a page that displays a random post every day. In order to change post every 24 hours I use
`set_transient('totd_trans_post_id', $totd[0]->ID, (60*60*24));`
What I'm wondering is this:
* Does the countdown (60\*60\*24) start as soon as I have inserted and saved the code?
* If yes: What happens if I let the co... | The simplest and most-common cause for this issue is that you have failed to fire [`wp_footer()`](http://codex.wordpress.org/Function_Reference/wp_footer) immediately before the closing `</body>` tag in your `footer.php` file:
```
<?php wp_footer(); ?>
</body>
``` |
130,844 | <p>I would like to populate a custom table, with more than one row of data at one time. If I delete the second array, it will insert one row of data. It won't add both rows at the same time though. How do I insert both rows at the same time? My code:</p>
<pre><code>function mp_install_name_data() {
global $wpdb;
... | [
{
"answer_id": 130845,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 3,
"selected": true,
"text": "<p>You could use a foreach loop -</p>\n\n<pre><code>function mp_install_name_data() {\n global $wpdb;\n $ta... | 2014/01/22 | [
"https://wordpress.stackexchange.com/questions/130844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I would like to populate a custom table, with more than one row of data at one time. If I delete the second array, it will insert one row of data. It won't add both rows at the same time though. How do I insert both rows at the same time? My code:
```
function mp_install_name_data() {
global $wpdb;
$table_name... | You could use a foreach loop -
```
function mp_install_name_data() {
global $wpdb;
$table_name = $wpdb->prefix . "names";
$rows = array(
array(
'id' => '1',
'name' => 'matt',
'age' => '20',
'point_one' => '0.45',
'point_two' => '0.22' ... |
130,874 | <p>Whenever i try to move the website from local to live or viceversa <strong>Theme Option settings</strong> resets. Exporting the settings and importing it couldnot restore the images which is an upload field(P.S.it restores the text fields).I tried changing the urls of the export file i.e from </p>
<pre><code>http:/... | [
{
"answer_id": 130881,
"author": "Chittaranjan",
"author_id": 43031,
"author_profile": "https://wordpress.stackexchange.com/users/43031",
"pm_score": 2,
"selected": false,
"text": "<p>I will suggest not to replace the data directly in the sql file. This is because wordpress stores data i... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45335/"
] | Whenever i try to move the website from local to live or viceversa **Theme Option settings** resets. Exporting the settings and importing it couldnot restore the images which is an upload field(P.S.it restores the text fields).I tried changing the urls of the export file i.e from
```
http://localhost/mysite/image.jpg... | I will suggest not to replace the data directly in the sql file. This is because wordpress stores data in terms of serialized manner. The reason for simply replacing data in serialized form leading to problems is that serialized data saves string length with it, so if you replace strings the length most likely will dif... |
130,877 | <p>I'm looking to style my wp_list_pages with a span class. I'd like to give it a unique class so that I can give each a specific icon.</p>
<pre><code>'link_before' => '<span class="'.[unique-identifier-here].'"></span>',
</code></pre>
<p>I was thinking of using the page slug but the menu I use also ha... | [
{
"answer_id": 130882,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>There is no need for extra markup. Your menu items have a unique CSS class <code>page-item-{ID}</code>, whic... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35801/"
] | I'm looking to style my wp\_list\_pages with a span class. I'd like to give it a unique class so that I can give each a specific icon.
```
'link_before' => '<span class="'.[unique-identifier-here].'"></span>',
```
I was thinking of using the page slug but the menu I use also has child pages involved so it would have... | Okay well in that case the way you've suggested in your question will not work as intended. It will put the same class on each `<span>`, that class would also be the `post_name` of the current page you are on.
You do have two options that you can use, one being much easier than the other:
**Method One**
Each `<li>` ... |
130,890 | <p>I have a custom dashboard plugin with one of the sections containing useful links. One of them should directly point to the documentation that comes with a template. This documentation is in the theme directory. Now I've tried different ways to get the path using for example:</p>
<pre><code><?php get_theme_root... | [
{
"answer_id": 130891,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 2,
"selected": true,
"text": "<p>I suppose, you want it to be like that:</p>\n\n<pre><code><?php echo get_stylesheet_directory_uri(); ?>... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45286/"
] | I have a custom dashboard plugin with one of the sections containing useful links. One of them should directly point to the documentation that comes with a template. This documentation is in the theme directory. Now I've tried different ways to get the path using for example:
```
<?php get_theme_root_uri(); ?>/mytheme... | I suppose, you want it to be like that:
```
<?php echo get_stylesheet_directory_uri(); ?>/documentation/index.html
``` |
130,899 | <p>I want to display the post title instead of the link to it with get_permalink.</p>
<p><code>get_permalink($comment->comment_post_ID)</code> only shows the link to the post!</p>
| [
{
"answer_id": 130901,
"author": "Ben Wainwright",
"author_id": 44235,
"author_profile": "https://wordpress.stackexchange.com/users/44235",
"pm_score": 0,
"selected": false,
"text": "<p>Inside the loop, you can use</p>\n\n<pre><code><?php the_title() ?>\n</code></pre>\n\n<p><a href... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130899",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45127/"
] | I want to display the post title instead of the link to it with get\_permalink.
`get_permalink($comment->comment_post_ID)` only shows the link to the post! | Thanks guys! I was able to solve it with:
```
<a href='".get_permalink($comment->comment_post_ID)."'>".get_the_title($comment->comment_post_ID)."</a>
``` |
130,903 | <p>I have a custom post "artist" and a taxonomy/category "artist category", and i want to create (by development) a new post and set the category of the artist but it doesn't work.</p>
<p>I have tested it with this code:</p>
<pre><code>function createNewPost( $response ){
global $userMeta;
$userID = $respons... | [
{
"answer_id": 130912,
"author": "Dk-Macadamia",
"author_id": 38118,
"author_profile": "https://wordpress.stackexchange.com/users/38118",
"pm_score": 0,
"selected": false,
"text": "<p>you can try something like this:\nfor example your category id is 3\nthen:</p>\n\n<pre><code>wp_set_post... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130903",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45548/"
] | I have a custom post "artist" and a taxonomy/category "artist category", and i want to create (by development) a new post and set the category of the artist but it doesn't work.
I have tested it with this code:
```
function createNewPost( $response ){
global $userMeta;
$userID = $response->ID;
$user = ne... | I know this is an old question, but the `tax_input` array should probably look like this since it appears to be hierarchical like a category:
`'tax_input' => array('artist-category' => array( 3 ) //use the ID of the category, not the name of the category`
From WordPress Codex on `wp_set_post_terms`
>
> If you want ... |
130,925 | <p>I created a widget which should use jQuery for switching between two views and implement the jQuery UI date picker.</p>
<p>I was wondering why my jQuery code does not work as I noticed that the date picker isn't working either. The console neither throws errors nor warnings.</p>
<p>This is my code inside the widge... | [
{
"answer_id": 170759,
"author": "FFrewin",
"author_id": 43534,
"author_profile": "https://wordpress.stackexchange.com/users/43534",
"pm_score": 0,
"selected": false,
"text": "<p>It looks like it can be a selector issue. Try making your selector more specific for the widget in the sideba... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31527/"
] | I created a widget which should use jQuery for switching between two views and implement the jQuery UI date picker.
I was wondering why my jQuery code does not work as I noticed that the date picker isn't working either. The console neither throws errors nor warnings.
This is my code inside the widget class:
```
fun... | In many cases, in backend you may use:
```
jQuery('#something')
```
instead of
```
$('#something')
``` |
130,943 | <p>I'm trying to get the stylesheet of the currently active admin color scheme to style a plugin to fit into the color context.</p>
<p>As mentioned in <a href="https://wordpress.stackexchange.com/questions/127401/get-current-active-wp-color-scheme">this post</a> I had a look at the implementation of <code>admin_color_... | [
{
"answer_id": 130951,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>The color scheme is stored as user meta:</p>\n\n<pre><code>$color = get_user_meta(get_current_user_id(), 'ad... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31527/"
] | I'm trying to get the stylesheet of the currently active admin color scheme to style a plugin to fit into the color context.
As mentioned in [this post](https://wordpress.stackexchange.com/questions/127401/get-current-active-wp-color-scheme) I had a look at the implementation of `admin_color_scheme_picker()` in `wp-ad... | I actually made it!
In my script file, at the to I define a new variable and copy the `$_wp_admin_css_colors` variable into it using the `admin_head` hook, since the variable gets destroyed at some later point:
```
<?php
global $admin_colors; // only needed if colors must be available in classes
add_action('a... |
130,947 | <p>I am working on a single post type template where I show a navigation menu with links to all the posts from the same term.</p>
<p>Now I want to use this template for all the different terms so $term_slug needs to hold the term slug of the current post so they can correspond to the other posts.</p>
<p>I have found ... | [
{
"answer_id": 130949,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 5,
"selected": true,
"text": "<p>Your code works on a page where a term is queried (a taxonomy term archive), not a single post.</p>\n\n<p>For a sin... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25834/"
] | I am working on a single post type template where I show a navigation menu with links to all the posts from the same term.
Now I want to use this template for all the different terms so $term\_slug needs to hold the term slug of the current post so they can correspond to the other posts.
I have found many times over ... | Your code works on a page where a term is queried (a taxonomy term archive), not a single post.
For a single post, you need to fetch the terms belonging to that post.
```
$terms = get_the_terms( $post->ID, 'your-taxonomy' );
if ( !empty( $terms ) ){
// get the first term
$term = array_shift( $terms );
ech... |
130,971 | <p>I have child page templates that need to be automatically applied based on the parent template.</p>
<p>I'm wondering if there is anyway Wordpress handles this.</p>
<p>This is the solution I came up with. (in page.php)</p>
<pre><code><?php
//Check parent template
if ($post->post_parent != $post->ID )
{
... | [
{
"answer_id": 130972,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 0,
"selected": false,
"text": "<p>That looks pretty good. Sounds like something Drupal would be good at. </p>\n\n<p>WordPress has a wrapper ... | 2014/01/23 | [
"https://wordpress.stackexchange.com/questions/130971",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35203/"
] | I have child page templates that need to be automatically applied based on the parent template.
I'm wondering if there is anyway Wordpress handles this.
This is the solution I came up with. (in page.php)
```
<?php
//Check parent template
if ($post->post_parent != $post->ID )
{
//Get parent template filename
... | Instead of putting something on the template, you can keep templates clean and add to `functions.php` a function that use `'template_include'` action hook to check parent page template and return same template for children pages.
```
add_action('template_include', 'auto_child_template');
function auto_child_template(... |
130,989 | <p>I have recently secured SSL certificates for my website and I would like to force HTTPS for all visitors.</p>
<p>And i want to remove HTTPS From permalinks</p>
<p>Like this</p>
<pre><code><link rel="canonical" href="http://www.mysite.com/archive/ID/" />
</code></pre>
<p>anyone suggest me plz</p>
| [
{
"answer_id": 130999,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 1,
"selected": false,
"text": "<p>This plugin should handle what you're requesting.\n<a href=\"http://wordpress.org/plugins/wordpress-https/... | 2014/01/24 | [
"https://wordpress.stackexchange.com/questions/130989",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45583/"
] | I have recently secured SSL certificates for my website and I would like to force HTTPS for all visitors.
And i want to remove HTTPS From permalinks
Like this
```
<link rel="canonical" href="http://www.mysite.com/archive/ID/" />
```
anyone suggest me plz | This plugin should handle what you're requesting.
<http://wordpress.org/plugins/wordpress-https/> |
130,990 | <p>I've searched around and have had no luck or success in finding a way to show how many posts an author has made in a certain period of time (e.g. - a week)</p>
<p>Any ideas on how one would approach this? I just want to display the total number of posts an author has made in a given time period.</p>
| [
{
"answer_id": 130998,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 0,
"selected": false,
"text": "<p>You could use a plugin such as <a href=\"http://wordpress.org/plugins/author-stats/\" rel=\"nofollow\">Aut... | 2014/01/24 | [
"https://wordpress.stackexchange.com/questions/130990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32409/"
] | I've searched around and have had no luck or success in finding a way to show how many posts an author has made in a certain period of time (e.g. - a week)
Any ideas on how one would approach this? I just want to display the total number of posts an author has made in a given time period. | Have a look on the date\_query parameter that has been added to WP 3.7
[WP\_Query#Date\_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters) and the [author parameter](http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters).
Combine the two parameters as you need them to quer... |
131,004 | <p>I want to link content comprised of a custom field(field1_details) using another custom field(field2_link) which is a URL type. <code>the_field('field1_details')</code> is text_area field and <code>get_field('field2_link')</code> is a website field (using a <a href="http://github.com/Jeradin/acf-website-field" rel=... | [
{
"answer_id": 130998,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 0,
"selected": false,
"text": "<p>You could use a plugin such as <a href=\"http://wordpress.org/plugins/author-stats/\" rel=\"nofollow\">Aut... | 2014/01/24 | [
"https://wordpress.stackexchange.com/questions/131004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2078/"
] | I want to link content comprised of a custom field(field1\_details) using another custom field(field2\_link) which is a URL type. `the_field('field1_details')` is text\_area field and `get_field('field2_link')` is a website field (using a [ACF addon](http://github.com/Jeradin/acf-website-field)).
(These custom fields... | Have a look on the date\_query parameter that has been added to WP 3.7
[WP\_Query#Date\_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters) and the [author parameter](http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters).
Combine the two parameters as you need them to quer... |
131,052 | <p>I'm creating a Wordpress blogging theme and have started doing the individual files for each post-format. In doing this I've encountered a problem for the functionality to the audio format. I would like to have whatever audio file the user uploads as a featured audio that will be displayed and playable over the titl... | [
{
"answer_id": 130998,
"author": "MikeNGarrett",
"author_id": 1670,
"author_profile": "https://wordpress.stackexchange.com/users/1670",
"pm_score": 0,
"selected": false,
"text": "<p>You could use a plugin such as <a href=\"http://wordpress.org/plugins/author-stats/\" rel=\"nofollow\">Aut... | 2014/01/24 | [
"https://wordpress.stackexchange.com/questions/131052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16605/"
] | I'm creating a Wordpress blogging theme and have started doing the individual files for each post-format. In doing this I've encountered a problem for the functionality to the audio format. I would like to have whatever audio file the user uploads as a featured audio that will be displayed and playable over the title o... | Have a look on the date\_query parameter that has been added to WP 3.7
[WP\_Query#Date\_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters) and the [author parameter](http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters).
Combine the two parameters as you need them to quer... |
131,061 | <p>I'm having problems with some "contact form" plugins whose use Ajax. The problem is that I use Ajax to call the plugin. Then the plugin is loaded, but when I try to submit the form, I'm redirected to this URL: <code>SITE/wp-admin/admin-ajax.php</code>, when it should send the Ajax request, and only a <code>0</code> ... | [
{
"answer_id": 131412,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 0,
"selected": false,
"text": "<p>A number of problems are present here.</p>\n\n<p>First and foremost, it appears that the first code block you p... | 2014/01/24 | [
"https://wordpress.stackexchange.com/questions/131061",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36778/"
] | I'm having problems with some "contact form" plugins whose use Ajax. The problem is that I use Ajax to call the plugin. Then the plugin is loaded, but when I try to submit the form, I'm redirected to this URL: `SITE/wp-admin/admin-ajax.php`, when it should send the Ajax request, and only a `0` is printed on the window.... | Your javascript is heavily reliant on inline attributes for event handling, rather than jQuery based event handling, and you're making AJAX calls to a different domain than the one you're currently on
 |
131,062 | <p>I'd like to know if it is possible for me to manipulate the output of wp_head()?</p>
<p>Right now I'm using the <a href="http://yoast.com/wordpress/seo/" rel="nofollow">Yoast SEO plugin</a> to add some social tags into my posts (og:*).</p>
<p>Now this site is an remake of an older umbraco based blog, and the perma... | [
{
"answer_id": 131063,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Information attached to the <code>wp_head</code> action hook is <code>echo</code>ed (if it needs to be <code... | 2014/01/24 | [
"https://wordpress.stackexchange.com/questions/131062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45611/"
] | I'd like to know if it is possible for me to manipulate the output of wp\_head()?
Right now I'm using the [Yoast SEO plugin](http://yoast.com/wordpress/seo/) to add some social tags into my posts (og:\*).
Now this site is an remake of an older umbraco based blog, and the permalink structure is different, so the old u... | I managed to find this post:
<https://wordpress.stackexchange.com/a/75168/45611>
It basically had what I needed.
```
/*
* This whole block here changes the og:url that Wordpress Seo Yoast provides
* It uses the addthis_share_url custom field, and if it is not present, it defaults
* to the permalink, just like the ... |
131,072 | <p>Sorry if this is a duplicate but I didn't find my answer in "Questions that already have your answer".</p>
<p>Currently on my site if I visit an old URL link or if I outright make up a URL like <code>example.com/made-up-place.html</code> I am getting redirected with a 302.</p>
<p>Whats weird is that it 302's by de... | [
{
"answer_id": 131063,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Information attached to the <code>wp_head</code> action hook is <code>echo</code>ed (if it needs to be <code... | 2014/01/24 | [
"https://wordpress.stackexchange.com/questions/131072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35677/"
] | Sorry if this is a duplicate but I didn't find my answer in "Questions that already have your answer".
Currently on my site if I visit an old URL link or if I outright make up a URL like `example.com/made-up-place.html` I am getting redirected with a 302.
Whats weird is that it 302's by default instead of 301 for mov... | I managed to find this post:
<https://wordpress.stackexchange.com/a/75168/45611>
It basically had what I needed.
```
/*
* This whole block here changes the og:url that Wordpress Seo Yoast provides
* It uses the addthis_share_url custom field, and if it is not present, it defaults
* to the permalink, just like the ... |
131,082 | <p>I followed this tutorial: <a href="http://wp.tutsplus.com/tutorials/using-the-settings-api-part-1-create-a-theme-options-page/" rel="nofollow">http://wp.tutsplus.com/tutorials/using-the-settings-api-part-1-create-a-theme-options-page/</a></p>
<p>There is a deprecated tag</p>
<pre><code>add_contextual_help
</code><... | [
{
"answer_id": 131063,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Information attached to the <code>wp_head</code> action hook is <code>echo</code>ed (if it needs to be <code... | 2014/01/24 | [
"https://wordpress.stackexchange.com/questions/131082",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45477/"
] | I followed this tutorial: <http://wp.tutsplus.com/tutorials/using-the-settings-api-part-1-create-a-theme-options-page/>
There is a deprecated tag
```
add_contextual_help
```
It says to use this instead
```
get_current_screen()->add_help_tab()
```
However, I don't understand how to translate add\_contextual\_help... | I managed to find this post:
<https://wordpress.stackexchange.com/a/75168/45611>
It basically had what I needed.
```
/*
* This whole block here changes the og:url that Wordpress Seo Yoast provides
* It uses the addthis_share_url custom field, and if it is not present, it defaults
* to the permalink, just like the ... |
131,127 | <p>I'm working with a frontend upload form that uses blueimp jQuery-File-Uploader to do all the heavy lifting ... but, after attempting to add the necessary WordPress functionality to blueimp I started running into some errors that I am unable to figure out.</p>
<p><strong>Update / My code</strong></p>
<p>HTML (the f... | [
{
"answer_id": 133705,
"author": "user3111957",
"author_id": 47252,
"author_profile": "https://wordpress.stackexchange.com/users/47252",
"pm_score": -1,
"selected": false,
"text": "<p>I recently modified a Wordpress page to include the file upload plugin. On a standalone test page the co... | 2014/01/25 | [
"https://wordpress.stackexchange.com/questions/131127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40491/"
] | I'm working with a frontend upload form that uses blueimp jQuery-File-Uploader to do all the heavy lifting ... but, after attempting to add the necessary WordPress functionality to blueimp I started running into some errors that I am unable to figure out.
**Update / My code**
HTML (the frontend form):
```
<form id="... | After doing tests and working with a friend I was able to find a solution:
Just change how the function `get_full_url` grabs the url:
```
// Go to 'protected function get_full_url()'
// Line 200 (approx. if you've made the same changes stated above) in UploadHandler.php
// change this line, should be the last one in... |
131,177 | <p>I've got two different loops. The default on the homepage, but a secondary loop on the archive page. It grabs all the content, like so:</p>
<pre><code><?php // WP_Query arguments
$args = array (
'posts_per_page' => '3'
);
// The Query
$archiveQuery = new WP_Query( $args );
// The Loop
if ( $archi... | [
{
"answer_id": 131183,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/posts_nav_link\" rel=\"nofollow noreferrer\"><code>p... | 2014/01/25 | [
"https://wordpress.stackexchange.com/questions/131177",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33541/"
] | I've got two different loops. The default on the homepage, but a secondary loop on the archive page. It grabs all the content, like so:
```
<?php // WP_Query arguments
$args = array (
'posts_per_page' => '3'
);
// The Query
$archiveQuery = new WP_Query( $args );
// The Loop
if ( $archiveQuery->have_posts(... | [`posts_nav_link`](http://codex.wordpress.org/Function_Reference/posts_nav_link) is intended for archive pages. That function uses `get_next_posts_nav_link` which [uses the `global` variable `$wp_query`](https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/link-template.php#L1720). There is a check for `!... |
131,194 | <p>I want to redirect to a page to my home page if there would be found only one post.I have tried below code but it is
not working, i have also tried header("location:url"), but it is also not working.</p>
<pre><code> <?php
$args = array(
'post_type' => 'post',
'posts_per_page'=> 10,
... | [
{
"answer_id": 131203,
"author": "Akshay Paghdar",
"author_id": 33512,
"author_profile": "https://wordpress.stackexchange.com/users/33512",
"pm_score": -1,
"selected": false,
"text": "<p>May be this will help you...</p>\n\n<p>Try Following code :--</p>\n\n<pre><code><?php\n $arg... | 2014/01/25 | [
"https://wordpress.stackexchange.com/questions/131194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45341/"
] | I want to redirect to a page to my home page if there would be found only one post.I have tried below code but it is
not working, i have also tried header("location:url"), but it is also not working.
```
<?php
$args = array(
'post_type' => 'post',
'posts_per_page'=> 10,
'post_status' => '... | You need to redirect before any content is sent to the browser. If you had [debugging](http://codex.wordpress.org/Debugging_in_WordPress) enabled, you'd see errors about headers already being sent.
The question is light on detail but if there is a way to avoid the secondary loop and use the main query this should wor... |
131,199 | <p>Gravity Forms adds a Admin Menu called Entries that points to page=gf_entries. I am trying to modify this URL so that it defaults to page=gf_entries&id=2 instead. Below is the order of my WordPress Admin Menu. How can I update the URL of the Entries menu item?</p>
<pre><code>Dashboard
Posts
Media
Forms
-Forms
-... | [
{
"answer_id": 131214,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 3,
"selected": true,
"text": "<p>Solution -</p>\n\n<pre><code>add_action( 'admin_menu', 'wpse_admin_menu', 100 );\nfunction wpse_admin_menu()\n... | 2014/01/25 | [
"https://wordpress.stackexchange.com/questions/131199",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Gravity Forms adds a Admin Menu called Entries that points to page=gf\_entries. I am trying to modify this URL so that it defaults to page=gf\_entries&id=2 instead. Below is the order of my WordPress Admin Menu. How can I update the URL of the Entries menu item?
```
Dashboard
Posts
Media
Forms
-Forms
-New Form
-Entrie... | Solution -
```
add_action( 'admin_menu', 'wpse_admin_menu', 100 );
function wpse_admin_menu()
{
global $menu, $submenu;
$parent = 'gf_edit_forms';
if( !isset($submenu[$parent]) )
return;
foreach( $submenu[$parent] as $k => $d ){
if( $d['2'] == 'gf_entries' )
{
$subm... |
131,206 | <p>I want to redirect the <a href="http://xyz.com/freebooks/" rel="nofollow">http://xyz.com/freebooks/</a> to <a href="http://xyz.com/shop/?min_price=0&max_price=0" rel="nofollow">http://xyz.com/shop/?min_price=0&max_price=0</a></p>
<p>I added this to the .htaccess and it redirects to the shop page but doesn't... | [
{
"answer_id": 131214,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 3,
"selected": true,
"text": "<p>Solution -</p>\n\n<pre><code>add_action( 'admin_menu', 'wpse_admin_menu', 100 );\nfunction wpse_admin_menu()\n... | 2014/01/25 | [
"https://wordpress.stackexchange.com/questions/131206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45673/"
] | I want to redirect the <http://xyz.com/freebooks/> to <http://xyz.com/shop/?min_price=0&max_price=0>
I added this to the .htaccess and it redirects to the shop page but doesn't retain the /freebooks/ or filters like the original url.
**.htaccees**:
```
RewriteEngine On
RewriteRule ^freebooks$ index.php?p=5&min_price... | Solution -
```
add_action( 'admin_menu', 'wpse_admin_menu', 100 );
function wpse_admin_menu()
{
global $menu, $submenu;
$parent = 'gf_edit_forms';
if( !isset($submenu[$parent]) )
return;
foreach( $submenu[$parent] as $k => $d ){
if( $d['2'] == 'gf_entries' )
{
$subm... |
131,215 | <p>I have a variable like this:</p>
<pre><code>$post_content = get_the_content();
</code></pre>
<p>Here I want to remove some specific shortcode from the $post_content variable e.g I want to remove only this <code>[video height="300" width="300" mp4="localhost.com/video.mp4"]</code> all other shortcodes and content f... | [
{
"answer_id": 131240,
"author": "RCNeil",
"author_id": 12294,
"author_profile": "https://wordpress.stackexchange.com/users/12294",
"pm_score": 0,
"selected": false,
"text": "<p>Wouldn't it be </p>\n\n<pre><code>$post_content_without_shortcodes = strip_shortcodes(get_the_content());\n</c... | 2014/01/25 | [
"https://wordpress.stackexchange.com/questions/131215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45269/"
] | I have a variable like this:
```
$post_content = get_the_content();
```
Here I want to remove some specific shortcode from the $post\_content variable e.g I want to remove only this `[video height="300" width="300" mp4="localhost.com/video.mp4"]` all other shortcodes and content formatting should be leaved intact.
... | If you want exactly this shortcode:
```
[video height="300" width="300" mp4="localhost.com/video.mp4"]
```
to output nothing, then you can use the `wp_video_shortcode_override` filter or the `wp_video_shortcode` filter to achieve that.
Here are two such examples:
Example #1
----------
```
/**
* Let the [video] ... |
131,216 | <p>My theme has styling by category using the following code, which inserts the current category's slug as a CSS class.</p>
<pre><code><div class="CategorySpecificStyle
<?php $category = get_the_category(); echo $category[0]->slug; ?>">
<?php echo $category[0]->cat_name; ?>
</di... | [
{
"answer_id": 131221,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p>You will need to query for the parent category data. <a href=\"http://codex.wordpress.org/Function_Reference... | 2014/01/25 | [
"https://wordpress.stackexchange.com/questions/131216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45674/"
] | My theme has styling by category using the following code, which inserts the current category's slug as a CSS class.
```
<div class="CategorySpecificStyle
<?php $category = get_the_category(); echo $category[0]->slug; ?>">
<?php echo $category[0]->cat_name; ?>
</div>
```
Now i'm about to add a large nu... | You will need to use the ID value returned by `$category[0]->category_parent` and pass it through `get_term()`. Example:
```
$category = get_the_category();
$category_parent_id = $category[0]->category_parent;
if ( $category_parent_id != 0 ) {
$category_parent = get_term( $category_parent_id, 'category' );
$c... |
131,248 | <p>In the docs for the translate function <code>__( $text, $domain )</code>, it states that you must put the string directly in place of $text, that you cannot do something clever such as <code>__( $my_text, 'text-domain' );</code>.</p>
<p>However, I am writing a method which takes in a string and needs to pass it to ... | [
{
"answer_id": 131249,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>No</p>\n\n<p>The tools that help in generating a translation can not parse your code and decide what are ... | 2014/01/26 | [
"https://wordpress.stackexchange.com/questions/131248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44304/"
] | In the docs for the translate function `__( $text, $domain )`, it states that you must put the string directly in place of $text, that you cannot do something clever such as `__( $my_text, 'text-domain' );`.
However, I am writing a method which takes in a string and needs to pass it to `__(` ... `)` somehow. Is there ... | You can do it with `printf()`.
E.g.
```
printf( __( 'We deleted %d spam messages.', 'my-text-domain' ), $count );
``` |
131,276 | <p>I just moved my subdomain multisite to a new server and I'm having some trouble with permalinks & redirects.</p>
<p>One difference post-move is that I have moved core WP files into it's own directory <code>/wp</code> (see <a href="https://github.com/roots/bedrock#folder-structure" rel="nofollow">roots/bedrock f... | [
{
"answer_id": 131278,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 0,
"selected": false,
"text": "<p>All WP installs - single and MS - store URL data in the database, both for basic configurations and for path... | 2014/01/26 | [
"https://wordpress.stackexchange.com/questions/131276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12055/"
] | I just moved my subdomain multisite to a new server and I'm having some trouble with permalinks & redirects.
One difference post-move is that I have moved core WP files into it's own directory `/wp` (see [roots/bedrock folder structure](https://github.com/roots/bedrock#folder-structure).
Now when I try to access `/wp... | Well, the answer has several different ways..
==Method 1==
============
(when you want your website permalinks to become like `example.com/wp/smth` )
if so, just change this:
```
RewriteBase /
```
to
```
RewriteBase /wp
```
and in database, change all occurrences of `example.com/` to `example.com/wp/`
==Met... |
131,304 | <p>I am having some difficulty logging into my WordPress site. When I attempt to visit example.com/wp-admin, I see a blank page and the url bar changes to:</p>
<p><a href="http://example.com/wp-login.php?redirect_to=http%3A%2F%2Fmysite.com%2Fwp-admin%2F&reauth=1" rel="noreferrer">http://example.com/wp-login.php?re... | [
{
"answer_id": 168700,
"author": "Luke Rehmann",
"author_id": 63592,
"author_profile": "https://wordpress.stackexchange.com/users/63592",
"pm_score": 2,
"selected": false,
"text": "<p>This could be caused by a wordpress table crashing. \nSetting define('WP_DEBUG', true); in the wp-config... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44754/"
] | I am having some difficulty logging into my WordPress site. When I attempt to visit example.com/wp-admin, I see a blank page and the url bar changes to:
<http://example.com/wp-login.php?redirect_to=http%3A%2F%2Fmysite.com%2Fwp-admin%2F&reauth=1>
If I visit example.com/wp-login.php, I only see a blank white page witho... | Had the same problem... clearing the cookies didn't do the trick.
What did the trick was logging in via **incognito** mode first, and then I was able to login normally. |
131,320 | <pre><code>the_title('<a class="" href="' . get_permalink() . '"><h1 class="">', '</h1></a>');
</code></pre>
<p>anywhere if I use <code>get_permalink()</code> it's just giving <strong>myblog.com/about_us</strong></p>
<p>eg: the above code I am getting H1 link as <strong>myblog.com/about_us</st... | [
{
"answer_id": 131325,
"author": "Akshay Paghdar",
"author_id": 33512,
"author_profile": "https://wordpress.stackexchange.com/users/33512",
"pm_score": 1,
"selected": false,
"text": "<p>Pass ID of post/page that you want to get link...</p>\n\n<p>like this:-- </p>\n\n<pre><code>//if you a... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131320",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43764/"
] | ```
the_title('<a class="" href="' . get_permalink() . '"><h1 class="">', '</h1></a>');
```
anywhere if I use `get_permalink()` it's just giving **myblog.com/about\_us**
eg: the above code I am getting H1 link as **myblog.com/about\_us**
weird... how can I solve this? | Pass ID of post/page that you want to get link...
like this:--
```
//if you are in loop.
$id = get_the_ID();
//If you are not in loop, simply pass post/page ID.
the_title('<a class="" href="' . get_permalink($id) . '"><h1 class="">', '</h1></a>');
``` |
131,331 | <p>I am breaking my head from last 1 hour but not getting any idea that what's going wrong with my code...</p>
<p>I am developing my own plugin and I am using <code>wp_mail()</code> function for sending mail in that but it's not sending mail it seems.</p>
<p>I tried to use PHP Mailer which is working fine but I want ... | [
{
"answer_id": 131339,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 0,
"selected": false,
"text": "<p>Try using the <code>$headers</code> as a string, and giving a name to the email.</p>\n\n<pre><code>$headers = ... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41362/"
] | I am breaking my head from last 1 hour but not getting any idea that what's going wrong with my code...
I am developing my own plugin and I am using `wp_mail()` function for sending mail in that but it's not sending mail it seems.
I tried to use PHP Mailer which is working fine but I want to use `wp_mail()`.. this is... | Since PHP Mailer is working fine do you have the same credentials setup for wp\_mail? If you're using an authenticated SMTP for PHP Mailer then you'll possibly need a plugin to get the authentication into wp\_mail. There are a few different ones that all work but one is <https://wordpress.org/plugins/wp-mail-smtp/> for... |
131,387 | <p>I'm not sure WordPress was build for this, but this is what I'm trying to achieve:</p>
<ul>
<li>I want to make a specific URL inside wordpress accessible, for example <code>www.example.com/some-template</code> .</li>
<li>This specific URL should be editable from a php file, part of an existing wordpress theme I'm ... | [
{
"answer_id": 131389,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 1,
"selected": false,
"text": "<p>You could do it the very simple way, putting your file <code>some-template.php</code> in the root directory of... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43477/"
] | I'm not sure WordPress was build for this, but this is what I'm trying to achieve:
* I want to make a specific URL inside wordpress accessible, for example `www.example.com/some-template` .
* This specific URL should be editable from a php file, part of an existing wordpress theme I'm working on, something like `some-... | You may use `template_redirect` action:
```
add_action( 'template_redirect', 'wpse131387_template_redirect' );
function wpse131387_template_redirect( ){
if ($_SERVER['REQUEST_URI'] == '/some-template') {
global $wp_query;
$wp_query->is_404 = false;
status_header(200);
include(dirnam... |
131,394 | <p>There is an opt-in filter that allows all plugins on my site to receive automatic updates:</p>
<p><code>add_filter( 'auto_update_plugin', '__return_true' );</code></p>
<p>I like this feature, but I don't want all my plugins to be updated automatically. How can I allow some plugins to be updated automatically, whil... | [
{
"answer_id": 131404,
"author": "David",
"author_id": 20963,
"author_profile": "https://wordpress.stackexchange.com/users/20963",
"pm_score": 5,
"selected": true,
"text": "<p>Instead of using the code from the question in functions.php, replace it with this:</p>\n\n<pre><code>/**\n * Pr... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20963/"
] | There is an opt-in filter that allows all plugins on my site to receive automatic updates:
`add_filter( 'auto_update_plugin', '__return_true' );`
I like this feature, but I don't want all my plugins to be updated automatically. How can I allow some plugins to be updated automatically, while excluding those I want to ... | Instead of using the code from the question in functions.php, replace it with this:
```
/**
* Prevent certain plugins from receiving automatic updates, and auto-update the rest.
*
* To auto-update certain plugins and exclude the rest, simply remove the "!" operator
* from the function.
*
* Also, by using the 'au... |
131,399 | <p>I have a WordPress installation at the document root for <a href="http://www.bradleycountypulse.com" rel="noreferrer">a domain</a>, and then an additional installation in <a href="http://www.bradleycountypulse.com/classifieds" rel="noreferrer">an immediate subdirectory</a> of that installation such that I may use di... | [
{
"answer_id": 131403,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 3,
"selected": false,
"text": "<p>You can share user tables between different WordPress installations by installing the second site (\"Site B\") ... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131399",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45752/"
] | I have a WordPress installation at the document root for [a domain](http://www.bradleycountypulse.com), and then an additional installation in [an immediate subdirectory](http://www.bradleycountypulse.com/classifieds) of that installation such that I may use different themes for the two. I want to link the two sites lo... | You can share user tables between different WordPress installations by installing the second site ("Site B") to use the original site's ("Site A") database, then choosing to use an alternate table prefix during installation so as to keep the rest of the data separate.
The second part of the problem is sharing login co... |
131,405 | <p>I've started using the dashicon fonts in my theme options page for WP 3.8+ users. To take care of users on < 3.8, I've added the dashicon fonts to my theme folder and also an entry at the top of my custom admin stylesheet:</p>
<pre><code>@font-face {
font-family: 'dashicons';
src: url('fonts/dashicons.eo... | [
{
"answer_id": 131407,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>This happens sometimes when the font is sent with a wrong MIME type. <code>application/x-font-woff</code> for example,... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | I've started using the dashicon fonts in my theme options page for WP 3.8+ users. To take care of users on < 3.8, I've added the dashicon fonts to my theme folder and also an entry at the top of my custom admin stylesheet:
```
@font-face {
font-family: 'dashicons';
src: url('fonts/dashicons.eot');
}
@font-fac... | This happens sometimes when the font is sent with a wrong MIME type. `application/x-font-woff` for example, [is wrong](http://www.iana.org/assignments/media-types/application/font-woff).
Try to add proper MIME types to your server configuration. In Apache, your can do that in a `.htaccess`:
```
AddType image/svg+xml ... |
131,410 | <p>According to <a href="https://wordpress.stackexchange.com/questions/6712/how-to-set-configuration-options-for-particular-sub-blogs">this question</a>, it's possible to turn on/off <code>WP_DEBUG</code> for specific sites on a multisite.</p>
<p>Is it possible to do this with a <strong>sub-directory multisite</strong... | [
{
"answer_id": 131429,
"author": "user42826",
"author_id": 42826,
"author_profile": "https://wordpress.stackexchange.com/users/42826",
"pm_score": 3,
"selected": true,
"text": "<p>You can do this by adding some code to wp-config.php</p>\n\n<pre><code>$request_uri = $_SERVER['REQUEST_URI'... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34751/"
] | According to [this question](https://wordpress.stackexchange.com/questions/6712/how-to-set-configuration-options-for-particular-sub-blogs), it's possible to turn on/off `WP_DEBUG` for specific sites on a multisite.
Is it possible to do this with a **sub-directory multisite**? | You can do this by adding some code to wp-config.php
```
$request_uri = $_SERVER['REQUEST_URI'];
$debug_dirs = array ('/debug-dir1/','/debug-dir2/'); // list of directories to turn on debugging
foreach ($debug_dirs as $debug_dir) {
if (!strncmp($request_uri,$debug_dir,strlen($debug_dir))) {
define('WP_DEBU... |
131,411 | <p>I have over 400 posts with images inside them, I have got a new template which requires a featured image for each post, something my last template did not require... I am wondering if there is a script I can add to my functions.php to be able to grab the first image in each post and set it as the featured... So far ... | [
{
"answer_id": 131436,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>Regarding the code you posted, I would say some things:</p>\n\n<ul>\n<li>you can avoid using 6 different acti... | 2014/01/27 | [
"https://wordpress.stackexchange.com/questions/131411",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45756/"
] | I have over 400 posts with images inside them, I have got a new template which requires a featured image for each post, something my last template did not require... I am wondering if there is a script I can add to my functions.php to be able to grab the first image in each post and set it as the featured... So far i h... | Regarding the code you posted, I would say some things:
* you can avoid using 6 different actions because one is enough: `'save_post'` is triggered everytime a post is created or updated
* you can drop globalize `$post`: `'save_post'` will pass the post id, you can use it, in addition, preparing the function to receiv... |
131,421 | <p>I moved a Wordpress install from /wordpress/ folder to root by just copying the index and .htaccess file to root and then updating the permalinks etc.</p>
<p>All works fine but I have a problem with the menu in the top nav.</p>
<p>The menu works fine while you're on the main page and scrolls down to the area it sh... | [
{
"answer_id": 131436,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>Regarding the code you posted, I would say some things:</p>\n\n<ul>\n<li>you can avoid using 6 different acti... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34987/"
] | I moved a Wordpress install from /wordpress/ folder to root by just copying the index and .htaccess file to root and then updating the permalinks etc.
All works fine but I have a problem with the menu in the top nav.
The menu works fine while you're on the main page and scrolls down to the area it should be. But when... | Regarding the code you posted, I would say some things:
* you can avoid using 6 different actions because one is enough: `'save_post'` is triggered everytime a post is created or updated
* you can drop globalize `$post`: `'save_post'` will pass the post id, you can use it, in addition, preparing the function to receiv... |
131,425 | <p>I'm working on a pretty complicated site where everything is managed by category type including automatic spinner image submission, etc.. Unfortunately, its doggone difficult to manage things when the admin panel "All Posts" sorts them by date (DESC) I'm thinking it sure would be handy to have the show "All Posts" i... | [
{
"answer_id": 131438,
"author": "1fixdotio",
"author_id": 45728,
"author_profile": "https://wordpress.stackexchange.com/users/45728",
"pm_score": 1,
"selected": false,
"text": "<p>zip, you might need to save your category as a new post meta first, that's how orderby meta_value works.</p... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131425",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45680/"
] | I'm working on a pretty complicated site where everything is managed by category type including automatic spinner image submission, etc.. Unfortunately, its doggone difficult to manage things when the admin panel "All Posts" sorts them by date (DESC) I'm thinking it sure would be handy to have the show "All Posts" in c... | zip, you might need to save your category as a new post meta first, that's how orderby meta\_value works.
Not sure if this could help, I stumbled upon this plugin: <http://wordpress.org/plugins/custom-post-order-category/>, it could let you specified a category then order posts in that category.
If you're curious abo... |
131,444 | <p>I'm coming over from Drupal and I'm very used to the way Drupal handles users and objects (called nodes over there.) I have to learn how WordPress handles these same situations.</p>
<p>Since we're going to be confused with the same words that mean different things, I will define some of them here:</p>
<ul>
<li><st... | [
{
"answer_id": 131458,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>This is a very general question and so will be the answer - \"Anyway you like\".</p>\n\n<p>AFAIK Wordpres... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45709/"
] | I'm coming over from Drupal and I'm very used to the way Drupal handles users and objects (called nodes over there.) I have to learn how WordPress handles these same situations.
Since we're going to be confused with the same words that mean different things, I will define some of them here:
* **Node** - In Drupal, ev... | I don't know Drupal, however, seems to me that what is "node" in drupal is "post type" in WordPress.
By default WordPress has several post types: posts, pages, atthachments, menu items, revisions (these post types are often referred as "built-in").
You can register any number of custom post types, aka CPT.
Post type... |
131,466 | <p>I am add new post type called <strong>journal</strong> using below code it works fine. But I now I need to add a single category for this post type. That is I have two types of journal category <strong>normal journal</strong> and <strong>featured journals</strong>. But my blog post has some more categories I need t... | [
{
"answer_id": 131467,
"author": "desmillicious",
"author_id": 34976,
"author_profile": "https://wordpress.stackexchange.com/users/34976",
"pm_score": 0,
"selected": false,
"text": "<p>Categories are actually a \"taxonomy\" for the <code>post</code> post type, so you need to add a new ta... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43523/"
] | I am add new post type called **journal** using below code it works fine. But I now I need to add a single category for this post type. That is I have two types of journal category **normal journal** and **featured journals**. But my blog post has some more categories I need to display only **normal journal** and **fea... | You can add this line to the code which registers your Custom Post Type:
```
'taxonomies' => array( 'category' ),
```
Or you could add Taxonomies rather than categories:
```
add_action( 'init', 'cpt_type_taxonomy' );
function cpt_type_taxonomy() {
register_taxonomy( 'portfolio-type', 'portfolio',
array(
... |
131,479 | <p>I have several pages, which are ordered like this:</p>
<pre><code>Home
Projects
- Project 1
-- Project 1 Subpage 1
-- Project 1 Subpage 2
- Project 2
-- ...
</code></pre>
<p>And I want to change the background color (in this case of <code>.site-main {}</code> or any other css classes) depending on the page the use... | [
{
"answer_id": 131484,
"author": "Circuit Circus",
"author_id": 17778,
"author_profile": "https://wordpress.stackexchange.com/users/17778",
"pm_score": 1,
"selected": false,
"text": "<p>Brad Dalton already gave a bit to answer this — add a body class (<code><body <?php body_class('... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131479",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45158/"
] | I have several pages, which are ordered like this:
```
Home
Projects
- Project 1
-- Project 1 Subpage 1
-- Project 1 Subpage 2
- Project 2
-- ...
```
And I want to change the background color (in this case of `.site-main {}` or any other css classes) depending on the page the user is right now.
1. Currently on Home... | Another solution could be you register a meta box for the project pages which lets you type in whatever class name you want for each page…
```
function add_project_page_metabox() {
add_meta_box(
'project_page_meta', // $id
'Project Meta',
// $title
'ppm_callbac... |
131,487 | <p>Let's say in my theme functions.php file, I included a php file that's only accessible in the admin control panel and named theme-options.php.</p>
<pre><code>require_once ( get_template_directory() . '/theme-options.php' );
</code></pre>
<p>As I said, this file is accessible in the admin control panel only with th... | [
{
"answer_id": 131489,
"author": "Nikola R.",
"author_id": 45784,
"author_profile": "https://wordpress.stackexchange.com/users/45784",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, functions.php in the active theme directory is executed in front-end, but \nthere is a simple solution... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131487",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37529/"
] | Let's say in my theme functions.php file, I included a php file that's only accessible in the admin control panel and named theme-options.php.
```
require_once ( get_template_directory() . '/theme-options.php' );
```
As I said, this file is accessible in the admin control panel only with this basic structure into it... | >
> My questions is, does this file get executed when browsing from the
> front end?
>
>
>
Well, yes and no.
Your file will be included on the front end when using the theme in question, but as your code is *hooked* to admin-only hooks, nothing really executes. The file is read but the code doesn't do anything e... |
131,488 | <p>I am trying to save secondary role field in user-edit.php which is independent of WP's main roles. I had no problem with saving other custom fields that are unique but for roles (wp_capabilities), it looks like it first saves my roles (I set sleep(10) to check in database in the process) and at the end of request, W... | [
{
"answer_id": 131498,
"author": "Jörn Lund",
"author_id": 35723,
"author_profile": "https://wordpress.stackexchange.com/users/35723",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the third argument of <code>add_action</code> to set the filter priority. The functions default... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45784/"
] | I am trying to save secondary role field in user-edit.php which is independent of WP's main roles. I had no problem with saving other custom fields that are unique but for roles (wp\_capabilities), it looks like it first saves my roles (I set sleep(10) to check in database in the process) and at the end of request, WP ... | I have finally found solution and the right hook for this: `profile_update` is called at the end of `wp_insert_user` in `user.php` which is called from `edit_user`.
wp\_insert\_user ending:
```
if ( $update )
do_action('profile_update', $user_id, $old_user_data);
else
do_action('user_register', $u... |
131,497 | <p><em>I'm trying to go about this without the use of a plugin, but actions and filters</em></p>
<p>Is there a way to remove extra image sizes generated by WordPress based on the Custom Post Type? I've been trying to work with the <code>intermediate_image_sizes_advanced</code> filter but it doesn't look like it has ac... | [
{
"answer_id": 131835,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 4,
"selected": true,
"text": "<p>May be this filter should work <a href=\"https://github.com/WordPress/WordPress/blob/e1759d668ab4aadda5... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131497",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | *I'm trying to go about this without the use of a plugin, but actions and filters*
Is there a way to remove extra image sizes generated by WordPress based on the Custom Post Type? I've been trying to work with the `intermediate_image_sizes_advanced` filter but it doesn't look like it has access to `$post` or `post_typ... | May be this filter should work [intermediate\_image\_sizes](https://github.com/WordPress/WordPress/blob/e1759d668ab4aadda588b34a2bc1cc5e0ecc4213/wp-includes/media.php#L494)
**Note:** This solution will work if you are uploading an image from post edit screen. (tested on localhost with WP-3.8.1)
```
add_filter( 'inter... |
131,499 | <p>I keep getting the following message in the browser <code>Fatal error: Call to undefined function plugin_url() in</code> </p>
<p>My code at present:</p>
<pre><code>add_action( 'wp_enqueue_script', 'load_jquery2' );
function load_jquery2() {
wp_enqueue_script( 'jquery' ); }
function add_my_css_and_my_js_... | [
{
"answer_id": 131835,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 4,
"selected": true,
"text": "<p>May be this filter should work <a href=\"https://github.com/WordPress/WordPress/blob/e1759d668ab4aadda5... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131499",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I keep getting the following message in the browser `Fatal error: Call to undefined function plugin_url() in`
My code at present:
```
add_action( 'wp_enqueue_script', 'load_jquery2' );
function load_jquery2() {
wp_enqueue_script( 'jquery' ); }
function add_my_css_and_my_js_files(){
wp_enqueue_scrip... | May be this filter should work [intermediate\_image\_sizes](https://github.com/WordPress/WordPress/blob/e1759d668ab4aadda588b34a2bc1cc5e0ecc4213/wp-includes/media.php#L494)
**Note:** This solution will work if you are uploading an image from post edit screen. (tested on localhost with WP-3.8.1)
```
add_filter( 'inter... |
131,507 | <p>I used Ian Stewart's Simple WordPress Theme Options Page (<a href="http://themeshaper.com/2010/06/03/sample-theme-options" rel="nofollow">Source^</a>) for my client's site, where I assigned my client as an Editor. But from the Editor account the <strong>Theme Options</strong> link is not visible.</p>
<p>I checked t... | [
{
"answer_id": 131835,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 4,
"selected": true,
"text": "<p>May be this filter should work <a href=\"https://github.com/WordPress/WordPress/blob/e1759d668ab4aadda5... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | I used Ian Stewart's Simple WordPress Theme Options Page ([Source^](http://themeshaper.com/2010/06/03/sample-theme-options)) for my client's site, where I assigned my client as an Editor. But from the Editor account the **Theme Options** link is not visible.
I checked the `theme-options.php` for `add_theme_page()`, wh... | May be this filter should work [intermediate\_image\_sizes](https://github.com/WordPress/WordPress/blob/e1759d668ab4aadda588b34a2bc1cc5e0ecc4213/wp-includes/media.php#L494)
**Note:** This solution will work if you are uploading an image from post edit screen. (tested on localhost with WP-3.8.1)
```
add_filter( 'inter... |
131,536 | <p>I like to secure a certain page for admins. How do I check if a user is logged (and is admin)? Of their not logged in, I want to show the login module.</p>
| [
{
"answer_id": 131540,
"author": "Kanta",
"author_id": 45814,
"author_profile": "https://wordpress.stackexchange.com/users/45814",
"pm_score": 1,
"selected": false,
"text": "<p>Alternatively you can set a page as PRIVATE and give a password for it. You get this option when you \"Quick Ed... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20548/"
] | I like to secure a certain page for admins. How do I check if a user is logged (and is admin)? Of their not logged in, I want to show the login module. | ```
if(!current_user_can('administrator')) {
wp_redirect( wp_login_url() );
}
```
This will redirect non-admins to login URL. Of course, logged in non-admins will be a bit confused. You'll want to run this before `get_header()` |
131,551 | <p>I've managed to loop through the current month's posts in January but I am trying to get the previous month's posts in December of the previous year. I think this is where the problem might be, that it is 2014 and the the posts I am after is in 2013 (Dec). I'd appreciate it if someone can spot the problem. I have be... | [
{
"answer_id": 131540,
"author": "Kanta",
"author_id": 45814,
"author_profile": "https://wordpress.stackexchange.com/users/45814",
"pm_score": 1,
"selected": false,
"text": "<p>Alternatively you can set a page as PRIVATE and give a password for it. You get this option when you \"Quick Ed... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12589/"
] | I've managed to loop through the current month's posts in January but I am trying to get the previous month's posts in December of the previous year. I think this is where the problem might be, that it is 2014 and the the posts I am after is in 2013 (Dec). I'd appreciate it if someone can spot the problem. I have been ... | ```
if(!current_user_can('administrator')) {
wp_redirect( wp_login_url() );
}
```
This will redirect non-admins to login URL. Of course, logged in non-admins will be a bit confused. You'll want to run this before `get_header()` |
131,562 | <p>I have a website using WordPress, and an e-commerce using WooCommerce. I would like my shop (and all its pages) to be seen by logged in users only.</p>
<p>Via the <em>User Access Manager</em> plugin, I have denied access to the shop page, but with a direct link to a product etc. one can access that particular page ... | [
{
"answer_id": 131563,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 6,
"selected": true,
"text": "<p>Put this in your <code>functions.php</code> file:</p>\n\n<pre><code>function wpse_131562_redirect() {\n if... | 2014/01/28 | [
"https://wordpress.stackexchange.com/questions/131562",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45822/"
] | I have a website using WordPress, and an e-commerce using WooCommerce. I would like my shop (and all its pages) to be seen by logged in users only.
Via the *User Access Manager* plugin, I have denied access to the shop page, but with a direct link to a product etc. one can access that particular page nonetheless, even... | Put this in your `functions.php` file:
```
function wpse_131562_redirect() {
if (
! is_user_logged_in()
&& (is_woocommerce() || is_cart() || is_checkout())
) {
// feel free to customize the following line to suit your needs
wp_redirect(home_url());
exit;
}
}
add_acti... |
131,582 | <p>Just installed Wordpress 3.8.1 multisite but can't remove the /blog/ slug. I've tried all suggestions for older versions of Wordpress (including the solutions to the question posted on this site 6 months ago regarding removing from root) to no avail. Anybody know how to fix this or if it's possible to fix?</p>
<p... | [
{
"answer_id": 132227,
"author": "Jim",
"author_id": 46074,
"author_profile": "https://wordpress.stackexchange.com/users/46074",
"pm_score": -1,
"selected": false,
"text": "<p>In your main install folder is: <code>wp-admin/options-permalink.php</code></p>\n\n<p>Change:</p>\n\n<pre><code>... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45830/"
] | Just installed Wordpress 3.8.1 multisite but can't remove the /blog/ slug. I've tried all suggestions for older versions of Wordpress (including the solutions to the question posted on this site 6 months ago regarding removing from root) to no avail. Anybody know how to fix this or if it's possible to fix?
I need two ... | I fixed this in the following way.
Go to the "Network admin". Then Sites → Edit → Settings → Permalink Structure. Remove `blog` from it.
Then I removed `blog` from two lines in table which obtained as a result of the query:
```
SELECT * FROM wp_options WHERE option_name = "permalink_structure" OR option_name = "rewr... |
131,585 | <p>I am going to make a "favourite" posts box, but the article id's are stored in another DB so I only get an array of IDs (which <strong>are</strong> relevant to the WP DB).</p>
<p>I think it could be done with <code>get_posts()</code> or simply just with <code>WP_Query</code>, however as I am surfing through the cod... | [
{
"answer_id": 132227,
"author": "Jim",
"author_id": 46074,
"author_profile": "https://wordpress.stackexchange.com/users/46074",
"pm_score": -1,
"selected": false,
"text": "<p>In your main install folder is: <code>wp-admin/options-permalink.php</code></p>\n\n<p>Change:</p>\n\n<pre><code>... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45050/"
] | I am going to make a "favourite" posts box, but the article id's are stored in another DB so I only get an array of IDs (which **are** relevant to the WP DB).
I think it could be done with `get_posts()` or simply just with `WP_Query`, however as I am surfing through the codex I cant find solution to my problem - you c... | I fixed this in the following way.
Go to the "Network admin". Then Sites → Edit → Settings → Permalink Structure. Remove `blog` from it.
Then I removed `blog` from two lines in table which obtained as a result of the query:
```
SELECT * FROM wp_options WHERE option_name = "permalink_structure" OR option_name = "rewr... |
131,588 | <p>This concerns a problem <a href="http://www.thebigquestions.com/blog" rel="nofollow">at my blog</a>.</p>
<p>My provider recently required me to upgrade from PHP 5.2 to PHP 5.4. This in turn required me to update WordPress.</p>
<p>Ever since the dual update, all line breaks in comments are rendering as "rn", so th... | [
{
"answer_id": 131744,
"author": "Steven Landsburg",
"author_id": 45831,
"author_profile": "https://wordpress.stackexchange.com/users/45831",
"pm_score": -1,
"selected": false,
"text": "<p>So it turns out that I solved the problem by editing the file wp-comments-post.php, where the follo... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45831/"
] | This concerns a problem [at my blog](http://www.thebigquestions.com/blog).
My provider recently required me to upgrade from PHP 5.2 to PHP 5.4. This in turn required me to update WordPress.
Ever since the dual update, all line breaks in comments are rendering as "rn", so that if you type this:
```
Hi
<br><br>
Hello
... | The above answer ("So it turns out") turns out not to be the answer after all. With the fix described there, comments that *I* submitted were rendered correctly but comments that others submitted were not (even though I was submitting through the same comment interface that everyone else was). Go figure.
Anyway, the r... |
131,649 | <p>I am using <code>pre_get_posts()</code> to allow all posts to be displayed on any category archive. This is because I will provide a javascript sorting and filtering method using isotope.js. Any category page will output all posts, but any that aren't a part of that category will initially be hidden.</p>
<pre><code... | [
{
"answer_id": 131652,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried this?</p>\n\n<pre><code>unset( $query->query_vars['cat'] );\n</code></pre>\n"
},
{
... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28811/"
] | I am using `pre_get_posts()` to allow all posts to be displayed on any category archive. This is because I will provide a javascript sorting and filtering method using isotope.js. Any category page will output all posts, but any that aren't a part of that category will initially be hidden.
```
function show_all_cats( ... | Just unsetting the cat variable probably isn't enough. The `pre_get_posts` hook happens after the query variables have already been parsed. So there's probably a tax\_query with the taxonomy = category and the terms = your category.
You're already dumping the $query in your code, presumably for debugging. So, look at ... |
131,663 | <p>how is it possible that using wp_insert_category throw a fatal error ?</p>
<p>I am using it as explained : <a href="http://codex.wordpress.org/Function_Reference/wp_insert_category" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_insert_category</a>
with no change except: </p>
<pre><code>$cat_defau... | [
{
"answer_id": 131665,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 4,
"selected": true,
"text": "<p>The <code>init</code> action is the wrong place. This is because <code>init</code> runs on all requests, admin or f... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131663",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41032/"
] | how is it possible that using wp\_insert\_category throw a fatal error ?
I am using it as explained : <http://codex.wordpress.org/Function_Reference/wp_insert_category>
with no change except:
```
$cat_defaults = array(
'cat_name' => 'some_name',
'category_description' => 'as asdfasdf sdf adfa fas f',
'ca... | The `init` action is the wrong place. This is because `init` runs on all requests, admin or front-end, but the `wp_insert_category` function is an admin-side only function. You generally don't insert categories from the front end.
Move to a more specific action, one that will be run in the admin side. Probably from yo... |
131,670 | <p>here's what i'm trying to achieve!</p>
<p>HTML:</p>
<pre><code>some text
<!--more-->
some text
</code></pre>
<p>when post is loaded:</p>
<pre><code>some text
MY TEXT WHICH WAS ADDED TO THE MORE TAG
some text
</code></pre>
<p>on my old WP site, i used this to have a banner displayed on posts exactly where ... | [
{
"answer_id": 131667,
"author": "David",
"author_id": 31323,
"author_profile": "https://wordpress.stackexchange.com/users/31323",
"pm_score": 3,
"selected": true,
"text": "<p>There are many »default post types« like <code>post</code>, <code>page</code> or even <code>nav_menu_item</code>... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131670",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45849/"
] | here's what i'm trying to achieve!
HTML:
```
some text
<!--more-->
some text
```
when post is loaded:
```
some text
MY TEXT WHICH WAS ADDED TO THE MORE TAG
some text
```
on my old WP site, i used this to have a banner displayed on posts exactly where the tag was inserted.
unfortunately, i can't get this to work... | There are many »default post types« like `post`, `page` or even `nav_menu_item`. If you talking about `post` as the default just go to Settings → Permalinks admin page, chose »custom structure« and use `/blog/notes/%postname%/` as your structure. |
131,687 | <p>I wrote a function which is supposed to return the number of rows found in a SELECT query but it always either seems to return 0 or an array. I have been messing around with this for about an hour now and I still can't figure it out! I'm sure I'm doing something stupidly wrong.</p>
<p>The MySQL Table</p>
<pre><cod... | [
{
"answer_id": 131693,
"author": "Chittaranjan",
"author_id": 43031,
"author_profile": "https://wordpress.stackexchange.com/users/43031",
"pm_score": 2,
"selected": false,
"text": "<p>Seems the query is wrong. <code>$ip</code> is string so you should put single quote around that as below... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131687",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22588/"
] | I wrote a function which is supposed to return the number of rows found in a SELECT query but it always either seems to return 0 or an array. I have been messing around with this for about an hour now and I still can't figure it out! I'm sure I'm doing something stupidly wrong.
The MySQL Table
```
+--------+---------... | If you are merely trying to get a count, `$wpdb->get_var();` along with using `COUNT()` in your sql will be better:
```
### Search for IP in database
function postviews_get_ip($id, $ip) {
global $post, $wpdb;
$rowcount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->wp_postviews_ips WHERE postid = $id AND ip = ... |
131,694 | <p>I want to remove the author name from every post. O am using a website in wordpress.org. and I'm using <code>tweenty fourteen</code> theme.</p>
<p>How to remove the author name?</p>
<p>Do I have to go to the <code>Author template</code> (author.php)? </p>
<p>And then will I edit here </p>
<pre><code> <?... | [
{
"answer_id": 131700,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 1,
"selected": false,
"text": "<p>First, rather than directly editing a template from the <code>twentyfourteen</code> theme, I'd recommend u... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to remove the author name from every post. O am using a website in wordpress.org. and I'm using `tweenty fourteen` theme.
How to remove the author name?
Do I have to go to the `Author template` (author.php)?
And then will I edit here
```
<?php
/**
* The template for displaying Author archive pages
*
... | First you need to have a child theme.
Add this to your style.css of your child theme
```
.entry-meta .byline { display: none; }
```
This should remove only the author from the post.
Here's a bit more information on customizing twenty fourteen theme in wordpress:
<http://techdwarf.com/customize-twenty-fourteen-the... |
131,697 | <h1>The Problem</h1>
<p>We all have been in a situation like this, and a lot of questions on this site need a solution like this. You either have to update a database, insert a lot of data automatically, convert <code>meta_keys</code>, or something similar.</p>
<p><em>Of course, in a running system based on best prac... | [
{
"answer_id": 131698,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 6,
"selected": true,
"text": "<p>I for myself use a combination of:</p>\n\n<ul>\n<li>one file dedicated to the one-time script</li>\n<li>using a... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15680/"
] | The Problem
===========
We all have been in a situation like this, and a lot of questions on this site need a solution like this. You either have to update a database, insert a lot of data automatically, convert `meta_keys`, or something similar.
*Of course, in a running system based on best practises this should not... | I for myself use a combination of:
* one file dedicated to the one-time script
* using a transient to stop the script from accidentally running more than once
* using capability-management or user-control to ensure the script is just run by me.
Structure
---------
I use a file (`onetime.php`) in my include-folder `i... |
131,726 | <p>What is the best method, to change the previously declared function into the new one?</p>
<p>for example, there is already declared:</p>
<pre><code>function smth(){
echo 'aaa';
}
</code></pre>
<p>and i want that it displayed not <strong>aaa</strong>, but <strong>bbb</strong></p>
<pre><code>function smth(){
echo ... | [
{
"answer_id": 131732,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": false,
"text": "<p>PHP cannot redeclare functions. You will need to use some other approach, like filters or similar.</p>\n"
},
{... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33667/"
] | What is the best method, to change the previously declared function into the new one?
for example, there is already declared:
```
function smth(){
echo 'aaa';
}
```
and i want that it displayed not **aaa**, but **bbb**
```
function smth(){
echo 'bbb';
}
```
but when i insert the new function (*inside functions.p... | PHP cannot redeclare functions. You will need to use some other approach, like filters or similar. |
131,733 | <p>I am working on a Woocommerce Wordpress site.</p>
<p>I want to hide a widget in frontend to non-logged in users.</p>
<p>The widget is "filter by price" from Woocommerce. I'm also using the "Catalog Visibility Options" because I am not able to show prices to non logged-in users.</p>
<p>I'm using canvas theme and a... | [
{
"answer_id": 131735,
"author": "eteich",
"author_id": 10301,
"author_profile": "https://wordpress.stackexchange.com/users/10301",
"pm_score": 1,
"selected": false,
"text": "<p>FInd out where the widget is being called and wrap like this:</p>\n\n<pre><code> if ( is_user_logged_in()... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am working on a Woocommerce Wordpress site.
I want to hide a widget in frontend to non-logged in users.
The widget is "filter by price" from Woocommerce. I'm also using the "Catalog Visibility Options" because I am not able to show prices to non logged-in users.
I'm using canvas theme and a child theme.
I want to... | **Tested on Twenty Fourteen and works.**
Change the loop\_start hook to another position if needed.
The code goes at the end of your child themes functions.php file.
```
function wpsites_register_widget() {
register_sidebar( array(
'name' => 'Logged In Only Widget',
'id' => 'members-widget',
'before_widget' => '<d... |
131,749 | <p>Using the following code in a category template, but instead of showing the current category page that I am on, it displays the first category of the first post. For example on Food category page it should say Food, but instead it says Desserts because the first post's category is desserts. Here is the site <a href=... | [
{
"answer_id": 131751,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 6,
"selected": true,
"text": "<p>On a category page, you can use the function <a href=\"http://codex.wordpress.org/Function_Reference/single_cat_tit... | 2014/01/29 | [
"https://wordpress.stackexchange.com/questions/131749",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42727/"
] | Using the following code in a category template, but instead of showing the current category page that I am on, it displays the first category of the first post. For example on Food category page it should say Food, but instead it says Desserts because the first post's category is desserts. Here is the site <http://the... | On a category page, you can use the function [`single_cat_title()`](http://codex.wordpress.org/Function_Reference/single_cat_title), or the more generic [`single_term_title()`](http://codex.wordpress.org/Function_Reference/single_term_title). These functions pull from the global `$wp_query` object, via [`get_queried_ob... |
131,753 | <p>I'm looking for solution for a gallery on a WP page that shows multiple thumbnails of images in that gallery, <strong>but not all thumbnails in gallery</strong> (like default Galleries in WP works).
I want (i.e.)certain 3 thumbnail images to show up on page, which (each one of them) leads to the same gallery with mo... | [
{
"answer_id": 131751,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 6,
"selected": true,
"text": "<p>On a category page, you can use the function <a href=\"http://codex.wordpress.org/Function_Reference/single_cat_tit... | 2014/01/30 | [
"https://wordpress.stackexchange.com/questions/131753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45875/"
] | I'm looking for solution for a gallery on a WP page that shows multiple thumbnails of images in that gallery, **but not all thumbnails in gallery** (like default Galleries in WP works).
I want (i.e.)certain 3 thumbnail images to show up on page, which (each one of them) leads to the same gallery with more than 3 images... | On a category page, you can use the function [`single_cat_title()`](http://codex.wordpress.org/Function_Reference/single_cat_title), or the more generic [`single_term_title()`](http://codex.wordpress.org/Function_Reference/single_term_title). These functions pull from the global `$wp_query` object, via [`get_queried_ob... |
131,785 | <p>In the theme twentyfouteen, the <code>full-width</code> class is defined with the following code</p>
<pre><code>if ( ( ! is_active_sidebar( 'sidebar-2' ) )
|| is_page_template( 'page-templates/full-width.php' )
|| is_page_template( 'page-templates/contributors.php' )
|| is_attachment() ) {
$classes[] = 'full-wid... | [
{
"answer_id": 131832,
"author": "1fixdotio",
"author_id": 45728,
"author_profile": "https://wordpress.stackexchange.com/users/45728",
"pm_score": 1,
"selected": false,
"text": "<p>Let's say if you don't like the default <code>page</code> body class which comes with WP by default, you co... | 2014/01/30 | [
"https://wordpress.stackexchange.com/questions/131785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31545/"
] | In the theme twentyfouteen, the `full-width` class is defined with the following code
```
if ( ( ! is_active_sidebar( 'sidebar-2' ) )
|| is_page_template( 'page-templates/full-width.php' )
|| is_page_template( 'page-templates/contributors.php' )
|| is_attachment() ) {
$classes[] = 'full-width';
}
```
from this f... | Thank you for all the insets with this question. Here is what I come up with working from 1fixdotio's answer above. I first had to unset the full-width body class and then register a new body class to incorporate my new sidebar. Here is the code
```
// Remove body class and register new body class to accomodate the ... |
131,796 | <p>I am trying to display one random product in my template header. So each time someone visits or refresh there will be a different product displayed in the header. </p>
<p>I searched and found this</p>
<pre><code><?php
echo do_shortcode('[products ids="1, 2, 3, 4, 5"]');
?>
</code></pre>
<p>But this only dis... | [
{
"answer_id": 131801,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 0,
"selected": false,
"text": "<p>There's a <a href=\"http://docs.woothemes.com/wc-apidocs/source-class-WC_Widget_Random_Products.html\" rel=... | 2014/01/30 | [
"https://wordpress.stackexchange.com/questions/131796",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45901/"
] | I am trying to display one random product in my template header. So each time someone visits or refresh there will be a different product displayed in the header.
I searched and found this
```
<?php
echo do_shortcode('[products ids="1, 2, 3, 4, 5"]');
?>
```
But this only displays products which have ids mentioned... | You could treat products like any other post type and query using [`get_posts()`](http://codex.wordpress.org/Template_Tags/get_posts). Limit the number of posts retrieved to 1 and change the orderby parameter to random:
```
$args = array(
'posts_per_page' => 1,
'orderby' => 'rand',
'post_type' ... |
131,814 | <p>How can I check to see if the current logged-in user is an administrator or an editor?</p>
<p>I know how to do each individually:</p>
<pre><code><?php if(current_user_can('editor')) { ?>
<!-- Stuff here for editors -->
<?php } ?>
<?php if(current_user_can('administrator')) { ?>
&l... | [
{
"answer_id": 131816,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 9,
"selected": true,
"text": "<p>First answer, not WordPress-related because it is just only PHP: Use the logic \"OR\" operator:</p>\n\n<pre><c... | 2014/01/30 | [
"https://wordpress.stackexchange.com/questions/131814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22450/"
] | How can I check to see if the current logged-in user is an administrator or an editor?
I know how to do each individually:
```
<?php if(current_user_can('editor')) { ?>
<!-- Stuff here for editors -->
<?php } ?>
<?php if(current_user_can('administrator')) { ?>
<!-- Stuff here for administrators -->
<?php } ... | First answer, not WordPress-related because it is just only PHP: Use the logic "OR" operator:
```
<?php if( current_user_can('editor') || current_user_can('administrator') ) { ?>
// Stuff here for administrators or editors
<?php } ?>
```
If you want to check more than two roles, you can check if the roles of th... |
131,818 | <p>I'm adding a meta box to a WordPress admin page.</p>
<p>It works fine on my local server but when I upload it to the live server, the meta box doesn't appear.</p>
<p>Its does however appear in the screen options, so I know the code is working to some extent but it's just not displaying anything on the edit page. <... | [
{
"answer_id": 131834,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 3,
"selected": true,
"text": "<p>You missed one argument in the <code>$args</code> for <code>add_meta_box</code>.</p>\n\n<p>The correct use woul... | 2014/01/30 | [
"https://wordpress.stackexchange.com/questions/131818",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16885/"
] | I'm adding a meta box to a WordPress admin page.
It works fine on my local server but when I upload it to the live server, the meta box doesn't appear.
Its does however appear in the screen options, so I know the code is working to some extent but it's just not displaying anything on the edit page.
I've uninstalled... | You missed one argument in the `$args` for `add_meta_box`.
The correct use would be ([Codex](http://codex.wordpress.org/Function_Reference/add_meta_box)):
```
add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );
```
You forgot to set the `context`, add it and you should be fine.
... |
131,833 | <p>I'm having a page on which all my custom post types are displayed.
I now need to add another to the existing ones:</p>
<pre><code>$args = array(
'post_type' => 'bkroadkill',
'post_status' => 'publish, future',
'posts_per_page' => '15'
);
if ( 'POST' == $_SERVER['REQUEST_METHOD'] &&a... | [
{
"answer_id": 131834,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 3,
"selected": true,
"text": "<p>You missed one argument in the <code>$args</code> for <code>add_meta_box</code>.</p>\n\n<p>The correct use woul... | 2014/01/30 | [
"https://wordpress.stackexchange.com/questions/131833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45158/"
] | I'm having a page on which all my custom post types are displayed.
I now need to add another to the existing ones:
```
$args = array(
'post_type' => 'bkroadkill',
'post_status' => 'publish, future',
'posts_per_page' => '15'
);
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['filterform'])... | You missed one argument in the `$args` for `add_meta_box`.
The correct use would be ([Codex](http://codex.wordpress.org/Function_Reference/add_meta_box)):
```
add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );
```
You forgot to set the `context`, add it and you should be fine.
... |
131,837 | <p>I am trying to sort through a multi level hierarchy in a custom taxonomy.</p>
<p>I have custom taxonomy's with multiple sub taxonomy's. Eg:</p>
<pre><code>Level1
-Level2
--Level3
</code></pre>
<p>ect</p>
<p>At the moment I can use <code>get_term_children()</code> to return the children for a top level taxonomy ... | [
{
"answer_id": 131834,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 3,
"selected": true,
"text": "<p>You missed one argument in the <code>$args</code> for <code>add_meta_box</code>.</p>\n\n<p>The correct use woul... | 2014/01/30 | [
"https://wordpress.stackexchange.com/questions/131837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44049/"
] | I am trying to sort through a multi level hierarchy in a custom taxonomy.
I have custom taxonomy's with multiple sub taxonomy's. Eg:
```
Level1
-Level2
--Level3
```
ect
At the moment I can use `get_term_children()` to return the children for a top level taxonomy but this doesn't tell me anything about there posit... | You missed one argument in the `$args` for `add_meta_box`.
The correct use would be ([Codex](http://codex.wordpress.org/Function_Reference/add_meta_box)):
```
add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );
```
You forgot to set the `context`, add it and you should be fine.
... |
131,879 | <p>How to redirect non-logged users requesting for a specific page/URL to another page/URL and display a message like "for members only". I know its quite easy to code using !is_user_logged_in() function but i don't know how to code it because i am a newbie to WordPress. Care to tell me the file to put the code also.... | [
{
"answer_id": 131891,
"author": "Borek",
"author_id": 45286,
"author_profile": "https://wordpress.stackexchange.com/users/45286",
"pm_score": 2,
"selected": false,
"text": "<p>How can we tell you where to put it if you didn't tell us what and where you want to display it? Whole posts? P... | 2014/01/30 | [
"https://wordpress.stackexchange.com/questions/131879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45622/"
] | How to redirect non-logged users requesting for a specific page/URL to another page/URL and display a message like "for members only". I know its quite easy to code using !is\_user\_logged\_in() function but i don't know how to code it because i am a newbie to WordPress. Care to tell me the file to put the code also. | Here are 2 examples which you will need to modify slightly to get it working for your specific needs.
```
add_action( 'admin_init', 'redirect_non_logged_users_to_specific_page' );
function redirect_non_logged_users_to_specific_page() {
if ( !is_user_logged_in() && is_page('add page slug or ID here') && $_SERVER['PH... |
131,904 | <p>I am using this code to try to upload images located in my server to Media Library of my wordpress installation.</p>
<pre><code><?php
include("../../../wp-blog-header.php");
include("../../../wp-admin/includes/file.php");
include("../../../wp-admin/includes/media.php");
$id = 0;
$image = $_... | [
{
"answer_id": 131911,
"author": "Chief Alchemist",
"author_id": 18343,
"author_profile": "https://wordpress.stackexchange.com/users/18343",
"pm_score": 0,
"selected": false,
"text": "<p>Does the form that the file is coming from use:</p>\n\n<pre><code>enctype=\"multipart/form-data\"\n</... | 2014/01/31 | [
"https://wordpress.stackexchange.com/questions/131904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20244/"
] | I am using this code to try to upload images located in my server to Media Library of my wordpress installation.
```
<?php
include("../../../wp-blog-header.php");
include("../../../wp-admin/includes/file.php");
include("../../../wp-admin/includes/media.php");
$id = 0;
$image = $_SERVER['DOCUMENT_... | Your failing and getting a WP\_Error object returned before the function runs wp\_insert\_attachment().
You should always include a check for [`is_wp_error( $thing )`](http://codex.wordpress.org/Function_Reference/is_wp_error) when calling a function that returns [WP\_Errors](https://codex.wordpress.org/Class_Referenc... |
131,931 | <p>I have the following loop, and only this loop, in my <code>home.php</code> file (apologies if I didn't paste the code properly). I have populated lorem ipsum posts, and noticed that of the five posts only four show up on the page. Any insights would be greatly appreciated.</p>
<pre><code><div itemscope itemtype=... | [
{
"answer_id": 131932,
"author": "1fixdotio",
"author_id": 45728,
"author_profile": "https://wordpress.stackexchange.com/users/45728",
"pm_score": 0,
"selected": false,
"text": "<p>Try to rewrite the query and dump it like:</p>\n\n<pre><code><?php\n$the_query = new WP_Query( 'category... | 2014/01/31 | [
"https://wordpress.stackexchange.com/questions/131931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45954/"
] | I have the following loop, and only this loop, in my `home.php` file (apologies if I didn't paste the code properly). I have populated lorem ipsum posts, and noticed that of the five posts only four show up on the page. Any insights would be greatly appreciated.
```
<div itemscope itemtype="http://schema.org/Blog" cla... | I found a solution to the problem I was having with WP\_Query. What I was missing was the offset (which I did not realize needed to be set when dealing with custom queries).
First: Get the current page
```
// If the query var is set use it; otherwise, initialize it to one.
$page = get_query_var( 'paged' ) ? get_query... |
131,936 | <p>I'm trying to create a really simple options page for my wordpress site that just contains one option - a conversion rate for a currency. I have the following code:</p>
<pre><code>add_action('admin_init', 'currency_options_set');
add_action( 'admin_menu', 'admin_menu' );
function admin_menu () {
add_options_pa... | [
{
"answer_id": 133664,
"author": "NW Tech",
"author_id": 5295,
"author_profile": "https://wordpress.stackexchange.com/users/5295",
"pm_score": 0,
"selected": false,
"text": "<p>Couldn't you use the built in Export and Import features of WordPress? Then it's just a matter of moving the th... | 2014/01/31 | [
"https://wordpress.stackexchange.com/questions/131936",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41483/"
] | I'm trying to create a really simple options page for my wordpress site that just contains one option - a conversion rate for a currency. I have the following code:
```
add_action('admin_init', 'currency_options_set');
add_action( 'admin_menu', 'admin_menu' );
function admin_menu () {
add_options_page( 'Currency ... | This can be somewhat tedious, but hopefully this helps. The less that changes from one environment to the next, the less painful this process will be. Particularly, if the domain, site id, file paths remain the same, the less painful this process will be.
This post assumes some knowledge of database management. It is ... |