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
168,182
<p>Using WP 4.0. I thought that the html5 schema was supposed to be turned on by default. That would mean that clicking the B (Bold) button would generate a <code>&lt;b&gt;</code> tag, rather than a <code>&lt;strong&gt;</code> tag (which has a different semantic meaning). The same question goes for clicking the I butto...
[ { "answer_id": 168183, "author": "skim-", "author_id": 25265, "author_profile": "https://wordpress.stackexchange.com/users/25265", "pm_score": -1, "selected": false, "text": "<p>The i and b tags are perfectly valid HTML(5).</p>\n\n<p>Otherwise ( untested, only on output thus saved to DB ...
2014/11/11
[ "https://wordpress.stackexchange.com/questions/168182", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63363/" ]
Using WP 4.0. I thought that the html5 schema was supposed to be turned on by default. That would mean that clicking the B (Bold) button would generate a `<b>` tag, rather than a `<strong>` tag (which has a different semantic meaning). The same question goes for clicking the I button to get an `<i>` tag instead of `<em...
Here's what I came up with. So far it doesn't seem to have broken anything: ``` add_filter('tiny_mce_before_init', 'modify_formats'); function modify_formats($settings){ $formats = array( 'bold' => array('inline' => 'b'), 'italic' => array('inline' => 'i') ); $settings['formats'] = json_encode( $...
168,186
<p>I have a CPT called 'Athlete' and a Taxonomy called 'School'.</p> <p>Two sample terms have been added called 'term1' and 'term2'.</p> <p>When a user views the archive for any of the 2 terms (taxonomy-school.php), I need to be able to echo the current post count of posts from within the Athlete CPT that contain the...
[ { "answer_id": 168189, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 2, "selected": true, "text": "<p>In your taxonomy archive template, just add the following:</p>\n\n<p>At the top: <code>global $wp_query;</co...
2014/11/11
[ "https://wordpress.stackexchange.com/questions/168186", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52560/" ]
I have a CPT called 'Athlete' and a Taxonomy called 'School'. Two sample terms have been added called 'term1' and 'term2'. When a user views the archive for any of the 2 terms (taxonomy-school.php), I need to be able to echo the current post count of posts from within the Athlete CPT that contain the currently viewed...
In your taxonomy archive template, just add the following: At the top: `global $wp_query;` Then to get the post count for the entire term: `echo $wp_query->found_posts` This will display all posts in the query, which in a taxonomy template will be all posts attached to a term. [WP Query Codex](http://codex.wordpre...
168,193
<p>Whenever I update a term it currently redirects me back to the <code>edit-tags.php</code> page for that taxonomy, the term list. Is it possible to instead of redirects to the term list to instead bring me back to the same term I just updated? Similar to how updating a post will bring you back to the same post you ju...
[ { "answer_id": 168206, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>I agree with you, it's somewhat an unexpected <em>user experience</em>, when you're redirected after updating ...
2014/11/11
[ "https://wordpress.stackexchange.com/questions/168193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
Whenever I update a term it currently redirects me back to the `edit-tags.php` page for that taxonomy, the term list. Is it possible to instead of redirects to the term list to instead bring me back to the same term I just updated? Similar to how updating a post will bring you back to the same post you just updated. A...
I agree with you, it's somewhat an unexpected *user experience*, when you're redirected after updating a term. Additionally there seems to be no error handling on the form itself, if you try to make some errors, like deleting the term name and slug, it will not show any errors, just ignore your changes and redirect. ...
168,243
<p>I'm using this code:</p> <pre><code>$post = array( 'post_content' =&gt; $desc, 'post_title' =&gt; $name_new, 'post_status' =&gt; 'publish', 'post_type' =&gt; 'portfolio_page', 'tax_input' =&gt; array('portfolio_category' =&gt; array($cat, 18, 19)) ); if (!$post_id = ...
[ { "answer_id": 168250, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>This is typical issue. While <code>wp_insert_post()</code> won't check for user capabilities to insert post, the <c...
2014/11/12
[ "https://wordpress.stackexchange.com/questions/168243", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63391/" ]
I'm using this code: ``` $post = array( 'post_content' => $desc, 'post_title' => $name_new, 'post_status' => 'publish', 'post_type' => 'portfolio_page', 'tax_input' => array('portfolio_category' => array($cat, 18, 19)) ); if (!$post_id = wp_insert_post($post)) { ...
This is typical issue. While `wp_insert_post()` won't check for user capabilities to insert post, the `tax_input` part actually *will* check if user has permission to manipulate those specific taxonomies. If you don't have user logged in state replicated in your shell context then it will fail accordingly. The soluti...
168,315
<p>When updating a post meta where the input will be always an integer, should I use <code>(int)</code> or is there a WordPress function for that (eg. <code>sanitize_text_field</code>)?</p> <p>For example:</p> <pre><code>if(isset($_POST['category_id'])){ update_post_meta($post-&gt;ID, 'category_id', (int)($_POST[...
[ { "answer_id": 168316, "author": "iyrin", "author_id": 33393, "author_profile": "https://wordpress.stackexchange.com/users/33393", "pm_score": 0, "selected": false, "text": "<p>Use a conditional statement to check if <code>$_POST['category_id'])</code> is an integer first. The PHP functi...
2014/11/13
[ "https://wordpress.stackexchange.com/questions/168315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63420/" ]
When updating a post meta where the input will be always an integer, should I use `(int)` or is there a WordPress function for that (eg. `sanitize_text_field`)? For example: ``` if(isset($_POST['category_id'])){ update_post_meta($post->ID, 'category_id', (int)($_POST['category_id'])); } ```
For integers KSES has no special function. Use `(int)` or `intval()` or `absint()` See more: [Data Validation - Integers](http://codex.wordpress.org/Data_Validation#Integers)
168,336
<p>I like to exclude certain posts with a custom field. So if <code>my_custom_field_ignore</code> isset AND <code>1</code> ignore this post. If it's not set include it.</p> <p>This is what I have</p> <pre><code> $args = array( 'post_type' =&gt; $post_type, 'offset' =&gt; $offset, 'meta_quer...
[ { "answer_id": 168337, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 5, "selected": true, "text": "<p>If we define the conditions:</p>\n\n<pre><code>A: my_custom_field_ignore EXISTS\nB: my_custom_field_ignore = 1...
2014/11/13
[ "https://wordpress.stackexchange.com/questions/168336", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18981/" ]
I like to exclude certain posts with a custom field. So if `my_custom_field_ignore` isset AND `1` ignore this post. If it's not set include it. This is what I have ``` $args = array( 'post_type' => $post_type, 'offset' => $offset, 'meta_query' => array( array( '...
If we define the conditions: ``` A: my_custom_field_ignore EXISTS B: my_custom_field_ignore = 1 ``` then `NOT ( A && B )` is equivalent to: ``` NOT ( A ) || NOT ( B ) ``` meaning in our case: ``` ( my_custom_field_ignore NOT EXISTS ) || ( my_custom_field_ignore != 1 ) ``` We could therefore try the following...
168,340
<p>For all of my pages I have setup a taxonomy field using the plugin <a href="http://www.advancedcustomfields.com/" rel="nofollow">Advanced Custom Fields</a>, for which I can then select as <code>Home</code> category, or something else like <code>News</code>. I am using the default category option, not a custom taxono...
[ { "answer_id": 168355, "author": "Computer Information Data Base", "author_id": 63437, "author_profile": "https://wordpress.stackexchange.com/users/63437", "pm_score": -1, "selected": false, "text": "<p>Use <code>wp_reset_query()</code> after first query, on 3th code line <code>$args = a...
2014/11/13
[ "https://wordpress.stackexchange.com/questions/168340", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63400/" ]
For all of my pages I have setup a taxonomy field using the plugin [Advanced Custom Fields](http://www.advancedcustomfields.com/), for which I can then select as `Home` category, or something else like `News`. I am using the default category option, not a custom taxonomy. I have a custom post type `slides_post_type` w...
The final code I used was: ``` <?php $slides_category = get_field('slider_category'); $args = array( 'post_type' => 'slides_post_type', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => array( $slides_category ), ), ...
168,379
<p>I am running a wordpress page and looking for a way to implement a forum (<a href="https://bbpress.org/" rel="nofollow">bbPress</a>) on one of my pages. I only want registered users (they are added by the admin manually) to post to the forum. I am able to set up the forum but I am not able to create a topic or post ...
[ { "answer_id": 168355, "author": "Computer Information Data Base", "author_id": 63437, "author_profile": "https://wordpress.stackexchange.com/users/63437", "pm_score": -1, "selected": false, "text": "<p>Use <code>wp_reset_query()</code> after first query, on 3th code line <code>$args = a...
2014/11/13
[ "https://wordpress.stackexchange.com/questions/168379", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63450/" ]
I am running a wordpress page and looking for a way to implement a forum ([bbPress](https://bbpress.org/)) on one of my pages. I only want registered users (they are added by the admin manually) to post to the forum. I am able to set up the forum but I am not able to create a topic or post anything since You must be lo...
The final code I used was: ``` <?php $slides_category = get_field('slider_category'); $args = array( 'post_type' => 'slides_post_type', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => array( $slides_category ), ), ...
168,382
<p>I have a client who has a WordPress site that uses a custom plugin written for them by another developer. Recently, they ran the WordPress updater and one of the updates clobbered that custom plugin and replaced it with a plugin from the Plugin Repository that happened to have the same name.</p> <p>I'm trying to fi...
[ { "answer_id": 168543, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 2, "selected": true, "text": "<p>The way WordPress uses to find a plugin in repository is not public AFAIK.</p>\n\n<p>As per Otto answer in que...
2014/11/13
[ "https://wordpress.stackexchange.com/questions/168382", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1782/" ]
I have a client who has a WordPress site that uses a custom plugin written for them by another developer. Recently, they ran the WordPress updater and one of the updates clobbered that custom plugin and replaced it with a plugin from the Plugin Repository that happened to have the same name. I'm trying to figure out e...
The way WordPress uses to find a plugin in repository is not public AFAIK. As per Otto answer in question you linked it involves plugin url header alongside plugin name. BTW, remove the plugin from the list of plugin to update is the best way to ensure this problem is not going to happen again: once the matching meth...
168,383
<p>I'd like to pull the avatar of a blog post's author and display it on the page using BuddyPress but I cannot seem to pull it off. How would I go about this?</p>
[ { "answer_id": 168385, "author": "edwardr", "author_id": 25724, "author_profile": "https://wordpress.stackexchange.com/users/25724", "pm_score": 1, "selected": false, "text": "<p>Something like this should work:</p>\n\n<pre><code>&lt;?php\n $author = get_the_author_meta('ID');\n ...
2014/11/13
[ "https://wordpress.stackexchange.com/questions/168383", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63265/" ]
I'd like to pull the avatar of a blog post's author and display it on the page using BuddyPress but I cannot seem to pull it off. How would I go about this?
Try this: ``` $author_id = get_the_author_meta('ID'); echo bp_core_fetch_avatar ( array( 'item_id' => $author_id, 'type' => 'full' ) ); ``` Defaults: ``` array( 'item_id' => false, 'object' => 'user', 'type' => 'thumb', 'avatar_dir' => false, 'width' => false, 'height' => f...
168,399
<p><strong>UPDATE:</strong></p> <p>I have this widget that allows me to <strong>CHOOSE</strong> and <strong>SHOW</strong> the latest posts from a <strong>specific category</strong> in the sidebar. Here's the code;</p> <pre><code>add_action( 'widgets_init', 'tie_categort_posts_widget' ); function tie_categort_posts_wi...
[ { "answer_id": 168402, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 0, "selected": false, "text": "<p>Have a try, I din't test. On line 48 change:</p>\n\n<pre><code>$categories_obj = get_categories();\n</...
2014/11/14
[ "https://wordpress.stackexchange.com/questions/168399", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63465/" ]
**UPDATE:** I have this widget that allows me to **CHOOSE** and **SHOW** the latest posts from a **specific category** in the sidebar. Here's the code; ``` add_action( 'widgets_init', 'tie_categort_posts_widget' ); function tie_categort_posts_widget() { register_widget( 'tie_categort_posts' ); } class tie_categor...
I think your idea is really nice here, but you have a couple of serious flaws in your code. * Never use `extract()`, ever. It is extremely hard to debug and can render unexpected output. It has now been completely removed from core, except in one instance as far as I can pick up from [this core trac ticket](https://co...
168,420
<p>First off I am well aware that there is a plugin but I am <strong>NOT</strong> talking about the BS Short code plugin. I am talking about the actual bootstrap accordion. So here is what I am trying to accomplish, I am pretty close I am trying to use custom post types and fields to generate an accordion of questions....
[ { "answer_id": 168421, "author": "Karun", "author_id": 63470, "author_profile": "https://wordpress.stackexchange.com/users/63470", "pm_score": 0, "selected": false, "text": "<p>Try The code below. In your code, the collapseOne was repeated throughout the loop. I added $i as counter and s...
2014/11/14
[ "https://wordpress.stackexchange.com/questions/168420", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63171/" ]
First off I am well aware that there is a plugin but I am **NOT** talking about the BS Short code plugin. I am talking about the actual bootstrap accordion. So here is what I am trying to accomplish, I am pretty close I am trying to use custom post types and fields to generate an accordion of questions. So I have a cus...
Never mind I got it. I used `<?php the_ID(); ?>` to set unique id's but even so that was not the problem. Turns out the first accordion had a class of `"in"` so the real question was `How can I only give a class to the first post of a loop?` and I did that by using a simple counter. `<?php $c = 0; ?>` increment it a...
168,448
<p>I'm creating a plugin that adds some data to a custom table created by my plugin on plugin activations.</p> <p>I also created a settings page with a form that users can insert their own data to the database.</p> <p><strong>The problem</strong> Everything is working fine but each time i deactivate(i don't mean unin...
[ { "answer_id": 168421, "author": "Karun", "author_id": 63470, "author_profile": "https://wordpress.stackexchange.com/users/63470", "pm_score": 0, "selected": false, "text": "<p>Try The code below. In your code, the collapseOne was repeated throughout the loop. I added $i as counter and s...
2014/11/14
[ "https://wordpress.stackexchange.com/questions/168448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59917/" ]
I'm creating a plugin that adds some data to a custom table created by my plugin on plugin activations. I also created a settings page with a form that users can insert their own data to the database. **The problem** Everything is working fine but each time i deactivate(i don't mean uninstall) and reactivate the plug...
Never mind I got it. I used `<?php the_ID(); ?>` to set unique id's but even so that was not the problem. Turns out the first accordion had a class of `"in"` so the real question was `How can I only give a class to the first post of a loop?` and I did that by using a simple counter. `<?php $c = 0; ?>` increment it a...
168,477
<p>I just developed a tool for web site owners. This works as a standalone app with its own user and routes system and other custom elements.</p> <p>Now it seems Wordpress is getting more and more popular and I'm considering also to develop a plugin version of this app.</p> <p>I wonder if its possible for my app to c...
[ { "answer_id": 168421, "author": "Karun", "author_id": 63470, "author_profile": "https://wordpress.stackexchange.com/users/63470", "pm_score": 0, "selected": false, "text": "<p>Try The code below. In your code, the collapseOne was repeated throughout the loop. I added $i as counter and s...
2014/11/14
[ "https://wordpress.stackexchange.com/questions/168477", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63507/" ]
I just developed a tool for web site owners. This works as a standalone app with its own user and routes system and other custom elements. Now it seems Wordpress is getting more and more popular and I'm considering also to develop a plugin version of this app. I wonder if its possible for my app to coexist with Wordp...
Never mind I got it. I used `<?php the_ID(); ?>` to set unique id's but even so that was not the problem. Turns out the first accordion had a class of `"in"` so the real question was `How can I only give a class to the first post of a loop?` and I did that by using a simple counter. `<?php $c = 0; ?>` increment it a...
168,498
<p>I am trying to add pagination in between post and comments.</p> <p>I used plugin <em>Automatically Paginate Posts</em> for that in which i can able to add pagination after comments and facebook plugin. </p> <ol> <li>Is it possible to add pagination just after post?</li> </ol> <p>i tried to add below code.</p> <p...
[ { "answer_id": 168511, "author": "ommunist", "author_id": 10285, "author_profile": "https://wordpress.stackexchange.com/users/10285", "pm_score": 0, "selected": false, "text": "<p>Depending on your theme, you may look into the template where your comments output reside and include callin...
2014/11/15
[ "https://wordpress.stackexchange.com/questions/168498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60803/" ]
I am trying to add pagination in between post and comments. I used plugin *Automatically Paginate Posts* for that in which i can able to add pagination after comments and facebook plugin. 1. Is it possible to add pagination just after post? i tried to add below code. ``` <div class="entry-content"> <?php t...
I got my solution. ``` <?php // move pagination links above other end-of-post content additions, like related posts etc. function move_pagination( $content ) { if ( is_single() ) { $pagination = wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-titl...
168,503
<p>I ran a performance report for my website (using <a href="https://gtmetrix.com" rel="nofollow">GTmetrix</a>) and I realized the image dimensions are not set, and I missed specifying the height and width attributes. The theme already had some images, but they are not specified by default. How can I specify them and m...
[ { "answer_id": 168531, "author": "jacobwarduk", "author_id": 63396, "author_profile": "https://wordpress.stackexchange.com/users/63396", "pm_score": 4, "selected": true, "text": "<p>In your theme's functions.php file you can add</p>\n\n<pre class=\"lang-php prettyprint-override\"><code>a...
2014/11/15
[ "https://wordpress.stackexchange.com/questions/168503", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62233/" ]
I ran a performance report for my website (using [GTmetrix](https://gtmetrix.com)) and I realized the image dimensions are not set, and I missed specifying the height and width attributes. The theme already had some images, but they are not specified by default. How can I specify them and more importantly, where do I s...
In your theme's functions.php file you can add ```php add_image_size( 'thumb', 600, 350, true ); add_image_size( 'thumbnil', 600, 350, true ); add_image_size( 'medium', 600, 350, true ); add_image_size( 'large', 600, 350, true ); add_image_size( 'post-thumbnail', 600, 350, true ); add_image_size( '{custom-image-type}...
168,512
<p>Currently I'm developing WordPress Theme.Within my theme I'm using Customizer API.I added some controls,setting,sections It works.</p> <p>Also, I created new PHP file called <code>class-customizer-control.php</code>.Inside this file I'll put all custom controls, so I created one custom control (textarea):</p> <pre...
[ { "answer_id": 168545, "author": "SkyShab", "author_id": 63263, "author_profile": "https://wordpress.stackexchange.com/users/63263", "pm_score": 1, "selected": false, "text": "<p>I'm not sure if there are different approaches for this, but this is a pattern I've implemented successfully ...
2014/11/15
[ "https://wordpress.stackexchange.com/questions/168512", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58239/" ]
Currently I'm developing WordPress Theme.Within my theme I'm using Customizer API.I added some controls,setting,sections It works. Also, I created new PHP file called `class-customizer-control.php`.Inside this file I'll put all custom controls, so I created one custom control (textarea): ``` <?php include_once ABSPAT...
I'm not sure if there are different approaches for this, but this is a pattern I've implemented successfully in several places. In my approach, I am including the "add\_control" inside the function that contains the custom class. The $wp\_customize object gets passed in to the main function. Also, I'm not sure why y...
168,513
<p>I'm currently scraping prices from three websites using xPath, but since it updates on every page load, it makes loading slow. What I would like to do is store that data and only update it weekly. So:</p> <blockquote> <p>1) Scrape prices from three different websites using xPath,</p> <p>2) Store that data (a...
[ { "answer_id": 168521, "author": "Fiaz Husyn", "author_id": 62739, "author_profile": "https://wordpress.stackexchange.com/users/62739", "pm_score": 1, "selected": false, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/wp_schedule_event\" rel=\"nofollow\">w...
2014/11/15
[ "https://wordpress.stackexchange.com/questions/168513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58166/" ]
I'm currently scraping prices from three websites using xPath, but since it updates on every page load, it makes loading slow. What I would like to do is store that data and only update it weekly. So: > > 1) Scrape prices from three different websites using xPath, > > > 2) Store that data (and update it weekly with...
You don't necessarily need to use the WP Cron API for this. Instead you could modify your existing code to make use of WP Transients. Transients are basically Options that expire after a set time. You can wrap your current scrape process in an `if` statement that checks for the existence of the stored transient. If it ...
168,524
<p>I have a Custom Post Type called "<strong>Banner</strong>" which has a custom Meta box with two advanced fields "<strong>Title</strong>" (text Field) and "<strong>Color</strong>" (color Picker). Can you please let me know how to use the WP Color Picker API in field of color? here is my code for doing the job for th...
[ { "answer_id": 213676, "author": "Kirill Polevsky", "author_id": 86194, "author_profile": "https://wordpress.stackexchange.com/users/86194", "pm_score": 0, "selected": false, "text": "<p>You have to create an input field with a class <code>color-field</code>.</p>\n\n<p>For example:</p>\n...
2014/11/15
[ "https://wordpress.stackexchange.com/questions/168524", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26628/" ]
I have a Custom Post Type called "**Banner**" which has a custom Meta box with two advanced fields "**Title**" (text Field) and "**Color**" (color Picker). Can you please let me know how to use the WP Color Picker API in field of color? here is my code for doing the job for the first field but confused how to develop s...
I've created a metabox once with color picker. You need to include color picker style and script in your `admin_enqueue_scripts` hook, and then initialize it with ``` $('.color-picker').wpColorPicker(); ``` From my [gist](https://gist.github.com/dingo-d/4b226c20f5071d0b0dd6): ``` <?php add_action( 'admin_enqueue_sc...
168,539
<p>I have created a custom taxonomy, which has 2 terms. I'd like to have both of these checked/selected by default when someone creates a new post. Is this possible? I've searched but found no solutions.</p> <p>Thank you!</p>
[ { "answer_id": 168540, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": true, "text": "<p>There is nothing directly meant for that (that I can think of), but there is very close in purpose function <a href=...
2014/11/15
[ "https://wordpress.stackexchange.com/questions/168539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31345/" ]
I have created a custom taxonomy, which has 2 terms. I'd like to have both of these checked/selected by default when someone creates a new post. Is this possible? I've searched but found no solutions. Thank you!
There is nothing directly meant for that (that I can think of), but there is very close in purpose function [`get_default_post_to_edit()`](http://queryposts.com/function/get_default_post_to_edit/). Since for the purpose of new post creation it makes post appear in DB before it is even saved for the first time (as auto...
168,557
<p>I'm following the advice found in several places to remove tabs by using the following filter. However, the same number of tabs appear, the last one is simply displayed x number of times. I'm running Multisite, 4.0</p> <p>The filter:</p> <pre><code>function remove_media_editor_tabs( $strings ) { $user_id = get...
[ { "answer_id": 168630, "author": "johnrom", "author_id": 55258, "author_profile": "https://wordpress.stackexchange.com/users/55258", "pm_score": 0, "selected": false, "text": "<p>This is the closest I've been able to get, but if anyone has any other ideas, that would be great. I don't ha...
2014/11/16
[ "https://wordpress.stackexchange.com/questions/168557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/55258/" ]
I'm following the advice found in several places to remove tabs by using the following filter. However, the same number of tabs appear, the last one is simply displayed x number of times. I'm running Multisite, 4.0 The filter: ``` function remove_media_editor_tabs( $strings ) { $user_id = get_current_user_id(); ...
Changing strings to null or to empty strings removes items from left menu of the uploader and corresponding tabs. Paste this code in functions.php: ``` function remove_media_tab( $strings ) { if( !current_user_can( 'administrator' ) ) { $strings["createGalleryTitle"] = ""; $strings["setFeaturedIm...
168,580
<p>I'm using the plugin (<a href="https://github.com/WP-API/WP-API" rel="nofollow">https://github.com/WP-API/WP-API</a>) to get JSON Data from WordPress, but I'm stuck on something, I've a custom post type, events, with which many custom fields is attached to, such as datefrom, dateto, latitude, longitude.</p> <p>This...
[ { "answer_id": 168630, "author": "johnrom", "author_id": 55258, "author_profile": "https://wordpress.stackexchange.com/users/55258", "pm_score": 0, "selected": false, "text": "<p>This is the closest I've been able to get, but if anyone has any other ideas, that would be great. I don't ha...
2014/11/16
[ "https://wordpress.stackexchange.com/questions/168580", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12000/" ]
I'm using the plugin (<https://github.com/WP-API/WP-API>) to get JSON Data from WordPress, but I'm stuck on something, I've a custom post type, events, with which many custom fields is attached to, such as datefrom, dateto, latitude, longitude. This URL <http://www.domainname.com/wp-json/posts?type=events&lang=fr> is ...
Changing strings to null or to empty strings removes items from left menu of the uploader and corresponding tabs. Paste this code in functions.php: ``` function remove_media_tab( $strings ) { if( !current_user_can( 'administrator' ) ) { $strings["createGalleryTitle"] = ""; $strings["setFeaturedIm...
168,581
<p>I want to add a new Dropbox Drop In Chooser button to my site.</p> <p>To include the code in a simple page you use</p> <pre><code>&lt;script type = "text/javascript" src = "https://www.dropbox.com/static/api/1/dropins.js" id = "dropboxjs" data-app-key = "xxxxxxxx"&gt; </code></pre> <p>Where <code>xxxxxxx</c...
[ { "answer_id": 168630, "author": "johnrom", "author_id": 55258, "author_profile": "https://wordpress.stackexchange.com/users/55258", "pm_score": 0, "selected": false, "text": "<p>This is the closest I've been able to get, but if anyone has any other ideas, that would be great. I don't ha...
2014/11/16
[ "https://wordpress.stackexchange.com/questions/168581", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6092/" ]
I want to add a new Dropbox Drop In Chooser button to my site. To include the code in a simple page you use ``` <script type = "text/javascript" src = "https://www.dropbox.com/static/api/1/dropins.js" id = "dropboxjs" data-app-key = "xxxxxxxx"> ``` Where `xxxxxxx` is the dropbox supplied key for the app using...
Changing strings to null or to empty strings removes items from left menu of the uploader and corresponding tabs. Paste this code in functions.php: ``` function remove_media_tab( $strings ) { if( !current_user_can( 'administrator' ) ) { $strings["createGalleryTitle"] = ""; $strings["setFeaturedIm...
168,613
<p>I need to display all thumbnails of a gallery on the homepage using the <a href="http://roots.io" rel="nofollow">Roots</a> theme with links to one page with a shortcode. The gallery has to be loaded as list items using <a href="http://bxslider.com/" rel="nofollow">BX Slider</a>'s jQuery to create a carousel. HTML co...
[ { "answer_id": 168630, "author": "johnrom", "author_id": 55258, "author_profile": "https://wordpress.stackexchange.com/users/55258", "pm_score": 0, "selected": false, "text": "<p>This is the closest I've been able to get, but if anyone has any other ideas, that would be great. I don't ha...
2014/11/16
[ "https://wordpress.stackexchange.com/questions/168613", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12260/" ]
I need to display all thumbnails of a gallery on the homepage using the [Roots](http://roots.io) theme with links to one page with a shortcode. The gallery has to be loaded as list items using [BX Slider](http://bxslider.com/)'s jQuery to create a carousel. HTML code: ``` <ul class="bxslider"> <li><img src="http://...
Changing strings to null or to empty strings removes items from left menu of the uploader and corresponding tabs. Paste this code in functions.php: ``` function remove_media_tab( $strings ) { if( !current_user_can( 'administrator' ) ) { $strings["createGalleryTitle"] = ""; $strings["setFeaturedIm...
168,628
<p>I have a search form on my home page that sets up the url query_string accordingly for the code below. When I use or I get results. However when I used "AND" for the relation I dont get any results as the user can select as many of the options as they want to choose from when searching (there are three as seen bel...
[ { "answer_id": 168626, "author": "Nabil Kadimi", "author_id": 17187, "author_profile": "https://wordpress.stackexchange.com/users/17187", "pm_score": -1, "selected": false, "text": "<p>You can modify the query using the <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre...
2014/11/17
[ "https://wordpress.stackexchange.com/questions/168628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57278/" ]
I have a search form on my home page that sets up the url query\_string accordingly for the code below. When I use or I get results. However when I used "AND" for the relation I dont get any results as the user can select as many of the options as they want to choose from when searching (there are three as seen below i...
You should probably use the [post\_\_in](https://developer.wordpress.org/reference/classes/wp_query/#post-page-parameters) argument of WP\_Query, and pass in an array of post IDs. This will work assuming you run the query with the extra posts first. Injecting them into the WP\_Query object like this allows SQL to still...
168,650
<p>I was wondering if anybody has a good idea how to solve this cheap.</p> <p>Assume there are two urls:</p> <ul> <li>example.com/portfolio-xyz</li> <li>example.com/portfolios/someidentification</li> </ul> <p><code>example.com/portfolios/someidentification</code> shall display the content of: <code>example.com/portf...
[ { "answer_id": 168659, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>The \"cheapest\" way to achieve this probably would be to simply add two pages:</p>\n\n<pre><code>// Standard temp...
2014/11/17
[ "https://wordpress.stackexchange.com/questions/168650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32871/" ]
I was wondering if anybody has a good idea how to solve this cheap. Assume there are two urls: * example.com/portfolio-xyz * example.com/portfolios/someidentification `example.com/portfolios/someidentification` shall display the content of: `example.com/portfolio-xyz` but using a different template. Is there a way ...
I don't know what your definition of "simple" is, so not sure this qualifies. It's not really a simple task to do this dynamically. First, we register a new query var to pass the alternate identifier: ``` function wpd_portfolios_query_var($query_vars){ $query_vars[] = 'portfolio_key'; return $query_vars; } ad...
168,658
<p>I refer to this post where I have just taken my code from: <a href="https://wordpress.stackexchange.com/questions/140470/how-to-display-a-listing-template-of-a-certain-taxonomy">How to display a listing template of a certain taxonomy?</a></p> <p>I am trying to create a page template that will list all categories in...
[ { "answer_id": 168659, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>The \"cheapest\" way to achieve this probably would be to simply add two pages:</p>\n\n<pre><code>// Standard temp...
2014/11/17
[ "https://wordpress.stackexchange.com/questions/168658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34820/" ]
I refer to this post where I have just taken my code from: [How to display a listing template of a certain taxonomy?](https://wordpress.stackexchange.com/questions/140470/how-to-display-a-listing-template-of-a-certain-taxonomy) I am trying to create a page template that will list all categories in "servicecats" taxono...
I don't know what your definition of "simple" is, so not sure this qualifies. It's not really a simple task to do this dynamically. First, we register a new query var to pass the alternate identifier: ``` function wpd_portfolios_query_var($query_vars){ $query_vars[] = 'portfolio_key'; return $query_vars; } ad...
168,674
<p>I created two template pages: <code>galerie.php</code> and <code>homepage.php</code>.</p> <p>Galerie already displays posts. So Homepage is <code>homepage.php</code> and posts page is <code>galerie.php</code>.</p> <p>Now the problem is that I wanted to display a post from Category <code>category-test</code> into <...
[ { "answer_id": 168679, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": true, "text": "<p>The template tags (like <code>the_content()</code>) aren't available when using <a href=\"http://codex.w...
2014/11/17
[ "https://wordpress.stackexchange.com/questions/168674", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63584/" ]
I created two template pages: `galerie.php` and `homepage.php`. Galerie already displays posts. So Homepage is `homepage.php` and posts page is `galerie.php`. Now the problem is that I wanted to display a post from Category `category-test` into `homepage.php`. I used the following code to try to display the posts fro...
The template tags (like `the_content()`) aren't available when using [`get_posts`](http://codex.wordpress.org/Template_Tags/get_posts). In order to make the template tags available, you have to make use of `setup_postdata( $post );` Example: ``` <?php $posts = get_posts('category_name=category-test'); foreach($post...
168,676
<p>I have the following to display my list of categories:</p> <pre><code> $categories = get_categories( $args ); foreach ( $categories as $category ) { echo '&lt;li&gt;&lt;img src=""/&gt;&lt;a href="' . get_category_link( $category-&gt;term_id ) . '" rel="bookmark"&gt;' . $category-&gt;name . '' . '' . $ca...
[ { "answer_id": 168680, "author": "Michelle", "author_id": 16, "author_profile": "https://wordpress.stackexchange.com/users/16", "pm_score": 0, "selected": false, "text": "<p>You could try this. </p>\n\n<pre><code>$categories = get_categories( $args );\nforeach ( $categories as $category ...
2014/11/17
[ "https://wordpress.stackexchange.com/questions/168676", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34820/" ]
I have the following to display my list of categories: ``` $categories = get_categories( $args ); foreach ( $categories as $category ) { echo '<li><img src=""/><a href="' . get_category_link( $category->term_id ) . '" rel="bookmark">' . $category->name . '' . '' . $category->description . '</a></li>'; }...
According to the plugins documentation (<http://zahlan.net/blog/2012/06/categories-images/>), this seems pretty simple: ``` <ul> <?php $categories = get_categories( $args ); foreach ( $categories as $category ) { $img_src = z_taxonomy_image_url($category->term_id); if ( $img_src ) { echo '<li><img src...
168,692
<p>I have a problem with WordPress and Ajax.</p> <p>This is my JavaScript part (I trimmed it a bit):</p> <pre><code>var posts = $.ajax({ type: 'POST', url: ajaxurl, async: false, dataType: 'json', data: { action: 'myAjaxFunc' }, done: function(response) { return response; } }).resp...
[ { "answer_id": 168694, "author": "BODA82", "author_id": 10723, "author_profile": "https://wordpress.stackexchange.com/users/10723", "pm_score": 2, "selected": false, "text": "<p>Almost there with your PHP function. No need to set the header. (Edit: Also, assuming <code>get_posts()</code>...
2014/11/17
[ "https://wordpress.stackexchange.com/questions/168692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8421/" ]
I have a problem with WordPress and Ajax. This is my JavaScript part (I trimmed it a bit): ``` var posts = $.ajax({ type: 'POST', url: ajaxurl, async: false, dataType: 'json', data: { action: 'myAjaxFunc' }, done: function(response) { return response; } }).responseText; $.each(pos...
[BODA82's answer](https://wordpress.stackexchange.com/questions/168692/cant-get-a-json-object-in-response-to-an-ajax-request-with-wp-ajax/168694#168694) helped, but eventually I realized that I should have replaced `responseText` with `responseJSON` method in my JavaScript code. In the example below I was storing the A...
168,718
<p>I created a custom post type called <strong>Traveller Post</strong> using the following code snippet:</p> <pre><code>/* custom post - traveller posts */ add_action( 'init', 'traveller' ); function traveller() { register_post_type( 'traveller', array( 'labels' =&gt; array( 'name' =&gt; __( 'Trav...
[ { "answer_id": 168721, "author": "Parth Kumar", "author_id": 43572, "author_profile": "https://wordpress.stackexchange.com/users/43572", "pm_score": 0, "selected": false, "text": "<p>This link might be useful in solving your problem:\n<a href=\"http://3.7designs.co/blog/2014/08/restricti...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168718", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43764/" ]
I created a custom post type called **Traveller Post** using the following code snippet: ``` /* custom post - traveller posts */ add_action( 'init', 'traveller' ); function traveller() { register_post_type( 'traveller', array( 'labels' => array( 'name' => __( 'Traveller Posts' ), 'singular...
> > But I want to allow basic traveller role users to create and edit travellers posts only. How can I do that? > > > The problem is that you have two different post types (posts and traveller), many roles (default roles plus basic\_traveller), but only one set of capabilities (default capabilities). What you nee...
168,728
<p>In a WordPress powered news portal, they need to upload many news at a time on a certain period of a day, in most of the cases, after 10pm (<em>today</em>). But they are actually inserting news for the next day (<em>tomorrow</em>). So in WordPress way they need to schedule the news (post) each time when publishing.<...
[ { "answer_id": 168740, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 1, "selected": false, "text": "<p>Okay, got a temporary solution, suggested by one of my non-WP colleague, Mr. Shamim. And tested in WP ...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168728", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
In a WordPress powered news portal, they need to upload many news at a time on a certain period of a day, in most of the cases, after 10pm (*today*). But they are actually inserting news for the next day (*tomorrow*). So in WordPress way they need to schedule the news (post) each time when publishing. ![scheduling a p...
Here's a **sketch** of another idea, where we create **scheduling shortcuts** to make it easier for the users: ![scheduling shortcuts](https://i.stack.imgur.com/xLBvj.jpg) We can use the `post_submitbox_misc_actions` to add extra fields to the *submit box*: ``` /** * Scheduling-Shortcuts fields. * * @see http://w...
168,729
<p>I'm looking to create a membership-only site which will serve to display logged-in users their company's stored documents.</p> <ul> <li>I have a custom post type named <code>Boxes</code>.</li> <li>I have a custom taxonomy called <code>Company</code> (non-hierarchal in case that matters)</li> </ul> <p>What I wish t...
[ { "answer_id": 168740, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 1, "selected": false, "text": "<p>Okay, got a temporary solution, suggested by one of my non-WP colleague, Mr. Shamim. And tested in WP ...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168729", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36136/" ]
I'm looking to create a membership-only site which will serve to display logged-in users their company's stored documents. * I have a custom post type named `Boxes`. * I have a custom taxonomy called `Company` (non-hierarchal in case that matters) What I wish to accomplish, is to be able to create custom roles for us...
Here's a **sketch** of another idea, where we create **scheduling shortcuts** to make it easier for the users: ![scheduling shortcuts](https://i.stack.imgur.com/xLBvj.jpg) We can use the `post_submitbox_misc_actions` to add extra fields to the *submit box*: ``` /** * Scheduling-Shortcuts fields. * * @see http://w...
168,747
<p>When defining a taxonomy I successfully set the slug base for it as well, all via functions.php. However, any change on the slug’s base (via editing functions.php again) is being recognised, i.e. it links to the right new URL, but lead to a 404. The term is still to be found at the original URL. More concrete:</p> ...
[ { "answer_id": 168740, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 1, "selected": false, "text": "<p>Okay, got a temporary solution, suggested by one of my non-WP colleague, Mr. Shamim. And tested in WP ...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168747", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25245/" ]
When defining a taxonomy I successfully set the slug base for it as well, all via functions.php. However, any change on the slug’s base (via editing functions.php again) is being recognised, i.e. it links to the right new URL, but lead to a 404. The term is still to be found at the original URL. More concrete: 1. For ...
Here's a **sketch** of another idea, where we create **scheduling shortcuts** to make it easier for the users: ![scheduling shortcuts](https://i.stack.imgur.com/xLBvj.jpg) We can use the `post_submitbox_misc_actions` to add extra fields to the *submit box*: ``` /** * Scheduling-Shortcuts fields. * * @see http://w...
168,749
<p>I'm looking to determine if a taxonomy term has children. See the below markup and I'll explain what I mean:</p> <pre><code>&lt;?php $terms = get_terms("wpsc_product_category"); if ( !empty( $terms ) &amp;&amp; !is_wp_error( $terms ) ){ foreach( get_terms( 'wpsc_product_category', array( 'hide_empty' =&gt; fals...
[ { "answer_id": 168758, "author": "DanBeckett", "author_id": 62651, "author_profile": "https://wordpress.stackexchange.com/users/62651", "pm_score": 3, "selected": true, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/get_term_children\" rel=\"nofollow\"><code>get_...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28065/" ]
I'm looking to determine if a taxonomy term has children. See the below markup and I'll explain what I mean: ``` <?php $terms = get_terms("wpsc_product_category"); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ foreach( get_terms( 'wpsc_product_category', array( 'hide_empty' => false, 'parent' => 0 ) ) as $par...
The [`get_term_children` function](http://codex.wordpress.org/Function_Reference/get_term_children) should help here. This returns an array, either with the child terms inside it, or empty. Checking if this array is truthy or not as you loop through will then let you determine whether or not to add the class. ``` <?...
168,754
<p>I'm trying to create template for specific category with id 1 for example. The template should be applied to all of the pages belongs to this category. So, it should be something like single-1.php.</p> <p>I tried a lot of solution that I found on the web, <a href="https://wordpress.stackexchange.com/questions/84537...
[ { "answer_id": 168756, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 2, "selected": false, "text": "<p>You can use this function to add category specific single template pages on your website. This goes in <co...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63624/" ]
I'm trying to create template for specific category with id 1 for example. The template should be applied to all of the pages belongs to this category. So, it should be something like single-1.php. I tried a lot of solution that I found on the web, [including this](https://wordpress.stackexchange.com/questions/84537/h...
You can use this function to add category specific single template pages on your website. This goes in `functions.php` You can define as many single templates as you want. ``` function wpse_category_single_template( $single_template ) { global $post; $all_cats = get_the_category(); if ( $all_cats[0]->cat...
168,770
<p>I'm trying to get posts which have applied the meta value <code>trainees</code>.</p> <pre><code>$args = array( 'posts_per_page' =&gt; -1, 'orderby' =&gt; 'post_date', 'order' =&gt; 'DESC', 'post_status' =&gt; 'publish', 'meta_query' =&gt; array( array( ...
[ { "answer_id": 168773, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 2, "selected": false, "text": "<p>I don't believe you can <em>accurately</em> compare values for a <a href=\"http://en.wikipedia.org/wiki/Ser...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168770", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50532/" ]
I'm trying to get posts which have applied the meta value `trainees`. ``` $args = array( 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish', 'meta_query' => array( array( 'key' => 'enterprise_on_page', ...
Thanks to @Howdy\_McGee. He gave me the hint to look after [serialized meta queries](https://wordpress.org/support/topic/meta_query-doesnt-find-value-if-custom-field-value-is-serialized). With this code I get the desired result. ``` $args = array( 'posts_per_page' => -1, 'orderby' => 'post_date', ...
168,783
<p>I have been working on my first plugin (call is myplugin). The path to the plugin code is wp-content/plugins/myplugin/myplugin.php. The myplugin.php file is essentially as follows:</p> <pre><code>&lt;?php defined( 'ABSPATH' ) OR exit; /* * Plugin Name: My Plugin */ function my_plugin_activation() { global...
[ { "answer_id": 168786, "author": "pwbred", "author_id": 6154, "author_profile": "https://wordpress.stackexchange.com/users/6154", "pm_score": 0, "selected": false, "text": "<p>You have a typo on this line: </p>\n\n<pre><code>register_deactivaction_hook( __FILE__, 'my_plugin_deactivation'...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63634/" ]
I have been working on my first plugin (call is myplugin). The path to the plugin code is wp-content/plugins/myplugin/myplugin.php. The myplugin.php file is essentially as follows: ``` <?php defined( 'ABSPATH' ) OR exit; /* * Plugin Name: My Plugin */ function my_plugin_activation() { global $wpdb; // SQL ...
I found the problem. I didn't realize this was a generic message for pretty much all errors. I stripped everything out of the activation routine (similar to above) and ran it... got no errors. Started adding "stuff" back. And it appears a call to flush() at the end of the activation function trying to force the /wp-con...
168,789
<p>I have a shortcode: [content_block]</p> <p>If that shortcode exists in content and has the attribute position=top, I would like to remove it from the content and display it in other place. For example, in sidebar.</p> <p>In summary:</p> <ul> <li>Detect if [content_block] exists</li> <li>If exists, detect if has t...
[ { "answer_id": 168794, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": false, "text": "<pre><code>add_filter( 'the_content', 'wpse168789_shortcode_checker' );\nfunction wpse168789_shortcode_checker( $c...
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168789", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16871/" ]
I have a shortcode: [content\_block] If that shortcode exists in content and has the attribute position=top, I would like to remove it from the content and display it in other place. For example, in sidebar. In summary: * Detect if [content\_block] exists * If exists, detect if has the attibute position=top * If has...
You can look to the code WordPress uses for parsing Shortcodes to get some ideas about how to do this. There are a couple of helpful core functions to simplify things. ``` // our callback function to check for the shortcode. // this is where you'd put code to set a flag for rendering the shortcode elsewhere // the com...
168,798
<p>Based on advice I got from another <a href="https://wordpress.stackexchange.com/questions/168446">question</a>, I created a development copy of a multisite installation I've inherited inside of a <a href="http://vagrantup.com" rel="nofollow noreferrer">Vagrant VM</a>. </p> <p>On a test site as described here...</p>...
[ { "answer_id": 168802, "author": "user42826", "author_id": 42826, "author_profile": "https://wordpress.stackexchange.com/users/42826", "pm_score": 3, "selected": true, "text": "<p>The 404 is coming from your http server and not making it to WP. htaccess is not configured on your server....
2014/11/18
[ "https://wordpress.stackexchange.com/questions/168798", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33401/" ]
Based on advice I got from another [question](https://wordpress.stackexchange.com/questions/168446), I created a development copy of a multisite installation I've inherited inside of a [Vagrant VM](http://vagrantup.com). On a test site as described here... ![enter image description here](https://i.stack.imgur.com/tH...
The 404 is coming from your http server and not making it to WP. htaccess is not configured on your server.
168,867
<p>I need to add custom inline styles to the header of a custom theme I'm creating. I've come across the <code>wp_add_inline_style()</code> function, which works but doesn't really suit me as it depends of a specific stylesheet. I'd need to add inline styles at the end of the head tag without a stylesheet dependency.</...
[ { "answer_id": 168889, "author": "SkyShab", "author_id": 63263, "author_profile": "https://wordpress.stackexchange.com/users/63263", "pm_score": 6, "selected": true, "text": "<p>You just need to add the styles directly to the page head. The best way to do this is to use the 'wp_head' act...
2014/11/19
[ "https://wordpress.stackexchange.com/questions/168867", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63675/" ]
I need to add custom inline styles to the header of a custom theme I'm creating. I've come across the `wp_add_inline_style()` function, which works but doesn't really suit me as it depends of a specific stylesheet. I'd need to add inline styles at the end of the head tag without a stylesheet dependency. I've tried to ...
You just need to add the styles directly to the page head. The best way to do this is to use the 'wp\_head' action hook, assuming you are using a theme that has the hook. Like so: ``` add_action('wp_head', 'my_custom_styles', 100); function my_custom_styles() { echo "<style>*{color: red}</style>"; } ``` Check out ...
168,872
<p>I'm writing a child theme for the editr theme and the featured image is not displaying for a new post. The featured images do display for demo content. For the new post, the following markup is rendered:</p> <pre><code>&lt;div class="featured" data-img_bg=""&gt; &lt;img src="" alt="" style="display: block;"...
[ { "answer_id": 168877, "author": "TomC", "author_id": 36980, "author_profile": "https://wordpress.stackexchange.com/users/36980", "pm_score": 0, "selected": false, "text": "<p>Is the html output to the page?\nIf not, then the issue is almost certainly with your if statement.\nShould it b...
2014/11/19
[ "https://wordpress.stackexchange.com/questions/168872", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/500/" ]
I'm writing a child theme for the editr theme and the featured image is not displaying for a new post. The featured images do display for demo content. For the new post, the following markup is rendered: ``` <div class="featured" data-img_bg=""> <img src="" alt="" style="display: block;"> </div> ``` The ...
The php extension PHP GD was not installed on my dev machine. Installing php5-gd resolved this - `sudo apt-get install php5-gd` Stepping through using xdebug revealed that the theme's `aq_resize` function was failing at the following code: ``` else { $editor = wp_get_image_editor($img_path); if ( is_wp_erro...
168,891
<p>I want to know if it is good practice to use: </p> <pre><code>if ( current_user_can( 'edit_user', $user_id ) ) { // do something } </code></pre> <p>because in Wordpress documentation a did not see this capability</p>
[ { "answer_id": 168894, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>Yes it can be good practice to check if a user is capable of doing something before doing something related i...
2014/11/19
[ "https://wordpress.stackexchange.com/questions/168891", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/55330/" ]
I want to know if it is good practice to use: ``` if ( current_user_can( 'edit_user', $user_id ) ) { // do something } ``` because in Wordpress documentation a did not see this capability
Yes it can be good practice to check if a user is capable of doing something before doing something related in code. For example, don't save a custom post type if the user doesn't have the capabilities needed to do it, or don't show certain things to users who don't have the `manage_options` capability ( super admins ...
168,899
<p>I am working on a plugin for 'hooking' an extra payment provider into a checkout system.</p> <p>I have a class <em>gtpCheckoutData</em> in my function.php which calculates the prices.</p> <p>In my plugin I want to use data from this <em>gtpCheckoutData</em> class, but if I do that I get a:</p> <p><strong>Fatal er...
[ { "answer_id": 168901, "author": "SkyShab", "author_id": 63263, "author_profile": "https://wordpress.stackexchange.com/users/63263", "pm_score": 2, "selected": true, "text": "<p>Plugins are loaded before functions.php. You should include the class in your plugin if possible. </p>\n\n<p>I...
2014/11/19
[ "https://wordpress.stackexchange.com/questions/168899", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25834/" ]
I am working on a plugin for 'hooking' an extra payment provider into a checkout system. I have a class *gtpCheckoutData* in my function.php which calculates the prices. In my plugin I want to use data from this *gtpCheckoutData* class, but if I do that I get a: **Fatal error: Class gtpCheckoutData not found in** M...
Plugins are loaded before functions.php. You should include the class in your plugin if possible. I have had scenarios where a class was part of the theme, but also needed in a plugin where you couldn't assume the class was included in the theme. In those cases, I simply included the class in both places and wrapped ...
168,913
<p>Am actually new to wordpress development. I am just trying to change title of the individual post..So i have used the function <code>get_the_ID()</code> to fetch a specific post.</p> <p>I know the name of the title can be changed by a user manually,But i just want to weather this can be done with the code.</p> <p>...
[ { "answer_id": 168922, "author": "apetto", "author_id": 62494, "author_profile": "https://wordpress.stackexchange.com/users/62494", "pm_score": 0, "selected": false, "text": "<p>i'm not a very good coder, and even my english is not the best, but I think you must enter a title for every p...
2014/11/19
[ "https://wordpress.stackexchange.com/questions/168913", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52461/" ]
Am actually new to wordpress development. I am just trying to change title of the individual post..So i have used the function `get_the_ID()` to fetch a specific post. I know the name of the title can be changed by a user manually,But i just want to weather this can be done with the code. So i have tried adding a fun...
Your question isn't terribly clear, because, yes it is possible to change post data programmatically, and you're on the right track using wp\_update\_post, but I'm unsure of what the code in your theme's index.php file is trying to achieve. My assumption is that you want to be able to change the post title from your ...
168,926
<p>I have this function to convert any YouTube URL in any post or page to embed :-</p> <pre><code>function embed_youtube_an($post_content) { global $posts; //preg_match('|http://www.youtube.com/watch?v=([a-zA-Z0-9]+)|', $posts-&gt;post_content, $matches); preg_match('#http://w?w?w?.?youtube.com/watch\?v=([A-Za-...
[ { "answer_id": 168927, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 3, "selected": false, "text": "<p><strong>EDIT</strong></p>\n\n<p>After reviewing your edit, you may want to try following <a href=\"http://c...
2014/11/19
[ "https://wordpress.stackexchange.com/questions/168926", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63665/" ]
I have this function to convert any YouTube URL in any post or page to embed :- ``` function embed_youtube_an($post_content) { global $posts; //preg_match('|http://www.youtube.com/watch?v=([a-zA-Z0-9]+)|', $posts->post_content, $matches); preg_match('#http://w?w?w?.?youtube.com/watch\?v=([A-Za-z0-9\-_]+)#s', $p...
**EDIT** After reviewing your edit, you may want to try following [These Instructions](http://codex.wordpress.org/Embeds) > > To embed a video or another object into a post or page, place its URL into the content area. Make sure the URL is on its own line and not hyperlinked (clickable when viewing the post). > > ...
168,939
<p>I have searched all through the forums and WP docs, but can't find an answer to whether or not WP Meta Query permits a sub meta query. My problem is this: I have a number of types of promos (custom post type) with start and end dates(stored as unixtime in the db). I want to exclude one type of promo ("walls", which ...
[ { "answer_id": 168940, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 1, "selected": false, "text": "<p>I don't think you need the <code>relation</code> parameter. It defaults to <code>AND</code>.</p>\n\n<pre><co...
2014/11/19
[ "https://wordpress.stackexchange.com/questions/168939", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11023/" ]
I have searched all through the forums and WP docs, but can't find an answer to whether or not WP Meta Query permits a sub meta query. My problem is this: I have a number of types of promos (custom post type) with start and end dates(stored as unixtime in the db). I want to exclude one type of promo ("walls", which is ...
I don't think you need the `relation` parameter. It defaults to `AND`. ``` $nowtime = time(); $the_query = new WP_Query( array( 'post_type' => 'promos', 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'wpcf-type-of-promo', ...
168,943
<p>I need to query all posts that belong to a given category (default, not custom) and a custom post type. As simple as that. The fact that it doesn't work, to me, is ridiculous. Unless I'm missing something?</p> <p>Here's what I've tried:</p> <pre><code>$args=array( 'posts_per_page' =&gt; 50, //'taxonomy' =...
[ { "answer_id": 238948, "author": "kunal Gauswami", "author_id": 102633, "author_profile": "https://wordpress.stackexchange.com/users/102633", "pm_score": 4, "selected": false, "text": "<p>try this, it's work for me.</p>\n\n<pre><code> $args=array(\n 'posts_per_page' =&gt; 50, \n ...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/168943", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63414/" ]
I need to query all posts that belong to a given category (default, not custom) and a custom post type. As simple as that. The fact that it doesn't work, to me, is ridiculous. Unless I'm missing something? Here's what I've tried: ``` $args=array( 'posts_per_page' => 50, //'taxonomy' => 'category', ...
try this, it's work for me. ``` $args=array( 'posts_per_page' => 50, 'post_type' => 'my_custom_type' 'cat' => $cat_id, ); $wp_query = new WP_Query( $args ); ``` **Category Parameters** ``` cat (int): use category id. category_name (string): use category slug (NOT name). category__and (array): use c...
168,946
<p>I'm new in wordpress .I wondering is there anyway to get the category id in permalink ? My current permalink is :</p> <pre><code>http:///example.com/%category%/%post_id%-%postname%.html http:///example.com/music/1-hello.html </code></pre> <p>Now my music category_id is 2 , how to add this category_id to permalink ...
[ { "answer_id": 238948, "author": "kunal Gauswami", "author_id": 102633, "author_profile": "https://wordpress.stackexchange.com/users/102633", "pm_score": 4, "selected": false, "text": "<p>try this, it's work for me.</p>\n\n<pre><code> $args=array(\n 'posts_per_page' =&gt; 50, \n ...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/168946", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63714/" ]
I'm new in wordpress .I wondering is there anyway to get the category id in permalink ? My current permalink is : ``` http:///example.com/%category%/%post_id%-%postname%.html http:///example.com/music/1-hello.html ``` Now my music category\_id is 2 , how to add this category\_id to permalink ? I want to this: ``` h...
try this, it's work for me. ``` $args=array( 'posts_per_page' => 50, 'post_type' => 'my_custom_type' 'cat' => $cat_id, ); $wp_query = new WP_Query( $args ); ``` **Category Parameters** ``` cat (int): use category id. category_name (string): use category slug (NOT name). category__and (array): use c...
168,949
<p>I want to add <code>nofollow</code> attribute to only external links in the content of the post. Internal links should stay <code>follow</code>.</p> <p>So, can I use <code>wp_rel_nofollow()</code> to make only external links nofollow? Or do I need to use another method?</p>
[ { "answer_id": 168953, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 3, "selected": true, "text": "<p><code>wp_rel_nofollow()</code> add nofollow attribute to all links so we can not use it or may be I am not ...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/168949", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14128/" ]
I want to add `nofollow` attribute to only external links in the content of the post. Internal links should stay `follow`. So, can I use `wp_rel_nofollow()` to make only external links nofollow? Or do I need to use another method?
`wp_rel_nofollow()` add nofollow attribute to all links so we can not use it or may be I am not sure how. You can use this function to add `rel="nofollow"` to all external links. This function will check all links in content against your blog/website URL (as internal domain) and add nofollow attribute if both does not...
168,956
<p>I am really struggling with this one - hopefully someone here can help...</p> <p>I am installing a brand new, fresh version of Wordpress v4.0 (A task I've performed easily 100+ times before without incident)</p> <p>I have setup a brand new sub-domain and database for it then run the install script... But, everytim...
[ { "answer_id": 168953, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 3, "selected": true, "text": "<p><code>wp_rel_nofollow()</code> add nofollow attribute to all links so we can not use it or may be I am not ...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/168956", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10368/" ]
I am really struggling with this one - hopefully someone here can help... I am installing a brand new, fresh version of Wordpress v4.0 (A task I've performed easily 100+ times before without incident) I have setup a brand new sub-domain and database for it then run the install script... But, everytime I try, I get ca...
`wp_rel_nofollow()` add nofollow attribute to all links so we can not use it or may be I am not sure how. You can use this function to add `rel="nofollow"` to all external links. This function will check all links in content against your blog/website URL (as internal domain) and add nofollow attribute if both does not...
168,967
<p><img src="https://i.stack.imgur.com/qQDnm.png" alt="enter image description here"></p> <p>I was creating a wordpress sidebar widget that will display recent posts. For, this i've created a custom widget(<strong>popular_posts_widget.php</strong>) and included in my theme <strong>functions.php</strong>. I was trying ...
[ { "answer_id": 168953, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 3, "selected": true, "text": "<p><code>wp_rel_nofollow()</code> add nofollow attribute to all links so we can not use it or may be I am not ...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/168967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62377/" ]
![enter image description here](https://i.stack.imgur.com/qQDnm.png) I was creating a wordpress sidebar widget that will display recent posts. For, this i've created a custom widget(**popular\_posts\_widget.php**) and included in my theme **functions.php**. I was trying to display post titles which when clicked displa...
`wp_rel_nofollow()` add nofollow attribute to all links so we can not use it or may be I am not sure how. You can use this function to add `rel="nofollow"` to all external links. This function will check all links in content against your blog/website URL (as internal domain) and add nofollow attribute if both does not...
168,981
<p>By default, when I click on an item in the media library, it takes me to the Attachment Details page, e.g. <code>.../wp-admin/upload.php?item=65</code>.</p> <p>What would I need to edit to make it go straight to the "Edit More Details" page instead? E.g. <code>.../wp-admin/post.php?post=65&amp;action=edit</code></p...
[ { "answer_id": 169378, "author": "Jeppe", "author_id": 28415, "author_profile": "https://wordpress.stackexchange.com/users/28415", "pm_score": 0, "selected": false, "text": "<p>You would be changing the wordpress back-end, these changes will be lost when updating.</p>\n\n<p>I suggest you...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/168981", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63673/" ]
By default, when I click on an item in the media library, it takes me to the Attachment Details page, e.g. `.../wp-admin/upload.php?item=65`. What would I need to edit to make it go straight to the "Edit More Details" page instead? E.g. `.../wp-admin/post.php?post=65&action=edit` I assumed it would be as simple as ch...
From `/wp-includes/script-loader.php`: ``` $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); ``` From `wp-admin/upload.php`: ``` wp_enqueue_script( 'media-grid' ); wp_enqueue_script( 'media' ); wp_localize_script( 'media-grid', '_wpMediaGridSettings', array( ...
169,032
<p>So I have a custom post title being written by a front-end (non-admin access) form using AFC fields. What I am after is a way to update the title when the post is updated from the front-end edit form.</p> <p>Here's the working code to assign the post title from ACF fields in the functions.php:</p> <pre><code>funct...
[ { "answer_id": 169040, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>That post ID is used to cross-link data across many different tables by the WordPress Core, plus whatever pl...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/169032", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63713/" ]
So I have a custom post title being written by a front-end (non-admin access) form using AFC fields. What I am after is a way to update the title when the post is updated from the front-end edit form. Here's the working code to assign the post title from ACF fields in the functions.php: ``` function auto_title_insert...
If you want sequential numbers for your posts, then don't use the post ID column. `AUTO_INCREMENT` is meant to provide unique numbers (and split-brains in multi-master replication), it is never going to be without gaps, especially not in WordPress (revisions, autosaves, pages, contact forms, galleries and a bunch of o...
169,046
<p>I have a custom post-type "downloads", and within the downloads menu, I have download categories, the taxonomy name is "downloadcats".</p> <p>My Downloads page uses a page template that lists all categories in the "downloadcats" taxonomy, this only shows parent categories. When a category is clicked, it uses the ta...
[ { "answer_id": 169083, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": true, "text": "<p>You are so very close here, you can almost smell it. Here is how you would complete your code:</p>\n\n<p...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/169046", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34820/" ]
I have a custom post-type "downloads", and within the downloads menu, I have download categories, the taxonomy name is "downloadcats". My Downloads page uses a page template that lists all categories in the "downloadcats" taxonomy, this only shows parent categories. When a category is clicked, it uses the taxonomy arc...
You are so very close here, you can almost smell it. Here is how you would complete your code: You already have all your child terms stored in an array called `$children`. To display these, you simply need a `foreach` loop. Something like this will do the trick. (You can just extend on this, simply do a `var_dump` or ...
169,050
<p>I am developing a e-commerce theme that requires an order page. I created a php file inside my theme folder named order-page.php and hope to access this page from the wordpress root url (example.com/order-page)</p> <pre><code>add_action('template_redirect', 'template_redirect'); function template_redirect(){ $b...
[ { "answer_id": 169075, "author": "Lulu", "author_id": 31211, "author_profile": "https://wordpress.stackexchange.com/users/31211", "pm_score": 0, "selected": false, "text": "<p>You should take a look at the WordPress hierarchy page in the documentation. Here it's the relevant part:</p>\n<...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/169050", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63195/" ]
I am developing a e-commerce theme that requires an order page. I created a php file inside my theme folder named order-page.php and hope to access this page from the wordpress root url (example.com/order-page) ``` add_action('template_redirect', 'template_redirect'); function template_redirect(){ $basename = base...
Problem#1: ---------- You can create a customized php file for your page using a **Page Template** > > ### [Page Templates](https://developer.wordpress.org/themes/template-files-section/page-templates/) > > > WordPress looks for template files in the following order: > > > 1. Page Template — If the page has a cu...
169,053
<p>I am creating a site for a friend of mine and I'm having trouble with the width of my homepage.</p> <p>The homepage is set as a full width page but when you view it it only displays about 60% of the span. Before attempting to do this on my friend's server and domain, I used a domain of myown to show him a model and...
[ { "answer_id": 169075, "author": "Lulu", "author_id": 31211, "author_profile": "https://wordpress.stackexchange.com/users/31211", "pm_score": 0, "selected": false, "text": "<p>You should take a look at the WordPress hierarchy page in the documentation. Here it's the relevant part:</p>\n<...
2014/11/20
[ "https://wordpress.stackexchange.com/questions/169053", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63764/" ]
I am creating a site for a friend of mine and I'm having trouble with the width of my homepage. The homepage is set as a full width page but when you view it it only displays about 60% of the span. Before attempting to do this on my friend's server and domain, I used a domain of myown to show him a model and the model...
Problem#1: ---------- You can create a customized php file for your page using a **Page Template** > > ### [Page Templates](https://developer.wordpress.org/themes/template-files-section/page-templates/) > > > WordPress looks for template files in the following order: > > > 1. Page Template — If the page has a cu...
169,079
<p>I use following code (<a href="http://scratch99.com/wordpress/development/how-to-change-post-template-via-url-parameter/" rel="nofollow">Source</a>) to change the single post template via url parameter:</p> <pre><code>function sjc_add_query_vars($vars) { return array('template') + $vars; } add_filter('query_vars', ...
[ { "answer_id": 169129, "author": "Ralph", "author_id": 63191, "author_profile": "https://wordpress.stackexchange.com/users/63191", "pm_score": 0, "selected": false, "text": "<p><strong>Update:</strong> I've come to realize that we have different goals... @NewUser accepts that both URL st...
2014/11/21
[ "https://wordpress.stackexchange.com/questions/169079", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45407/" ]
I use following code ([Source](http://scratch99.com/wordpress/development/how-to-change-post-template-via-url-parameter/)) to change the single post template via url parameter: ``` function sjc_add_query_vars($vars) { return array('template') + $vars; } add_filter('query_vars', 'sjc_add_query_vars'); function sjc_tem...
Your should add rewrite endpoint `template` on theme activation hook and `init` hook. Also there is some little checks to perform to prevent errors. ``` function sjc_theme_activate(){ sjc_theme_add_rewrite_endpoint(); flush_rewrite_rules(); } //for more info http://codex.wordpress.org/Plugin_API/Action_Refere...
169,084
<p>I have a function that I am using to number posts in a category. It is in my function.php and looks like this:</p> <pre><code>function get_episode_number($postID){ $options = get_option('theme-opts'); $opts_cat = isset($options['opts-category']) ? $options['opts-category'] : ''; /* passes category from theme optio...
[ { "answer_id": 169129, "author": "Ralph", "author_id": 63191, "author_profile": "https://wordpress.stackexchange.com/users/63191", "pm_score": 0, "selected": false, "text": "<p><strong>Update:</strong> I've come to realize that we have different goals... @NewUser accepts that both URL st...
2014/11/21
[ "https://wordpress.stackexchange.com/questions/169084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18937/" ]
I have a function that I am using to number posts in a category. It is in my function.php and looks like this: ``` function get_episode_number($postID){ $options = get_option('theme-opts'); $opts_cat = isset($options['opts-category']) ? $options['opts-category'] : ''; /* passes category from theme options */ $postNu...
Your should add rewrite endpoint `template` on theme activation hook and `init` hook. Also there is some little checks to perform to prevent errors. ``` function sjc_theme_activate(){ sjc_theme_add_rewrite_endpoint(); flush_rewrite_rules(); } //for more info http://codex.wordpress.org/Plugin_API/Action_Refere...
169,100
<p>I have had a site that has been working perfectly for the past few months. Then all of a sudden when I go to upload an image via the Media Manager on the Admin Dashboard I get a 500: Internal Server Error.</p> <p>I don't understand what might be causing this. I checked my server error logs and there is nothing in t...
[ { "answer_id": 169129, "author": "Ralph", "author_id": 63191, "author_profile": "https://wordpress.stackexchange.com/users/63191", "pm_score": 0, "selected": false, "text": "<p><strong>Update:</strong> I've come to realize that we have different goals... @NewUser accepts that both URL st...
2014/11/21
[ "https://wordpress.stackexchange.com/questions/169100", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26255/" ]
I have had a site that has been working perfectly for the past few months. Then all of a sudden when I go to upload an image via the Media Manager on the Admin Dashboard I get a 500: Internal Server Error. I don't understand what might be causing this. I checked my server error logs and there is nothing in their that ...
Your should add rewrite endpoint `template` on theme activation hook and `init` hook. Also there is some little checks to perform to prevent errors. ``` function sjc_theme_activate(){ sjc_theme_add_rewrite_endpoint(); flush_rewrite_rules(); } //for more info http://codex.wordpress.org/Plugin_API/Action_Refere...
169,122
<p>I have this code to populate a custom dropdown menu of my WP categories. Now this is all working fine, but i'd like the current category to be selected in the dropdown. How can i do this?</p> <pre><code>&lt;select name="page-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'&gt; &l...
[ { "answer_id": 169125, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 0, "selected": false, "text": "<p>From the looks of this script, as soon as you click an option it redirects you to whatever the category arc...
2014/11/21
[ "https://wordpress.stackexchange.com/questions/169122", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32810/" ]
I have this code to populate a custom dropdown menu of my WP categories. Now this is all working fine, but i'd like the current category to be selected in the dropdown. How can i do this? ``` <select name="page-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <?php hierarchica...
Use the `selected` HTML attribute. [See w3schools docs](http://www.w3schools.com/tags/att_option_selected.asp). In your foreach loop, check if the current category matches the current iteration, and add the `selected` attribute to that `option` element. You are already getting the ID of each term, so you'll need to al...
169,123
<p>I am having some trouble with wordpress. First time user.</p> <p>How do you add an image in the title space in a post on wordpress.</p> <p>Can someone help ? Thank you</p>
[ { "answer_id": 169125, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 0, "selected": false, "text": "<p>From the looks of this script, as soon as you click an option it redirects you to whatever the category arc...
2014/11/21
[ "https://wordpress.stackexchange.com/questions/169123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63799/" ]
I am having some trouble with wordpress. First time user. How do you add an image in the title space in a post on wordpress. Can someone help ? Thank you
Use the `selected` HTML attribute. [See w3schools docs](http://www.w3schools.com/tags/att_option_selected.asp). In your foreach loop, check if the current category matches the current iteration, and add the `selected` attribute to that `option` element. You are already getting the ID of each term, so you'll need to al...
169,136
<p>I am trying to figure out the problem stated in the title. Every image/photo I upload to my wordpress site gets slightly blurry. I format them according to my wp theme requirements, however after the image is processed by wordpress and I open the site in a browser I is slightly blurry. This is specially noticeable i...
[ { "answer_id": 169137, "author": "vembutech", "author_id": 63807, "author_profile": "https://wordpress.stackexchange.com/users/63807", "pm_score": 0, "selected": false, "text": "<p>Normally this might due to some discrepancy from default set values for image in functions.php in wordpress...
2014/11/21
[ "https://wordpress.stackexchange.com/questions/169136", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63837/" ]
I am trying to figure out the problem stated in the title. Every image/photo I upload to my wordpress site gets slightly blurry. I format them according to my wp theme requirements, however after the image is processed by wordpress and I open the site in a browser I is slightly blurry. This is specially noticeable in F...
Actually WordPress reduce quality of image when you upload it via media uploader. WordPress has built in compression for JPG images. Whenever you upload an JPG/JPEG image to WordPress media library, WordPress will automatically compress your images to 90% of the original quality, this is intended to help your pages loa...
169,142
<p>I suspect I may be asking for the moon on a stick with this, but:</p> <p>I have a filter for my <code>shows</code> custom post type. The filter uses standard taxonomies attached to <code>shows</code>, but also allows the user to filter by Venue, which is a meta value for each show, or by Month, as there is a start ...
[ { "answer_id": 169156, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 0, "selected": false, "text": "<p>You can't figure out a way to do that because there is no such way. It is not possible to mix ANDs and ORs like th...
2014/11/21
[ "https://wordpress.stackexchange.com/questions/169142", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17826/" ]
I suspect I may be asking for the moon on a stick with this, but: I have a filter for my `shows` custom post type. The filter uses standard taxonomies attached to `shows`, but also allows the user to filter by Venue, which is a meta value for each show, or by Month, as there is a start date attached to each show. The...
Because I am a complete idiot, I seem to have completely forgotten that I [basically answered my own question over a year ago](https://wordpress.stackexchange.com/a/119222/17826). I was struggling to get the `posts_join` filter to behave (I generally have trouble with `INNER JOIN`s anyway), and so instead looked to t...
169,145
<p>I created a plugin and want to add a function to delete my tables from the database when a user deletes my plugin. I created a function that deletes tables from the DB when a user deactivates my plugin, but I don't want that. Here is the code:</p> <pre><code>// Delete table when deactivate function my_plugin_remov...
[ { "answer_id": 169192, "author": "Arevico", "author_id": 11487, "author_profile": "https://wordpress.stackexchange.com/users/11487", "pm_score": -1, "selected": false, "text": "<p>Unfortunately, WordPress does not expose functionality to do that. It only supports the register_uninstall_h...
2014/11/21
[ "https://wordpress.stackexchange.com/questions/169145", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63811/" ]
I created a plugin and want to add a function to delete my tables from the database when a user deletes my plugin. I created a function that deletes tables from the DB when a user deactivates my plugin, but I don't want that. Here is the code: ``` // Delete table when deactivate function my_plugin_remove_database() { ...
You could do this using the WordPress uninstall.php support: ``` <?php if( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit(); global $wpdb; $wpdb->query( "DROP TABLE IF EXISTS NestoNovo" ); delete_option("my_plugin_db_version"); ?> ``` This uninstall.php file is called when your plugin is deleted.
169,170
<p>I have many custom post types that need the Add [custom post type] feature but I have a custom post type of "About" and I do not need to "Add New" about to the about custom post type. So I want to remove the button on top that says "Add About"</p> <p>This is what I mean:</p> <p><img src="https://i.stack.imgur.com/...
[ { "answer_id": 169172, "author": "Helping Hands", "author_id": 63730, "author_profile": "https://wordpress.stackexchange.com/users/63730", "pm_score": 4, "selected": true, "text": "<p>Please refer below : </p>\n\n<pre><code>function disable_new_posts() {\n // Hide sidebar link\n gl...
2014/11/22
[ "https://wordpress.stackexchange.com/questions/169170", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63171/" ]
I have many custom post types that need the Add [custom post type] feature but I have a custom post type of "About" and I do not need to "Add New" about to the about custom post type. So I want to remove the button on top that says "Add About" This is what I mean: ![enter image description here](https://i.stack.imgur...
Please refer below : ``` function disable_new_posts() { // Hide sidebar link global $submenu; unset($submenu['edit.php?post_type=CUSTOM_POST_TYPE'][10]); // Hide link on listing page if (isset($_GET['post_type']) && $_GET['post_type'] == 'CUSTOM_POST_TYPE') { echo '<style type="text/css">...
169,178
<p>Currently my videos are hosted within my wp installation. I want to move all videos to my new server.</p> <p>Currently, my media url are as follows <a href="http://mysite.com/wp-content/uploads/video01.mp4" rel="noreferrer">http://mysite.com/wp-content/uploads/video01.mp4</a></p> <p>I am moving all videos to my ce...
[ { "answer_id": 169181, "author": "Helping Hands", "author_id": 63730, "author_profile": "https://wordpress.stackexchange.com/users/63730", "pm_score": -1, "selected": false, "text": "<p>Assuming that there are limited video in your site. you can replace URL by do following :</p>\n\n<p>Ex...
2014/11/22
[ "https://wordpress.stackexchange.com/questions/169178", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46060/" ]
Currently my videos are hosted within my wp installation. I want to move all videos to my new server. Currently, my media url are as follows <http://mysite.com/wp-content/uploads/video01.mp4> I am moving all videos to my central media server which will have this new url <http://media.mysite.com/videos/video01.mp4> M...
> > is there a way to update all media urls in wordpress > > > I had a similar issue with my media files not having the correct file location after a Wordpress upgrade (somehow all the media links switched to a crazy incorrect directory), so I found [Upload URL and Path Enabler](https://wordpress.org/plugins/uploa...
169,183
<p>Hey guys am new to wordpress development actually.I am trying to make my wordpress menu horizontal at the top below the title name.</p> <p>My <code>header.php</code></p> <p>In my header file i have assigned the menus with a class like</p> <pre><code>&lt;nav class="mythirdclass"&gt; &lt;?php wp_nav_menu(); ?&gt; &...
[ { "answer_id": 169181, "author": "Helping Hands", "author_id": 63730, "author_profile": "https://wordpress.stackexchange.com/users/63730", "pm_score": -1, "selected": false, "text": "<p>Assuming that there are limited video in your site. you can replace URL by do following :</p>\n\n<p>Ex...
2014/11/22
[ "https://wordpress.stackexchange.com/questions/169183", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52461/" ]
Hey guys am new to wordpress development actually.I am trying to make my wordpress menu horizontal at the top below the title name. My `header.php` In my header file i have assigned the menus with a class like ``` <nav class="mythirdclass"> <?php wp_nav_menu(); ?> </nav> ``` In my `style.css` in the style.css fi...
> > is there a way to update all media urls in wordpress > > > I had a similar issue with my media files not having the correct file location after a Wordpress upgrade (somehow all the media links switched to a crazy incorrect directory), so I found [Upload URL and Path Enabler](https://wordpress.org/plugins/uploa...
169,204
<p>I have a website: www.a.com<br> I want to add a folder of code samples like this: www.a.com/code//index.html<br> So that at the end of each post I can refer the user to an example. How can I create a static folder independent with Wordpress that can be accessed from the outside? </p>
[ { "answer_id": 169238, "author": "Jim Maguire", "author_id": 63669, "author_profile": "https://wordpress.stackexchange.com/users/63669", "pm_score": 0, "selected": false, "text": "<p>Well, for code samples, you can't beat putting them in a Git repository, then just putting a link into yo...
2014/11/22
[ "https://wordpress.stackexchange.com/questions/169204", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63239/" ]
I have a website: www.a.com I want to add a folder of code samples like this: www.a.com/code//index.html So that at the end of each post I can refer the user to an example. How can I create a static folder independent with Wordpress that can be accessed from the outside?
Use the File Manager from cPanel or use a FTP account, and easily create your folder wherever you want and then direct the user with its real path something like: ``` http://example.com/code/somepath/index.html ``` It should work. :)
169,219
<p>Hi everybody and thanks in advance for helping.</p> <p>I am experiencing a problem with the categories I have created for my custom post type: when I click on the URL of the category (every category) I get the query error message. It is not a 404 page, it just seems that Wordpress cannot retrieve posts from the tax...
[ { "answer_id": 169221, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>I get the query error message.</p>\n</blockquote>\n\n<p>What exactly is the error? </p>\n\n<p...
2014/11/22
[ "https://wordpress.stackexchange.com/questions/169219", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63846/" ]
Hi everybody and thanks in advance for helping. I am experiencing a problem with the categories I have created for my custom post type: when I click on the URL of the category (every category) I get the query error message. It is not a 404 page, it just seems that Wordpress cannot retrieve posts from the taxonomy. Th...
Your code is fine, I just tested it. Consider the following: Sometimes you may have a blog and you want URLS to beset up like `.xyz/DATE/POSTNAME` or perhaps you have a picture website and want it to be `.xyz/category/image`. Luckily, Wordpress has built-in functionality to handle this. They are known as `Permalinks...
169,263
<p>I have a Wordpress multisite.</p> <p>I would like to change the email address on the super admin account.</p> <p>The current email address on the super admin account is no longer accessible.</p> <p>I can change the Network Admin Email in Network Settings but if I try to change the super admin email in users > pro...
[ { "answer_id": 323689, "author": "Md. Ehsanul Haque Kanan", "author_id": 75705, "author_profile": "https://wordpress.stackexchange.com/users/75705", "pm_score": 1, "selected": false, "text": "<p>The question is old. However, I would like to answer it in the most effective way, as it can ...
2014/11/23
[ "https://wordpress.stackexchange.com/questions/169263", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17373/" ]
I have a Wordpress multisite. I would like to change the email address on the super admin account. The current email address on the super admin account is no longer accessible. I can change the Network Admin Email in Network Settings but if I try to change the super admin email in users > profile I get a message say...
The network admin email is changed from wp\_sitemeta table. Use following query in phpmyadmin or any mysql client in order to update the email if you are unable to change from network admin settings. ``` UPDATE `wp_sitemeta` SET `meta_value` = 'the_new_email@abc.com' WHERE `meta_value` = 'the_old_email@abc.com'; ``` ...
169,288
<p>I am looking to use the 'the_modified_date' function to display the date and time of a <strong>specific post</strong> has been modified. This information will appear in the header of our website on every single page.</p> <p>How would I go about completing this? </p> <p>I can use to get the title, and was hoping t...
[ { "answer_id": 169322, "author": "Helping Hands", "author_id": 63730, "author_profile": "https://wordpress.stackexchange.com/users/63730", "pm_score": -1, "selected": false, "text": "<p>Kindly refer below :</p>\n\n<pre><code> &lt;?php if (get_the_modified_time() != get_the_time()) : ?...
2014/11/23
[ "https://wordpress.stackexchange.com/questions/169288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63883/" ]
I am looking to use the 'the\_modified\_date' function to display the date and time of a **specific post** has been modified. This information will appear in the header of our website on every single page. How would I go about completing this? I can use to get the title, and was hoping there would be a way just as e...
Place this code snippet put in **function.php**, this should give you what you need. ``` function my_theme_wp_title( $title, $sep ) { global $post; /* my other title cases */ //get post's modified date $m_date = get_the_modified_date(); //concatenate the current title with the date string, using...
169,306
<p>I am trying to output a logo depending on which page is being viewed.</p> <pre><code>&lt;?php if ( is_page('home') || is_page('services') ) { ?&gt; &lt;div class="col-md-2 col-sm-4"&gt; &lt;?php ci_e_logo('&lt;h1 class="logo ' . get_logo_class() . '"&gt;', '&lt;/h1&gt;'); ?&gt; &lt;/div&gt; &lt;?php...
[ { "answer_id": 169307, "author": "Loai Abdelhalim", "author_id": 63843, "author_profile": "https://wordpress.stackexchange.com/users/63843", "pm_score": 1, "selected": false, "text": "<p>Use <code>get_post_ancestors($post)</code>. It will return an array if the current shown post is chil...
2014/11/24
[ "https://wordpress.stackexchange.com/questions/169306", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28275/" ]
I am trying to output a logo depending on which page is being viewed. ``` <?php if ( is_page('home') || is_page('services') ) { ?> <div class="col-md-2 col-sm-4"> <?php ci_e_logo('<h1 class="logo ' . get_logo_class() . '">', '</h1>'); ?> </div> <?php } else { ?> <div class="col-md-2 col-sm-4"> ...
``` <?php global $post; if ( is_page('home') || is_page('services') ) { ?> <div class="col-md-2 col-sm-4"> <?php ci_e_logo('<h1 class="logo ' . get_logo_class() . '">', '</h1>'); ?> </div> <?php } elseif ( preg_match( '#^service(/.+)?$#', $wp->request ) ) { ?> <div class="col-md-2 col-sm-4"> ...
169,311
<p>I've been wasting hours and hours trying to solve a permalink issue with custom post types. It keeps returning page not found (404). When I use the default permalinks, it works, but when I switch to post-name, it breaks. I have tried changing the slug name, flush rewrite, disabling all plug-ins, a 'custom post type ...
[ { "answer_id": 169314, "author": "Ankit Panchal", "author_id": 63895, "author_profile": "https://wordpress.stackexchange.com/users/63895", "pm_score": 0, "selected": false, "text": "<p>I checked it with create the Authors Custom post type.</p>\n\n<p>I just changed the permalink structure...
2014/11/24
[ "https://wordpress.stackexchange.com/questions/169311", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63894/" ]
I've been wasting hours and hours trying to solve a permalink issue with custom post types. It keeps returning page not found (404). When I use the default permalinks, it works, but when I switch to post-name, it breaks. I have tried changing the slug name, flush rewrite, disabling all plug-ins, a 'custom post type per...
Every time while you create new post type with code (plugins do that automatically) you have to rebuild/update you permalink on Settings - Permalink.
169,359
<p>I've got the following WP_USER_QUERY in WordPress:</p> <pre><code>$args = array( 'orderby'=&gt;'meta_value', 'meta_query' =&gt; array ( 0 =&gt; array( 'key' =&gt; 'last_name', 'value' =&gt; 'smith' ), 1 =&gt; array( ...
[ { "answer_id": 169361, "author": "SinisterBeard", "author_id": 63673, "author_profile": "https://wordpress.stackexchange.com/users/63673", "pm_score": 1, "selected": true, "text": "<p>Short answer: you can't. I had to write a custom query.</p>\n" }, { "answer_id": 313831, "au...
2014/11/24
[ "https://wordpress.stackexchange.com/questions/169359", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63673/" ]
I've got the following WP\_USER\_QUERY in WordPress: ``` $args = array( 'orderby'=>'meta_value', 'meta_query' => array ( 0 => array( 'key' => 'last_name', 'value' => 'smith' ), 1 => array( 'key' => 'first_name' ...
Short answer: you can't. I had to write a custom query.
169,360
<p>I'm using <a href="http://codex.wordpress.org/Function_Reference/is_email"><code>is_email()</code></a> to check if a user-provided email address is valid. For example:</p> <pre><code>$email = $_POST['email']; if ( is_email( $email ) ) // Do something. </code></pre> <p>To the best of my knowledge, nothing in th...
[ { "answer_id": 169365, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 4, "selected": true, "text": "<p>Looking at the <a href=\"https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/formatting.php#L20...
2014/11/24
[ "https://wordpress.stackexchange.com/questions/169360", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22599/" ]
I'm using [`is_email()`](http://codex.wordpress.org/Function_Reference/is_email) to check if a user-provided email address is valid. For example: ``` $email = $_POST['email']; if ( is_email( $email ) ) // Do something. ``` To the best of my knowledge, nothing in this function writes info to the database. Should ...
Looking at the [`is_email()`](https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/formatting.php#L2089) functionality on trac, it looks like you don't need to sanatizie as it's just string testing. I would even go so far as to say that if this function returns true, you wouldn't need to sanitize it before ...
169,408
<p>I use Wp_query class to query my posts. 15 posts are in a template fetched on page load and their filtering works fine. Infinity scroll fetches for other posts using <a href="https://wordpress.org/plugins/json-rest-api/">JSON restful services</a>. The filter on the server side works fine but I don't know how to tra...
[ { "answer_id": 169471, "author": "DamianS1987", "author_id": 59728, "author_profile": "https://wordpress.stackexchange.com/users/59728", "pm_score": 3, "selected": false, "text": "<p>Sorry for answering my own question but it may help some other devs too.</p>\n\n<p>I created this additio...
2014/11/24
[ "https://wordpress.stackexchange.com/questions/169408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59728/" ]
I use Wp\_query class to query my posts. 15 posts are in a template fetched on page load and their filtering works fine. Infinity scroll fetches for other posts using [JSON restful services](https://wordpress.org/plugins/json-rest-api/). The filter on the server side works fine but I don't know how to transfer the log...
Sorry for answering my own question but it may help some other devs too. I created this additional filter 'json\_query\_var-meta\_query'that returns the necessary arguments. ``` function adjustQrry($data){ $args = array(); $args['relation'] = 'AND'; foreach ($data as $key=>$value) { if ( 'relatio...
169,434
<p>I have moved my wordpress blog to new domain.</p> <p>Old Address : <strong>domainname.com/blog</strong> | New Address : <strong>newdomainname.com</strong></p> <p>Please pay attention about <strong>old address and new address</strong>.</p> <p>Now I want to redirect all old pages to new blog ( should be 30 redirect...
[ { "answer_id": 169436, "author": "Helping Hands", "author_id": 63730, "author_profile": "https://wordpress.stackexchange.com/users/63730", "pm_score": 0, "selected": false, "text": "<p>Below query will help you to replace old pages to new domain :</p>\n\n<pre><code>UPDATE wp_options SET ...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169434", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56652/" ]
I have moved my wordpress blog to new domain. Old Address : **domainname.com/blog** | New Address : **newdomainname.com** Please pay attention about **old address and new address**. Now I want to redirect all old pages to new blog ( should be 30 redirection). I could not find way to do it properly because I moved ...
### WAY #1 - cPanel I assume your host is using cPanel managing your Server. Browse `domainname.com/cpanel`, login their with cPanel credential: ![enter image description here](https://i.stack.imgur.com/vVGAR.png) Change the values according the following image: ![enter image description here](https://i.stack....
169,457
<p>What I'm trying to achieve is to set the list shown in alphabetical order. Any thoughts on how i can successfully achieve this? </p> <p>I have pasted the snippet below for reference. </p> <pre><code> &lt;ul class="hotel-list"&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; ...
[ { "answer_id": 169458, "author": "Helping Hands", "author_id": 63730, "author_profile": "https://wordpress.stackexchange.com/users/63730", "pm_score": -1, "selected": true, "text": "<p>Set below code : </p>\n\n<pre><code> &lt;?php if (is_category()) { $posts = query_posts($query_string ...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58748/" ]
What I'm trying to achieve is to set the list shown in alphabetical order. Any thoughts on how i can successfully achieve this? I have pasted the snippet below for reference. ``` <ul class="hotel-list"> <?php while (have_posts()) : the_post(); ?> <?php $sho...
Set below code : ``` <?php if (is_category()) { $posts = query_posts($query_string .'&orderby=title&order=asc'); } ?> ``` You can exclude if condition if do not using category. For more reference: [Alphabetizing Posts](http://codex.wordpress.org/Alphabetizing_Posts)
169,466
<p>I have WP-CLI working fine using WP Multisite (or network). I can create blogs, add users, set permissions etc. But am not certain how to enable plugins for individual blogs via WP CLI.</p> <p>For example, I can see for a specific blog that I have the following plugins enabled:</p> <pre><code>$ wp option get activ...
[ { "answer_id": 169458, "author": "Helping Hands", "author_id": 63730, "author_profile": "https://wordpress.stackexchange.com/users/63730", "pm_score": -1, "selected": true, "text": "<p>Set below code : </p>\n\n<pre><code> &lt;?php if (is_category()) { $posts = query_posts($query_string ...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169466", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63957/" ]
I have WP-CLI working fine using WP Multisite (or network). I can create blogs, add users, set permissions etc. But am not certain how to enable plugins for individual blogs via WP CLI. For example, I can see for a specific blog that I have the following plugins enabled: ``` $ wp option get active_plugins --url=blogs...
Set below code : ``` <?php if (is_category()) { $posts = query_posts($query_string .'&orderby=title&order=asc'); } ?> ``` You can exclude if condition if do not using category. For more reference: [Alphabetizing Posts](http://codex.wordpress.org/Alphabetizing_Posts)
169,469
<p>I have a plugin that shows posts from a chosen category. When child categories are chosen it works perfectly. However when i choose a parent category, it doesn't display any posts from the child categories.</p> <p>I hope this is the snippet that has to be changed, but i'm not sure.</p> <p>Would be nice if someone ...
[ { "answer_id": 169483, "author": "Seenuvasan Velayutham", "author_id": 64188, "author_profile": "https://wordpress.stackexchange.com/users/64188", "pm_score": -1, "selected": false, "text": "<p>you may use this way:</p>\n\n<pre><code> &lt;?php\n$category_id = get_cat_ID('Category Name...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169469", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62365/" ]
I have a plugin that shows posts from a chosen category. When child categories are chosen it works perfectly. However when i choose a parent category, it doesn't display any posts from the child categories. I hope this is the snippet that has to be changed, but i'm not sure. Would be nice if someone could help me. `...
As I have stated in my comments to your question > > Crappy written plugins always leads to some disaster at some time. In my opinion, delete that plugin and write your own code or find a properly written plugin. There is no use changing the damaged tire while the whole car is a complete write-off :-) > > > Just ...
169,475
<p>I am using the <a href="https://wordpress.org/plugins/manual-image-crop/" rel="nofollow">Manual Image Crop</a> plugin to set thumbnails for images. I am not using any images as 'featured images' however.</p> <p>I have a number of thumbnails saved to each image. If I use <code>wp_get_attachment_link(id, 'medium');</...
[ { "answer_id": 169479, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 3, "selected": true, "text": "<p>Have a look at <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src\" rel=\"no...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51823/" ]
I am using the [Manual Image Crop](https://wordpress.org/plugins/manual-image-crop/) plugin to set thumbnails for images. I am not using any images as 'featured images' however. I have a number of thumbnails saved to each image. If I use `wp_get_attachment_link(id, 'medium');` then I get the desired 'medium' thumbnail...
Have a look at [wp\_get\_attachment\_image\_src](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src) ``` <?php $attachment_id = 8; // attachment ID $image_attributes = wp_get_attachment_image_src( $attachment_id, 'medium' ); // returns an array if( $image_attributes ) { ?> <img src="<?php ech...
169,481
<p>I quite often run into a situation where I develop a site on a staging domain, have my client fill it there with content, and then when everything's approved move it to production. Now, my installation is quite portable (permalinks, assets are all fine), and I have environment-specific configuration, the only thing ...
[ { "answer_id": 169479, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 3, "selected": true, "text": "<p>Have a look at <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src\" rel=\"no...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169481", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40553/" ]
I quite often run into a situation where I develop a site on a staging domain, have my client fill it there with content, and then when everything's approved move it to production. Now, my installation is quite portable (permalinks, assets are all fine), and I have environment-specific configuration, the only thing tha...
Have a look at [wp\_get\_attachment\_image\_src](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src) ``` <?php $attachment_id = 8; // attachment ID $image_attributes = wp_get_attachment_image_src( $attachment_id, 'medium' ); // returns an array if( $image_attributes ) { ?> <img src="<?php ech...
169,499
<p>I'm using the Advanced Custom Fields plugin to place a taxonomy checkbox on certain pages. </p> <p>This checkbox will filter the data that is pulled through etc on that page.</p> <p>Using the example found on the ACF website (which aims at using the term object output) - </p> <pre><code>&lt;?php $terms = get_fi...
[ { "answer_id": 169501, "author": "karpstrucking", "author_id": 55214, "author_profile": "https://wordpress.stackexchange.com/users/55214", "pm_score": 1, "selected": true, "text": "<p>if I recall correctly, <code>get_field()</code> simply returns the value of the field, not the actual te...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169499", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63971/" ]
I'm using the Advanced Custom Fields plugin to place a taxonomy checkbox on certain pages. This checkbox will filter the data that is pulled through etc on that page. Using the example found on the ACF website (which aims at using the term object output) - ``` <?php $terms = get_field('taxonomy_field_name'); if...
if I recall correctly, `get_field()` simply returns the value of the field, not the actual term object. try using this with `get_term()` (or `get_term_by()` depending on your needs/preference).
169,504
<p>How can I get the current custom post type name and echo it on a page?</p>
[ { "answer_id": 169509, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 5, "selected": false, "text": "<p>You'll need the post object somehow, or, alternatively the queried object on post type archives. On a si...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169504", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25971/" ]
How can I get the current custom post type name and echo it on a page?
You'll need the post object somehow, or, alternatively the queried object on post type archives. On a singular page you might do: ``` $post = get_queried_object(); $postType = get_post_type_object(get_post_type($post)); if ($postType) { echo esc_html($postType->labels->singular_name); } ``` Or in the loop: ``` ...
169,510
<p>I have looked all over the Codex and searched the web and I cannot find a way to accomplish what I am trying to do. All I need to do is display what CPT a post belongs to. For instance, I have two different post types, Courses and Resources, and I need a way to output which one of these a particular post belongs to....
[ { "answer_id": 169509, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 5, "selected": false, "text": "<p>You'll need the post object somehow, or, alternatively the queried object on post type archives. On a si...
2014/11/25
[ "https://wordpress.stackexchange.com/questions/169510", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58422/" ]
I have looked all over the Codex and searched the web and I cannot find a way to accomplish what I am trying to do. All I need to do is display what CPT a post belongs to. For instance, I have two different post types, Courses and Resources, and I need a way to output which one of these a particular post belongs to. Ca...
You'll need the post object somehow, or, alternatively the queried object on post type archives. On a singular page you might do: ``` $post = get_queried_object(); $postType = get_post_type_object(get_post_type($post)); if ($postType) { echo esc_html($postType->labels->singular_name); } ``` Or in the loop: ``` ...
169,555
<p>I got a table with one of the column have special charaters. I inserted to the table as</p> <pre><code>$sql=$wpdb-&gt;prepare( "INSERT INTO `mytable` ( `question`, `remarks`) VALUES ('%s', '%s' )", array(sanitize_text_field($question),sanitize_text_field($remarks)) ); $wpdb-&g...
[ { "answer_id": 169557, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 0, "selected": false, "text": "<p>You can try the following query</p>\n\n<pre><code>SELECT * FROM `mytable` WHERE `question` = '\\\\\\\"creating...
2014/11/26
[ "https://wordpress.stackexchange.com/questions/169555", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63619/" ]
I got a table with one of the column have special charaters. I inserted to the table as ``` $sql=$wpdb->prepare( "INSERT INTO `mytable` ( `question`, `remarks`) VALUES ('%s', '%s' )", array(sanitize_text_field($question),sanitize_text_field($remarks)) ); $wpdb->query($sql); ``` ...
Guys i figured out a way to do this.... Not a clean one but it just do the job for me.. ``` global $wpdb; $sql=$wpdb->prepare("SELECT * FROM mytable WHERE question ='%s'", like_escape(sanitize_text_field($question))); /******************* actualy following do the trick for me all SINGLE ...
169,561
<p>I have successfully implemented a <a href="https://wordpress.stackexchange.com/questions/142215/custom-excerpt-showing-first-paragraph-with-html-formatting">solution from WPSE</a> that trims the except to the first paragraph, but I'd like to change that to trim after the second paragraph instead. </p> <p>There's a ...
[ { "answer_id": 169557, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 0, "selected": false, "text": "<p>You can try the following query</p>\n\n<pre><code>SELECT * FROM `mytable` WHERE `question` = '\\\\\\\"creating...
2014/11/26
[ "https://wordpress.stackexchange.com/questions/169561", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63999/" ]
I have successfully implemented a [solution from WPSE](https://wordpress.stackexchange.com/questions/142215/custom-excerpt-showing-first-paragraph-with-html-formatting) that trims the except to the first paragraph, but I'd like to change that to trim after the second paragraph instead. There's a link floating around ...
Guys i figured out a way to do this.... Not a clean one but it just do the job for me.. ``` global $wpdb; $sql=$wpdb->prepare("SELECT * FROM mytable WHERE question ='%s'", like_escape(sanitize_text_field($question))); /******************* actualy following do the trick for me all SINGLE ...
169,582
<p>i am getting a weird error - white screen in the list of posts<br> for a specific Custom post type (just for that one)</p> <ul> <li>tried deactivating all the plugins</li> <li>tried checking for error (debugging = true)</li> </ul> <p><strong>Still nothing</strong><br> the page just doesnt echos anything... (nothin...
[ { "answer_id": 169627, "author": "emilushi", "author_id": 63983, "author_profile": "https://wordpress.stackexchange.com/users/63983", "pm_score": -1, "selected": false, "text": "<p>Here is a full example from wordpress codex</p>\n\n<pre><code>add_action( 'init', 'codex_book_init' );\nfun...
2014/11/26
[ "https://wordpress.stackexchange.com/questions/169582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
i am getting a weird error - white screen in the list of posts for a specific Custom post type (just for that one) * tried deactivating all the plugins * tried checking for error (debugging = true) **Still nothing** the page just doesnt echos anything... (nothing in source too) I am talking about such a url in...
Ok... for anyone visiting this post - i have found the solution... i actually encountered this issues again (when a site has a lot of pages) **The issue is this line when registering a custom post type:** ``` 'hierarchical' => true, ``` **All you need to do is to change it to false!** ``` 'hierarchica...
169,597
<p>I'm trying to do some server side validation of post fields (custom and/or non-custom fields). Validation works just fine, but I can't seem to stop the post from saving if validation fails. </p> <p>I tried hooks like <code>save_post</code>, <code>publish_post</code>, <code>wp_insert_post_data</code>, etc. All of th...
[ { "answer_id": 169993, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 0, "selected": false, "text": "<p>The easiest - in my mind - way to achieve this, is to make use of <a href=\"https://wordpress.stack...
2014/11/26
[ "https://wordpress.stackexchange.com/questions/169597", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43756/" ]
I'm trying to do some server side validation of post fields (custom and/or non-custom fields). Validation works just fine, but I can't seem to stop the post from saving if validation fails. I tried hooks like `save_post`, `publish_post`, `wp_insert_post_data`, etc. All of these hooks are being called but I can't stop...
You can capture the form submission by creating a small plugin / or by editing your theme functions file, and you can do this using a ajax hook. In the plugin you would load this on the edit post page: ``` jQuery(document).ready(function(){ jQuery('#post').submit(function(){ var request = jQuery(this).seriali...
169,600
<p>To prevent my visitors from seeing a broken version of my site during maintenance, and to give them a heads up on the updates, I would like to redirect them automatically to a temporary maintenance page. I am looking for a portable solution which can be used on any site, without hardcoding URLs.</p> <p>Logged in ad...
[ { "answer_id": 169610, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 6, "selected": true, "text": "<p>WordPress has an embedded feature for handling maintenance mode.</p>\n\n<p>When you upgrade a plugin, or WordP...
2014/11/26
[ "https://wordpress.stackexchange.com/questions/169600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45407/" ]
To prevent my visitors from seeing a broken version of my site during maintenance, and to give them a heads up on the updates, I would like to redirect them automatically to a temporary maintenance page. I am looking for a portable solution which can be used on any site, without hardcoding URLs. Logged in administrato...
WordPress has an embedded feature for handling maintenance mode. When you upgrade a plugin, or WordPress core from WP dashboard, WordPress enters maintenance mode: it tries to load a file named `maintenance.php` located in the content folder (usually `/wp-content`), and if that file is not there, WP shows a default me...
169,626
<p>running into issues querying a custom table and getting results.</p> <p>As of Wordpress 3.9, I can no longer run mysql_query(), and have to use $wpdb->query();</p> <p>So keeping that in mind:</p> <p>Old Code:</p> <pre><code>&lt;?php if (!empty($_GET['msg'])) { global $wpdb; $vuser_id = $_GET['id']; $sql = "SELE...
[ { "answer_id": 169628, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 2, "selected": false, "text": "<p>First off, you <em>should not</em> be handing an untrusted input (in this case, <code>$_GET['id']</code> to you...
2014/11/26
[ "https://wordpress.stackexchange.com/questions/169626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12999/" ]
running into issues querying a custom table and getting results. As of Wordpress 3.9, I can no longer run mysql\_query(), and have to use $wpdb->query(); So keeping that in mind: Old Code: ``` <?php if (!empty($_GET['msg'])) { global $wpdb; $vuser_id = $_GET['id']; $sql = "SELECT * FROM wp_quiz WHERE quiz_id='$vus...
``` <?php if (!empty($_GET['msg'])) { global $wpdb; $user_id = (int) $_GET['id']; $sql = $wpdb->prepare("SELECT * FROM wp_quiz WHERE quiz_id='%d'", $user_id); $result = $wpdb->get_row($sql, ARRAY_A); var_dump($user_id); var_dump($result); $total = $result['total_count']; ``` Ended up fig...
169,633
<p>I need to load a separate js file into a widget and just can't get it to work. So far I have </p> <pre><code>if ( is_active_widget( false, false, $this-&gt;id_base, true ) ) { function tab_widget_scripts() { wp_register_script( 'tabs', plugins_url( 'tabs.js', __FILE__ ), array(), false, true ); ...
[ { "answer_id": 169628, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 2, "selected": false, "text": "<p>First off, you <em>should not</em> be handing an untrusted input (in this case, <code>$_GET['id']</code> to you...
2014/11/26
[ "https://wordpress.stackexchange.com/questions/169633", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45504/" ]
I need to load a separate js file into a widget and just can't get it to work. So far I have ``` if ( is_active_widget( false, false, $this->id_base, true ) ) { function tab_widget_scripts() { wp_register_script( 'tabs', plugins_url( 'tabs.js', __FILE__ ), array(), false, true ); wp_enqueue_script...
``` <?php if (!empty($_GET['msg'])) { global $wpdb; $user_id = (int) $_GET['id']; $sql = $wpdb->prepare("SELECT * FROM wp_quiz WHERE quiz_id='%d'", $user_id); $result = $wpdb->get_row($sql, ARRAY_A); var_dump($user_id); var_dump($result); $total = $result['total_count']; ``` Ended up fig...
169,634
<p>I set up a shortcode which includes a standard php/html form file. In the form I have a hidden field where the value is a variable which is meant to be available in the form via the shortcode attributes. </p> <p>The problem is that the value for clientId is not being passed from:</p> <pre><code>[insert-form form_l...
[ { "answer_id": 169668, "author": "WaterBottle", "author_id": 64056, "author_profile": "https://wordpress.stackexchange.com/users/64056", "pm_score": -1, "selected": false, "text": "<p>Using <code>SESSION</code>, storing <code>$clientId</code> to <code>SESSION</code> and calling it back i...
2014/11/26
[ "https://wordpress.stackexchange.com/questions/169634", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19692/" ]
I set up a shortcode which includes a standard php/html form file. In the form I have a hidden field where the value is a variable which is meant to be available in the form via the shortcode attributes. The problem is that the value for clientId is not being passed from: ``` [insert-form form_location="form.php" cl...
Ok, so somehow I got it working by changing it to this: It looks like it didn't like 'the\_clientId'. Maybe it just doesn't like capital letters???? ``` [insert-form form_location="form.php" identification_number="12345"] function insert_the_form($atts){ $form_base = plugin_dir_path(__DIR__); // Shortcode attrib...
169,655
<p>I am trying to integrate jQuery Datables into my Wordpress plugin <a href="http://editor.datatables.net/" rel="nofollow">http://editor.datatables.net/</a></p> <p>I have Created a database table</p> <pre><code>CREATE TABLE `id` ( `id` int(10) NOT NULL auto_increment, `first` varchar(255) default NULL, `last` varcha...
[ { "answer_id": 169668, "author": "WaterBottle", "author_id": 64056, "author_profile": "https://wordpress.stackexchange.com/users/64056", "pm_score": -1, "selected": false, "text": "<p>Using <code>SESSION</code>, storing <code>$clientId</code> to <code>SESSION</code> and calling it back i...
2014/11/27
[ "https://wordpress.stackexchange.com/questions/169655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44991/" ]
I am trying to integrate jQuery Datables into my Wordpress plugin <http://editor.datatables.net/> I have Created a database table ``` CREATE TABLE `id` ( `id` int(10) NOT NULL auto_increment, `first` varchar(255) default NULL, `last` varchar(255) default NULL, `age` varchar(255) default NULL, PRIMARY KEY (`id`) ); ...
Ok, so somehow I got it working by changing it to this: It looks like it didn't like 'the\_clientId'. Maybe it just doesn't like capital letters???? ``` [insert-form form_location="form.php" identification_number="12345"] function insert_the_form($atts){ $form_base = plugin_dir_path(__DIR__); // Shortcode attrib...
169,688
<p>I am trying to display all posts from a selected month.</p> <p>Currently once I select a month, only 10 posts display. I understand I can increase the amount of posts to show under the 'reading' options within the dashboard. </p> <p>I want to be able to keep the front posts page to display 10 posts but the 'archiv...
[ { "answer_id": 169692, "author": "seenuvasan", "author_id": 64070, "author_profile": "https://wordpress.stackexchange.com/users/64070", "pm_score": -1, "selected": false, "text": "<pre><code>&lt;?php $oct_04 = get_month_link('2004', '10'); ?&gt;\n</code></pre>\n\n<p>explanation:</p>\n\n<...
2014/11/27
[ "https://wordpress.stackexchange.com/questions/169688", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37243/" ]
I am trying to display all posts from a selected month. Currently once I select a month, only 10 posts display. I understand I can increase the amount of posts to show under the 'reading' options within the dashboard. I want to be able to keep the front posts page to display 10 posts but the 'archive' pages to displ...
You can use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to set `posts_per_page` to `-1` on the monthly archive pages. I said wrongly in a comment to use `is_archive()` as your conditional. The problem with `is_archive()` is, it returns true on all archives, which ...
169,704
<p>I am not using any custom login plugins or any bespoke code. A few of my pages have got this bit of code in them at the very beginning.</p> <pre><code>&lt;?php if(!is_user_logged_in()) wp_redirect('/login/'); ?&gt; </code></pre> <p>So, this doesn't allow the users to view the page when not logged in. I h...
[ { "answer_id": 169709, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 5, "selected": true, "text": "<p>I'm not sure I understand your setup, but here are few ideas:</p>\n\n<h2>A) Display a login link with the <cod...
2014/11/27
[ "https://wordpress.stackexchange.com/questions/169704", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16809/" ]
I am not using any custom login plugins or any bespoke code. A few of my pages have got this bit of code in them at the very beginning. ``` <?php if(!is_user_logged_in()) wp_redirect('/login/'); ?> ``` So, this doesn't allow the users to view the page when not logged in. I have these pages bearing this b...
I'm not sure I understand your setup, but here are few ideas: A) Display a login link with the `redirect_to` parameter set: ------------------------------------------------------------- You could add the following to your custom template pages: ``` if( ! is_user_logged_in() ) { printf( '<a href="%s">%s</a>', ...
169,710
<p><strong>Update:</strong> I read that a custom rewrite rule might be overridden and drop any parameter variables, when the custom rewrite rule is used on a child/parent page/post. The post my custom rewrite rule is meant for, is not a child/parent but it is part of a custom post type. Could this be causing similar re...
[ { "answer_id": 169716, "author": "PotterSys", "author_id": 10349, "author_profile": "https://wordpress.stackexchange.com/users/10349", "pm_score": 0, "selected": false, "text": "<p>Search for the <code>add_rewrite_tag</code> function. You have to add a tag to catch up any variable in a r...
2014/11/27
[ "https://wordpress.stackexchange.com/questions/169710", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63191/" ]
**Update:** I read that a custom rewrite rule might be overridden and drop any parameter variables, when the custom rewrite rule is used on a child/parent page/post. The post my custom rewrite rule is meant for, is not a child/parent but it is part of a custom post type. Could this be causing similar rewrite issues (dr...
Well, I found the solution. It seems that, when applying a rewrite rule on a custom post type post, one needs to tell WP the custom post type's name within the rewrite rule itself. Here's the code that does **NOT** work (redirects and drops parameter variables instead of rewrite): ``` function add_rewrite_rules($rule...
169,721
<h1>What I have:</h1> <p>A basic plugin that's calling a stylesheet contained in the plugin folder:</p> <pre><code>function my_login_enqueues() { // First attempt: //wp_enqueue_style( 'custom-login', 'style-login.css' ); // Second attempt: $plugin_stylesheet = plugins_url( 'style-login.css', __FILE_...
[ { "answer_id": 169726, "author": "Clarus Dignus", "author_id": 41545, "author_profile": "https://wordpress.stackexchange.com/users/41545", "pm_score": 0, "selected": false, "text": "<p>The code was actually working fine:</p>\n\n<pre><code>function my_login_enqueues() {\n wp_enqueue_st...
2014/11/27
[ "https://wordpress.stackexchange.com/questions/169721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41545/" ]
What I have: ============ A basic plugin that's calling a stylesheet contained in the plugin folder: ``` function my_login_enqueues() { // First attempt: //wp_enqueue_style( 'custom-login', 'style-login.css' ); // Second attempt: $plugin_stylesheet = plugins_url( 'style-login.css', __FILE__ ); w...
You can do this two way.But I prefer to go for the second way.You need to put this code in your plugins file. First way: ``` function my_loginlcustomization() { echo '<style type="text/css"> h1 a { background-image: url(' . plugin_dir_url( __FILE__ ).'/login/logo.png) !important; } </style>'; } add_a...
169,801
<p>I have the following:</p> <pre><code>foreach( $this_post_terms as $term ) : $thiscat = get_term_by( 'slug', $term-&gt;slug, 'categories_whatever' ); echo $thiscat-&gt;ID; endforeach; </code></pre> <p>The last line throws an error, Undefined property: stdClass::$ID.</p> <p>What's weird to me is that </p> <pre...
[ { "answer_id": 169804, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>Not weird, there is no <code>ID</code> in a term object, it's <code>term_id</code>. You can also <code>var_dump($t...
2014/11/28
[ "https://wordpress.stackexchange.com/questions/169801", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14378/" ]
I have the following: ``` foreach( $this_post_terms as $term ) : $thiscat = get_term_by( 'slug', $term->slug, 'categories_whatever' ); echo $thiscat->ID; endforeach; ``` The last line throws an error, Undefined property: stdClass::$ID. What's weird to me is that ``` echo $thiscat->name; ``` works, doesn't t...
The fields returned by `get_term_by()` are: * term\_id * name * slug * term\_group * term\_taxonomy\_id * taxonomy * description * parent * count So instead of `$thiscat->ID`, you should use `$thiscat->term_id` Ref: <http://codex.wordpress.org/Function_Reference/get_term_by>