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
225,323
<p>How can I set placeholder and second argument for that kind of sql prepare</p> <pre><code>$wpdb-&gt;prepare( "SELECT ID FROM {$wpdb-&gt;posts} WHERE post_type = 'attachment' AND ID IN ('".implode("','",$slideshow_imgs)."') ORDER BY menu_order ASC" ); </code></pre> <p>ANSWER??</p> <p>I do it ...
[ { "answer_id": 225325, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>Just use <code>%s</code> for string and <code>%d</code> for digit replacements. Do not forget to use the proper <c...
2016/05/01
[ "https://wordpress.stackexchange.com/questions/225323", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71139/" ]
How can I set placeholder and second argument for that kind of sql prepare ``` $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND ID IN ('".implode("','",$slideshow_imgs)."') ORDER BY menu_order ASC" ); ``` ANSWER?? I do it that way and there is no debug error: ...
Just use `%s` for string and `%d` for digit replacements. Do not forget to use the proper `esc_*()` functions (use full text search for `esc_` in the [function reference](https://codex.wordpress.org/Function_Reference)). ``` global $wpdb; $wpdb->show_errors = true; $wpdb->suppress_errors = false; ! defined( 'DIEONDBER...
225,387
<p>I have decided to use a WooCommerce Storefront child theme called Galleria, when I have previously used the Storefront theme I have used the common remove_action to unhook the defaults and replaced with my own add_action.</p> <p>However as Galleria is a child theme of Storefront, it has its own add_action in the fi...
[ { "answer_id": 225390, "author": "Antony Gibbs", "author_id": 93359, "author_profile": "https://wordpress.stackexchange.com/users/93359", "pm_score": 2, "selected": false, "text": "<p>Sorry I can not comment yet on this site</p>\n\n<p>Could you be removing an action before it is register...
2016/05/02
[ "https://wordpress.stackexchange.com/questions/225387", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93357/" ]
I have decided to use a WooCommerce Storefront child theme called Galleria, when I have previously used the Storefront theme I have used the common remove\_action to unhook the defaults and replaced with my own add\_action. However as Galleria is a child theme of Storefront, it has its own add\_action in the file clas...
I eventually figured this out, I don't know exactly why, but it seems the issue was due to the original use of init, once i replaced it with 'wp\_head' it worked correctly, my final code looked like this ``` function change_default_galleria_header() { remove_action( 'storefront_header', 'storefront_header_cart', 4 ); ...
225,392
<p>I have added a drop down to the WooCommerce Inventory Tab where the user can choose message to show in front end.</p> <p>In functions.php:</p> <pre><code>// Display Fields in Back End add_action( 'woocommerce_product_options_inventory_product_data', 'woo_add_custom_status_fields' ); function woo_add_custom_status...
[ { "answer_id": 225390, "author": "Antony Gibbs", "author_id": 93359, "author_profile": "https://wordpress.stackexchange.com/users/93359", "pm_score": 2, "selected": false, "text": "<p>Sorry I can not comment yet on this site</p>\n\n<p>Could you be removing an action before it is register...
2016/05/02
[ "https://wordpress.stackexchange.com/questions/225392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92735/" ]
I have added a drop down to the WooCommerce Inventory Tab where the user can choose message to show in front end. In functions.php: ``` // Display Fields in Back End add_action( 'woocommerce_product_options_inventory_product_data', 'woo_add_custom_status_fields' ); function woo_add_custom_status_fields() { global $...
I eventually figured this out, I don't know exactly why, but it seems the issue was due to the original use of init, once i replaced it with 'wp\_head' it worked correctly, my final code looked like this ``` function change_default_galleria_header() { remove_action( 'storefront_header', 'storefront_header_cart', 4 ); ...
225,431
<p>There is a code in <a href="https://codex.wordpress.org/Function_Reference/wp_add_inline_style" rel="nofollow">here</a> that dynamically load custom script. </p> <pre><code>&lt;?php function my_styles_method() { wp_enqueue_style( 'custom-style', get_template_directory_uri() . '/css/custom_script...
[ { "answer_id": 225390, "author": "Antony Gibbs", "author_id": 93359, "author_profile": "https://wordpress.stackexchange.com/users/93359", "pm_score": 2, "selected": false, "text": "<p>Sorry I can not comment yet on this site</p>\n\n<p>Could you be removing an action before it is register...
2016/05/02
[ "https://wordpress.stackexchange.com/questions/225431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88606/" ]
There is a code in [here](https://codex.wordpress.org/Function_Reference/wp_add_inline_style) that dynamically load custom script. ``` <?php function my_styles_method() { wp_enqueue_style( 'custom-style', get_template_directory_uri() . '/css/custom_script.css' ); $color = get_theme_mod...
I eventually figured this out, I don't know exactly why, but it seems the issue was due to the original use of init, once i replaced it with 'wp\_head' it worked correctly, my final code looked like this ``` function change_default_galleria_header() { remove_action( 'storefront_header', 'storefront_header_cart', 4 ); ...
225,439
<p>I use the following code in my PHP script to automatically download the latest version of WordPress...</p> <pre><code>$wordpress_zip_file_url = 'https://wordpress.org/latest.zip'; file_put_contents("wordpress.zip", file_get_contents($wordpress_zip_file_url)); </code></pre> <p>Does this work for plugins the same wa...
[ { "answer_id": 225444, "author": "sălă", "author_id": 93062, "author_profile": "https://wordpress.stackexchange.com/users/93062", "pm_score": 0, "selected": false, "text": "<p>When you're doing a plugin update, in the process where it shows you all the steps, you can also see the plugin ...
2016/05/02
[ "https://wordpress.stackexchange.com/questions/225439", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93195/" ]
I use the following code in my PHP script to automatically download the latest version of WordPress... ``` $wordpress_zip_file_url = 'https://wordpress.org/latest.zip'; file_put_contents("wordpress.zip", file_get_contents($wordpress_zip_file_url)); ``` Does this work for plugins the same way? For example, I'd like t...
`https://downloads.wordpress.org/plugin/{plugin-name}.latest-stable.zip` The structure should be the same for all WordPress.org plugins and the link you're looking for is: [`https://downloads.wordpress.org/plugin/backupwordpress.latest-stable.zip`](https://downloads.wordpress.org/plugin/backupwordpress.latest-stable....
225,449
<p>How do you change the user that gets the notification email announcement for new comments and comment moderation?</p> <p>WordPress sends the notices to the <em>admin</em> user. My client is the editor of the site. I want the comment notices to get mailed to the editor user and not the <em>admin</em> user.</p> <p>H...
[ { "answer_id": 225455, "author": "N00b", "author_id": 80903, "author_profile": "https://wordpress.stackexchange.com/users/80903", "pm_score": 2, "selected": false, "text": "<p>I'm not aware of any hook that could change only the comment notification recipient... You would probably need t...
2016/05/03
[ "https://wordpress.stackexchange.com/questions/225449", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93385/" ]
How do you change the user that gets the notification email announcement for new comments and comment moderation? WordPress sends the notices to the *admin* user. My client is the editor of the site. I want the comment notices to get mailed to the editor user and not the *admin* user. How do you do that?
There's a great article explaining how to hook into 2 filters for this at <https://web.archive.org/web/20200216075253/http://www.sourcexpress.com/customize-wordpress-comment-notification-emails/> To send your notifications to a particular user and not the site admin, try this for a user with ID 123: ``` function se_c...
225,452
<p>I have a plugin used on a parent theme which uses shortcode. The plugin (shortcode) works on the parent theme but when I switch to child theme it no longer works. I've only added the child theme code in the child theme function... this is the only script currently in child function.</p> <pre><code> function prpi...
[ { "answer_id": 225455, "author": "N00b", "author_id": 80903, "author_profile": "https://wordpress.stackexchange.com/users/80903", "pm_score": 2, "selected": false, "text": "<p>I'm not aware of any hook that could change only the comment notification recipient... You would probably need t...
2016/05/03
[ "https://wordpress.stackexchange.com/questions/225452", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45462/" ]
I have a plugin used on a parent theme which uses shortcode. The plugin (shortcode) works on the parent theme but when I switch to child theme it no longer works. I've only added the child theme code in the child theme function... this is the only script currently in child function. ``` function prpin_scripts_chil...
There's a great article explaining how to hook into 2 filters for this at <https://web.archive.org/web/20200216075253/http://www.sourcexpress.com/customize-wordpress-comment-notification-emails/> To send your notifications to a particular user and not the site admin, try this for a user with ID 123: ``` function se_c...
225,477
<p>Is there a way to wrap the submit button with html element while using wordpress function comment_form function.</p> <pre><code>$comments_args = array( 'id_form' =&gt; 'main-contact-form', 'class_form' =&gt; 'contact-form', 'class_submit' =&gt; '...
[ { "answer_id": 225480, "author": "bravokeyl", "author_id": 43098, "author_profile": "https://wordpress.stackexchange.com/users/43098", "pm_score": 5, "selected": true, "text": "<p>We can use <a href=\"https://developer.wordpress.org/reference/functions/comment_form/\" rel=\"noreferrer\">...
2016/05/03
[ "https://wordpress.stackexchange.com/questions/225477", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75767/" ]
Is there a way to wrap the submit button with html element while using wordpress function comment\_form function. ``` $comments_args = array( 'id_form' => 'main-contact-form', 'class_form' => 'contact-form', 'class_submit' => 'btn btn-primary btn-lg...
We can use [`comment_form`](https://developer.wordpress.org/reference/functions/comment_form/) function's **`submit_button`** parameter to change submit button HTML. Default HTML for `submit_button` is ``` <input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /> ``` You can change your code like thi...
225,499
<p>I have a custom sign up form in my Wordpress site which has confirmation email functionality for activating the account. For the confirmation step am keeping another DB table where am keeping the pending users info and when they are going with confirmation link then am copying the info from that table and adding to ...
[ { "answer_id": 225507, "author": "Refilon", "author_id": 92815, "author_profile": "https://wordpress.stackexchange.com/users/92815", "pm_score": 5, "selected": true, "text": "<p>If you have the ID of the user you can do this:</p>\n<pre><code>wp_update_user([\n 'ID' =&gt; $userId, // t...
2016/05/03
[ "https://wordpress.stackexchange.com/questions/225499", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77773/" ]
I have a custom sign up form in my Wordpress site which has confirmation email functionality for activating the account. For the confirmation step am keeping another DB table where am keeping the pending users info and when they are going with confirmation link then am copying the info from that table and adding to wp\...
If you have the ID of the user you can do this: ``` wp_update_user([ 'ID' => $userId, // this is the ID of the user you want to update. 'first_name' => $firstName, 'last_name' => $lastName, ]); ``` You can update / insert almost all fields with this function. Take a look at the documentation [here](https...
225,527
<p>I generally use the <a href="https://wordpress.org/plugins/intuitive-custom-post-order" rel="nofollow">Intuitive Custom Post Order</a> plugin for any WordPress sites I work with so clients can order their posts visually.</p> <p>For this project, I'm using WordPress as an admin panel and consuming it's data with an ...
[ { "answer_id": 225692, "author": "Ahed Eid", "author_id": 81934, "author_profile": "https://wordpress.stackexchange.com/users/81934", "pm_score": 0, "selected": false, "text": "<p>Ordering posts with menu_order as orderby parameter will give invalid parameter error e.g. </p>\n\n<p><code>...
2016/05/03
[ "https://wordpress.stackexchange.com/questions/225527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27168/" ]
I generally use the [Intuitive Custom Post Order](https://wordpress.org/plugins/intuitive-custom-post-order) plugin for any WordPress sites I work with so clients can order their posts visually. For this project, I'm using WordPress as an admin panel and consuming it's data with an Ember.js front-end. (using wp-api V...
Let's assume it stores the custom order into the `menu_order` column in the `wp_posts` table. If you mean the hierarchical `page` post type (supports *page-attributes*) then one can order with the query variables: ``` /wp-json/wp/v2/pages/?orderby=menu_order&order=asc ``` If you mean the `post` post type with: ``...
225,582
<p>I am working on a custom post type and I don't want it to get all the clutter from <code>wp_head()</code>. However, I do want to show a specific hook, for example the YoastSEO meta tags.</p> <p>How do I call a specific single hook in the template file without <code>wp_head()</code>? I tried adding a filter to <code...
[ { "answer_id": 225585, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 3, "selected": true, "text": "<p><code>wp_head</code> is an essential part of the theme, and there is too many things that might fall apart...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82468/" ]
I am working on a custom post type and I don't want it to get all the clutter from `wp_head()`. However, I do want to show a specific hook, for example the YoastSEO meta tags. How do I call a specific single hook in the template file without `wp_head()`? I tried adding a filter to `wp_head` that removes the parts I do...
`wp_head` is an essential part of the theme, and there is too many things that might fall apart if it is not there. Hunting and fixing them one by one might be time consuming and the worthiness of the all operation questionable. In you snippet for example you want to remove things that make no sense to remove specific...
225,587
<p>I'm wondering how you can receive a categories parent name and link for a breadcrumb I've written.</p> <p>I basically want to have the following structure</p> <pre><code>if child category blog &gt; parent_category else if grandchild category blog &gt; grand_parent_category &gt; parent_category </code></pre>
[ { "answer_id": 225596, "author": "Ahed Eid", "author_id": 81934, "author_profile": "https://wordpress.stackexchange.com/users/81934", "pm_score": 1, "selected": true, "text": "<p>This query will help you </p>\n\n<pre><code>global $wpdb;\n\n$cat_id = 65;\n\n// this query will get parent r...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225587", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92492/" ]
I'm wondering how you can receive a categories parent name and link for a breadcrumb I've written. I basically want to have the following structure ``` if child category blog > parent_category else if grandchild category blog > grand_parent_category > parent_category ```
This query will help you ``` global $wpdb; $cat_id = 65; // this query will get parent relationships from term_taxonomy table and get category names from terms table $category = $wpdb->get_row( "SELECT t4.term_id as parent_id, t4.name as parent_name, t5.term_id as grandparent_id, t5.name as grandparent_name FRO...
225,588
<p>I have a snippet that will select a data from database table. But I encounter an error: <code>Warning: Invalid argument supplied for foreach()</code></p> <p>I encounter a new error: <code>Notice: Trying to get property of non-object</code>in this line <code>echo $result-&gt;Name;</code></p> <p>Snippet (updated):</...
[ { "answer_id": 225598, "author": "Ahed Eid", "author_id": 81934, "author_profile": "https://wordpress.stackexchange.com/users/81934", "pm_score": 3, "selected": true, "text": "<p>You have a problem with your query which is you can't use <code>GROUP BY</code> and <code>ORDER BY</code> bef...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225588", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93475/" ]
I have a snippet that will select a data from database table. But I encounter an error: `Warning: Invalid argument supplied for foreach()` I encounter a new error: `Notice: Trying to get property of non-object`in this line `echo $result->Name;` Snippet (updated): ``` $results = $wpdb->get_results( 'SELECT DATE_FORMA...
You have a problem with your query which is you can't use `GROUP BY` and `ORDER BY` before `WHERE` replace ``` FROM tablename GROUP BY submit_time ORDER BY submit_time DESC ``` with ``` FROM tablename ``` This is your query ``` $results = $wpdb->get_results( 'SELECT DATE_FORMAT(FROM_UNIXTIME(submit_time), "%...
225,616
<p>I'm trying to find the first hook that will pass the current post ID, as I would like to update the current post (by getting its ID) and the variables submitted to that page.</p> <p>This is the code I'm using:</p> <pre><code>class my_class { public function __construct(){ add_action( 'init', array( $...
[ { "answer_id": 298396, "author": "knsheely", "author_id": 70429, "author_profile": "https://wordpress.stackexchange.com/users/70429", "pm_score": 0, "selected": false, "text": "<p>I think you are looking for <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/the_post\" rel...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57389/" ]
I'm trying to find the first hook that will pass the current post ID, as I would like to update the current post (by getting its ID) and the variables submitted to that page. This is the code I'm using: ``` class my_class { public function __construct(){ add_action( 'init', array( $this, 'my_method' ) )...
Answer by @Pieter Goosen : > > If you need to update the page before the main query fires and returns > the page object, you will manually need to parse the URL (probably on > init) and get the page ID from get\_page\_by\_title() or > get\_page\_by\_path(). > > > Otherwise, 'wp' would be earliest hook to get the pa...
225,625
<p>Which hook or filter is used to edit the post content before <code>the_content</code> filter is applied to it.</p> <p>For instance, if I wanted to add <strong>Hello World,</strong> as the first text in every post.</p>
[ { "answer_id": 225627, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>There is no other global filter applied before <code>the_content</code> - you can use the <a href=\"https:...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20557/" ]
Which hook or filter is used to edit the post content before `the_content` filter is applied to it. For instance, if I wanted to add **Hello World,** as the first text in every post.
You can use `the_content` with an high prioriety (lower number). ``` add_filter( 'the_content', function( $content ) { return 'Hello World '.$content; }, 0); ``` You can even use negative priority: ``` add_filter( 'the_content', function( $content ) { return 'Hello World '.$content; }, -10); ``` Note that thi...
225,635
<p>Is there any way to disable or remove the "Auto add pages - Automatically add new top-level pages to this menu" functionality via a theme?</p> <p>I suppose I could hide it with a bit of CSS, but I'd rather do more cleanly if possible.</p> <p>Many clients click that not realizing what it does and chaos ensues. </p>...
[ { "answer_id": 239668, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>As per comments and <a href=\"https://github.com/WordPress/WordPress/blob/788c3680f90b7570f8f9b5277f5d6bf57d7d92...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225635", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83367/" ]
Is there any way to disable or remove the "Auto add pages - Automatically add new top-level pages to this menu" functionality via a theme? I suppose I could hide it with a bit of CSS, but I'd rather do more cleanly if possible. Many clients click that not realizing what it does and chaos ensues.
Since there is no filter to remove this option, your best best to to stick to using CSS by putting the following in your child theme's `functions.php`: ``` add_action( 'admin_head', 'wpse_225635_menu_css' ); function wpse_225635_menu_css() { global $pagenow; if ( $pagenow == 'nav-menus.php' ) { ?> ...
225,641
<p>After rolling back a Wordpress database to a backup version it seems that all the tables lost their auto_increment on the primary key columns. I read on another post this could be to do with InnoDB storing the auto_increment value in memory. I've rolled back and migrated databases before without such issues. Anyone ...
[ { "answer_id": 225647, "author": "N00b", "author_id": 80903, "author_profile": "https://wordpress.stackexchange.com/users/80903", "pm_score": 3, "selected": false, "text": "<p>Why did it happen? It's hard to tell for sure because there are lots of variables to consider: mistakes made in ...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225641", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93506/" ]
After rolling back a Wordpress database to a backup version it seems that all the tables lost their auto\_increment on the primary key columns. I read on another post this could be to do with InnoDB storing the auto\_increment value in memory. I've rolled back and migrated databases before without such issues. Anyone r...
I had a similar issue, I solved it and since this comes up high on Google for what I was looking for it may help others. I migrated several Wordpress databases from AWS RDS MySQL to MySQL running on an EC2 instance, using the database migration service. What I didn't know is it doesn't copy indexes, keys, auto increme...
225,642
<p>I need to add the author name as a subdirectory prefix for all user's posts and pages.</p> <p>For example:</p> <pre><code>example.com/johndoe/ //The author page for John Doe example.com/johndoe/category/test-post/ //Test post by user John Doe example.com/johndoe/test-page/ //Test page by user John Doe </code></pre...
[ { "answer_id": 339561, "author": "Paul G.", "author_id": 41288, "author_profile": "https://wordpress.stackexchange.com/users/41288", "pm_score": 1, "selected": false, "text": "<p>By the looks of it, there's a plugin to achieve exactly this, so save you rolling your own for it.</p>\n\n<p>...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225642", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57849/" ]
I need to add the author name as a subdirectory prefix for all user's posts and pages. For example: ``` example.com/johndoe/ //The author page for John Doe example.com/johndoe/category/test-post/ //Test post by user John Doe example.com/johndoe/test-page/ //Test page by user John Doe ``` If I change the permalink s...
By the looks of it, there's a plugin to achieve exactly this, so save you rolling your own for it. The plugin is: <https://wordpress.org/plugins/permalinks-customizer/> I installed it to test that it does what you're looking for. Here's a screenshot that shows what you'd do: [![Permalinks Customizer](https://i.stack...
225,673
<p>I'm not very expert of wordpress and I'm trying to create a frontend form sending information to my php function through ajax. I'd need help about uploading images and files as attachments of the post.</p> <p>My jQuery / Ajax is sending everything correctly to my php file. The only thing I don't understand is why i...
[ { "answer_id": 225675, "author": "Tim Malone", "author_id": 46066, "author_profile": "https://wordpress.stackexchange.com/users/46066", "pm_score": 3, "selected": true, "text": "<p>I mentioned in a comment how it's important to debug your code. Here's why:</p>\n\n<p>The images are added ...
2016/05/04
[ "https://wordpress.stackexchange.com/questions/225673", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92398/" ]
I'm not very expert of wordpress and I'm trying to create a frontend form sending information to my php function through ajax. I'd need help about uploading images and files as attachments of the post. My jQuery / Ajax is sending everything correctly to my php file. The only thing I don't understand is why images are ...
I mentioned in a comment how it's important to debug your code. Here's why: The images are added first. In the image adding section, you're running this line of code: ``` $_FILES = array("moreimages" => $image); ``` Then when you get to your routine that adds the files, you start with this: ``` $files = $_FILES['m...
225,683
<p>I am creating a plugin that registers a custom post type, and I want it to be displayed using the theme's page.php template, rather than the post.php. I set the <code>hierarchical</code> flag when I register it, but the post.php template is still called.</p> <p>Way, way down inside wp-includes/post.php, where it ap...
[ { "answer_id": 225684, "author": "frogg3862", "author_id": 83367, "author_profile": "https://wordpress.stackexchange.com/users/83367", "pm_score": 0, "selected": false, "text": "<p>That's exactly it. You should be able to use something like this, replacing the <code>your_post_type</code>...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225683", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93443/" ]
I am creating a plugin that registers a custom post type, and I want it to be displayed using the theme's page.php template, rather than the post.php. I set the `hierarchical` flag when I register it, but the post.php template is still called. Way, way down inside wp-includes/post.php, where it appears to decide which...
You can filter `template_include` and then let WordPress search for a page template in all valid templates like `page.php`, `index.php` and even files from a parent theme. ``` add_filter( 'template_include', function( $template ) { return is_singular( [ 'YOUR_POST_TYPE' ] ) ? get_page_template() : $template; }); ...
225,686
<p>I have a custom field that is an Image and the return value of the field is Image URL. </p> <p>I have custom page templates where I render these image fields. Is there a way to get the meta info for the image through the image url. I do not want to change the return value to Image Object or Image ID. </p>
[ { "answer_id": 225707, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>I can already tell that you're using ACF - if you don't want to change the return settings for the field, ...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93528/" ]
I have a custom field that is an Image and the return value of the field is Image URL. I have custom page templates where I render these image fields. Is there a way to get the meta info for the image through the image url. I do not want to change the return value to Image Object or Image ID.
I needed the code in functions.php so that I could re-use it. Here's my solution below: ``` function get_img_alt($attachment) { $post = get_post(); $image_id = get_post_meta( $post->ID, $attachment, true ); $image_alt = get_post_meta($image_id, '_wp_attachment_image_alt', true); print $image_alt; } ```
225,693
<p>How to add a CSS Class to <code>ul</code> and anchor element of Tag Cloud generated through <code>wp_tag_cloud</code> function?</p> <p>I want the default class for <code>ul</code> of <code>wp-tag-cloud</code> to be <code>tag-cloud</code> and anchor tag would have <code>btn btn-xs btn-primary</code> class.</p> <pre...
[ { "answer_id": 225720, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>The classes are hardcoded in <code>wp_generate_tag_cloud()</code> function. Your only option there is to modify fin...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75767/" ]
How to add a CSS Class to `ul` and anchor element of Tag Cloud generated through `wp_tag_cloud` function? I want the default class for `ul` of `wp-tag-cloud` to be `tag-cloud` and anchor tag would have `btn btn-xs btn-primary` class. ``` <ul class="tag-cloud"> <li><a class="btn btn-xs btn-primary" href="#">Apple</...
The classes are hardcoded in `wp_generate_tag_cloud()` function. Your only option there is to modify final string output via `wp_generate_tag_cloud` filter.
225,698
<p>Been pulling my hair out trying to get related articles going. I've tried a few methods but this is the only one that has given me results but random posts are shown rather than posts related to it by article.</p> <pre><code>&lt;?php $args=array('tag_in'=&gt;$tags, 'exclude'=&gt;$post-&gt;ID, ...
[ { "answer_id": 225701, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>Whithout knowing the value of <code>$tags</code> variable (you are not showing it to us), the only thing I se...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225698", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93537/" ]
Been pulling my hair out trying to get related articles going. I've tried a few methods but this is the only one that has given me results but random posts are shown rather than posts related to it by article. ``` <?php $args=array('tag_in'=>$tags, 'exclude'=>$post->ID, 'post_per_page'=> 4, ...
1) It's `tag__in` (two underscores) 2) `get_the_tags()` returns an array of *objects*, you need IDs: ``` if ( $the_tags = get_the_tags() ) { // https://developer.wordpress.org/reference/functions/wp_list_pluck/ $the_tags = wp_list_pluck( $the_tags, 'term_id' ); } $rel_pst = get_posts( array( 'tag__in' ...
225,700
<p>I have an enqueued script called <code>custom_js</code> that loads the file <code>js/custom.js</code>. I want the file to change when a certain condition is true, but it does not seem to work. Here is my code:</p> <pre><code>add_action('wp_print_scripts', 'my_custom_js', 11); function my_custom_js() { wp_enqueu...
[ { "answer_id": 225702, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>The first <code>wp_enqueue_script()</code> in your code should be <code>wp_register_script()</code>. The...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82468/" ]
I have an enqueued script called `custom_js` that loads the file `js/custom.js`. I want the file to change when a certain condition is true, but it does not seem to work. Here is my code: ``` add_action('wp_print_scripts', 'my_custom_js', 11); function my_custom_js() { wp_enqueue_script( 'custom_js', get_template_...
The first `wp_enqueue_script()` in your code should be `wp_register_script()`. The enqueue function does the job while the register function is getting ready to do the job. It is always better to rather create a new js file to keep things organised. As to calling them, you can do the following ``` wp_register_script...
225,721
<p>I have the following code running in a plugin:</p> <pre><code> add_filter('the_content','thousand_pay'); //Callback function function thousand_pay($content) { echo $content; if( !in_category( 'Stories') ) { return; } ?&gt; &lt;hr&gt;&lt;/hr&gt; [Some HTML] &lt;?php return } </cod...
[ { "answer_id": 225722, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>It is normal for content to be accessed multiple times. For example SEO plugins need to do this to access it and gen...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93552/" ]
I have the following code running in a plugin: ``` add_filter('the_content','thousand_pay'); //Callback function function thousand_pay($content) { echo $content; if( !in_category( 'Stories') ) { return; } ?> <hr></hr> [Some HTML] <?php return } ``` For some reason, on individual ...
It is normal for content to be accessed multiple times. For example SEO plugins need to do this to access it and generate meta data from. Also it is a *filter* hook. Filters should never echo anything to the page, they are meant to modify passed value and return it. If you do want to do something at that point, but o...
225,728
<p>I'm putting together a basic landing page <a href="http://shurity.com/" rel="nofollow noreferrer">http://shurity.com/</a>, and in trying to clean up my code, I wanted to replace some static content with dynamic content for the user. </p> <p>The element in question is the modal that pops up when you click subscribe....
[ { "answer_id": 225735, "author": "Owais Alam", "author_id": 91939, "author_profile": "https://wordpress.stackexchange.com/users/91939", "pm_score": 0, "selected": false, "text": "<p>Try the following code </p>\n\n<pre><code>&lt;?php\n/*\nTemplate Name: Template_Name\n*/\nget_header();\n$...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225728", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92793/" ]
I'm putting together a basic landing page <http://shurity.com/>, and in trying to clean up my code, I wanted to replace some static content with dynamic content for the user. The element in question is the modal that pops up when you click subscribe...my text does not show up when I attempt to include it in the loop....
Answer found on Stackoverflow. Custom fields need to be called inside the loop like so... ``` while ( $loop -> have_posts() ) : $loop -> the_post(); $modal_header = get_field('modal_header'); $modal_body = get_field('modal_body'); $modal_footer = get_field('modal_footer'); .... ``` Answer from [Codefore...
225,737
<p>I want start saying that I'm learning and I'm trying to understand the use of <code>$_FILES</code> and <code>$file_handler</code> which are making me crazy into this function to upload attachments from a frontend form. </p> <p>What I've discovered into mine yesterday <a href="https://wordpress.stackexchange.com/que...
[ { "answer_id": 225735, "author": "Owais Alam", "author_id": 91939, "author_profile": "https://wordpress.stackexchange.com/users/91939", "pm_score": 0, "selected": false, "text": "<p>Try the following code </p>\n\n<pre><code>&lt;?php\n/*\nTemplate Name: Template_Name\n*/\nget_header();\n$...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225737", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92398/" ]
I want start saying that I'm learning and I'm trying to understand the use of `$_FILES` and `$file_handler` which are making me crazy into this function to upload attachments from a frontend form. What I've discovered into mine yesterday [question](https://wordpress.stackexchange.com/questions/225673/upload-images-an...
Answer found on Stackoverflow. Custom fields need to be called inside the loop like so... ``` while ( $loop -> have_posts() ) : $loop -> the_post(); $modal_header = get_field('modal_header'); $modal_body = get_field('modal_body'); $modal_footer = get_field('modal_footer'); .... ``` Answer from [Codefore...
225,747
<p>I'm using <code>the_excerpt()</code> in my template loop to display post excerpt on the front page.</p> <p>It's currently displaying unwanted shortcode directly on the front page</p> <p>eg.</p> <p><code>[box]post content[/box]</code></p> <p><code>[alert]post content[/alert]</code></p> <p>How can I filter out th...
[ { "answer_id": 225751, "author": "Shoeb Mirza", "author_id": 36797, "author_profile": "https://wordpress.stackexchange.com/users/36797", "pm_score": 1, "selected": false, "text": "<pre class=\"lang-php prettyprint-override\"><code>function wpsesess_ddecode_excerpt( $excerpt )\n{\n ret...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225747", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92505/" ]
I'm using `the_excerpt()` in my template loop to display post excerpt on the front page. It's currently displaying unwanted shortcode directly on the front page eg. `[box]post content[/box]` `[alert]post content[/alert]` How can I filter out these shortcode only while keeping the actual content?
try this ``` add_filter( 'get_the_excerpt', 'strip_shortcodes', 20 ); ``` or try this edit ``` echo strip_shortcodes( get_the_excerpt() ); ``` if shortcode is not register with wordpress function add\_shortcode ``` add_filter( 'the_excerpt', 'remove_shortcodes_in_excerpt', 20 ); function remove_shortcodes_in_e...
225,760
<p>I'm trying to fire some code only when a document type is created using save_post, but $update is always true, even when first publishing it.</p> <p>I assume this is because there's an autodraft created first. Is there any way around this?</p>
[ { "answer_id": 225764, "author": "fsenna", "author_id": 93436, "author_profile": "https://wordpress.stackexchange.com/users/93436", "pm_score": 1, "selected": false, "text": "<p>One approach is to use get_post_status()</p>\n\n<p>According to the codex <a href=\"http://codex.wordpress.org...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225760", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63673/" ]
I'm trying to fire some code only when a document type is created using save\_post, but $update is always true, even when first publishing it. I assume this is because there's an autodraft created first. Is there any way around this?
So appreciate this is a bit late but I was having the exact same issue, the $update parameter is almost completely useless if you want to check whether it is a new post or not. The way I got around this was to compare the `$post->post_date` with `$post->post_modified`. Full code snippet below. ``` add_action( 'save_p...
225,772
<p>Help me figure out how to structure this meta_query within my post query!</p> <p>There are two taxonomies attached to my post type ('audition_type', and 'union_requirement'). On a page of my site the user is able to use checkboxes to filter a query of the post type ('audition'). The below meta_query is working fine...
[ { "answer_id": 225817, "author": "amit singh", "author_id": 81713, "author_profile": "https://wordpress.stackexchange.com/users/81713", "pm_score": -1, "selected": false, "text": "<p>Try this code, meta query will not give you the results you want. Please go through the meta query for mo...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225772", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23492/" ]
Help me figure out how to structure this meta\_query within my post query! There are two taxonomies attached to my post type ('audition\_type', and 'union\_requirement'). On a page of my site the user is able to use checkboxes to filter a query of the post type ('audition'). The below meta\_query is working fine to ge...
Sorry for the delay on this everyone, I was out of town! Here is what I figured out and am using today. I had to check for the cases where one taxonomy was selected and one was not, which actually only requires a simple tax query, but that was giving me null values and breaking the query, so I had to use some conditio...
225,774
<p>I'm loading a custom script file using an enqueue and here's the output:</p> <p><code>&lt;script type='text/javascript' src='.../wp-content/themes/enfold-child/js/custom_script.js?ver=4.5.1'&gt;&lt;/script&gt;</code></p> <p>curious why it's appending that "?ver=4.5.1" at end. When I remove in console file loads fi...
[ { "answer_id": 225776, "author": "Jarod Thornton", "author_id": 44017, "author_profile": "https://wordpress.stackexchange.com/users/44017", "pm_score": 4, "selected": true, "text": "<p>I agree with @Mark Kaplun - what you're describing is an odd behavior though. Try this markup to overri...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225774", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54953/" ]
I'm loading a custom script file using an enqueue and here's the output: `<script type='text/javascript' src='.../wp-content/themes/enfold-child/js/custom_script.js?ver=4.5.1'></script>` curious why it's appending that "?ver=4.5.1" at end. When I remove in console file loads fine, but when it's there blank file. Not ...
I agree with @Mark Kaplun - what you're describing is an odd behavior though. Try this markup to override the `$ver` param. `wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', array ( 'jquery' ), null, true);` <https://developer.wordpress.org/themes/basics/including-css-javascript/> Altern...
225,783
<p>On my site I have a number of post category archive pages. What I would like to do is set it up so that when links to specific posts are clicked on these pages the user is sent to the post only if they are logged in. Otherwise they would be sent to the login/sign up page.</p> <p>I don't want the articles themselves...
[ { "answer_id": 225785, "author": "LPH", "author_id": 47326, "author_profile": "https://wordpress.stackexchange.com/users/47326", "pm_score": 2, "selected": false, "text": "<p>You might start by looking at the <code>is_user_logged_in()</code> pluggable function.</p>\n\n<p><a href=\"https:...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93578/" ]
On my site I have a number of post category archive pages. What I would like to do is set it up so that when links to specific posts are clicked on these pages the user is sent to the post only if they are logged in. Otherwise they would be sent to the login/sign up page. I don't want the articles themselves to be res...
You might start by looking at the `is_user_logged_in()` pluggable function. <https://developer.wordpress.org/reference/functions/is_user_logged_in/> This is basically two lines: ``` $user = wp_get_current_user(); return $user->exists(); ``` In your case, wrap the links inside the curly braces of a conditional. ``...
225,802
<p>I was making a plugin and I have a javascript file where I want to take some options saved in the database to show well the function.</p> <p>So I have this:</p> <pre><code>function wp_home(){ wp_enqueue_script( 'some-name-1', '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', '1.0.0', true ); w...
[ { "answer_id": 225804, "author": "Manu", "author_id": 22963, "author_profile": "https://wordpress.stackexchange.com/users/22963", "pm_score": 2, "selected": false, "text": "<p>You can try this function: <code>wp_localize_script( $handle, $name, $data );</code></p>\n\n<p>See <a href=\"htt...
2016/05/05
[ "https://wordpress.stackexchange.com/questions/225802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81402/" ]
I was making a plugin and I have a javascript file where I want to take some options saved in the database to show well the function. So I have this: ``` function wp_home(){ wp_enqueue_script( 'some-name-1', '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', '1.0.0', true ); wp_enqueue_style( 'som...
You can use [wp\_localize\_script()](https://codex.wordpress.org/Function_Reference/wp_localize_script) to pass php variables to javascript. You create an array in php and then pass it to the function as the third parameter. It will come through as an object you name with the second parameter. First, register the scri...
225,867
<p>Hey so I am trying to create this conditional that auto creates a grid layout when widgets/sidebars are added and removed. The goal is let the user put in as many widgets as possible without worrying about the layout. This is my code, let me know if you want me to further explain myself:</p> <pre><code>if (functio...
[ { "answer_id": 225868, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": false, "text": "<p>You haven't actually said what the problem is. But I can see one for starters - <code>dynamic_sidebar</cod...
2016/05/06
[ "https://wordpress.stackexchange.com/questions/225867", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93640/" ]
Hey so I am trying to create this conditional that auto creates a grid layout when widgets/sidebars are added and removed. The goal is let the user put in as many widgets as possible without worrying about the layout. This is my code, let me know if you want me to further explain myself: ``` if (function_exists('crea...
You haven't actually said what the problem is. But I can see one for starters - `dynamic_sidebar` in your `if` conditions will echo out the widgets immediately. If you want to *check* a sidebar has widgets, use [`is_active_sidebar`](https://developer.wordpress.org/reference/functions/is_active_sidebar/): ``` is_active...
225,893
<p>I am trying to use mathJax in my wordpress. According to the documentation at mathjax, the mathjax script url needs to mentioned in headers.php. Which is exactly what I did. And right now this is what the head section in the headers.php looks like:</p> <pre><code>&lt;head&gt; &lt;meta charset="&lt;?php bloginfo(...
[ { "answer_id": 225894, "author": "Anuroop Kuppam", "author_id": 93655, "author_profile": "https://wordpress.stackexchange.com/users/93655", "pm_score": -1, "selected": false, "text": "<p>I could understand what the problem was. Firstly the statement<code>&lt;script type=\"text/javascript...
2016/05/07
[ "https://wordpress.stackexchange.com/questions/225893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93655/" ]
I am trying to use mathJax in my wordpress. According to the documentation at mathjax, the mathjax script url needs to mentioned in headers.php. Which is exactly what I did. And right now this is what the head section in the headers.php looks like: ``` <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <t...
The proper way to enqueue a script is as follows: ``` function mathJax_scripts() { wp_enqueue_script( 'mathjax-js', http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML', array(), '2.7.1', false ); } add_action( 'wp_enqueue_scripts', 'mathJax_scripts' ); ``` I added the version number (2...
225,895
<p>I have updated WordPress to the newest version. But due to compatibility issues, I need your help.</p> <p>How can I change the font size of each text? What I'm doing right now is using some kinds of buttons on the bar in the image.</p> <p><a href="https://i.stack.imgur.com/dbFVq.jpg" rel="nofollow noreferrer"><img...
[ { "answer_id": 225897, "author": "Jared Caputo", "author_id": 89128, "author_profile": "https://wordpress.stackexchange.com/users/89128", "pm_score": 0, "selected": false, "text": "<p>You can edit your theme's stylesheet (style.css) to change the font size for each of the headings and th...
2016/05/07
[ "https://wordpress.stackexchange.com/questions/225895", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93656/" ]
I have updated WordPress to the newest version. But due to compatibility issues, I need your help. How can I change the font size of each text? What I'm doing right now is using some kinds of buttons on the bar in the image. [![enter image description here](https://i.stack.imgur.com/dbFVq.jpg)](https://i.stack.imgur....
First of all, remember that html is for adding meaning and css appearance. If you want to change the text size for sematic reasons, like *"this text is a subsection title"* or *"this sentence is very important"*, I would advice you not to use `<span style="font-size: xx">`. It's a better practice for those cases to us...
225,899
<p>Would be potential problems if I delete <code>wordpress_logged_in_47d1523b...</code> cookie using javascript? Is there something additional that <code>wp_logout</code> does?</p>
[ { "answer_id": 225902, "author": "N00b", "author_id": 80903, "author_profile": "https://wordpress.stackexchange.com/users/80903", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Is there something additional that wp_logout does?</p>\n</blockquote>\n\n<p>As I said in my comm...
2016/05/07
[ "https://wordpress.stackexchange.com/questions/225899", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47988/" ]
Would be potential problems if I delete `wordpress_logged_in_47d1523b...` cookie using javascript? Is there something additional that `wp_logout` does?
You can log out the current user with [`wp_logout()` function](https://codex.wordpress.org/Function_Reference/wp_logout): I think it is much better approach. `wp_logout()` destroys current session, clears authorization cookie and call `wp_logout` action. Also, it is a pluggable function, which means can be redefined b...
225,901
<p>I have this code in my functions.php file:</p> <pre><code>function user_content_replace($content) { // it's not a URL, let's apply the replacement if (!filter_var($string, FILTER_VALIDATE_URL)) { $replacement = '$1.&lt;/p&gt;&lt;p&gt;$2'; return preg_replace("/([^\\.]*\\.[^\\.]*\\.[^\\.]*){...
[ { "answer_id": 226012, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": true, "text": "<pre><code>&lt;?php\n$string = 'Sentence 1. Sentence 2? Sentence 3! Sentence 4... Sentence 5… Sentence 6! Sente...
2016/05/07
[ "https://wordpress.stackexchange.com/questions/225901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31498/" ]
I have this code in my functions.php file: ``` function user_content_replace($content) { // it's not a URL, let's apply the replacement if (!filter_var($string, FILTER_VALIDATE_URL)) { $replacement = '$1.</p><p>$2'; return preg_replace("/([^\\.]*\\.[^\\.]*\\.[^\\.]*){1}\\.([^\\.]*)/s", $replac...
``` <?php $string = 'Sentence 1. Sentence 2? Sentence 3! Sentence 4... Sentence 5… Sentence 6! Sentence 7. Sentence 8. Sentence 9… Sentence 10... Sentence 11. '; $sentences_per_paragraph = 3; // settings $pattern = '~(?<=[.?!…])\s+~'; // some punctuation and trailing space(s) $sentences_array = preg_split($pattern, ...
225,926
<p>I have a server elastic-search instance running, as well as an off-site firebase data account. What I am trying to do is basically fire a curl request to create certain user fields with data once the user creates an account. The site automatically checks for these values once the user logs in (I did this by automati...
[ { "answer_id": 225931, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 2, "selected": false, "text": "<pre><code>//This action hook allows you to access data for a new user immediately after they are added to...
2016/05/07
[ "https://wordpress.stackexchange.com/questions/225926", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93670/" ]
I have a server elastic-search instance running, as well as an off-site firebase data account. What I am trying to do is basically fire a curl request to create certain user fields with data once the user creates an account. The site automatically checks for these values once the user logs in (I did this by automatical...
``` //This action hook allows you to access data for a new user immediately after they are added to the database. The user id is passed to hook as an argument. do_action( 'user_register', $user_id ); ``` so you could: ``` add_action('user_register','my_user_register_function'); function my_user_register_functi...
225,933
<p>I am creating theme for WordPress which I hope to maintain. The current method of updating a non-WordPress hosted theme is to either replace the old theme with the new theme through FTP or switch to say WP2016 then delete the old theme and install the new one. Neither of these are really user friendly methods.</p> ...
[ { "answer_id": 225931, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 2, "selected": false, "text": "<pre><code>//This action hook allows you to access data for a new user immediately after they are added to...
2016/05/07
[ "https://wordpress.stackexchange.com/questions/225933", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36773/" ]
I am creating theme for WordPress which I hope to maintain. The current method of updating a non-WordPress hosted theme is to either replace the old theme with the new theme through FTP or switch to say WP2016 then delete the old theme and install the new one. Neither of these are really user friendly methods. Would t...
``` //This action hook allows you to access data for a new user immediately after they are added to the database. The user id is passed to hook as an argument. do_action( 'user_register', $user_id ); ``` so you could: ``` add_action('user_register','my_user_register_function'); function my_user_register_functi...
225,941
<p>I have a custom post type called "products". My goal is to make my custom query that I have on homepage and also the search query show first the posts that have a custom field called "id_number" not empty and then the other posts that have the "id_number" empty. All should be ordered by title.</p> <p>This is my cod...
[ { "answer_id": 225931, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 2, "selected": false, "text": "<pre><code>//This action hook allows you to access data for a new user immediately after they are added to...
2016/05/07
[ "https://wordpress.stackexchange.com/questions/225941", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69589/" ]
I have a custom post type called "products". My goal is to make my custom query that I have on homepage and also the search query show first the posts that have a custom field called "id\_number" not empty and then the other posts that have the "id\_number" empty. All should be ordered by title. This is my code so far...
``` //This action hook allows you to access data for a new user immediately after they are added to the database. The user id is passed to hook as an argument. do_action( 'user_register', $user_id ); ``` so you could: ``` add_action('user_register','my_user_register_function'); function my_user_register_functi...
225,963
<p>In the phase of developing a new wordpress-based site, I'm evaluating also future pitfalls such as upgrades. Unfortunately, there's no guarantee that a third party plugin will not be discontinued. But that's how it works! There are two possible options:</p> <p>1) Develop a tight robust site, with no future updates,...
[ { "answer_id": 225931, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 2, "selected": false, "text": "<pre><code>//This action hook allows you to access data for a new user immediately after they are added to...
2016/05/07
[ "https://wordpress.stackexchange.com/questions/225963", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1210/" ]
In the phase of developing a new wordpress-based site, I'm evaluating also future pitfalls such as upgrades. Unfortunately, there's no guarantee that a third party plugin will not be discontinued. But that's how it works! There are two possible options: 1) Develop a tight robust site, with no future updates, and cross...
``` //This action hook allows you to access data for a new user immediately after they are added to the database. The user id is passed to hook as an argument. do_action( 'user_register', $user_id ); ``` so you could: ``` add_action('user_register','my_user_register_function'); function my_user_register_functi...
226,029
<p>The 40,000 urls have the same structure between them.</p> <p>How can we redirect 40,000 urls in bulk instead of inputting each url 1 by 1?</p> <p>Here's a sample format of the url structure:</p> <p>www.website.com/School-A-Cost to www.website.com/School-A/Cost</p> <p>www.website.com/School-B-Cost to www.website....
[ { "answer_id": 226030, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>That can be solved without WordPress per .htaccess (or whatever config file your webserver is using).</p>\n\n<p>Examp...
2016/05/09
[ "https://wordpress.stackexchange.com/questions/226029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86907/" ]
The 40,000 urls have the same structure between them. How can we redirect 40,000 urls in bulk instead of inputting each url 1 by 1? Here's a sample format of the url structure: www.website.com/School-A-Cost to www.website.com/School-A/Cost www.website.com/School-B-Cost to www.website.com/School-B/Cost
That can be solved without WordPress per .htaccess (or whatever config file your webserver is using). Example for .htaccess: ``` RedirectMatch Permanent /School-(.*)-Cost /School-$1/Cost ```
226,044
<p>I've added meta box: checkbox on admin edit screen</p> <pre><code>&lt;input type="checkbox" name="changeposition" /&gt; </code></pre> <p>So how could we sanitize the input came from the checkbox as we do for input type text by <code>sanitize_text_field()</code>. Is there any function like this for checkbox sanitiz...
[ { "answer_id": 226045, "author": "550", "author_id": 92492, "author_profile": "https://wordpress.stackexchange.com/users/92492", "pm_score": 0, "selected": false, "text": "<p>I would suggest the <a href=\"http://php.net/manual/en/function.filter-var.php\" rel=\"nofollow\"><code>filter_va...
2016/05/09
[ "https://wordpress.stackexchange.com/questions/226044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75767/" ]
I've added meta box: checkbox on admin edit screen ``` <input type="checkbox" name="changeposition" /> ``` So how could we sanitize the input came from the checkbox as we do for input type text by `sanitize_text_field()`. Is there any function like this for checkbox sanitization or should we create custom method for...
Be sure to set the value in your markup. You should have. ``` <input type="checkbox" name="changeposition" value="yes" /> ``` Then, I'd suggest using [`sanitize_key()`](https://developer.wordpress.org/reference/functions/sanitize_key/) to sanitize. > > Keys are used as internal identifiers. Lowercase alphanumeric ...
226,065
<p>I have a homepage displaying the <code>home.php</code> template, containing 2 sidebars with widgets in them.</p> <p>The main query still pulls in the standard 10 posts, but since I'm not displaying these, I'd like to eliminate the query being made to the database entirely. If needs be, an empty post loop will do as...
[ { "answer_id": 226070, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>Here is a neat trick I learned from @birgire, we can halt the main query by appending <code>AND where 0...
2016/05/09
[ "https://wordpress.stackexchange.com/questions/226065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/736/" ]
I have a homepage displaying the `home.php` template, containing 2 sidebars with widgets in them. The main query still pulls in the standard 10 posts, but since I'm not displaying these, I'd like to eliminate the query being made to the database entirely. If needs be, an empty post loop will do as I am not using the m...
The `posts_request` filter -------------------------- Skimming through the `WP_Query` we find this part of interest: ``` if ( !$q['suppress_filters'] ) { /** * Filter the completed SQL query before sending. * * @since 2.0.0 * * @param array $request The complete SQL query. * @para...
226,099
<p>I'm trying to stop the WordPress from automatically wrapping <code>&lt;img&gt;</code>s with <code>&lt;p&gt;</code> tags. I've tried this recommended snippet in my <code>functions.php</code>:</p> <pre><code>function filter_ptags_on_images($content){ // Remove p tags from around images return preg_replace('/&lt;...
[ { "answer_id": 269399, "author": "mukto90", "author_id": 57944, "author_profile": "https://wordpress.stackexchange.com/users/57944", "pm_score": 0, "selected": false, "text": "<p>If you want to <em>remove</em> <code>&lt;p&gt;</code> from entire content (not only from the images), this ca...
2016/05/09
[ "https://wordpress.stackexchange.com/questions/226099", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93768/" ]
I'm trying to stop the WordPress from automatically wrapping `<img>`s with `<p>` tags. I've tried this recommended snippet in my `functions.php`: ``` function filter_ptags_on_images($content){ // Remove p tags from around images return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3...
this is a function, that unwraps images from p tags inside the\_content ``` /** * WP: Unwrap images from <p> tag * @param $content * @return mixed */ function so226099_filter_p_tags_on_images( $content ) { $content = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '\1', $content); r...
226,112
<p>I have this code that generates a link to a random post in my blog:</p> <pre><code>&lt;?php $posts = get_posts('orderby=rand&amp;numberposts=1'); foreach($posts as $post): ?&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;" title="Random Post from Our Blog" style="float:right;" class="random-widget"&gt; ...
[ { "answer_id": 226113, "author": "The Maniac", "author_id": 10966, "author_profile": "https://wordpress.stackexchange.com/users/10966", "pm_score": 0, "selected": false, "text": "<p>I think you just need to add a call to <code>setup_postdata</code>. Otherwise your code looks like it shou...
2016/05/09
[ "https://wordpress.stackexchange.com/questions/226112", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43473/" ]
I have this code that generates a link to a random post in my blog: ``` <?php $posts = get_posts('orderby=rand&numberposts=1'); foreach($posts as $post): ?> <a href="<?php the_permalink(); ?>" title="Random Post from Our Blog" style="float:right;" class="random-widget"> <span class="fa-random" style="...
Ok, thanks to The Maniac for all the help troublshooting. Looks like I had to take this completely outside the loop and call the WP\_Query class on a new variable to make it happen. Here's what worked: ``` <?php $query = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => '1' ) ); while ( $query->have_po...
226,117
<p>I'm new to WordPress and I'm hoping to display post formats differently on the home page; sort of like this image:</p> <p><img src="https://i.stack.imgur.com/ZsJNe.jpg" alt="homepage"></p> <p>The problem is that the theme I'm using is very different than other themes I've seen, <strong>the loop is in a function</s...
[ { "answer_id": 226124, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 0, "selected": false, "text": "<p>Looking at your list, you are really only changing the default result for excerpts for the image and quote for...
2016/05/09
[ "https://wordpress.stackexchange.com/questions/226117", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93779/" ]
I'm new to WordPress and I'm hoping to display post formats differently on the home page; sort of like this image: ![homepage](https://i.stack.imgur.com/ZsJNe.jpg) The problem is that the theme I'm using is very different than other themes I've seen, **the loop is in a function**. In my `index.php`, I have ``` <?p...
The best way to do this is get the post format and then use the switch statement, like this: ``` $my_format = get_post_format (); switch ($my_format) { case 'quote': $htmlcontent = ... ; break; case 'aside': $htmlcontent = ... ; break; and so on } ``` The function that builds up $htmlcontent starts w...
226,167
<p>I am writing a function to query some information from a custom table in the database. It seems that I am unable to query the database on the field I need.</p> <pre><code>function ch_details_from_id($id) { global $wpdb; $details = $wpdb-&gt;get_results("SELECT * FROM " . $wpdb-&gt;prefix . "ch_guests WHER...
[ { "answer_id": 226168, "author": "Badger", "author_id": 66660, "author_profile": "https://wordpress.stackexchange.com/users/66660", "pm_score": -1, "selected": false, "text": "<p>The field name is a reserved name. Changing from <code>key</code> to <code>id</code> has solved the issue.</p...
2016/05/10
[ "https://wordpress.stackexchange.com/questions/226167", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/66660/" ]
I am writing a function to query some information from a custom table in the database. It seems that I am unable to query the database on the field I need. ``` function ch_details_from_id($id) { global $wpdb; $details = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ch_guests WHERE key = '" . $id . "...
Here issue with the column name. You are using column **key** in the query which is the default keyword/index in mysql. For resolving this kind of issue just use the "Grave accent(`)' symbol in the query for the column name, No need to change the column name. So in your case the right query is ``` $details = $wpdb-...
226,187
<p>I want to remove the coupon drop down feature and just have the input field and 'add coupon' button on the checkout page. Does anyone know how I can get rid of the dropdown feature? Thank you in advance!</p> <p>HTML:</p> <pre><code>if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } if ( ! wc...
[ { "answer_id": 226224, "author": "Steven", "author_id": 13118, "author_profile": "https://wordpress.stackexchange.com/users/13118", "pm_score": 0, "selected": false, "text": "<p>You can do that with css - the form is hidden by default, but can be targeted like this:</p>\n\n<pre><code>.wo...
2016/05/10
[ "https://wordpress.stackexchange.com/questions/226187", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93762/" ]
I want to remove the coupon drop down feature and just have the input field and 'add coupon' button on the checkout page. Does anyone know how I can get rid of the dropdown feature? Thank you in advance! HTML: ``` if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } if ( ! wc_coupons_enabled() ) ...
You can try this action. Put this line into your active theme **functions.php** file ``` remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); ```
226,211
<p>I am using a child theme but it does not display any images. I am reading a book which suggests the following: "There is a difference in calling images from parent themes and child themes: </p> <p>for parent Theme:</p> <pre><code> &lt;?php echo get template_directory_uri(); ?&gt; </code></pre> <p>for child ...
[ { "answer_id": 226287, "author": "Pim Schaaf", "author_id": 25886, "author_profile": "https://wordpress.stackexchange.com/users/25886", "pm_score": 0, "selected": false, "text": "<p>Images that are uploaded through WordPress are saved to <code>/wp-content/uploads/</code> <em>independent<...
2016/05/10
[ "https://wordpress.stackexchange.com/questions/226211", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93829/" ]
I am using a child theme but it does not display any images. I am reading a book which suggests the following: "There is a difference in calling images from parent themes and child themes: for parent Theme: ``` <?php echo get template_directory_uri(); ?> ``` for child Theme: ``` <?php bloginfo('styleshe...
You could try the following if you have a child theme and trying to reference your images from that file location, onto your custom .php files... ``` <img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/images/your-custom-image.jpg" /> ``` Just make sure in your child theme location, you really have a chil...
226,216
<p>I'm learning how to build a WordPress plugin. In the sample plugin code, I have this PHP/HTML:</p> <pre><code>ob_start(); // other plugin code &lt;?php function plugin_rvce_options_page() { ?&gt; &lt;div&gt; &lt;form action="options.php" method="post"&gt; &lt;?php settings_fields('plugi...
[ { "answer_id": 226218, "author": "Steven", "author_id": 13118, "author_profile": "https://wordpress.stackexchange.com/users/13118", "pm_score": 2, "selected": false, "text": "<p>No, this is not a correct use for <code>ob_start()</code>. You're getting the warning because your script is o...
2016/05/10
[ "https://wordpress.stackexchange.com/questions/226216", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93195/" ]
I'm learning how to build a WordPress plugin. In the sample plugin code, I have this PHP/HTML: ``` ob_start(); // other plugin code <?php function plugin_rvce_options_page() { ?> <div> <form action="options.php" method="post"> <?php settings_fields('plugin_options'); ?> <?php d...
No, this is not a correct use for `ob_start()`. You're getting the warning because your script is outputting code before the page headers are sent - meaning you're printing output before the html page. Without knowing what's going on in your `// other plugin code` it's difficult to say what's happening exactly. I woul...
226,229
<p>I have a working query which returns a set of custom posts which are ordered by their package ID (ASC). For a query with 9 results this may return for example:</p> <blockquote> <p>4 posts (Post ID's 1,2,3,4) with Package ID 1</p> <p>3 posts (Post ID's 5,6,7) with Package ID 2</p> <p>2 posts (Post ID's ...
[ { "answer_id": 226230, "author": "ngearing", "author_id": 50184, "author_profile": "https://wordpress.stackexchange.com/users/50184", "pm_score": 1, "selected": false, "text": "<p>Not possible with a single query you would have to do 3 seperate query each one targeting the different \"Pa...
2016/05/11
[ "https://wordpress.stackexchange.com/questions/226229", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64450/" ]
I have a working query which returns a set of custom posts which are ordered by their package ID (ASC). For a query with 9 results this may return for example: > > 4 posts (Post ID's 1,2,3,4) with Package ID 1 > > > 3 posts (Post ID's 5,6,7) with Package ID 2 > > > 2 posts (Post ID's 8,9) with Package ID 3 > > ...
There is no need to do an overrated amount of queries to accomplish this. you can still use **only** one query, `the_posts` filter and some PHP to sort your code as needed. I take that this is a custom query from what I read in your question, so we can do the following: * First, we want to introduce a custom `WP_Que...
226,244
<p>I upgraded WordPress to 4.5.1 from 4.2.2 and it has broken the functionality I have extending the Walker class. The Walker extension:</p> <pre><code>class ReturnWalker extends Walker{ public $db_fields = array( 'parent' =&gt; 'parent', 'id' =&gt; 'term_id' ); public $show_all = FALSE; ...
[ { "answer_id": 226246, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>Your original solution was a hack, and no surprise it failed. In general never add methods/attributes to ...
2016/05/11
[ "https://wordpress.stackexchange.com/questions/226244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93845/" ]
I upgraded WordPress to 4.5.1 from 4.2.2 and it has broken the functionality I have extending the Walker class. The Walker extension: ``` class ReturnWalker extends Walker{ public $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' ); public $show_all = FALSE; /* * * @par...
Update - Creating a class that mimics WP\_Terms and copying over the objects returned by get\_the\_terms() to my \*\_Terms class worked. Passing in the returned objects when instantiating my class hits the constructor and builds out a copy of the properties that I have control over without worrying about core code chan...
226,252
<pre><code># Adds ability to add break tags on posts remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); add_filter( 'the_content', 'nl2br' ); add_filter( 'the_excerpt', 'nl2br' ); </code></pre> <p>We had the above code in our custom plugin for years and it made the break tag work.</...
[ { "answer_id": 246052, "author": "sMyles", "author_id": 51201, "author_profile": "https://wordpress.stackexchange.com/users/51201", "pm_score": 0, "selected": false, "text": "<p>When are you calling the code to remove and add the new filters? You can try calling them with a higher prior...
2016/05/11
[ "https://wordpress.stackexchange.com/questions/226252", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32393/" ]
``` # Adds ability to add break tags on posts remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); add_filter( 'the_content', 'nl2br' ); add_filter( 'the_excerpt', 'nl2br' ); ``` We had the above code in our custom plugin for years and it made the break tag work. Well it still works...
From the comments, problems seems to be related to some plugin misbehaving.
226,256
<p>EDIT: Due to downvotes (with no comments!), I've edited this post to be a bit more specific...</p> <p>Why isn't the following change working?</p> <pre><code>$custom_message = get_the_title( $post-&gt;ID ) .''. $hash_tags; </code></pre> <p>to:</p> <pre><code>$custom_message = get_the_content( $post-&gt;ID ) .' '....
[ { "answer_id": 226279, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Just some general remarks:</p>\n\n<blockquote>\n <p>Why isn't the following change working?</p>\n\n<pre><code...
2016/05/11
[ "https://wordpress.stackexchange.com/questions/226256", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36980/" ]
EDIT: Due to downvotes (with no comments!), I've edited this post to be a bit more specific... Why isn't the following change working? ``` $custom_message = get_the_title( $post->ID ) .''. $hash_tags; ``` to: ``` $custom_message = get_the_content( $post->ID ) .' '. $hash_tags; ``` --- Original Post I'm trying...
Just some general remarks: > > Why isn't the following change working? > > > > ``` > $custom_message = get_the_title( $post->ID ) .''. $hash_tags; > > ``` > > to: > > > > ``` > $custom_message = get_the_content( $post->ID ) .' '. $hash_tags; > > ``` > > Note that `get_the_content()` doesn't take a...
226,269
<p>I know I can get rid of some of the default WP theme files required using <code>get_template_part()</code> for instance. But some files still need to be present - for instance, how would I move page.php to a subfolder so it still works? I am also aware, that you can put you own page templates to a custom folder and ...
[ { "answer_id": 226279, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Just some general remarks:</p>\n\n<blockquote>\n <p>Why isn't the following change working?</p>\n\n<pre><code...
2016/05/11
[ "https://wordpress.stackexchange.com/questions/226269", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65585/" ]
I know I can get rid of some of the default WP theme files required using `get_template_part()` for instance. But some files still need to be present - for instance, how would I move page.php to a subfolder so it still works? I am also aware, that you can put you own page templates to a custom folder and they are being...
Just some general remarks: > > Why isn't the following change working? > > > > ``` > $custom_message = get_the_title( $post->ID ) .''. $hash_tags; > > ``` > > to: > > > > ``` > $custom_message = get_the_content( $post->ID ) .' '. $hash_tags; > > ``` > > Note that `get_the_content()` doesn't take a...
226,292
<p>If the answer is case-by-case basis, check out this blog post: <a href="http://www.inquisitr.com/3078539/starting-in-west-virginia-bernie-sanders-could-win-8-of-the-next-9-primaries/" rel="nofollow">http://www.inquisitr.com/3078539/starting-in-west-virginia-bernie-sanders-could-win-8-of-the-next-9-primaries/</a></p>...
[ { "answer_id": 226279, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Just some general remarks:</p>\n\n<blockquote>\n <p>Why isn't the following change working?</p>\n\n<pre><code...
2016/05/11
[ "https://wordpress.stackexchange.com/questions/226292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86497/" ]
If the answer is case-by-case basis, check out this blog post: <http://www.inquisitr.com/3078539/starting-in-west-virginia-bernie-sanders-could-win-8-of-the-next-9-primaries/> Does the title and description of images ever get shown on WordPress sites?
Just some general remarks: > > Why isn't the following change working? > > > > ``` > $custom_message = get_the_title( $post->ID ) .''. $hash_tags; > > ``` > > to: > > > > ``` > $custom_message = get_the_content( $post->ID ) .' '. $hash_tags; > > ``` > > Note that `get_the_content()` doesn't take a...
226,303
<p>So i spent the entire day yesterday trying to achieve a full width responsive background video inside of a custom wordpress page template. </p> <p>This is the bg-video code added to landing.php (my future landing page)</p> <pre><code>&lt;div class="fullscreen-bg"&gt; &lt;video loop muted autoplay poster="public_ht...
[ { "answer_id": 226279, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Just some general remarks:</p>\n\n<blockquote>\n <p>Why isn't the following change working?</p>\n\n<pre><code...
2016/05/11
[ "https://wordpress.stackexchange.com/questions/226303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93651/" ]
So i spent the entire day yesterday trying to achieve a full width responsive background video inside of a custom wordpress page template. This is the bg-video code added to landing.php (my future landing page) ``` <div class="fullscreen-bg"> <video loop muted autoplay poster="public_html/wp-content/themes/gt3-wp-pu...
Just some general remarks: > > Why isn't the following change working? > > > > ``` > $custom_message = get_the_title( $post->ID ) .''. $hash_tags; > > ``` > > to: > > > > ``` > $custom_message = get_the_content( $post->ID ) .' '. $hash_tags; > > ``` > > Note that `get_the_content()` doesn't take a...
226,312
<p>I am working on a wordpress project with the following plugins :</p> <ul> <li>Woocommerce</li> <li>Woocommerce product vendors</li> <li>WP Job Manager</li> <li>Wp Job Manager products</li> </ul> <p>I am trying to <strong>upgrade the user role</strong> after adding a job, so the user can access the wp-admin and edi...
[ { "answer_id": 226315, "author": "Shane", "author_id": 10555, "author_profile": "https://wordpress.stackexchange.com/users/10555", "pm_score": 2, "selected": false, "text": "<p>Have you tried logging in the user after your changes?</p>\n\n<p>Such as:</p>\n\n<pre><code> wp_set_current_use...
2016/05/11
[ "https://wordpress.stackexchange.com/questions/226312", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76008/" ]
I am working on a wordpress project with the following plugins : * Woocommerce * Woocommerce product vendors * WP Job Manager * Wp Job Manager products I am trying to **upgrade the user role** after adding a job, so the user can access the wp-admin and edit his own product. Now the user can be upgraded to Manage his...
I think you are on the right track, `wp_cache_delete` was what finally helped me get an auto-signup with auto-login plugin working... I have this from there: ``` wp_cache_delete($current_user->ID, 'users'); wp_cache_delete($current_user->user_login, 'userlogins'); ``` Then see what roles you get after that with: ``...
226,363
<p><code>Wordpress version 4.5.1</code></p> <p>I'm trying to dynamically update page titles on a particular template. After lots of digging and learning about the <code>wp_title()</code> changes, I'm attempting to use <code>document_title_parts</code>. However, I can't get the filter to run at all.</p> <p>I'm in a ch...
[ { "answer_id": 230963, "author": "Nikhil Chavan", "author_id": 85061, "author_profile": "https://wordpress.stackexchange.com/users/85061", "pm_score": 2, "selected": false, "text": "<p>If the parent theme does not declare support for <code>title-tag</code> you can do it like this in chil...
2016/05/12
[ "https://wordpress.stackexchange.com/questions/226363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7229/" ]
`Wordpress version 4.5.1` I'm trying to dynamically update page titles on a particular template. After lots of digging and learning about the `wp_title()` changes, I'm attempting to use `document_title_parts`. However, I can't get the filter to run at all. I'm in a child theme, `functions.php`: ``` add_theme_support...
I ran your filter in my development area. It didn't work. Then I switched off the Yoast SEO plugin, which I knew was also messing with the page title. Then it worked. So my suggestion would be another plugin is messing with it. In the case of Yoast, it was a filter call to `pre_get_document_title` returning non empty....
226,398
<p>I have setup .htaccess to map a custom url to a custom php script. This page is not part of wordpress, but i want it to use the wordpress theme. At the top of the script I load up Wordpress. And from here i populate the global $post object with my own custom data. </p> <pre><code>require_once('../wp-blog-header.php...
[ { "answer_id": 226399, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 0, "selected": false, "text": "<p>I am not sure this will be suitable to your case but you can try:</p>\n\n<pre><code>define('SHORTINIT',true); ...
2016/05/12
[ "https://wordpress.stackexchange.com/questions/226398", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/190834/" ]
I have setup .htaccess to map a custom url to a custom php script. This page is not part of wordpress, but i want it to use the wordpress theme. At the top of the script I load up Wordpress. And from here i populate the global $post object with my own custom data. ``` require_once('../wp-blog-header.php'); //change s...
If you want the WordPress framework without the querying, use `wp-load.php`: ``` require '/path/to/wordpress/wp-load.php'; ```
226,400
<p>I have a problem with ajax load more for my CustomPostType. I think i have mistake but don't know where. If it possible to edit my code, i will happy.</p> <p><strong>UPDATE</strong></p> <p>I have create div <code>cool</code> to paste in it loaded more post. After clicking load more i have 0 in div cool. What does ...
[ { "answer_id": 226417, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": false, "text": "<p>This will (*should) fix your first problem:</p>\n\n<pre><code>function rmcc_post_listing_shortcode1( $atts...
2016/05/12
[ "https://wordpress.stackexchange.com/questions/226400", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88709/" ]
I have a problem with ajax load more for my CustomPostType. I think i have mistake but don't know where. If it possible to edit my code, i will happy. **UPDATE** I have create div `cool` to paste in it loaded more post. After clicking load more i have 0 in div cool. What does it mean? **In functions.php** ``` a...
This will (\*should) fix your first problem: ``` function rmcc_post_listing_shortcode1( $atts ) { // No need for output buffering - AJAX handlers should ECHO their response // ob_start(); // .. // So long, farewell // $myvariable = ob_get_clean(); // return $myvariable; // Now terminate ...
226,403
<p>My problem is that I can't verify if some user insert an existing email into AJAX registration form. However my form is working fine, it's registering users and it's giving all other errors, like "invalid email" or "empty fields". The only thing it doesn't disaply is <strong>the error for the existing emails</strong...
[ { "answer_id": 226407, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": true, "text": "<p>Why are you making work hard for yourself? <code>wp_create_user</code> already checks if the email/login ex...
2016/05/12
[ "https://wordpress.stackexchange.com/questions/226403", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93927/" ]
My problem is that I can't verify if some user insert an existing email into AJAX registration form. However my form is working fine, it's registering users and it's giving all other errors, like "invalid email" or "empty fields". The only thing it doesn't disaply is **the error for the existing emails**. ``` function...
Why are you making work hard for yourself? `wp_create_user` already checks if the email/login exists, which is also why your code is "failing" - `$user_id` will already be a `WP_Error`, so your `elseif ( is_wp_error( $newerrors ) )` never fires. All you need is: ``` $user_id = wp_create_user( $sanitized_user_login, $...
226,436
<p>I am trying to figure out how to replace the value of one advanced custom field with the value from a different custom field. Would anyone be able to help me structure a SQL query that will do this across the database?</p> <p>The meta_key that contains the material I am looking to duplicate is "ehp_citation", and t...
[ { "answer_id": 309605, "author": "Cubakos", "author_id": 107648, "author_profile": "https://wordpress.stackexchange.com/users/107648", "pm_score": 2, "selected": false, "text": "<p>First take a db backup! \nSecond, in your question you mention the same meta_key, so made the following ass...
2016/05/12
[ "https://wordpress.stackexchange.com/questions/226436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54061/" ]
I am trying to figure out how to replace the value of one advanced custom field with the value from a different custom field. Would anyone be able to help me structure a SQL query that will do this across the database? The meta\_key that contains the material I am looking to duplicate is "ehp\_citation", and the targe...
First take a db backup! Second, in your question you mention the same meta\_key, so made the following assumption: > > The meta\_key you want to keep is "ehp\_citation" > > > The meta\_key you want to change is "ehp\_citation\_old" \* so make the correction accordingly > > > Then you can try something like: `...
226,482
<p>I have a form with a WP Media to allow user uploads for a custom post type on the front end. Every time I try to upload as a user I can the message <code>You don't have permission to attach files to this post.</code></p> <p>Investigating it further, I get denied action in the file <code>ajax-actions.php</code> wher...
[ { "answer_id": 226486, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 0, "selected": false, "text": "<p>If you want to allow user to upload files. <code>edit_post</code> is wrong cap to check. Instead you will need to...
2016/05/13
[ "https://wordpress.stackexchange.com/questions/226482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54189/" ]
I have a form with a WP Media to allow user uploads for a custom post type on the front end. Every time I try to upload as a user I can the message `You don't have permission to attach files to this post.` Investigating it further, I get denied action in the file `ajax-actions.php` where it checks `current_user_can( '...
If I understood correctly the situation described in the question and its comments, the user has capabilities to upload files and to edit your post type, so you shouldn't be fitering capabilities, the user already has the correct capabilities. The problem is that `wp_editor()` use the global `$post` by default, and in...
226,483
<p>I want to display a list of categories excluding the category of the current single post that the user is navigating on. The list is displayed on the <code>single.php</code> template.</p> <p>I'm using this code to display all categories and is working well but I can't find a way to exclude the current post category...
[ { "answer_id": 226490, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 0, "selected": false, "text": "<p>First you will need an array that contains all categories of the current post:</p>\n\n<pre><code>$current_cats =...
2016/05/13
[ "https://wordpress.stackexchange.com/questions/226483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22933/" ]
I want to display a list of categories excluding the category of the current single post that the user is navigating on. The list is displayed on the `single.php` template. I'm using this code to display all categories and is working well but I can't find a way to exclude the current post category: ``` <ul class="sub...
The idea here would be to use the queried object's ID to get the post terms (*because we are most probably outside the loop here, if inside the loop, just use `get_the_ID()`*). From there, we can use `wp_list_pluck()` to get all the term ID's and simply pass that to `get_terms()` `exclude` parameter Just a note, as fr...
226,487
<p>First of all I do not have a lot of experience with wordpress plugins, but I am developing a plugin which has to connect and send data to a remote database ( which it is already doing ). But at this point of time my connection is not secure at all because all the database info is shown for the admin of the site.</p>...
[ { "answer_id": 226631, "author": "wax", "author_id": 94014, "author_profile": "https://wordpress.stackexchange.com/users/94014", "pm_score": -1, "selected": false, "text": "<p>Great question. </p>\n\n<p>A couple of things:</p>\n\n<p>First, best practices tell us to always keep these type...
2016/05/13
[ "https://wordpress.stackexchange.com/questions/226487", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93989/" ]
First of all I do not have a lot of experience with wordpress plugins, but I am developing a plugin which has to connect and send data to a remote database ( which it is already doing ). But at this point of time my connection is not secure at all because all the database info is shown for the admin of the site. This ...
I'd recommend setting up an API, and also ensuring the sites are HTTPS (have an SSL certificate) to encrypt communication between the servers. If you don't have one already, there are free certifiers such as <https://letsencrypt.org/>
226,533
<p>Is it possible to stop WordPress adding a width and height to an object when you pate it in to the source view?</p> <p>When I paste in</p> <pre><code>&lt;a href="#"&gt;&lt;object data="grid-linked-in.svg" type="image/svg+xml"&gt;&lt;/object&gt;&lt;/a&gt; </code></pre> <p>WP changes it to</p> <pre><code>&lt;a hre...
[ { "answer_id": 226539, "author": "Captain Yar", "author_id": 87544, "author_profile": "https://wordpress.stackexchange.com/users/87544", "pm_score": 0, "selected": false, "text": "<p>You can use jQuery for this:</p>\n\n<pre><code>$('object').each(function(){\n $(this).removeAttr('widt...
2016/05/13
[ "https://wordpress.stackexchange.com/questions/226533", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94003/" ]
Is it possible to stop WordPress adding a width and height to an object when you pate it in to the source view? When I paste in ``` <a href="#"><object data="grid-linked-in.svg" type="image/svg+xml"></object></a> ``` WP changes it to ``` <a href="#"><object width="300" height="150" type="image/svg+xml" data="grid-...
You can try this: ``` add_filter( 'media_send_to_editor', 'remove_width_height_attribute', 10 ); function remove_width_height_attribute( $html ) { $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); return $html; } ```
226,581
<p>Can anyone explain what is the difference between <code>update_user_meta</code> and <code>update_user_option</code> and in which scenarios the both can be used?</p>
[ { "answer_id": 226585, "author": "Jarod Thornton", "author_id": 44017, "author_profile": "https://wordpress.stackexchange.com/users/44017", "pm_score": 3, "selected": false, "text": "<p>Both write their data in the “usermeta” table. User options stored in the usermeta table retain the wo...
2016/05/14
[ "https://wordpress.stackexchange.com/questions/226581", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48573/" ]
Can anyone explain what is the difference between `update_user_meta` and `update_user_option` and in which scenarios the both can be used?
In layman terms there is no major difference! `update_user_option()` uses `update_user_meta()` internally. The only difference is `update_user_option()` prefix the option name with database table prefix + blog ID if you are in multisite and just table prefix if you are in single site installation. Take a look at the c...
226,588
<p>I imported the <a href="https://codex.wordpress.org/Theme_Unit_Test" rel="nofollow">Theme Unit Test</a> xml file with the wordpress importer. But all of the data is imported as pages. I am following an online tutorial to build a wordpress theme development and I believe the data should be imported as posts.</p> <p>...
[ { "answer_id": 226602, "author": "Shadat501", "author_id": 94059, "author_profile": "https://wordpress.stackexchange.com/users/94059", "pm_score": 3, "selected": false, "text": "<p>I get that answer. </p>\n\n<p>I go to this file: <code>wp-includes/deprecated.php</code> and find this line...
2016/05/14
[ "https://wordpress.stackexchange.com/questions/226588", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94059/" ]
I imported the [Theme Unit Test](https://codex.wordpress.org/Theme_Unit_Test) xml file with the wordpress importer. But all of the data is imported as pages. I am following an online tutorial to build a wordpress theme development and I believe the data should be imported as posts. When I proceed with the import. I ca...
I get that answer. I go to this file: `wp-includes/deprecated.php` and find this line in (deprecated) `wp_get_http()` function: ``` @set_time_limit ( 60 ); ``` just comment out this line and it works fine. Because wordpress hard coded that 60 seconds limit, this hard coded setting was over-ridding my `php.ini` s...
226,589
<p>I want to filter posts based on multiple acf custom fields with AND relation. Something like this:</p> <pre><code>$args = array( 'post_type' =&gt; 'product', 'meta_query' =&gt; array( 'relation' =&gt; 'AND', array( 'key' =&gt; 'color', 'va...
[ { "answer_id": 227814, "author": "Igor Fedorov", "author_id": 94657, "author_profile": "https://wordpress.stackexchange.com/users/94657", "pm_score": 1, "selected": false, "text": "<p>You can do it without Rest API\nLike this\n(It is my posts filter)</p>\n\n<pre>\n $paged = (get_query...
2016/05/14
[ "https://wordpress.stackexchange.com/questions/226589", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/72848/" ]
I want to filter posts based on multiple acf custom fields with AND relation. Something like this: ``` $args = array( 'post_type' => 'product', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'color', 'value' => 'blue', ...
This solution works with [`get_items()`](https://github.com/WP-API/WP-API/blob/develop/lib/endpoints/class-wp-rest-posts-controller.php#L81) in [`/lib/endpoints/class-wp-rest-posts-controller.php`](https://github.com/WP-API/WP-API/blob/develop/lib/endpoints/class-wp-rest-posts-controller.php) of the [`v2 WP Rest API`](...
226,605
<p>I am working on a theme that uses dynamic in head CSS and gives admin an option to also place the same in a file. Problem is that I am not sure what WP folder is always writable. I originally added the CSS file creation to <code>themename/css/</code> dir but since WP deletes the theme on update this has become an is...
[ { "answer_id": 226606, "author": "Jorin van Vilsteren", "author_id": 68062, "author_profile": "https://wordpress.stackexchange.com/users/68062", "pm_score": 0, "selected": false, "text": "<p>I think the best place to write to is to add a folder in the <code>wp-content</code> folder. Here...
2016/05/14
[ "https://wordpress.stackexchange.com/questions/226605", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67176/" ]
I am working on a theme that uses dynamic in head CSS and gives admin an option to also place the same in a file. Problem is that I am not sure what WP folder is always writable. I originally added the CSS file creation to `themename/css/` dir but since WP deletes the theme on update this has become an issue. What do...
Best place is the `uploads` directory - it'll be writable by the server, and it's the defacto directory for storing any user-generated/uploaded files: ``` $dirs = wp_upload_dir(); $path = $dirs['basedir']; // /path/to/wordpress/wp-content/uploads ```
226,609
<p>I am in the process of importing large amounts of data into a custom post type that has several custom fields (postmeta fields created by <a href="https://wordpress.org/plugins/advanced-custom-fields/" rel="nofollow">Advanced Custom Fields</a>). I am using the following function to import the data and it works fine ...
[ { "answer_id": 226606, "author": "Jorin van Vilsteren", "author_id": 68062, "author_profile": "https://wordpress.stackexchange.com/users/68062", "pm_score": 0, "selected": false, "text": "<p>I think the best place to write to is to add a folder in the <code>wp-content</code> folder. Here...
2016/05/14
[ "https://wordpress.stackexchange.com/questions/226609", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34045/" ]
I am in the process of importing large amounts of data into a custom post type that has several custom fields (postmeta fields created by [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/)). I am using the following function to import the data and it works fine with my test file of about 10...
Best place is the `uploads` directory - it'll be writable by the server, and it's the defacto directory for storing any user-generated/uploaded files: ``` $dirs = wp_upload_dir(); $path = $dirs['basedir']; // /path/to/wordpress/wp-content/uploads ```
226,610
<p>That's my loop:</p> <pre><code>&lt;main id="main"&gt; &lt;?php // the query $args = array('posts_per_page' =&gt; 10 ); $the_query = new WP_Query( $args ); ?&gt; &lt;?php if ( $the_query-&gt;have_posts() ) { ?&gt; &lt;!-- loop --&gt; &lt;?php while ( $the_query-&gt;have...
[ { "answer_id": 226611, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p><code>set_post_thumbnail_size()</code> (and other API functions which add/change sizes) applies to generation while...
2016/05/14
[ "https://wordpress.stackexchange.com/questions/226610", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94072/" ]
That's my loop: ``` <main id="main"> <?php // the query $args = array('posts_per_page' => 10 ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) { ?> <!-- loop --> <?php while ( $the_query->have_posts() ) { $the_query->the_...
`set_post_thumbnail_size()` (and other API functions which add/change sizes) applies to generation while it's *active*. So *existing* generated image sizes won't be retroactively affected by it. There are plenty of tools around (plugins, wp-cli) which regenerate files with current sizes configuration.
226,621
<p>I currently have this code from a plugin.</p> <pre><code>[imdbi meta_name=poster] </code></pre> <p>This cache an Image Link, and it simply display the link, I want it to display it as an image. Is this possible?</p>
[ { "answer_id": 226637, "author": "Usce", "author_id": 81451, "author_profile": "https://wordpress.stackexchange.com/users/81451", "pm_score": 2, "selected": true, "text": "<p>This is some specific shortcode to some plugin, that if you just want to paste an image in wordpress editor isn't...
2016/05/14
[ "https://wordpress.stackexchange.com/questions/226621", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94079/" ]
I currently have this code from a plugin. ``` [imdbi meta_name=poster] ``` This cache an Image Link, and it simply display the link, I want it to display it as an image. Is this possible?
This is some specific shortcode to some plugin, that if you just want to paste an image in wordpress editor isn't necessary. (Also there is not enough info about what this shortcode is about). So there is simple HTML that will simply display link you want as an image, following: ``` <img src="http://here-goes-some-...
226,652
<p>I am trying to make the featured images retrieved by the_post_thumbnai() in the loop responsive, but can't seem to find a simplified solution.</p> <p>The logic I want to implement is something like this:</p> <pre><code>If the screen size is less or equal to 728px the_post_thumbnai('thumbnail') //Display the thumbn...
[ { "answer_id": 226637, "author": "Usce", "author_id": 81451, "author_profile": "https://wordpress.stackexchange.com/users/81451", "pm_score": 2, "selected": true, "text": "<p>This is some specific shortcode to some plugin, that if you just want to paste an image in wordpress editor isn't...
2016/05/14
[ "https://wordpress.stackexchange.com/questions/226652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/90205/" ]
I am trying to make the featured images retrieved by the\_post\_thumbnai() in the loop responsive, but can't seem to find a simplified solution. The logic I want to implement is something like this: ``` If the screen size is less or equal to 728px the_post_thumbnai('thumbnail') //Display the thumbnail size image Els...
This is some specific shortcode to some plugin, that if you just want to paste an image in wordpress editor isn't necessary. (Also there is not enough info about what this shortcode is about). So there is simple HTML that will simply display link you want as an image, following: ``` <img src="http://here-goes-some-...
226,685
<p>I have been asked to switch between the existing front/home page of a website which has the URL</p> <pre class="lang-none prettyprint-override"><code>http://www.example.com </code></pre> <p>to a differnt page with the URL</p> <pre class="lang-none prettyprint-override"><code>http://www.example.com/?i=0 </code></p...
[ { "answer_id": 226672, "author": "Monkey Puzzle", "author_id": 48568, "author_profile": "https://wordpress.stackexchange.com/users/48568", "pm_score": 3, "selected": true, "text": "<p>Yes, this is a known problem between ios devices and Wordpress. It's a real issue due to the high number...
2016/05/15
[ "https://wordpress.stackexchange.com/questions/226685", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94124/" ]
I have been asked to switch between the existing front/home page of a website which has the URL ```none http://www.example.com ``` to a differnt page with the URL ```none http://www.example.com/?i=0 ``` It's a very old website (twenty twelve theme), and I can't understand what this `?i=0` means, and how they buil...
Yes, this is a known problem between ios devices and Wordpress. It's a real issue due to the high numbers of iPhone/ipad users who also use Wordpress, and I'm surprised it hasn't been addressed in the Wordpress core. Looks like it's still being debated/ worked on [here](https://core.trac.wordpress.org/ticket/14459). I...
226,696
<p>I am working on a CSS and JS compiler and need to find a way to list the contents of <code>wp_head()</code> </p> <p>I am trying to get a list of all CSS/JS files and inline CSS on any give page. </p> <p>Hooking on the wp_head action does not do anything </p> <p>I was hoping that something like this would work </p...
[ { "answer_id": 226720, "author": "Ismail", "author_id": 70833, "author_profile": "https://wordpress.stackexchange.com/users/70833", "pm_score": 2, "selected": false, "text": "<p>Simple solution is to listen for <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head\" r...
2016/05/15
[ "https://wordpress.stackexchange.com/questions/226696", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67176/" ]
I am working on a CSS and JS compiler and need to find a way to list the contents of `wp_head()` I am trying to get a list of all CSS/JS files and inline CSS on any give page. Hooking on the wp\_head action does not do anything I was hoping that something like this would work ``` function head_content($list){ ...
I wanted to search-and-replace in the header, but Neither @majick or @Samuel Elh answers worked for me directly. So, combining their answers I got what eventually works: ``` function start_wp_head_buffer() { ob_start(); } add_action('wp_head','start_wp_head_buffer',0); function end_wp_head_buffer() { $in = ob...
226,749
<p>I am developing a new WP site. My client complains that he see old site data like links that refer to old category names. On my PC and other I have no problems with this. On server side there is no cache plugin running. Reason: site is still in development. On my PC and in every browser there is no such problem. Alw...
[ { "answer_id": 226751, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Unsurprisingly so since you tell browser to cache everything for 1 month by default (<code>ExpiresDefault \"access ...
2016/05/16
[ "https://wordpress.stackexchange.com/questions/226749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78746/" ]
I am developing a new WP site. My client complains that he see old site data like links that refer to old category names. On my PC and other I have no problems with this. On server side there is no cache plugin running. Reason: site is still in development. On my PC and in every browser there is no such problem. Always...
Unsurprisingly so since you tell browser to cache everything for 1 month by default (`ExpiresDefault "access plus 1 month"`). You should limit long caching times to static resources and leave pages served by WP out of it. My go to resource for [`.htaccess` configuration](https://github.com/h5bp/server-configs-apache/...
226,765
<p>I want to add a meta value to my post , which will be based on another meta value , before publish post . This is what I have tried </p> <pre><code>add_action('save_post_my_custom_post', 'add_custom_field_automatically' ); function add_custom_field_automatically($post_ID) { $new_meta_value = get_post_meta($p...
[ { "answer_id": 226857, "author": "Mithun Sarker Shuvro", "author_id": 56654, "author_profile": "https://wordpress.stackexchange.com/users/56654", "pm_score": 3, "selected": true, "text": "<p>The solution is using <code>added_post_meta</code> and <code>updated_post_meta</code> hook . </p>...
2016/05/16
[ "https://wordpress.stackexchange.com/questions/226765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56654/" ]
I want to add a meta value to my post , which will be based on another meta value , before publish post . This is what I have tried ``` add_action('save_post_my_custom_post', 'add_custom_field_automatically' ); function add_custom_field_automatically($post_ID) { $new_meta_value = get_post_meta($post_ID,'_my_met...
The solution is using `added_post_meta` and `updated_post_meta` hook . Here is the working code . ``` add_action( 'added_post_meta', 'add_custom_field_automatically', 10, 4 ); add_action( 'updated_post_meta', 'add_custom_field_automatically', 10, 4 ); function add_custom_field_automatically( $meta_id, $post_id, $me...
226,832
<p>I'm trying to output an array into one table cell. Here is a truncated version of what I have now:</p> <pre><code>$prerequisites = get_post_meta($post-&gt;ID, 'opl_prerequisites', true); $output .= '&lt;td&gt;'; if(count($prerequisites) === 1){ foreach( $prerequisites as &amp;$prerequ...
[ { "answer_id": 226834, "author": "BillK", "author_id": 87352, "author_profile": "https://wordpress.stackexchange.com/users/87352", "pm_score": 1, "selected": false, "text": "<p>Passing <code>true</code> as the 3rd parameter to <code>get_post_meta()</code> says to return only one item. P...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226832", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93811/" ]
I'm trying to output an array into one table cell. Here is a truncated version of what I have now: ``` $prerequisites = get_post_meta($post->ID, 'opl_prerequisites', true); $output .= '<td>'; if(count($prerequisites) === 1){ foreach( $prerequisites as &$prerequisite ): ...
Alternatively, make an array of the titles and then use [implode](http://php.net/manual/en/function.implode.php)... ``` $prerequisites = get_post_meta($post->ID, 'opl_prerequisites', TRUE); $titles = array(); foreach( $prerequisites as $prerequisite ){ $titles[] = get_the_title( $prerequisite ); } $output .= '<td>'...
226,839
<p>In my site, I created a <code>custom post type</code> called: "Pictures"</p> <pre><code>add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'Pictures', array( 'labels' =&gt; array( 'name' =&gt; __( 'Pictures' ), 'singular_name' =&gt; __( 'Pictures'...
[ { "answer_id": 226840, "author": "v3leno", "author_id": 94216, "author_profile": "https://wordpress.stackexchange.com/users/94216", "pm_score": 1, "selected": false, "text": "<p>Hello maybe this can help, i use this kind of query to retrieve cpt query and display contents:</p>\n\n<pre><c...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226839", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94215/" ]
In my site, I created a `custom post type` called: "Pictures" ``` add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'Pictures', array( 'labels' => array( 'name' => __( 'Pictures' ), 'singular_name' => __( 'Pictures' ) ), 'public' => true...
You need to add: ``` 'supports' => array('title', 'editor','page-attributes','thumbnail') ``` add this to your array after 'singular name' => 'pictures'. The thumbnail adds the featured image option to your post type. You can access the post type archive: yoursite/archive-pictures, this will use your themes arc...
226,841
<p>I am using a theme which shows the featured image as background image in post navigation elements (next and previous links on a single post). But I want to remove these background images. </p> <p>Here is the actual code in template-tags.php file.</p> <pre><code>function shoreditch_post_nav_background() { if ( ...
[ { "answer_id": 226840, "author": "v3leno", "author_id": 94216, "author_profile": "https://wordpress.stackexchange.com/users/94216", "pm_score": 1, "selected": false, "text": "<p>Hello maybe this can help, i use this kind of query to retrieve cpt query and display contents:</p>\n\n<pre><c...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20840/" ]
I am using a theme which shows the featured image as background image in post navigation elements (next and previous links on a single post). But I want to remove these background images. Here is the actual code in template-tags.php file. ``` function shoreditch_post_nav_background() { if ( ! is_single() ) { ...
You need to add: ``` 'supports' => array('title', 'editor','page-attributes','thumbnail') ``` add this to your array after 'singular name' => 'pictures'. The thumbnail adds the featured image option to your post type. You can access the post type archive: yoursite/archive-pictures, this will use your themes arc...
226,848
<p>I've coded a plugin that creates a shortcode, among other things. That shortcode expects a post_id parameter, it extracts the content of that post and it returns the filtered content of that post (e.g. it applies all filters so that any other shortcode in that content is done). Here is a cut down version of the code...
[ { "answer_id": 227318, "author": "Nefro", "author_id": 86801, "author_profile": "https://wordpress.stackexchange.com/users/86801", "pm_score": 2, "selected": false, "text": "<ul>\n<li><p>Load visual compose css </p>\n\n<pre><code>function get_visual_composer_style($id) {\n return '&lt...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226848", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84622/" ]
I've coded a plugin that creates a shortcode, among other things. That shortcode expects a post\_id parameter, it extracts the content of that post and it returns the filtered content of that post (e.g. it applies all filters so that any other shortcode in that content is done). Here is a cut down version of the code: ...
I think you could get around this by pre-running the shortcodes on the page by applying the content filters before the header is output. This should allow any internal shortcodes run inside the included post to add any action hooks properly and thus any needed stylesheets/resources. ``` add_action('wp_loaded','maybe_p...
226,850
<p>How do I build goodlooking, custom pages into my themes. I've decided to use underscores to create custom client themes, as I need complete freedom in design, and all the tutorials I've found on theme development seem to just show how to build blog style websites, but I'd like to build sites with multi column layout...
[ { "answer_id": 226851, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 0, "selected": false, "text": "<p>Why not build a blog style website first? If you're new to WordPress, it's better to start with something relati...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226850", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94157/" ]
How do I build goodlooking, custom pages into my themes. I've decided to use underscores to create custom client themes, as I need complete freedom in design, and all the tutorials I've found on theme development seem to just show how to build blog style websites, but I'd like to build sites with multi column layouts, ...
Static pages: Valid? -------------------- Yes. You absolutely can add static pages that have nothing to do with a blog aside from using WordPress "routing" API out of the box and the database. Styles, Script: How? -------------------- Simply add your custom styles and scripts to your theme. Then [register and enqueu...
226,859
<p>We are using the Divi theme for our Wordpress site, we have also activated a Child Theme that we have named our SEO keyword.</p> <p>However, when you look in the "View Source" and Theme Sniffer Chrome Extensions the Divi theme is still visible.</p> <pre><code> &lt;link rel='stylesheet' id='parent-style-css' hr...
[ { "answer_id": 226863, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>You would have to rename the directory of the Divi theme. However, this could break the theme if there are compo...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93747/" ]
We are using the Divi theme for our Wordpress site, we have also activated a Child Theme that we have named our SEO keyword. However, when you look in the "View Source" and Theme Sniffer Chrome Extensions the Divi theme is still visible. ``` <link rel='stylesheet' id='parent-style-css' href="http://example.com/w...
You'll be unable to automatically update the parent Divi theme when it's directory becomes renamed. You can use any of caching​ plugins with `CSS minify` or/and `CSS combine` turned `ON`. This way everybody will see `/cache` directory instead of the actual theme directory. Or as the alternative, you can update rename...
226,861
<p>I`m using my own page template, for display post from some category:</p> <pre><code>$wp_query = new WP_Query(); $wp_query-&gt;query('&amp;cat=9' . '&amp;paged=' . $paged); while ($wp_query-&gt;have_posts()) : $wp_query-&gt;the_post(); ?&gt; &lt;div class="post-list"&gt; &lt;div class...
[ { "answer_id": 226865, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 3, "selected": true, "text": "<p>This is because password protection applied on <code>get_the_content()</code> function. And you are not using it...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226861", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83974/" ]
I`m using my own page template, for display post from some category: ``` $wp_query = new WP_Query(); $wp_query->query('&cat=9' . '&paged=' . $paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div class="post-list"> <div class="post-list-title"><a href="<?php the_perma...
This is because password protection applied on `get_the_content()` function. And you are not using it instead you've written your own custom loop. So you can alter the code before loop and check if page is not password protected using function [`post_password_required()`](https://codex.wordpress.org/Function_Reference...
226,862
<p>I have the code below on my homepage to list posts from a specific category, then a second piece to list posts from across the site. </p> <p>The problem I'm having is that there is some sort of weirdness going on, where I can't scroll to the bottom of the page. When I reach the bottom the page instantly jumps up. <...
[ { "answer_id": 226867, "author": "AR Bhatti", "author_id": 94177, "author_profile": "https://wordpress.stackexchange.com/users/94177", "pm_score": -1, "selected": false, "text": "<p>Use <code>wp_reset_query();</code> in the end of the loop </p>\n" }, { "answer_id": 226877, "...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226862", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68272/" ]
I have the code below on my homepage to list posts from a specific category, then a second piece to list posts from across the site. The problem I'm having is that there is some sort of weirdness going on, where I can't scroll to the bottom of the page. When I reach the bottom the page instantly jumps up. This beha...
It was Stellar parallax. Here is the offending code: `// Stellar parallax var $ = jQuery.noConflict(); $(function(){ $.stellar({ horizontalScrolling: false, verticalOffset: 40 }); });` I now need to go away and figure out what in this code was giving me the problem. Thanks for the prompts of where to look.
226,884
<p>I want to add <code>javascript:void(0);</code> to menu link item instead of <code>#</code> but it is not accepting any JavaScript. Now i am thing to replace <code>#</code> with <code>javascript:void(0);</code> using filters, but could not find the appropriate filter for the task.</p> <p>Can any one tell me which f...
[ { "answer_id": 226920, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>I am not sure how it does effect the SEO but just to answer this\n question:-</p>\n</blockquote...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226884", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76325/" ]
I want to add `javascript:void(0);` to menu link item instead of `#` but it is not accepting any JavaScript. Now i am thing to replace `#` with `javascript:void(0);` using filters, but could not find the appropriate filter for the task. Can any one tell me which filter can be used for this task. Note. I know this cou...
> > I am not sure how it does effect the SEO but just to answer this > question:- > > > You can not save menu item with `javascript:void(0);` because WordPress filter the URL using function [`esc_url()`](https://codex.wordpress.org/Function_Reference/esc_url) thus removing bad values. And it all happens in Nav Wa...
226,889
<p>I am working on a site for a client and am using a plugin that adds an "<strong>event</strong>" custom post type and an "<strong>event-category</strong>" taxonomy.</p> <p>I have also attached the "event-category" taxonomy to the default Wordpress "post" post type using the <strong>register_taxonomy_for_object_type<...
[ { "answer_id": 226920, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>I am not sure how it does effect the SEO but just to answer this\n question:-</p>\n</blockquote...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226889", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8620/" ]
I am working on a site for a client and am using a plugin that adds an "**event**" custom post type and an "**event-category**" taxonomy. I have also attached the "event-category" taxonomy to the default Wordpress "post" post type using the **register\_taxonomy\_for\_object\_type** function. Now I have the following ...
> > I am not sure how it does effect the SEO but just to answer this > question:- > > > You can not save menu item with `javascript:void(0);` because WordPress filter the URL using function [`esc_url()`](https://codex.wordpress.org/Function_Reference/esc_url) thus removing bad values. And it all happens in Nav Wa...
226,891
<p>I need to save URL's from old site, in options-permalink in admin wordpress i use </p> <pre><code>/blog/%category%/%postname%.html </code></pre> <p>I do it for blog posts. <strong>But i don't need to get it for CPT</strong></p> <p>I have created CPT</p> <pre><code>function uslugi_init() { $args = array( ...
[ { "answer_id": 226920, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>I am not sure how it does effect the SEO but just to answer this\n question:-</p>\n</blockquote...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226891", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88709/" ]
I need to save URL's from old site, in options-permalink in admin wordpress i use ``` /blog/%category%/%postname%.html ``` I do it for blog posts. **But i don't need to get it for CPT** I have created CPT ``` function uslugi_init() { $args = array( 'label' => 'Услуги', 'public' => true, ...
> > I am not sure how it does effect the SEO but just to answer this > question:- > > > You can not save menu item with `javascript:void(0);` because WordPress filter the URL using function [`esc_url()`](https://codex.wordpress.org/Function_Reference/esc_url) thus removing bad values. And it all happens in Nav Wa...
226,899
<p>I've added the following code to <code>functions.php</code> of my activated child theme:</p> <pre><code>function fullpagejs() { $slimscroll = get_stylesheet_directory_uri() . '/library/fullPage.js-master/vendors/jquery.slimscroll.min.js' ; wp_register_script('fullpage-slimscroll', $slimscroll, false, null);...
[ { "answer_id": 226900, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": true, "text": "<p>You must not only register the script, but also enqueue it after that, like this:</p>\n\n<pre><code>wp_enqueue_sc...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226899", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94239/" ]
I've added the following code to `functions.php` of my activated child theme: ``` function fullpagejs() { $slimscroll = get_stylesheet_directory_uri() . '/library/fullPage.js-master/vendors/jquery.slimscroll.min.js' ; wp_register_script('fullpage-slimscroll', $slimscroll, false, null); //some more files wi...
You must not only register the script, but also enqueue it after that, like this: ``` wp_enqueue_script('fullpage-slimscroll'); ```
226,916
<p>I am trying to search through post meta for keyword matches but I'm new to MySQL and I don't know how to write my query. I can write a basic query for <code>post_title</code> matches but I don't know how to properly jump across tables.</p> <p>In pseudo code, my query would be </p> <pre><code>"SELECT post_id FROM $...
[ { "answer_id": 226925, "author": "Pawel J", "author_id": 93877, "author_profile": "https://wordpress.stackexchange.com/users/93877", "pm_score": 1, "selected": false, "text": "<p>I'm not an expert but try this one:</p>\n\n<pre><code>SELECT wp_posts.ID, wp_postmeta.meta_value FROM wp_post...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226916", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44937/" ]
I am trying to search through post meta for keyword matches but I'm new to MySQL and I don't know how to write my query. I can write a basic query for `post_title` matches but I don't know how to properly jump across tables. In pseudo code, my query would be ``` "SELECT post_id FROM $wpdb->postmeta WHERE meta_key L...
Is this what you're trying to do? ``` // WP_Query arguments $args = array ( 'post_type' => array( 'project' ), 'meta_query' => array( array( 'key' => 'meta_key', 'value' => '%$query%', ), ), ); // The Query $query = new WP_Query( $...
226,922
<p>I have a video gallery, and all the titles are generated by <code>php</code>. They are coming from my Wordpress media library's attachment titles.</p> <p>The lightbox for these videos, however, is customized in javascript. How can I put the <code>php</code> titles inside the <code>iframe</code> <code>markup</code>?...
[ { "answer_id": 226927, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>First, don't echo your php, but assemble everything in a string, let's say <code>$titlestring</code>.</p>\n\n<p>...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226922", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93909/" ]
I have a video gallery, and all the titles are generated by `php`. They are coming from my Wordpress media library's attachment titles. The lightbox for these videos, however, is customized in javascript. How can I put the `php` titles inside the `iframe` `markup`? PHP - need to use `$attachment_data['title']`: ``` ...
The developer included a solution for this, discussed here: <https://stackoverflow.com/questions/17612258/title-for-iframe-video-in-magnific-popup> First I needed to include the title in my `php`: ``` echo'<figure><a class="video" title="'.$attachment_data['title'].'" href="'.get_post_meta($post->ID, 'credit_url', t...
226,923
<p>I've seen this question posted in different forms before, but most of those solutions are centered around the admin interface, and I haven't found any answers that apply to the front end.</p> <p>I've got a custom post type, and an associated custom taxonomy. I'm using the archive page (<code>archive-{custom_type}.p...
[ { "answer_id": 226927, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>First, don't echo your php, but assemble everything in a string, let's say <code>$titlestring</code>.</p>\n\n<p>...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226923", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50668/" ]
I've seen this question posted in different forms before, but most of those solutions are centered around the admin interface, and I haven't found any answers that apply to the front end. I've got a custom post type, and an associated custom taxonomy. I'm using the archive page (`archive-{custom_type}.php`) to display...
The developer included a solution for this, discussed here: <https://stackoverflow.com/questions/17612258/title-for-iframe-video-in-magnific-popup> First I needed to include the title in my `php`: ``` echo'<figure><a class="video" title="'.$attachment_data['title'].'" href="'.get_post_meta($post->ID, 'credit_url', t...
226,956
<p>I inherited a problem that no one in my office can figure out. </p> <p>Our company website has page titles in the format of "Page Name Company Name - Company Name." The first instance of Company Name is a duplicate and needs to be deleted (it should be Page Name - Company Name), but I'm not sure how to proceed from...
[ { "answer_id": 226958, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 1, "selected": false, "text": "<p>You're on a page and if we read through the list of conditionals it should hit this one specifically:</p>\n...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226956", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92178/" ]
I inherited a problem that no one in my office can figure out. Our company website has page titles in the format of "Page Name Company Name - Company Name." The first instance of Company Name is a duplicate and needs to be deleted (it should be Page Name - Company Name), but I'm not sure how to proceed from looking a...
You're on a page and if we read through the list of conditionals it should hit this one specifically: ``` elseif( ! ( is_404() ) && ( is_single() ) || ( is_page() ) ) { wp_title( '' ); echo ' - '; } ``` It will also hit the below conditional in the next set: ``` else { bloginfo( 'name' ); } ``` Given ...
226,960
<p>There are two <code>query_posts()</code> functions technically speaking. One <code>query_posts()</code> is actually <code>WP_Query::query_posts()</code> and the other is in global space.</p> <p>Asking from sanity: </p> <p>If global <code>query_posts()</code> is that "evil" why isn't deprecated? </p> <p>Or why isn...
[ { "answer_id": 226992, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": false, "text": "<p>I have just created a new trac ticket, <a href=\"https://core.trac.wordpress.org/ticket/36874\" rel=\"n...
2016/05/17
[ "https://wordpress.stackexchange.com/questions/226960", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88606/" ]
There are two `query_posts()` functions technically speaking. One `query_posts()` is actually `WP_Query::query_posts()` and the other is in global space. Asking from sanity: If global `query_posts()` is that "evil" why isn't deprecated? Or why isn't marked as `_doing_it_wong`.
Essential question ================== Let's dig into the trio: `::query_posts`, `::get_posts` and `class WP_Query` to understand `::query_posts` better. The cornerstone for getting the data in WordPress is the `WP_Query` class. Both methods `::query_posts` and `::get_posts` use that class. > > Note that the class ...
226,979
<p>Is it possible to have two different blog layouts in the same theme? They would pull the same posts, but have a different layout structure. The only idea I've had is making a couple custom page templates that pull blog posts but have different structure/styles. Is there something simple I am missing? </p> <p>The...
[ { "answer_id": 226992, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": false, "text": "<p>I have just created a new trac ticket, <a href=\"https://core.trac.wordpress.org/ticket/36874\" rel=\"n...
2016/05/18
[ "https://wordpress.stackexchange.com/questions/226979", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64173/" ]
Is it possible to have two different blog layouts in the same theme? They would pull the same posts, but have a different layout structure. The only idea I've had is making a couple custom page templates that pull blog posts but have different structure/styles. Is there something simple I am missing? The reasoning is...
Essential question ================== Let's dig into the trio: `::query_posts`, `::get_posts` and `class WP_Query` to understand `::query_posts` better. The cornerstone for getting the data in WordPress is the `WP_Query` class. Both methods `::query_posts` and `::get_posts` use that class. > > Note that the class ...
226,990
<p>Is there a function, action or filter that I can use to add a third level drop-down menu to the WordPress admin menu.</p> <p>For instance, right now in the sidebar menu, there is a menu for posts and under posts there are sub-menus for editing posts, adding a new post, categories, and tags. There is something simi...
[ { "answer_id": 227002, "author": "Karthikeyani Srijish", "author_id": 86125, "author_profile": "https://wordpress.stackexchange.com/users/86125", "pm_score": 5, "selected": true, "text": "<p>No, it is not possible to create third level menu in admin panel. If you look at the definition o...
2016/05/18
[ "https://wordpress.stackexchange.com/questions/226990", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94279/" ]
Is there a function, action or filter that I can use to add a third level drop-down menu to the WordPress admin menu. For instance, right now in the sidebar menu, there is a menu for posts and under posts there are sub-menus for editing posts, adding a new post, categories, and tags. There is something similar for Pag...
No, it is not possible to create third level menu in admin panel. If you look at the definition of **add\_submenu\_page**, you need to mention the parent slug name. **For eg:** ``` add_menu_page ( 'Test Menu', 'Test Menu', 'read', 'testmainmenu', '', '' ); add_submenu_page ( 'testmainmenu', 'Test Menu', 'Child1', 'rea...