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
183,250
<p><a href="http://www.winnebagoparts.com/specials/top-100-products/" rel="nofollow">This page</a> is created using a recent posts shortcode included with my theme. It is not displaying paragraph breaks that I've added in the editor and I'd like it to. How can I get the shortcode to display the paragraph breaks?</p> <...
[ { "answer_id": 183500, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": true, "text": "<p><code>get_the_content()</code> returns unfiltered content, and using a shortcode you cannot use <code>th...
2015/04/04
[ "https://wordpress.stackexchange.com/questions/183250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43424/" ]
[This page](http://www.winnebagoparts.com/specials/top-100-products/) is created using a recent posts shortcode included with my theme. It is not displaying paragraph breaks that I've added in the editor and I'd like it to. How can I get the shortcode to display the paragraph breaks? This is the code that compiles the...
`get_the_content()` returns unfiltered content, and using a shortcode you cannot use `the_content()` to return filtered content as you cannot echo inside a shortcode. Your best option here will be is to applying `the_content` filters to `get_the_content()`, something like: ``` apply_filters( 'the_content', get_the_con...
183,278
<p>I have a custom theme that I use for many client sites. I regularly update the theme and need a way to have the sites notified when there is an update to the theme.</p> <p>I tried using <a href="https://github.com/UCF/Theme-Updater" rel="nofollow">https://github.com/UCF/Theme-Updater</a> but since it is no longer s...
[ { "answer_id": 183285, "author": "Frankie Jarrett", "author_id": 10993, "author_profile": "https://wordpress.stackexchange.com/users/10993", "pm_score": 0, "selected": false, "text": "<p>If you are looking for a simple solution that you don't have to worry about coding yourself I would r...
2015/04/04
[ "https://wordpress.stackexchange.com/questions/183278", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70162/" ]
I have a custom theme that I use for many client sites. I regularly update the theme and need a way to have the sites notified when there is an update to the theme. I tried using <https://github.com/UCF/Theme-Updater> but since it is no longer supported and hasn't been updated I can not get it to work with WP 4.1.1. ...
Here is a full documentation for how to do this: [Github updater - Documentation](https://github.com/afragen/github-updater) **Upload in wordpress** Download the latest tagged archive (choose the "[**zip**](https://github.com/afragen/github-updater/archive/develop.zip)" option). Unzip the archive, rename the folder ...
183,283
<p>I want to specify an alternative image that will be displayed when oEmbed fails.</p> <p>The specific use case is to offer an alternative when China (or other countries) block YouTube. We know the YouTube content won't be available there, but want to provide an alternate image in that case.</p> <p>Can the oEmbed er...
[ { "answer_id": 191740, "author": "codecowboy", "author_id": 500, "author_profile": "https://wordpress.stackexchange.com/users/500", "pm_score": 0, "selected": false, "text": "<p>One approach might be to make another request using oEmbed on the server side via a proxy which is based in Ch...
2015/04/05
[ "https://wordpress.stackexchange.com/questions/183283", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31322/" ]
I want to specify an alternative image that will be displayed when oEmbed fails. The specific use case is to offer an alternative when China (or other countries) block YouTube. We know the YouTube content won't be available there, but want to provide an alternate image in that case. Can the oEmbed error code be made ...
I think the best thing to do in this case is to wrap your oEmbed content with a `div` before they are rendered and then show an alternate image with the CSS `background-image` property. If the video loads, then the oEmbed content will cover the background image. You can add the wrapper using the `embed_oembed_html` fi...
183,292
<p>I'm using <code>wp_dropdown_categories()</code> for populating <code>&lt;select&gt;</code> field with custom taxonomy terms.</p> <p>If the code is like below:</p> <pre><code>&lt;?php $args = array( 'show_option_none' =&gt; __( 'Select one', 'text-domain' ), 'taxonomy' =&gt; 'my_tax', 'id' ...
[ { "answer_id": 183298, "author": "William Turrell", "author_id": 42868, "author_profile": "https://wordpress.stackexchange.com/users/42868", "pm_score": 1, "selected": false, "text": "<p>There's a filter - <code>wp_dropdown_cats</code> (not documented anywhere as far as I know.)</p>\n\n<...
2015/04/05
[ "https://wordpress.stackexchange.com/questions/183292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
I'm using `wp_dropdown_categories()` for populating `<select>` field with custom taxonomy terms. If the code is like below: ``` <?php $args = array( 'show_option_none' => __( 'Select one', 'text-domain' ), 'taxonomy' => 'my_tax', 'id' => 'tax-type', 'echo' => ...
If you want to apply the `required` attribute every time you use `wp_categories_dropdown`, use `wp_dropdown_cats` filter as suggested in other answers: ``` add_filter( 'wp_dropdown_cats', 'wp_dropdown_categories_required' ); function wp_dropdown_categories_required( $output ){ return preg_replace( '^' . p...
183,376
<p>I have a wordpress plugin where i included this (with some changes)</p> <pre><code>$fep_files = array( 'first' =&gt; 'first.php', 'second' =&gt; 'second.php' ); $fep_files = apply_filters('include_files', $fep_files ); foreach ( $fep_files as $fep_file ) require_once ( $fep_file ); unset ( $fep_files ); <...
[ { "answer_id": 183413, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>Your plugin code is going to run before the theme code and hence will run before anything is added to the hoo...
2015/04/06
[ "https://wordpress.stackexchange.com/questions/183376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70211/" ]
I have a wordpress plugin where i included this (with some changes) ``` $fep_files = array( 'first' => 'first.php', 'second' => 'second.php' ); $fep_files = apply_filters('include_files', $fep_files ); foreach ( $fep_files as $fep_file ) require_once ( $fep_file ); unset ( $fep_files ); ``` Now i added in ...
Your plugin code is going to run before the theme code and hence will run before anything is added to the hook. You will need to the code that processes the file inclusion to some other hook that runs after all of the plugins load, like [`after_setup_theme`](https://codex.wordpress.org/Plugin_API/Action_Reference/after...
183,429
<p>I've got 20+ hours into this and could really use some help. Here is what I am trying to do.. For each record, add post meta. If the post meta already exists, update each field in the array. Just like it would be with adding and updating a single custom field, except this one is repeatable based off of each record.<...
[ { "answer_id": 183413, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>Your plugin code is going to run before the theme code and hence will run before anything is added to the hoo...
2015/04/07
[ "https://wordpress.stackexchange.com/questions/183429", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64444/" ]
I've got 20+ hours into this and could really use some help. Here is what I am trying to do.. For each record, add post meta. If the post meta already exists, update each field in the array. Just like it would be with adding and updating a single custom field, except this one is repeatable based off of each record. I ...
Your plugin code is going to run before the theme code and hence will run before anything is added to the hook. You will need to the code that processes the file inclusion to some other hook that runs after all of the plugins load, like [`after_setup_theme`](https://codex.wordpress.org/Plugin_API/Action_Reference/after...
183,441
<p>I'm really stuck on the WP_Rewrite functionality...</p> <h2>What I have</h2> <p>I have a plugin that's rendered using a shortcode and is displaying full-site content. E.g.:</p> <pre><code>//?p=2 (maps to domain.tld/myplugin/) [my-plugin] </code></pre> <p>This plugin basically is a directory of some list-content....
[ { "answer_id": 183927, "author": "websupporter", "author_id": 48693, "author_profile": "https://wordpress.stackexchange.com/users/48693", "pm_score": 3, "selected": true, "text": "<p>This approach should work for you:</p>\n\n<pre><code>&lt;?php\n/**\n * Plugin Name: Rewrite Shortcode\n *...
2015/04/07
[ "https://wordpress.stackexchange.com/questions/183441", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13711/" ]
I'm really stuck on the WP\_Rewrite functionality... What I have ----------- I have a plugin that's rendered using a shortcode and is displaying full-site content. E.g.: ``` //?p=2 (maps to domain.tld/myplugin/) [my-plugin] ``` This plugin basically is a directory of some list-content. What I want ----------- B...
This approach should work for you: ``` <?php /** * Plugin Name: Rewrite Shortcode **/ add_shortcode( 'myplugin', 'mp_shortcode' ); function mp_shortcode(){ return '<p>Filter: ' . get_query_var( 'filter' ) . '</p>'; } add_action( 'init', 'mp_rewrite' ); function mp_rewrite(){ $post_id = 2; add_rewr...
183,455
<p>I created CPT called "Basics", then added the following code to functions.php</p> <pre><code>add_theme_support('post-thumbnails'); add_image_size('large_thumb', 900, 500, true); add_image_size('small_thumb', 250, 250, true); </code></pre> <p>Featured Image Option only appear default post type, and not appeared...
[ { "answer_id": 183457, "author": "Bhavik Patel", "author_id": 26471, "author_profile": "https://wordpress.stackexchange.com/users/26471", "pm_score": 1, "selected": false, "text": "<p>Please Use this For custom post type after register_post_type </p>\n\n<p><code>add_theme_support( 'post-...
2015/04/07
[ "https://wordpress.stackexchange.com/questions/183455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64198/" ]
I created CPT called "Basics", then added the following code to functions.php ``` add_theme_support('post-thumbnails'); add_image_size('large_thumb', 900, 500, true); add_image_size('small_thumb', 250, 250, true); ``` Featured Image Option only appear default post type, and not appeared in CPT(Basics)
use this code to create a custom post type, mainly you need to include this line: ``` 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', ), " ``` full code to create: ``` // Register Custom Post Type function custom_post_type() { $labels = array( 'name' => ...
183,461
<p>I'm trying to send jQuery data via AJAX to a WordPress template file. I've tried several different techniques and solutions based on other questions posted that pertain to this topic, with no success. I can successfully pass data from the functions.php file to my promotions.php template file. </p> <p>However, ...
[ { "answer_id": 183457, "author": "Bhavik Patel", "author_id": 26471, "author_profile": "https://wordpress.stackexchange.com/users/26471", "pm_score": 1, "selected": false, "text": "<p>Please Use this For custom post type after register_post_type </p>\n\n<p><code>add_theme_support( 'post-...
2015/04/07
[ "https://wordpress.stackexchange.com/questions/183461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70271/" ]
I'm trying to send jQuery data via AJAX to a WordPress template file. I've tried several different techniques and solutions based on other questions posted that pertain to this topic, with no success. I can successfully pass data from the functions.php file to my promotions.php template file. However, I cannot get th...
use this code to create a custom post type, mainly you need to include this line: ``` 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', ), " ``` full code to create: ``` // Register Custom Post Type function custom_post_type() { $labels = array( 'name' => ...
183,463
<p>As part of a much broader problem I'm trying to tackle, I am wondering if I can automatically create a taxonomy term with the same name as a new post of a specific CPT.</p> <p>The idea would be as follows. I'd have a cartoon-series CPT. When I create a new cartoon series post, a taxonomy term for the cartoon-series...
[ { "answer_id": 183457, "author": "Bhavik Patel", "author_id": 26471, "author_profile": "https://wordpress.stackexchange.com/users/26471", "pm_score": 1, "selected": false, "text": "<p>Please Use this For custom post type after register_post_type </p>\n\n<p><code>add_theme_support( 'post-...
2015/04/07
[ "https://wordpress.stackexchange.com/questions/183463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68905/" ]
As part of a much broader problem I'm trying to tackle, I am wondering if I can automatically create a taxonomy term with the same name as a new post of a specific CPT. The idea would be as follows. I'd have a cartoon-series CPT. When I create a new cartoon series post, a taxonomy term for the cartoon-series taxonomy ...
use this code to create a custom post type, mainly you need to include this line: ``` 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', ), " ``` full code to create: ``` // Register Custom Post Type function custom_post_type() { $labels = array( 'name' => ...
183,475
<p>In my little age with WordPress, I've seen WordPress itself and its friendly plugins are using PHP <code>serialize()</code> in storing data into db in many cases. But in a recent search I found a serious community support for the <code>json_encode()</code> over the <code>serialize()</code>.</p> <ul> <li><a href="htt...
[ { "answer_id": 183478, "author": "Ramy Deeb", "author_id": 15117, "author_profile": "https://wordpress.stackexchange.com/users/15117", "pm_score": 5, "selected": true, "text": "<p>I think, not 100% sure that this was the real reason the WP developers took this approach, but common sense ...
2015/04/07
[ "https://wordpress.stackexchange.com/questions/183475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
In my little age with WordPress, I've seen WordPress itself and its friendly plugins are using PHP `serialize()` in storing data into db in many cases. But in a recent search I found a serious community support for the `json_encode()` over the `serialize()`. * [A test that proves `json_encode()` is better than `serial...
I think, not 100% sure that this was the real reason the WP developers took this approach, but common sense tells me that serialize preserves the variable types and have a mini built in error detection, and json stores only string values `{ key : value }`, so when you go back to PHP you will have to guess the format, o...
183,489
<p>On a blog, i'm using the following to display the post authors avatars:</p> <pre><code>&lt;a href="&lt;?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?&gt;" style="color:#ffffff;"&gt;&lt;?php echo get_avatar( get_the_author_meta( 'ID' )); ?&gt;&lt;/a&gt; </code></pre> <p>But some posts have more than...
[ { "answer_id": 183491, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>The obvious answer is to use <a href=\"https://codex.wordpress.org/Function_Reference/get_avatar\" rel=\"nof...
2015/04/07
[ "https://wordpress.stackexchange.com/questions/183489", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34820/" ]
On a blog, i'm using the following to display the post authors avatars: ``` <a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>" style="color:#ffffff;"><?php echo get_avatar( get_the_author_meta( 'ID' )); ?></a> ``` But some posts have more than one author, and this only displays one avatar, ho...
Here we go, found a nice thread which gave some answers and developed this which works a treat: ``` if ( class_exists( 'coauthors_plus' ) ) { $co_authors = get_coauthors(); foreach ( $co_authors as $key => $co_author ) { $co_author_classes = array( 'co-author-wrap', 'co-author-n...
183,502
<p>I'm trying to allow "author" users to embed in posts. I (the administrator) can iframe, embed, etc...., but authors can not. </p> <p>Can someone show me to give authors 'just' the ability to embed and iframe in posts?</p>
[ { "answer_id": 183504, "author": "Olivier", "author_id": 23275, "author_profile": "https://wordpress.stackexchange.com/users/23275", "pm_score": 4, "selected": true, "text": "<p>The capability you are after is called <code>unfiltered_html</code>. Some options:</p>\n\n<ol>\n<li><p>Modify ...
2015/04/07
[ "https://wordpress.stackexchange.com/questions/183502", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64181/" ]
I'm trying to allow "author" users to embed in posts. I (the administrator) can iframe, embed, etc...., but authors can not. Can someone show me to give authors 'just' the ability to embed and iframe in posts?
The capability you are after is called `unfiltered_html`. Some options: 1. Modify **author** capabilities in your theme `functions.php`. This is saved in the DB, so you can access a page, make sure it works then remove it from your `functions.php` file. A better option would be to run it on theme activation. See [this...
183,517
<p>I'm just looking to make sure my home page and pages display my featured image if set, and other wise if not set show blog-banner.jpg. So that's what I thought I had however now my 404 error page doesn't have a banner image. Any advice on correcting this if statement?</p> <pre><code>/** Add the featured image secti...
[ { "answer_id": 183504, "author": "Olivier", "author_id": 23275, "author_profile": "https://wordpress.stackexchange.com/users/23275", "pm_score": 4, "selected": true, "text": "<p>The capability you are after is called <code>unfiltered_html</code>. Some options:</p>\n\n<ol>\n<li><p>Modify ...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25108/" ]
I'm just looking to make sure my home page and pages display my featured image if set, and other wise if not set show blog-banner.jpg. So that's what I thought I had however now my 404 error page doesn't have a banner image. Any advice on correcting this if statement? ``` /** Add the featured image section */ add_acti...
The capability you are after is called `unfiltered_html`. Some options: 1. Modify **author** capabilities in your theme `functions.php`. This is saved in the DB, so you can access a page, make sure it works then remove it from your `functions.php` file. A better option would be to run it on theme activation. See [this...
183,520
<p>I have a question today. I am looking for a solution to make sticky post available on my website. But, i just got it work on homepage with the code below.</p> <pre><code>function wpb_latest_sticky() { /* Get all sticky posts */ $sticky = get_option( 'sticky_posts' ); /* Sort the stickies with the newest ones at ...
[ { "answer_id": 183620, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>This same exact question was asked earlier this week or over the weekend, and it had me thinking. Here i...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183520", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23036/" ]
I have a question today. I am looking for a solution to make sticky post available on my website. But, i just got it work on homepage with the code below. ``` function wpb_latest_sticky() { /* Get all sticky posts */ $sticky = get_option( 'sticky_posts' ); /* Sort the stickies with the newest ones at the top */ rso...
This same exact question was asked earlier this week or over the weekend, and it had me thinking. Here is the idea that I came up with. If you look at the [source code](https://github.com/WordPress/WordPress/blob/master/wp-includes/query.php#L3580) of the `WP_Query` class, you will see that sticky posts is only added ...
183,548
<p>When publishing a custom post type, I'm trying to override the custom permalink based on code rather than what the user types into the input box. I can confirm my action is firing correctly, but I'm suspecting it's being triggered before the update event, so the user's value then overrides mine.</p> <pre><code>add_...
[ { "answer_id": 183551, "author": "Web Dev", "author_id": 69449, "author_profile": "https://wordpress.stackexchange.com/users/69449", "pm_score": -1, "selected": false, "text": "<p>You could just do a <code>display:none</code> on the css selector for the slug so they never see it.</p>\n" ...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183548", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69831/" ]
When publishing a custom post type, I'm trying to override the custom permalink based on code rather than what the user types into the input box. I can confirm my action is firing correctly, but I'm suspecting it's being triggered before the update event, so the user's value then overrides mine. ``` add_action('publis...
The `publish_{post-type}` action is triggered only when the post change from any post status (not published) to published; for example, if the post is already published and you edit it, the `publish_{post-type}` action is not triggered. I think you need to hook your function to `save_post_{post_type}` action, which is ...
183,553
<p>I would have thought a simple question but I can't find a function to do this in the WordPress API. </p> <p>I just want to revert to one previous revision as soon as a user updates a post. This would allow admins/editors to review the latest non live revision whilst the old one gives the appearance of staying li...
[ { "answer_id": 183551, "author": "Web Dev", "author_id": 69449, "author_profile": "https://wordpress.stackexchange.com/users/69449", "pm_score": -1, "selected": false, "text": "<p>You could just do a <code>display:none</code> on the css selector for the slug so they never see it.</p>\n" ...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183553", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28543/" ]
I would have thought a simple question but I can't find a function to do this in the WordPress API. I just want to revert to one previous revision as soon as a user updates a post. This would allow admins/editors to review the latest non live revision whilst the old one gives the appearance of staying live. The edito...
The `publish_{post-type}` action is triggered only when the post change from any post status (not published) to published; for example, if the post is already published and you edit it, the `publish_{post-type}` action is not triggered. I think you need to hook your function to `save_post_{post_type}` action, which is ...
183,554
<p>I install fresh installation of wordpress in my server sub-folder call <code>blog</code>.</p> <p>So in the beginning I access the site <code>mydomain/blog</code> and it works perfectly. </p> <p>But when I changed the <code>permalinks</code> settings to <code>Post name</code> option in the <code>settings</code>, al...
[ { "answer_id": 183551, "author": "Web Dev", "author_id": 69449, "author_profile": "https://wordpress.stackexchange.com/users/69449", "pm_score": -1, "selected": false, "text": "<p>You could just do a <code>display:none</code> on the css selector for the slug so they never see it.</p>\n" ...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183554", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68403/" ]
I install fresh installation of wordpress in my server sub-folder call `blog`. So in the beginning I access the site `mydomain/blog` and it works perfectly. But when I changed the `permalinks` settings to `Post name` option in the `settings`, all urls giving me 403 - forbidden error including frot-end. And then I r...
The `publish_{post-type}` action is triggered only when the post change from any post status (not published) to published; for example, if the post is already published and you edit it, the `publish_{post-type}` action is not triggered. I think you need to hook your function to `save_post_{post_type}` action, which is ...
183,576
<p>I've tinkered with WordPress a little, but I'm far from an expert, so apologies in advance if this is a duplicate question.</p> <p>I've built a simple WordPress theme based around Bootstrap, and I can successfully display posts using <code>the_content()</code>, while filling in the sidebar using <code>get_sidebar()...
[ { "answer_id": 183596, "author": "dynamicad", "author_id": 70281, "author_profile": "https://wordpress.stackexchange.com/users/70281", "pm_score": 1, "selected": false, "text": "<p>You could try using <a href=\"http://www.advancedcustomfields.com/\" rel=\"nofollow\">advanced custom field...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70325/" ]
I've tinkered with WordPress a little, but I'm far from an expert, so apologies in advance if this is a duplicate question. I've built a simple WordPress theme based around Bootstrap, and I can successfully display posts using `the_content()`, while filling in the sidebar using `get_sidebar()`. My question is whether...
You can make use of [featured images](https://codex.wordpress.org/Post_Thumbnails) as suggested by @gmazzap in comments. This featured image will not be included in post content. However, if you already have your images included in post content, then you need to strip the post content down in two parts, as you've said ...
183,582
<p>I have this site that uses the <code>&lt;!--nextpage--&gt;</code> tag in posts for pagination purposes. I want to disable pagination, but without deleting the tags for the database (maybe they'll want to use them again in the future). </p> <p>Tried removing <code>wp_link_pages();</code> from the template, but then ...
[ { "answer_id": 183587, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>You can try to use the <code>the_post</code> filter, to override the content pagination, that takes place with...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70333/" ]
I have this site that uses the `<!--nextpage-->` tag in posts for pagination purposes. I want to disable pagination, but without deleting the tags for the database (maybe they'll want to use them again in the future). Tried removing `wp_link_pages();` from the template, but then it would only show the first page's co...
You can try to use the `the_post` filter, to override the content pagination, that takes place within the `setup_postdata()` function ( *PHP 5.4+* ): ``` /** * Ignore the <!--nextpage--> for content pagination. * * @see http://wordpress.stackexchange.com/a/183587/26350 */ add_action( 'the_post', function( $post ...
183,598
<p>On one of my pages I changed the slug to form a different URL. E.g.</p> <p>Old: <a href="http://example.com/old-slug" rel="noreferrer">http://example.com/old-slug</a></p> <p>New: <a href="http://example.com/new-slug" rel="noreferrer">http://example.com/new-slug</a></p> <p>WordPress has done it's thing of redirect...
[ { "answer_id": 183603, "author": "William Turrell", "author_id": 42868, "author_profile": "https://wordpress.stackexchange.com/users/42868", "pm_score": 3, "selected": false, "text": "<p>This (in your <code>functions.php</code>) will turn it off (but see also the comment I've left):</p>\...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23620/" ]
On one of my pages I changed the slug to form a different URL. E.g. Old: <http://example.com/old-slug> New: <http://example.com/new-slug> WordPress has done it's thing of redirecting <http://example.com/old-slug> to <http://example.com/new-slug>. I'd like to remove this behaviour as a plugin I am using makes use of...
This (in your `functions.php`) will turn it off (but see also the comment I've left): ``` remove_action('template_redirect', 'wp_old_slug_redirect'); ``` It seems odd that your `wp_postmeta` table wouldn't have any `_wp_old_slug` keys - the bit of code that does that is in `wp-includes/query.php` (wp\_old\_slug\_red...
183,604
<p>I have a WordPress site that uses custom post types. However, the custom post types are not being recognized by google. It's like the custom post type is a box full of our original content that google can't see inside of it seems. What can I do to change this?</p>
[ { "answer_id": 183603, "author": "William Turrell", "author_id": 42868, "author_profile": "https://wordpress.stackexchange.com/users/42868", "pm_score": 3, "selected": false, "text": "<p>This (in your <code>functions.php</code>) will turn it off (but see also the comment I've left):</p>\...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183604", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70345/" ]
I have a WordPress site that uses custom post types. However, the custom post types are not being recognized by google. It's like the custom post type is a box full of our original content that google can't see inside of it seems. What can I do to change this?
This (in your `functions.php`) will turn it off (but see also the comment I've left): ``` remove_action('template_redirect', 'wp_old_slug_redirect'); ``` It seems odd that your `wp_postmeta` table wouldn't have any `_wp_old_slug` keys - the bit of code that does that is in `wp-includes/query.php` (wp\_old\_slug\_red...
183,614
<p>I'm running through a normal loop on one of my templates, and it displays a list of upcoming events with dates. I'd like the events that have passed to stay active, but not appear in my list of posts. </p> <p>As it currently stands, I select a date for the event (custom field), compare that to the current date via ...
[ { "answer_id": 183603, "author": "William Turrell", "author_id": 42868, "author_profile": "https://wordpress.stackexchange.com/users/42868", "pm_score": 3, "selected": false, "text": "<p>This (in your <code>functions.php</code>) will turn it off (but see also the comment I've left):</p>\...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/55073/" ]
I'm running through a normal loop on one of my templates, and it displays a list of upcoming events with dates. I'd like the events that have passed to stay active, but not appear in my list of posts. As it currently stands, I select a date for the event (custom field), compare that to the current date via PHP date f...
This (in your `functions.php`) will turn it off (but see also the comment I've left): ``` remove_action('template_redirect', 'wp_old_slug_redirect'); ``` It seems odd that your `wp_postmeta` table wouldn't have any `_wp_old_slug` keys - the bit of code that does that is in `wp-includes/query.php` (wp\_old\_slug\_red...
183,615
<p>Space is being added to a sidebar in a WordPress theme I have created. The space isn't being added via my own style sheet, but I think I have isolated it to this from my code editor:</p> <pre><code> ul, menu, dir { display: block; list-style-type: disc; -webkit-margin-before: 1em; -webkit...
[ { "answer_id": 183603, "author": "William Turrell", "author_id": 42868, "author_profile": "https://wordpress.stackexchange.com/users/42868", "pm_score": 3, "selected": false, "text": "<p>This (in your <code>functions.php</code>) will turn it off (but see also the comment I've left):</p>\...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183615", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70347/" ]
Space is being added to a sidebar in a WordPress theme I have created. The space isn't being added via my own style sheet, but I think I have isolated it to this from my code editor: ``` ul, menu, dir { display: block; list-style-type: disc; -webkit-margin-before: 1em; -webkit-margin-after:...
This (in your `functions.php`) will turn it off (but see also the comment I've left): ``` remove_action('template_redirect', 'wp_old_slug_redirect'); ``` It seems odd that your `wp_postmeta` table wouldn't have any `_wp_old_slug` keys - the bit of code that does that is in `wp-includes/query.php` (wp\_old\_slug\_red...
183,652
<p>I am trying to show subcategories of a category in WordPress using AJAX: when I select a main category, there is a call to WP Ajax and the result is used in showing the subcategories.</p> <p>So far, I have the client-side code that works when not calling a WP function (this code is in a theme page):</p> <pre><code...
[ { "answer_id": 183657, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>Your problem is probably because you do not return a json object but an html (actually mixed text and htm...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70361/" ]
I am trying to show subcategories of a category in WordPress using AJAX: when I select a main category, there is a call to WP Ajax and the result is used in showing the subcategories. So far, I have the client-side code that works when not calling a WP function (this code is in a theme page): ``` jQuery('#cat-locatio...
Your problem is probably because you do not return a json object but an html (actually mixed text and html), and you set jQuery to validate that the response is json, which it isn't. your code at the ajax handler should be something like ``` $catshtml = wp_dropdown_categories(.....echo=0); $ret = array('data' => $cat...
183,669
<h2>Use Case</h2> <p>I've been experimenting with Chrome's Dev Tools Workspace features. It includes the ability to edit a file directly in Dev Tools and have the saved stylesheet refresh itself (or even compile and then refresh!).</p> <p>However, as documented in the <a href="https://stackoverflow.com/questions/2088...
[ { "answer_id": 183670, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 5, "selected": true, "text": "<h2>Default <code>wp_enqueue_[style/script]()</code> behavior</h2>\n\n<p>The <a href=\"https://codex.wordpress.org/F...
2015/04/08
[ "https://wordpress.stackexchange.com/questions/183669", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9844/" ]
Use Case -------- I've been experimenting with Chrome's Dev Tools Workspace features. It includes the ability to edit a file directly in Dev Tools and have the saved stylesheet refresh itself (or even compile and then refresh!). However, as documented in the [StackOverflow question "Chrome's “Auto-Reload Generated CS...
Default `wp_enqueue_[style/script]()` behavior ---------------------------------------------- The [default value for the `$version` argument](https://codex.wordpress.org/Function_Reference/wp_enqueue_style#Parameters) of [`wp_enqueue_style()`](https://codex.wordpress.org/Function_Reference/wp_enqueue_style) is `false`...
183,699
<p>I have a wordpress site (lets call it site1) and another site with oauth2 (site2).</p> <p>When a new user is created, a record is created in both site1 and site2 databases with the same email as username, the typed password hashed in site2 database and a dummy (e.g. "pass") password for site1 database. Then login a...
[ { "answer_id": 183670, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 5, "selected": true, "text": "<h2>Default <code>wp_enqueue_[style/script]()</code> behavior</h2>\n\n<p>The <a href=\"https://codex.wordpress.org/F...
2015/04/09
[ "https://wordpress.stackexchange.com/questions/183699", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70391/" ]
I have a wordpress site (lets call it site1) and another site with oauth2 (site2). When a new user is created, a record is created in both site1 and site2 databases with the same email as username, the typed password hashed in site2 database and a dummy (e.g. "pass") password for site1 database. Then login action auth...
Default `wp_enqueue_[style/script]()` behavior ---------------------------------------------- The [default value for the `$version` argument](https://codex.wordpress.org/Function_Reference/wp_enqueue_style#Parameters) of [`wp_enqueue_style()`](https://codex.wordpress.org/Function_Reference/wp_enqueue_style) is `false`...
183,708
<p>I am using a page hierarchy and I want to show the title of the 2nd parents The structure is something like</p> <p>Main Page</p> <p>Main Page > Second page</p> <p>Main Page > Second page > Third page</p> <p>Main Page > Second page > Third page > Fourth page</p> <p>I want to show the Second page title in the Fo...
[ { "answer_id": 183709, "author": "websupporter", "author_id": 48693, "author_profile": "https://wordpress.stackexchange.com/users/48693", "pm_score": 0, "selected": false, "text": "<p>The function you are looking for is <a href=\"https://codex.wordpress.org/Function_Reference/get_post_an...
2015/04/09
[ "https://wordpress.stackexchange.com/questions/183708", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70400/" ]
I am using a page hierarchy and I want to show the title of the 2nd parents The structure is something like Main Page Main Page > Second page Main Page > Second page > Third page Main Page > Second page > Third page > Fourth page I want to show the Second page title in the Fouth page. How can i do this? Any help...
get\_post\_ancestors() returns all of the ancestors hierarchically. As you only want to display the 2nd level post title on 4th post page, you can do something like - ``` global $post; $parents = get_post_ancestors( get_the_ID() ); if( count($parents) == 4 ){ // ancestor1 = 1st parent, ancestor2 = second. e...
183,720
<p>I'm having some issues sharing the user sessions across two installs. </p> <p>(a) site on <a href="http://stolenmx.com" rel="nofollow">http://stolenmx.com</a> (b) site on <a href="http://arcade.stolenmx.com" rel="nofollow">http://arcade.stolenmx.com</a></p> <p>I have installed B in the same database as A and I hav...
[ { "answer_id": 183750, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": false, "text": "<p>You also need to define a matching <code>COOKIEHASH</code> for both sites - a random 32 bit string will do...
2015/04/09
[ "https://wordpress.stackexchange.com/questions/183720", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70406/" ]
I'm having some issues sharing the user sessions across two installs. (a) site on <http://stolenmx.com> (b) site on <http://arcade.stolenmx.com> I have installed B in the same database as A and I have defined the user and user\_meta tables so I am sharing user data and users etc but I can't seem to bridge the sessio...
You also need to define a matching `COOKIEHASH` for both sites - a random 32 bit string will do. By default, `COOKIEHASH` is an MD5 hash of the site URL, and is used to generate the default names for all authentication-related cookies. Hence why, at the moment, your cross-domain login isn't working (the names of the c...
183,752
<p>It's easy enough to find help with admin_notices which:</p> <ul> <li>show permanently in the admin screen</li> <li>only show when a particular kind of page is shown</li> <li>show until the user dismisses it</li> </ul> <p>But I can't find help with creating a message which shows until the user leaves that particula...
[ { "answer_id": 183775, "author": "Mike", "author_id": 69112, "author_profile": "https://wordpress.stackexchange.com/users/69112", "pm_score": 0, "selected": false, "text": "<p>Not entirely sure I understand what you are doing but would it be feasible to add an option (add_option) during ...
2015/04/09
[ "https://wordpress.stackexchange.com/questions/183752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/875/" ]
It's easy enough to find help with admin\_notices which: * show permanently in the admin screen * only show when a particular kind of page is shown * show until the user dismisses it But I can't find help with creating a message which shows until the user leaves that particular page. ie. *exactly* what WordPress show...
The short answer is: **Use Query Strings.** If you notice in the address bar immediately after you publish a Post... You will see something similar to this: `domain.com/wp-admin/post.php?post=4935&action=edit&message=6` **There's a few different Query Variables:** 1. `post` contains the ID of the Post being edited. ...
183,828
<p>I try to remove metaboxes from non-admin for posts, pages, and add products page (WooCommerce), and this my code:</p> <pre><code>// ciusART Remove Metaboxes add_action('admin_head', 'remove_metaboxes_for_non_admin'); function remove_metaboxes_for_non_admin(){ if (!is_admin()){ // only remove for non admins ...
[ { "answer_id": 183829, "author": "GastroGeek", "author_id": 70445, "author_profile": "https://wordpress.stackexchange.com/users/70445", "pm_score": 1, "selected": false, "text": "<p>I don't think this will ever fire....</p>\n\n<p>Is_admin() detects admin UI not admin priveleges... Try:</...
2015/04/10
[ "https://wordpress.stackexchange.com/questions/183828", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68053/" ]
I try to remove metaboxes from non-admin for posts, pages, and add products page (WooCommerce), and this my code: ``` // ciusART Remove Metaboxes add_action('admin_head', 'remove_metaboxes_for_non_admin'); function remove_metaboxes_for_non_admin(){ if (!is_admin()){ // only remove for non admins remove_met...
I don't think this will ever fire.... Is\_admin() detects admin UI not admin priveleges... Try: ``` if (is_admin()) : function my_remove_meta_boxes() { if( !current_user_can('manage_options') ) { remove_meta_box(...); }} add_action( 'admin_menu', 'my_remove_meta_boxes' ); endif; ```
183,898
<p>How to make below code safe from sql injection ... I am working in wordpress. global $wpdb;</p> <pre><code> if($wpdb-&gt;insert( 'votes', array( 'votes' =&gt; $votes, 'competition' =&gt; $competition, 'uid' =&gt; $uid ...
[ { "answer_id": 183899, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p><code>wpdb::insert</code> already protects against SQL injection, it's a wrapper for <a href=\"https://cod...
2015/04/11
[ "https://wordpress.stackexchange.com/questions/183898", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67938/" ]
How to make below code safe from sql injection ... I am working in wordpress. global $wpdb; ``` if($wpdb->insert( 'votes', array( 'votes' => $votes, 'competition' => $competition, 'uid' => $uid ) ) == false) ...
The insert method of `$wpdb` already scapes the data taking care of SQL injection. What you should worry about is about data sanitization and validation. For exmpla: **Sanitization** What type of data do you accept in `$votes`? A integer value? If so, be sure `$votes` contains a integer value. You cuold do it, for e...
183,903
<p>This is about running code on wordpress . The given code runs properly outside wordpress but when I put it on theme functions file it does not do anything. </p> <pre><code>ob_start(); require('dynamic-css.php'); $content = ob_get_contents(); ob_end_clean(); $f = fopen("custom.css", "w"); fwrite($f, $content); fclos...
[ { "answer_id": 183899, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p><code>wpdb::insert</code> already protects against SQL injection, it's a wrapper for <a href=\"https://cod...
2015/04/11
[ "https://wordpress.stackexchange.com/questions/183903", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30937/" ]
This is about running code on wordpress . The given code runs properly outside wordpress but when I put it on theme functions file it does not do anything. ``` ob_start(); require('dynamic-css.php'); $content = ob_get_contents(); ob_end_clean(); $f = fopen("custom.css", "w"); fwrite($f, $content); fclose($f); ``` I...
The insert method of `$wpdb` already scapes the data taking care of SQL injection. What you should worry about is about data sanitization and validation. For exmpla: **Sanitization** What type of data do you accept in `$votes`? A integer value? If so, be sure `$votes` contains a integer value. You cuold do it, for e...
183,914
<p>Each of these bits of code work separately in category.php, but when I use both together, the first one is ignored. Can someone tell me how to combine them into a single piece of code, or at least make them play nicely together?</p> <pre><code>&lt;?php if (is_category()) { $posts = query_posts( $query_string . '&am...
[ { "answer_id": 183899, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p><code>wpdb::insert</code> already protects against SQL injection, it's a wrapper for <a href=\"https://cod...
2015/04/11
[ "https://wordpress.stackexchange.com/questions/183914", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/53989/" ]
Each of these bits of code work separately in category.php, but when I use both together, the first one is ignored. Can someone tell me how to combine them into a single piece of code, or at least make them play nicely together? ``` <?php if (is_category()) { $posts = query_posts( $query_string . '&orderby=title&order...
The insert method of `$wpdb` already scapes the data taking care of SQL injection. What you should worry about is about data sanitization and validation. For exmpla: **Sanitization** What type of data do you accept in `$votes`? A integer value? If so, be sure `$votes` contains a integer value. You cuold do it, for e...
183,921
<p>When having this:</p> <pre><code>$tag_list = get_the_tag_list( '', ', ' ); </code></pre> <p>I substituted the meta print:</p> <pre><code>printf( $tag_list, $category:list, etc ); </code></pre> <p>by this:</p> <pre><code>$printArray_tag_list = explode(', ', $tag_list); echo $category_list."/".$printArray_tag_lis...
[ { "answer_id": 183922, "author": "websupporter", "author_id": 48693, "author_profile": "https://wordpress.stackexchange.com/users/48693", "pm_score": 3, "selected": true, "text": "<p>By <code>get_the_tags()</code> you receive an array of tags attached to the current post. So you could do...
2015/04/11
[ "https://wordpress.stackexchange.com/questions/183921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/66195/" ]
When having this: ``` $tag_list = get_the_tag_list( '', ', ' ); ``` I substituted the meta print: ``` printf( $tag_list, $category:list, etc ); ``` by this: ``` $printArray_tag_list = explode(', ', $tag_list); echo $category_list."/".$printArray_tag_list[0].','.$printArray_tag_list[1]; ``` to print only the fi...
By `get_the_tags()` you receive an array of tags attached to the current post. So you could do the following: ``` $tags = get_the_tags(); $tag_ids_to_print = array( 1, 2, 3 ); //List of Tag IDs which you want to be printed $print_tags = array(); if( is_array( $tags ) ){ foreach( $tags as $tag ){ if( in_ar...
183,971
<p>I'm storing CPT <code>products</code>' post IDs into CPT <code>companies</code>' post meta (meta_key = <code>prefix_products</code>). As a company can have multiple products, so I'm storing them into a PHP serialized array value.</p> <pre><code>s:48:"a:3:{i:0;s:3:"334";i:1;s:3:"333";i:2;s:3:"331";}"; </code></pre> ...
[ { "answer_id": 183992, "author": "Erez.info", "author_id": 70538, "author_profile": "https://wordpress.stackexchange.com/users/70538", "pm_score": 1, "selected": false, "text": "<p>It's not possible, you have to store that value separately, and then you'll be able to use it. </p>\n" },...
2015/04/12
[ "https://wordpress.stackexchange.com/questions/183971", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
I'm storing CPT `products`' post IDs into CPT `companies`' post meta (meta\_key = `prefix_products`). As a company can have multiple products, so I'm storing them into a PHP serialized array value. ``` s:48:"a:3:{i:0;s:3:"334";i:1;s:3:"333";i:2;s:3:"331";}"; ``` Where 334, 333, 331 are three post\_ids of post type `...
I would strongly suggest to separate the products and not to put them all into one array. Or even to create a taxonomy companies, but this is more up to the while design and maybe a bad idea. Nevertheless this is a nice question to solve, so let's play. So, the `'prefix_products'` meta key is always an array of produc...
184,002
<p>Weird Problem: I registered two menus (theme-positions) and then added two different menus to each (in Wordpress Admin), but it always shows same menu in both positions:</p> <p>sidebar.php</p> <pre><code>&lt;?php wp_nav_menu( array( 'menu_name' =&gt; 'Header Menu', 'theme-location' =&gt; 'he...
[ { "answer_id": 183992, "author": "Erez.info", "author_id": 70538, "author_profile": "https://wordpress.stackexchange.com/users/70538", "pm_score": 1, "selected": false, "text": "<p>It's not possible, you have to store that value separately, and then you'll be able to use it. </p>\n" },...
2015/04/12
[ "https://wordpress.stackexchange.com/questions/184002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70544/" ]
Weird Problem: I registered two menus (theme-positions) and then added two different menus to each (in Wordpress Admin), but it always shows same menu in both positions: sidebar.php ``` <?php wp_nav_menu( array( 'menu_name' => 'Header Menu', 'theme-location' => 'header-menu', ) ); ?> <di...
I would strongly suggest to separate the products and not to put them all into one array. Or even to create a taxonomy companies, but this is more up to the while design and maybe a bad idea. Nevertheless this is a nice question to solve, so let's play. So, the `'prefix_products'` meta key is always an array of produc...
184,009
<p>I want to make custom url and handle it from my plugin </p> <p>Ex:- </p> <pre><code>domain.com/myplugin=endpoint&amp;id=num&amp;.. </code></pre> <p>i want to return just json data not template </p> <p>Thanks</p>
[ { "answer_id": 183992, "author": "Erez.info", "author_id": 70538, "author_profile": "https://wordpress.stackexchange.com/users/70538", "pm_score": 1, "selected": false, "text": "<p>It's not possible, you have to store that value separately, and then you'll be able to use it. </p>\n" },...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184009", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65428/" ]
I want to make custom url and handle it from my plugin Ex:- ``` domain.com/myplugin=endpoint&id=num&.. ``` i want to return just json data not template Thanks
I would strongly suggest to separate the products and not to put them all into one array. Or even to create a taxonomy companies, but this is more up to the while design and maybe a bad idea. Nevertheless this is a nice question to solve, so let's play. So, the `'prefix_products'` meta key is always an array of produc...
184,014
<p>I am using this code to auto create a page when I activate my plugin..</p> <pre><code>function insert_page(){ // Create post object $my_post = array( 'post_title' =&gt; 'My post', 'post_content' =&gt; 'This is my post.', 'post_status' =&gt; 'publish', 'post_author' =&gt; get_...
[ { "answer_id": 183992, "author": "Erez.info", "author_id": 70538, "author_profile": "https://wordpress.stackexchange.com/users/70538", "pm_score": 1, "selected": false, "text": "<p>It's not possible, you have to store that value separately, and then you'll be able to use it. </p>\n" },...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184014", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68933/" ]
I am using this code to auto create a page when I activate my plugin.. ``` function insert_page(){ // Create post object $my_post = array( 'post_title' => 'My post', 'post_content' => 'This is my post.', 'post_status' => 'publish', 'post_author' => get_current_user_id(), '...
I would strongly suggest to separate the products and not to put them all into one array. Or even to create a taxonomy companies, but this is more up to the while design and maybe a bad idea. Nevertheless this is a nice question to solve, so let's play. So, the `'prefix_products'` meta key is always an array of produc...
184,027
<p>The method <code>OpenMods</code> that you see below, is supposed to take an array generated by an <code>fgetcsv</code> function, and put it into an HTML table. <code>__construct</code> is supposed to, as is typically the case, define the attributes for the class, and <code>shortcode</code> is supposed to take two at...
[ { "answer_id": 184033, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 3, "selected": true, "text": "<p>First, you have to initiate the class, something like:</p>\n\n<pre><code>add_action( 'init', function() {\n\n ...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65738/" ]
The method `OpenMods` that you see below, is supposed to take an array generated by an `fgetcsv` function, and put it into an HTML table. `__construct` is supposed to, as is typically the case, define the attributes for the class, and `shortcode` is supposed to take two attributes from the shortcode, and if mods comes ...
First, you have to initiate the class, something like: ``` add_action( 'init', function() { $CsvImporter = new CsvImporter; } ); ``` Also, you are using `extract()` wrong; `extract()` won't build `$attributes` as an array. Anyway, `extract()` is not recommended any more and you should avoid using it. Also, no...
184,028
<p>I want to check if there are sidebars rendered on the front end and if so output some body classes so I can style the page differently. I tried using <em>is_active_sidebar</em> but that just returns true if the sidebar contains some widget (is active) - I want to check if it exists on the page. How can I do this?</p...
[ { "answer_id": 184033, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 3, "selected": true, "text": "<p>First, you have to initiate the class, something like:</p>\n\n<pre><code>add_action( 'init', function() {\n\n ...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184028", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5079/" ]
I want to check if there are sidebars rendered on the front end and if so output some body classes so I can style the page differently. I tried using *is\_active\_sidebar* but that just returns true if the sidebar contains some widget (is active) - I want to check if it exists on the page. How can I do this? My code l...
First, you have to initiate the class, something like: ``` add_action( 'init', function() { $CsvImporter = new CsvImporter; } ); ``` Also, you are using `extract()` wrong; `extract()` won't build `$attributes` as an array. Anyway, `extract()` is not recommended any more and you should avoid using it. Also, no...
184,038
<p>Which function should be used to move post from trash to published pages? <br/> i.e. is there <strong><code>wp_undelete_post</code></strong> or something like?</p>
[ { "answer_id": 184040, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 4, "selected": true, "text": "<p>There is not <code>wp_undelete_post</code> but you have other choices:</p>\n\n<ul>\n<li><a href=\"https://deve...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184038", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33667/" ]
Which function should be used to move post from trash to published pages? i.e. is there **`wp_undelete_post`** or something like?
There is not `wp_undelete_post` but you have other choices: * [`wp_untrash_post()`](https://developer.wordpress.org/reference/functions/wp_untrash_post/): when post is trashed, the previous status is stored in `_wp_trash_meta_status` meta field. `wp_untrash_post()` restore trashed posts to previous status whatever it ...
184,050
<p>I need a little help with what I believe would be PHP.</p> <p><a href="http://www.domain.com/author/" rel="nofollow">http://www.domain.com/author/</a><strong>username</strong>/achievements/</p> <p>Depending on the username of the person logged in, I would like to create a URL that redirects a user to the aforement...
[ { "answer_id": 184040, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 4, "selected": true, "text": "<p>There is not <code>wp_undelete_post</code> but you have other choices:</p>\n\n<ul>\n<li><a href=\"https://deve...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184050", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70566/" ]
I need a little help with what I believe would be PHP. <http://www.domain.com/author/>**username**/achievements/ Depending on the username of the person logged in, I would like to create a URL that redirects a user to the aforementioned page. To do this, **username** needs to be replaced with their logged in username...
There is not `wp_undelete_post` but you have other choices: * [`wp_untrash_post()`](https://developer.wordpress.org/reference/functions/wp_untrash_post/): when post is trashed, the previous status is stored in `_wp_trash_meta_status` meta field. `wp_untrash_post()` restore trashed posts to previous status whatever it ...
184,093
<p>I am working through the documentation on wp-api.org/ and trying to get my head around this awesome plugin, but I have a question that I can't find the answer to anywhere, so thought I'd ask...it's probably quite simple, but hey ho..</p> <p>Whilst exploring the json data my install is spitting out (by going to loca...
[ { "answer_id": 184079, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": true, "text": "<p>There is a <code>template_redirect</code> hooks which is perfectly suitable for task like this.</p>\n\n<ol>\n<li>Hoo...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50090/" ]
I am working through the documentation on wp-api.org/ and trying to get my head around this awesome plugin, but I have a question that I can't find the answer to anywhere, so thought I'd ask...it's probably quite simple, but hey ho.. Whilst exploring the json data my install is spitting out (by going to localhost/word...
There is a `template_redirect` hooks which is perfectly suitable for task like this. 1. Hook into `template_redirect` 2. Check your context (`is_single()`, etc) 3. Redirect with `wp_safe_redirect()` (if it's inside a site) 4. `die()` to prevent execution from proceeding
184,104
<p>Update: As with so many mysteries, the cause turned out to be extremely stupid. I had the file saved in a different theme's directory. Thanks to @a4jp.com</p> <p>I'm building a theme using underscores. I've created a template file and added a template header at the top.</p> <pre><code>&lt;?php /** * Template Name...
[ { "answer_id": 184108, "author": "a4jp.com", "author_id": 70586, "author_profile": "https://wordpress.stackexchange.com/users/70586", "pm_score": 4, "selected": true, "text": "<p>Maybe this will help.</p>\n\n<pre><code>&lt;?php \n/*\nTemplate Name: Featured\n*/\nget_header(); ?&gt;\n</co...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70344/" ]
Update: As with so many mysteries, the cause turned out to be extremely stupid. I had the file saved in a different theme's directory. Thanks to @a4jp.com I'm building a theme using underscores. I've created a template file and added a template header at the top. ``` <?php /** * Template Name: Featured **/ get_heade...
Maybe this will help. ``` <?php /* Template Name: Featured */ get_header(); ?> ``` Regular code here... ``` <?php get_footer(); ?> ``` If one theme works you could try replacing the files in the broken theme and test which file or files are broken. But first save the old files in a separate folder as a backup. T...
184,122
<p>I'm having an issue inserting a wrapper div into my php index file that we're using for the front page of the site. </p> <p>Right now it looks like this: <img src="https://i.stack.imgur.com/4vxyz.png" alt="Ugly!"></p> <p>And it needs to look like this: <img src="https://i.stack.imgur.com/QBZ7z.png" alt="Much bett...
[ { "answer_id": 184108, "author": "a4jp.com", "author_id": 70586, "author_profile": "https://wordpress.stackexchange.com/users/70586", "pm_score": 4, "selected": true, "text": "<p>Maybe this will help.</p>\n\n<pre><code>&lt;?php \n/*\nTemplate Name: Featured\n*/\nget_header(); ?&gt;\n</co...
2015/04/13
[ "https://wordpress.stackexchange.com/questions/184122", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70547/" ]
I'm having an issue inserting a wrapper div into my php index file that we're using for the front page of the site. Right now it looks like this: ![Ugly!](https://i.stack.imgur.com/4vxyz.png) And it needs to look like this: ![Much better!](https://i.stack.imgur.com/QBZ7z.png) I'm aware this is a CSS issue, and the...
Maybe this will help. ``` <?php /* Template Name: Featured */ get_header(); ?> ``` Regular code here... ``` <?php get_footer(); ?> ``` If one theme works you could try replacing the files in the broken theme and test which file or files are broken. But first save the old files in a separate folder as a backup. T...
184,163
<p>I'm looking for a way to prevent the default behaviour (when you have a static page set as the site homepage or 'frontpage' (in <code>settings&gt;reading&gt;front page displays</code> );</p> <p>I want the <code>domain.com/</code> page to point here (as it does), but if I made a page <code>home</code>, which would o...
[ { "answer_id": 184170, "author": "Bysander", "author_id": 47618, "author_profile": "https://wordpress.stackexchange.com/users/47618", "pm_score": 0, "selected": false, "text": "<p>If i have understood you correctly you just need your <code>domain.com/home</code> to display your homepage ...
2015/04/14
[ "https://wordpress.stackexchange.com/questions/184163", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6353/" ]
I'm looking for a way to prevent the default behaviour (when you have a static page set as the site homepage or 'frontpage' (in `settings>reading>front page displays` ); I want the `domain.com/` page to point here (as it does), but if I made a page `home`, which would otherwise live at `domain.com/home` Wordpress auto...
The redirect is thanks to [`redirect_canonical()`](http://codex.wordpress.org/Function_Reference/redirect_canonical) - we can simply swoop in with a filter and disable it for the front page: ``` function wpse_184163_disable_canonical_front_page( $redirect ) { if ( is_page() && $front_page = get_option( 'page_on_fr...
184,168
<p>I need my users to be able to upload files to the media library and therefore need to somehow automatically set the user role to something other than the default "subscriber" when they register. </p> <p>I know in Settings > General you can set the ‘New User Default Role’, however if I change this to a role that all...
[ { "answer_id": 184170, "author": "Bysander", "author_id": 47618, "author_profile": "https://wordpress.stackexchange.com/users/47618", "pm_score": 0, "selected": false, "text": "<p>If i have understood you correctly you just need your <code>domain.com/home</code> to display your homepage ...
2015/04/14
[ "https://wordpress.stackexchange.com/questions/184168", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/66275/" ]
I need my users to be able to upload files to the media library and therefore need to somehow automatically set the user role to something other than the default "subscriber" when they register. I know in Settings > General you can set the ‘New User Default Role’, however if I change this to a role that allows user u...
The redirect is thanks to [`redirect_canonical()`](http://codex.wordpress.org/Function_Reference/redirect_canonical) - we can simply swoop in with a filter and disable it for the front page: ``` function wpse_184163_disable_canonical_front_page( $redirect ) { if ( is_page() && $front_page = get_option( 'page_on_fr...
184,211
<p>I want to reduce the font size of the text inside the table so I can fit in more columns. Is there a hook I can use or do I need to modify wordpress/woocommerce's core? In that case, which css or template file do i need to change?<img src="https://i.stack.imgur.com/TFAU3.png" alt="woocommerce-products-listing-page">...
[ { "answer_id": 184254, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>You can use the <code>admin_print_styles</code> hook to output custom CSS - in this case I've used the suf...
2015/04/14
[ "https://wordpress.stackexchange.com/questions/184211", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58172/" ]
I want to reduce the font size of the text inside the table so I can fit in more columns. Is there a hook I can use or do I need to modify wordpress/woocommerce's core? In that case, which css or template file do i need to change?![woocommerce-products-listing-page](https://i.stack.imgur.com/TFAU3.png)
Another option would be to use the `current_screen` hook ``` add_action( 'current_screen', 'my_admin_listing_custom_styles' ); function my_admin_listing_custom_styles() { $current_screen = get_current_screen(); if( 'edit' == $current_screen->base && 'product' == $current_screen->post_type) { // Run som...
184,235
<p>I have a variable in header.php, such as:</p> <pre><code>$page_extra_title = get_post_meta($this_page-&gt;ID, "_theme_extra_title", true); </code></pre> <p>Once I do:</p> <pre><code>var_dump($page_extra_title); </code></pre> <p>I always get <code>NULL</code> outside of header.php (var_dump works properly in head...
[ { "answer_id": 184239, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": true, "text": "<h2>Basic separated data structures</h2>\n\n<p>To pass around data, you normally utilize a <em>Model</em> (that's the ...
2015/04/14
[ "https://wordpress.stackexchange.com/questions/184235", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I have a variable in header.php, such as: ``` $page_extra_title = get_post_meta($this_page->ID, "_theme_extra_title", true); ``` Once I do: ``` var_dump($page_extra_title); ``` I always get `NULL` outside of header.php (var\_dump works properly in header.php only). I've been pasting the same variable everywhere I...
Basic separated data structures ------------------------------- To pass around data, you normally utilize a *Model* (that's the "M" in "MVC"). Let's look at a very simple interface for data. *Interfaces* are just used as "Recipes" for our building blocks: ``` namespace WeCodeMore\Package\Models; interface ArgsInterfa...
184,258
<p>I've made a new template file for Wordpress constructing the elements of the page via PHP and Wordpress recognizes the template as such.</p> <p>Then I wanted to include a CSS file for said template (same folder) and went with the standard:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="style.css"&g...
[ { "answer_id": 184260, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": true, "text": "<p>CSS links are relative to the current request URI, not your PHP file. Use an absolute path like:</p>\n\n<pr...
2015/04/15
[ "https://wordpress.stackexchange.com/questions/184258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63130/" ]
I've made a new template file for Wordpress constructing the elements of the page via PHP and Wordpress recognizes the template as such. Then I wanted to include a CSS file for said template (same folder) and went with the standard: ``` <link rel="stylesheet" type="text/css" href="style.css"> ``` but for some reaso...
CSS links are relative to the current request URI, not your PHP file. Use an absolute path like: ``` <link rel="stylesheet" href="<?php bloginfo( 'template_url' ) ?>/themesubfolder/style.css" /> ```
184,271
<p>Hi guys wonder if there is something like a guide to use git to manage WP projects. I have always been a cowboy coder, and I need to make this shift to Git to become more standarized...how can I begin? at least i would love to have my theme in GIT to have a backup copy of it and be able to track the changes. Im the ...
[ { "answer_id": 184260, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": true, "text": "<p>CSS links are relative to the current request URI, not your PHP file. Use an absolute path like:</p>\n\n<pr...
2015/04/15
[ "https://wordpress.stackexchange.com/questions/184271", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50943/" ]
Hi guys wonder if there is something like a guide to use git to manage WP projects. I have always been a cowboy coder, and I need to make this shift to Git to become more standarized...how can I begin? at least i would love to have my theme in GIT to have a backup copy of it and be able to track the changes. Im the onl...
CSS links are relative to the current request URI, not your PHP file. Use an absolute path like: ``` <link rel="stylesheet" href="<?php bloginfo( 'template_url' ) ?>/themesubfolder/style.css" /> ```
184,310
<p>I've done a plugin where you can add shortcode like this: <code>[myplugin xx]</code> (where <code>xx</code> is a number which calls a specific content <code>xx</code>).</p> <p>I have to do a multilingual version of my plugin, so here's my trick: my client writes content <code>xx</code> for language #1 and content <...
[ { "answer_id": 184260, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": true, "text": "<p>CSS links are relative to the current request URI, not your PHP file. Use an absolute path like:</p>\n\n<pr...
2015/04/15
[ "https://wordpress.stackexchange.com/questions/184310", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4347/" ]
I've done a plugin where you can add shortcode like this: `[myplugin xx]` (where `xx` is a number which calls a specific content `xx`). I have to do a multilingual version of my plugin, so here's my trick: my client writes content `xx` for language #1 and content `yy` for language #2. Then, in an article, he would ha...
CSS links are relative to the current request URI, not your PHP file. Use an absolute path like: ``` <link rel="stylesheet" href="<?php bloginfo( 'template_url' ) ?>/themesubfolder/style.css" /> ```
184,317
<p>I am attempting to compare a username to a page template name. I found the following code:</p> <pre><code>get_post_meta( $post-&gt;ID, '_wp_page_template', true ); </code></pre> <p>But this isn't quite what I am looking for. This returns the filename of the page template, IE:</p> <pre><code>templates/page-product...
[ { "answer_id": 184320, "author": "Ben Cole", "author_id": 32532, "author_profile": "https://wordpress.stackexchange.com/users/32532", "pm_score": 1, "selected": false, "text": "<p>One way to retrieve the name of the template as defined in the file could be like this:</p>\n\n<pre><code>fu...
2015/04/15
[ "https://wordpress.stackexchange.com/questions/184317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13286/" ]
I am attempting to compare a username to a page template name. I found the following code: ``` get_post_meta( $post->ID, '_wp_page_template', true ); ``` But this isn't quite what I am looking for. This returns the filename of the page template, IE: ``` templates/page-products.php ``` What I am looking for is th...
An alternative to @Ben Cole that's less intensive (especially if you have several page templates), but not as awesome because it doesn't use the `WP_Theme` object ;) ``` function wpse_184317_get_template_name( $page_id = null ) { if ( ! $template = get_page_template_slug( $page_id ) ) return; if ( ! $f...
184,330
<p>I cannot login to dashboard after installing multisite - I have infinite redirect loop to login page.</p> <p>Here is what I have added to wp-config </p> <pre><code>/* Multisite */ define( 'WP_ALLOW_MULTISITE', true ); define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('DOMAIN_CURRENT_SITE', 'naz...
[ { "answer_id": 184336, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": false, "text": "<p>If I'm not mistaken you have to set the cookie paths and domain, like it is explained here:</p>\n\n...
2015/04/15
[ "https://wordpress.stackexchange.com/questions/184330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70683/" ]
I cannot login to dashboard after installing multisite - I have infinite redirect loop to login page. Here is what I have added to wp-config ``` /* Multisite */ define( 'WP_ALLOW_MULTISITE', true ); define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('DOMAIN_CURRENT_SITE', 'nazarserdyuk.com'); defi...
If I'm not mistaken you have to set the cookie paths and domain, like it is explained here: * [Resolving The WordPress Multisite Redirect Loop](https://tommcfarlin.com/resolving-the-wordpress-multisite-redirect-loop/) by Tom McFarlin. In a nutshell: > > In your `wp-config.php` file, add the following lines of code:...
184,384
<p><em>Caveat- I'm not a programmer, I'm a designer that has taught myself basic php/wordpress theming.</em></p> <p>This is a very specific question, I realize, but I'm hoping the experts can help me find some universal principle I've overlooked.</p> <p>I am using the plugin posts 2 posts to generate a relationship b...
[ { "answer_id": 184335, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>WordPress essentially <em>completely ignores</em> native PHP date functionality, in favor of its own handling. That...
2015/04/16
[ "https://wordpress.stackexchange.com/questions/184384", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59536/" ]
*Caveat- I'm not a programmer, I'm a designer that has taught myself basic php/wordpress theming.* This is a very specific question, I realize, but I'm hoping the experts can help me find some universal principle I've overlooked. I am using the plugin posts 2 posts to generate a relationship between the CPT "speakers...
WordPress essentially *completely ignores* native PHP date functionality, in favor of its own handling. That traditionally allowed it to manage related aspects (such as timezones and translation) with no regards for server configuration. My educated guess that it would be largely oblivious to such change. At most the ...
184,391
<p>I have been using WPML for the use of multilingual but I am having major issues with it and am tired of it.</p> <p>I have now set up two WordPress set ups on two different domains. What I need to do is create a button / way of having an if statement that will take the user to the exact page / post / product in the ...
[ { "answer_id": 184392, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": false, "text": "<p>When a user creates a new page/post/product on one site, use the <a href=\"https://codex.wordpress.org/XML...
2015/04/16
[ "https://wordpress.stackexchange.com/questions/184391", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69859/" ]
I have been using WPML for the use of multilingual but I am having major issues with it and am tired of it. I have now set up two WordPress set ups on two different domains. What I need to do is create a button / way of having an if statement that will take the user to the exact page / post / product in the different ...
When a user creates a new page/post/product on one site, use the [XML-RPC API](https://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost) to create a matching one on the other site. Make sure to save the ID of the original post under a meta key for the "duplicate" post, and then use the response ID from the AP...
184,429
<p>I have searched this forum for the possible solutions but I am not getting anything which works. Maybe I am doing it the wrong way.</p> <p>Here is the code that I have tried so far </p> <pre><code>$parent_categories = '' ; $sub_categories = ''; $subcat = ''; $args = array( 'number' =&gt; $number, 'orderby' ...
[ { "answer_id": 184421, "author": "Ricardo Andres", "author_id": 70093, "author_profile": "https://wordpress.stackexchange.com/users/70093", "pm_score": 1, "selected": true, "text": "<p>I do not currently have access to a multi-site, but as far as I remember: Each site in the multi-site i...
2015/04/16
[ "https://wordpress.stackexchange.com/questions/184429", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70729/" ]
I have searched this forum for the possible solutions but I am not getting anything which works. Maybe I am doing it the wrong way. Here is the code that I have tried so far ``` $parent_categories = '' ; $sub_categories = ''; $subcat = ''; $args = array( 'number' => $number, 'orderby' => $orderby, 'order' ...
I do not currently have access to a multi-site, but as far as I remember: Each site in the multi-site install can have their own theme; same with the plugins. However, you can install themes in the main site profile and it will display as optional themes for all the other sites in the multi-site install. I am not sure...
184,446
<p>I'm a newbie at PHP and WordPress, so please be gentle!</p> <p>I'm building a plugin - following a few tutorials, getting it all working.</p> <p>My question is why is the function I want to call wrapped up in the <code>array($this, function)</code>? For example I have this constructor code inside my class</p> <pr...
[ { "answer_id": 184452, "author": "Loopo", "author_id": 40423, "author_profile": "https://wordpress.stackexchange.com/users/40423", "pm_score": 3, "selected": false, "text": "<p>the <em>add_action()</em> function definition looks like:</p>\n\n<pre><code> function add_action($tag, $functio...
2015/04/16
[ "https://wordpress.stackexchange.com/questions/184446", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70739/" ]
I'm a newbie at PHP and WordPress, so please be gentle! I'm building a plugin - following a few tutorials, getting it all working. My question is why is the function I want to call wrapped up in the `array($this, function)`? For example I have this constructor code inside my class ``` function __construct() { ...
the *add\_action()* function definition looks like: ``` function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { return add_filter($tag, $function_to_add, $priority, $accepted_args); } ``` so according to that it looks like it expects (string,string,int,int) In a traditional php file...
184,449
<p>I am aiming to pagination <a href="https://codex.wordpress.org/Class_Reference/WP_Comment_Query">WP_Comment_Query()</a>. It appears this is either taboo or there is no viable information about it <a href="https://www.google.co.uk/search?q=%22WP_Comment_Query%22%20pagination">online</a>, not anything.</p> <p>Why? Is...
[ { "answer_id": 184451, "author": "Christine Cooper", "author_id": 24875, "author_profile": "https://wordpress.stackexchange.com/users/24875", "pm_score": 4, "selected": true, "text": "<p>Yes, it is possible, but it is a bit of a pain.</p>\n\n<p>Looking at the <a href=\"https://codex.word...
2015/04/16
[ "https://wordpress.stackexchange.com/questions/184449", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
I am aiming to pagination [WP\_Comment\_Query()](https://codex.wordpress.org/Class_Reference/WP_Comment_Query). It appears this is either taboo or there is no viable information about it [online](https://www.google.co.uk/search?q=%22WP_Comment_Query%22%20pagination), not anything. Why? Is it possible? If so, **how**?
Yes, it is possible, but it is a bit of a pain. Looking at the [codex page](https://codex.wordpress.org/Class_Reference/WP_Comment_Query), only arguments of note are `number` and `offset`. We need these two to create our paginated pages. First, we set the `$paged` parameter, which is the current page: ``` $paged =...
184,458
<p>A client of mine wants to be able to choose between a dark and a light theme each time he publishes a post. What's the best way to change the color of a theme per post?</p> <p>I thought in creating a taxonomy called "template" and within that two options: "dark" and "light". However, I dont know yet how to change t...
[ { "answer_id": 184451, "author": "Christine Cooper", "author_id": 24875, "author_profile": "https://wordpress.stackexchange.com/users/24875", "pm_score": 4, "selected": true, "text": "<p>Yes, it is possible, but it is a bit of a pain.</p>\n\n<p>Looking at the <a href=\"https://codex.word...
2015/04/16
[ "https://wordpress.stackexchange.com/questions/184458", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47846/" ]
A client of mine wants to be able to choose between a dark and a light theme each time he publishes a post. What's the best way to change the color of a theme per post? I thought in creating a taxonomy called "template" and within that two options: "dark" and "light". However, I dont know yet how to change the whole t...
Yes, it is possible, but it is a bit of a pain. Looking at the [codex page](https://codex.wordpress.org/Class_Reference/WP_Comment_Query), only arguments of note are `number` and `offset`. We need these two to create our paginated pages. First, we set the `$paged` parameter, which is the current page: ``` $paged =...
184,498
<p>I currently have this:</p> <pre><code> &lt;?php $terms = wp_get_post_terms( $post-&gt;ID, 'artist-genre'); foreach($terms as $term) : ?&gt; &lt;li&gt; &lt;?php echo $term-&gt;name; ?&gt; &lt;/li&gt; &lt;?php endforeach;?&gt; </code></pre> <p>Just to list out the name on a custom post type page calle...
[ { "answer_id": 184502, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>What about <a href=\"https://codex.wordpress.org/Function_Reference/get_the_term_list\" rel=\"nofollow\">usin...
2015/04/17
[ "https://wordpress.stackexchange.com/questions/184498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16613/" ]
I currently have this: ``` <?php $terms = wp_get_post_terms( $post->ID, 'artist-genre'); foreach($terms as $term) : ?> <li> <?php echo $term->name; ?> </li> <?php endforeach;?> ``` Just to list out the name on a custom post type page called `artwork`. It's working, but I feel that doing a `foreach` ...
What about [using](https://codex.wordpress.org/Function_Reference/get_the_term_list): ``` echo get_the_term_list( $post->ID, 'artist-genre', '<li>', ',</li><li>', '</li>' ); ``` instead, to generate the HTML list? Or [simply](https://codex.wordpress.org/Function_Reference/the_terms): ``` the_terms( $post->ID, 'art...
184,513
<p>I need to set different screen options(title,author,categories...) in post summary page for non admin users(editor,author..) which can not be altered by user him/her self.</p> <p>Example : <img src="https://i.stack.imgur.com/MzmD7.jpg" alt="enter image description here"></p> <p>This is the administrator view and I...
[ { "answer_id": 184527, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>You can use the <a href=\"https://codex.wordpress.org/Roles_and_Capabilities\" rel=\"nofollow\">capabiliti...
2015/04/17
[ "https://wordpress.stackexchange.com/questions/184513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68403/" ]
I need to set different screen options(title,author,categories...) in post summary page for non admin users(editor,author..) which can not be altered by user him/her self. Example : ![enter image description here](https://i.stack.imgur.com/MzmD7.jpg) This is the administrator view and I need to hide `View Count` & `S...
I assume, you need something like editors can't see the category column or something like this. This snippet might help you: ``` /** Remove "Options"-Panel, when User is not admin **/ add_filter( 'manage_posts_columns', 'change_columns_for_user', 10, 2 ); function change_columns_for_user( $columns, $post_type ){ ...
184,519
<p>I am using the following code for submit custom post by users in a custom page. When i submit form i get this error:</p> <blockquote> <p>Fatal error: Call to a member function get_error_messages() on null in D:\Ampps\www\wordpress2\wp-content\themes\tours\includes\add_tour.func.php on line 85</p> </blockquote> ...
[ { "answer_id": 184527, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>You can use the <a href=\"https://codex.wordpress.org/Roles_and_Capabilities\" rel=\"nofollow\">capabiliti...
2015/04/17
[ "https://wordpress.stackexchange.com/questions/184519", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63723/" ]
I am using the following code for submit custom post by users in a custom page. When i submit form i get this error: > > Fatal error: Call to a member function get\_error\_messages() on null in D:\Ampps\www\wordpress2\wp-content\themes\tours\includes\add\_tour.func.php on line 85 > > > Line 85: > > ...} elseif...
I assume, you need something like editors can't see the category column or something like this. This snippet might help you: ``` /** Remove "Options"-Panel, when User is not admin **/ add_filter( 'manage_posts_columns', 'change_columns_for_user', 10, 2 ); function change_columns_for_user( $columns, $post_type ){ ...
184,557
<p>On attachment pages, I have a link back to the post/page where the file was uploaded. (This is not displayed for files that were directly added to the Media Library and that's fine.)</p> <p>For attachments added to posts and pages, the following code generates the link:</p> <pre><code>$post = get_post( get_the_ID(...
[ { "answer_id": 184527, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>You can use the <a href=\"https://codex.wordpress.org/Roles_and_Capabilities\" rel=\"nofollow\">capabiliti...
2015/04/17
[ "https://wordpress.stackexchange.com/questions/184557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70779/" ]
On attachment pages, I have a link back to the post/page where the file was uploaded. (This is not displayed for files that were directly added to the Media Library and that's fine.) For attachments added to posts and pages, the following code generates the link: ``` $post = get_post( get_the_ID() ); if ( $post->pos...
I assume, you need something like editors can't see the category column or something like this. This snippet might help you: ``` /** Remove "Options"-Panel, when User is not admin **/ add_filter( 'manage_posts_columns', 'change_columns_for_user', 10, 2 ); function change_columns_for_user( $columns, $post_type ){ ...
184,574
<p>I have an old intranet site running on 3.6.2 and tried to manually upgrade it to 4.1.1. After moving the files over the site just "spins". I have manually upgraded our sites literally 100 times (connection directly to wp.org does not work so there is no way to do it auto) and have never had this come up. I ended ...
[ { "answer_id": 184527, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>You can use the <a href=\"https://codex.wordpress.org/Roles_and_Capabilities\" rel=\"nofollow\">capabiliti...
2015/04/17
[ "https://wordpress.stackexchange.com/questions/184574", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32393/" ]
I have an old intranet site running on 3.6.2 and tried to manually upgrade it to 4.1.1. After moving the files over the site just "spins". I have manually upgraded our sites literally 100 times (connection directly to wp.org does not work so there is no way to do it auto) and have never had this come up. I ended up goi...
I assume, you need something like editors can't see the category column or something like this. This snippet might help you: ``` /** Remove "Options"-Panel, when User is not admin **/ add_filter( 'manage_posts_columns', 'change_columns_for_user', 10, 2 ); function change_columns_for_user( $columns, $post_type ){ ...
184,587
<p>I am using the <code>get_terms</code> function to order all the terms of a custom taxonomy alphabetically. My client however has now requested that one of the terms be put at the very end (therefore not in alphabetical order). Does anyone have any suggestions on how the best way to achieve this?</p>
[ { "answer_id": 184589, "author": "Stephen S.", "author_id": 5019, "author_profile": "https://wordpress.stackexchange.com/users/5019", "pm_score": 0, "selected": false, "text": "<p>There may be a better way of doing this, but you could probably just do two queries. Maybe something along t...
2015/04/17
[ "https://wordpress.stackexchange.com/questions/184587", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23406/" ]
I am using the `get_terms` function to order all the terms of a custom taxonomy alphabetically. My client however has now requested that one of the terms be put at the very end (therefore not in alphabetical order). Does anyone have any suggestions on how the best way to achieve this?
This can be easily done with your own custom function. What you want to do here is, get your object from `get_terms()` which will hold your term objects, check if your unique key is set as a parameter and then according to that, remove that key/pair and add it to the back Now, lets put that into code: (*I have comment...
184,600
<p>I see this subject comes up regularly but have not seen an answer to my specific requirement yet.</p> <p>I'm trying to use a WordPress page as a template and insert database-sourced content (about 20 or so fields of text, including image file names) based on an ID passed as a URL parameter (and index to my database...
[ { "answer_id": 184602, "author": "GastroGeek", "author_id": 70445, "author_profile": "https://wordpress.stackexchange.com/users/70445", "pm_score": 0, "selected": false, "text": "<p>I might be missing something but:</p>\n\n<p>If you only need the 'pid' for example and it is part of the U...
2015/04/18
[ "https://wordpress.stackexchange.com/questions/184600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70803/" ]
I see this subject comes up regularly but have not seen an answer to my specific requirement yet. I'm trying to use a WordPress page as a template and insert database-sourced content (about 20 or so fields of text, including image file names) based on an ID passed as a URL parameter (and index to my database). e.g. ww...
As you are building a page template, you can insert in the content of that template whatever you want and use any PHP snippet you want. So, you can continue doing it as you was doing in PHP. For example, this could be your page template: ``` <?php /* Template Name: My template */ get_header(); ?> <main> <?php ...
184,627
<p>first of all, im sorry for my poor english, when i upadte a post this code changes the post slug to a "profileid" costom field value.. </p> <pre><code>add_action('save_post', 'my_custom_slug'); function my_custom_slug($post_id) { //Check it's not an auto save routine if ( defined('DOING_AUTOSAVE') &amp;&...
[ { "answer_id": 184602, "author": "GastroGeek", "author_id": 70445, "author_profile": "https://wordpress.stackexchange.com/users/70445", "pm_score": 0, "selected": false, "text": "<p>I might be missing something but:</p>\n\n<p>If you only need the 'pid' for example and it is part of the U...
2015/04/18
[ "https://wordpress.stackexchange.com/questions/184627", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70816/" ]
first of all, im sorry for my poor english, when i upadte a post this code changes the post slug to a "profileid" costom field value.. ``` add_action('save_post', 'my_custom_slug'); function my_custom_slug($post_id) { //Check it's not an auto save routine if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) ...
As you are building a page template, you can insert in the content of that template whatever you want and use any PHP snippet you want. So, you can continue doing it as you was doing in PHP. For example, this could be your page template: ``` <?php /* Template Name: My template */ get_header(); ?> <main> <?php ...
184,637
<p>I want to be able to trigger the WooCommerce order complete email at a different stage in the WooCommerce checkout process. So I've disabled WooCommerce order complete email from the backend and am now looking for a line of code that will trigger the email at the point that I want. I've done a bit of research and I'...
[ { "answer_id": 184639, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 5, "selected": true, "text": "<p>You can try this</p>\n\n<pre><code>$mailer = WC()-&gt;mailer();\n$mails = $mailer-&gt;get_emails();\nif ( ! empt...
2015/04/18
[ "https://wordpress.stackexchange.com/questions/184637", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45404/" ]
I want to be able to trigger the WooCommerce order complete email at a different stage in the WooCommerce checkout process. So I've disabled WooCommerce order complete email from the backend and am now looking for a line of code that will trigger the email at the point that I want. I've done a bit of research and I've ...
You can try this ``` $mailer = WC()->mailer(); $mails = $mailer->get_emails(); if ( ! empty( $mails ) ) { foreach ( $mails as $mail ) { if ( $mail->id == 'customer_completed_order' ) { $mail->trigger( $order->id ); } } } ```
184,646
<p>So I have the following code:</p> <pre><code> &lt;span class="delete"&gt;&lt;a onclick="return confirm('Are you sure?');" href="&lt;?php echo wp_nonce_url( add_query_arg( array( 'action' =&gt; 'my-delete-product', 'product_id' =&gt; $post-&gt;ID ), my_get_navigation_url('products') ), 'my-delete-product' ); ?&gt;"&...
[ { "answer_id": 184639, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 5, "selected": true, "text": "<p>You can try this</p>\n\n<pre><code>$mailer = WC()-&gt;mailer();\n$mails = $mailer-&gt;get_emails();\nif ( ! empt...
2015/04/19
[ "https://wordpress.stackexchange.com/questions/184646", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67604/" ]
So I have the following code: ``` <span class="delete"><a onclick="return confirm('Are you sure?');" href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'my-delete-product', 'product_id' => $post->ID ), my_get_navigation_url('products') ), 'my-delete-product' ); ?>"><?php _e( '삭제', 'my' ); ?></a> | </spa...
You can try this ``` $mailer = WC()->mailer(); $mails = $mailer->get_emails(); if ( ! empty( $mails ) ) { foreach ( $mails as $mail ) { if ( $mail->id == 'customer_completed_order' ) { $mail->trigger( $order->id ); } } } ```
184,674
<p>I want to integrate a public API to a plugin that I develop.</p> <p>The usual way other plugins integrate APIs is to define some functions that can be called by any theme or plugin.</p> <p>However, I think this is a bad idea since it will cause errors when my API plugin is not active and I came up with the idea of...
[ { "answer_id": 184680, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 4, "selected": true, "text": "<p>Surely this approach has some benefits, but has also some issues.</p>\n\n<h2>It's not really easy to use</h2>\...
2015/04/19
[ "https://wordpress.stackexchange.com/questions/184674", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31140/" ]
I want to integrate a public API to a plugin that I develop. The usual way other plugins integrate APIs is to define some functions that can be called by any theme or plugin. However, I think this is a bad idea since it will cause errors when my API plugin is not active and I came up with the idea of using filters an...
Surely this approach has some benefits, but has also some issues. It's not really easy to use --------------------------- If the target of your plugin are WordPress developers, they will be very familiar with plugin API, but *end users* are not. For a non-developer, something like: ``` $data = give_me_the_data(); ...
184,689
<p>I'm not sure what this feature is called, but I've seen examples of this before. Lets say, on my site I want additional collections of things (besides blog posts) that have their own sections in the admin area.</p> <p>For example, I have:</p> <ul> <li>a list of events</li> <li>a list of products</li> <li>a list of...
[ { "answer_id": 185589, "author": "mukto90", "author_id": 57944, "author_profile": "https://wordpress.stackexchange.com/users/57944", "pm_score": 0, "selected": false, "text": "<p>These are called <strong>custom post types</strong>. There are several ways to create new post type, using a ...
2015/04/19
[ "https://wordpress.stackexchange.com/questions/184689", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60152/" ]
I'm not sure what this feature is called, but I've seen examples of this before. Lets say, on my site I want additional collections of things (besides blog posts) that have their own sections in the admin area. For example, I have: * a list of events * a list of products * a list of testimonials ...and they each nee...
I believe what you're referring to is called **"Post Types"**. By default, WordPress has a complete post types you're already familiar with - `post` ( news / blog ), `page` ( Pages ), `attachment` ( Media ), `revision` ( Page / Post Revisions ). You can read up on the full list of built in post types on [The Codex - Po...
184,708
<p>I have a bunch of redirects to sites like sharethis, media6, and some random character urls. Most of these are leading to a blank pixel or each other. I know a lot has to do with facebook and needed resources but how would I find out where these are being loaded from? So I can figure out what plugin is causing them ...
[ { "answer_id": 185589, "author": "mukto90", "author_id": 57944, "author_profile": "https://wordpress.stackexchange.com/users/57944", "pm_score": 0, "selected": false, "text": "<p>These are called <strong>custom post types</strong>. There are several ways to create new post type, using a ...
2015/04/19
[ "https://wordpress.stackexchange.com/questions/184708", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70863/" ]
I have a bunch of redirects to sites like sharethis, media6, and some random character urls. Most of these are leading to a blank pixel or each other. I know a lot has to do with facebook and needed resources but how would I find out where these are being loaded from? So I can figure out what plugin is causing them and...
I believe what you're referring to is called **"Post Types"**. By default, WordPress has a complete post types you're already familiar with - `post` ( news / blog ), `page` ( Pages ), `attachment` ( Media ), `revision` ( Page / Post Revisions ). You can read up on the full list of built in post types on [The Codex - Po...
184,711
<p>Im trying to change the title of a post, but I want to include info from a meta field, the value of which isn't saved to the database until after the posts has already been saved. Other than this one thing, it's working fine as a <code>wp_insert_post_data</code> filter.</p> <pre><code>// add_filter('wp_insert_post_...
[ { "answer_id": 184739, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>You hook the <code>tr_change_show_title</code> to a filter inside the function itself, that can make a infini...
2015/04/19
[ "https://wordpress.stackexchange.com/questions/184711", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13551/" ]
Im trying to change the title of a post, but I want to include info from a meta field, the value of which isn't saved to the database until after the posts has already been saved. Other than this one thing, it's working fine as a `wp_insert_post_data` filter. ``` // add_filter('wp_insert_post_data', 'tr_change_show_ti...
You hook the `tr_change_show_title` to a filter inside the function itself, that can make a infinite loop. All the stuff removing/adding actions and filters inside the functions should be deleted; instead check if the post data should be updated or not. In your case you should check if the title has the value you desir...
184,717
<p>I've set up a select field labeled "asset_type" with two values: "image" and "video". I then have two fields that rely on conditional logic to be displayed. If "image" is selected from the select I show the "image_asset" field, and if "video" is selected from the select I show the "video_asset" field. Reading thr...
[ { "answer_id": 184720, "author": "pcarvalho", "author_id": 18559, "author_profile": "https://wordpress.stackexchange.com/users/18559", "pm_score": 3, "selected": true, "text": "<p>Just for the sake of closing the question:\n</p>\n\n<pre><code>&lt;?php if(get_sub_field('asset_type') == \"...
2015/04/19
[ "https://wordpress.stackexchange.com/questions/184717", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70865/" ]
I've set up a select field labeled "asset\_type" with two values: "image" and "video". I then have two fields that rely on conditional logic to be displayed. If "image" is selected from the select I show the "image\_asset" field, and if "video" is selected from the select I show the "video\_asset" field. Reading throug...
Just for the sake of closing the question: ``` <?php if(get_sub_field('asset_type') == "Image") { ?> <div><?php the_sub_field('image_asset'); ?></div> <?php } ?> <?php if(get_sub_field('asset_type') == "Video") { ?> <div><?php the_sub_field('video_asset'); ?></div> <?php } ?> ```
184,750
<p>I have added a new image size to a wordpress site with lots of images already present with all their thumbnails.</p> <p>Is there a way to do this: given the post using a specific image, get the attachment image and generate the thumbnail of the new size?</p> <p>I'm looking for a way to do this when needed and only...
[ { "answer_id": 184720, "author": "pcarvalho", "author_id": 18559, "author_profile": "https://wordpress.stackexchange.com/users/18559", "pm_score": 3, "selected": true, "text": "<p>Just for the sake of closing the question:\n</p>\n\n<pre><code>&lt;?php if(get_sub_field('asset_type') == \"...
2015/04/20
[ "https://wordpress.stackexchange.com/questions/184750", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/745/" ]
I have added a new image size to a wordpress site with lots of images already present with all their thumbnails. Is there a way to do this: given the post using a specific image, get the attachment image and generate the thumbnail of the new size? I'm looking for a way to do this when needed and only on specific sele...
Just for the sake of closing the question: ``` <?php if(get_sub_field('asset_type') == "Image") { ?> <div><?php the_sub_field('image_asset'); ?></div> <?php } ?> <?php if(get_sub_field('asset_type') == "Video") { ?> <div><?php the_sub_field('video_asset'); ?></div> <?php } ?> ```
184,761
<p>I want to cleanup all inactive widgets. I tried following snippet as suggested by this answer <a href="https://wordpress.stackexchange.com/questions/13510/script-to-remove-all-inactive-widgets]">Script to remove all inactive widgets?</a>.</p> <pre><code>$sidebars_widgets = get_option( 'sidebars_widgets' ); $sidebar...
[ { "answer_id": 184781, "author": "Behzad", "author_id": 70359, "author_profile": "https://wordpress.stackexchange.com/users/70359", "pm_score": 3, "selected": true, "text": "<p>You should do it with <code>after_setup_theme</code> action: </p>\n\n<pre><code>function remove_inactive_widget...
2015/04/20
[ "https://wordpress.stackexchange.com/questions/184761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27998/" ]
I want to cleanup all inactive widgets. I tried following snippet as suggested by this answer [Script to remove all inactive widgets?](https://wordpress.stackexchange.com/questions/13510/script-to-remove-all-inactive-widgets]). ``` $sidebars_widgets = get_option( 'sidebars_widgets' ); $sidebars_widgets['wp_inactive_wi...
You should do it with `after_setup_theme` action: ``` function remove_inactive_widgets() { $sidebars_widgets = get_option( 'sidebars_widgets' ); $sidebars_widgets['wp_inactive_widgets'] = array(); update_option( 'sidebars_widgets', $sidebars_widgets ); } add_action( 'after_setup_theme', 'remove_inactiv...
184,780
<p>I am working in wordpress and on pressing the submit button I want the function to return result through ajax and result should be shown as an alert on the screen. But when I press submit nothing shows.</p> <p>Below is my code</p> <p>Ajax code (ajaxinsert.js file)</p> <pre><code>jQuery(document).ready(function(){...
[ { "answer_id": 184786, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>Shortcodes are too late to add ajax actions. Additionally, that actions would be added only if shortcode is e...
2015/04/20
[ "https://wordpress.stackexchange.com/questions/184780", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67938/" ]
I am working in wordpress and on pressing the submit button I want the function to return result through ajax and result should be shown as an alert on the screen. But when I press submit nothing shows. Below is my code Ajax code (ajaxinsert.js file) ``` jQuery(document).ready(function(){ //////////////////////////...
Shortcodes are too late to add ajax actions. Additionally, that actions would be added only if shortcode is executed, which is very unlikely to happen on a ajax request. The quickest way to make your code work is to move the `add_action` outside `addimage()` function. ``` add_action( 'wp_ajax_wp_up', 'wp_up' ); add_ac...
184,785
<p>I'm a total newbie regarding to wp or coding or anything like that but I manage to get things done with a bit of reading. I need a way to convert IPTC extracted keywords that are attached to it's media file to a blog post tags. </p> <p>This is my workflow - I upload an image, image get's attached to a post as feat...
[ { "answer_id": 184792, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": -1, "selected": false, "text": "<p>It depends. To extract the IPTC keywords you will have to find a library or a code sample that you can u...
2015/04/20
[ "https://wordpress.stackexchange.com/questions/184785", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70892/" ]
I'm a total newbie regarding to wp or coding or anything like that but I manage to get things done with a bit of reading. I need a way to convert IPTC extracted keywords that are attached to it's media file to a blog post tags. This is my workflow - I upload an image, image get's attached to a post as featured image...
WordPres has a function that extract IPTC info from images, that function is `wp_read_image_metadata`. That function is only available on admin side and, [according with the codex](https://codex.wordpress.org/Function_Reference/wp_read_image_metadata), it doesn't extract IPTC keywords. But you can use [`iptcparse` from...
184,798
<p>We are looking to modify the registration so that no email is required (yes we know this will be an issue). We are using the Registration Plus Redux plugin since it has options we are using currently.</p> <p>How can we have it so that when a new user signs up, we only ask for their First Name, Username they choose ...
[ { "answer_id": 184923, "author": "user42826", "author_id": 42826, "author_profile": "https://wordpress.stackexchange.com/users/42826", "pm_score": -1, "selected": false, "text": "<p>To customize your registration form, follow the instructions outlined here - <a href=\"https://codex.wordp...
2015/04/20
[ "https://wordpress.stackexchange.com/questions/184798", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70898/" ]
We are looking to modify the registration so that no email is required (yes we know this will be an issue). We are using the Registration Plus Redux plugin since it has options we are using currently. How can we have it so that when a new user signs up, we only ask for their First Name, Username they choose and passwo...
Just install a plugin called - *Snippets & Activate*. Than on left panel click *Snippets -> Add new*. Type a title of your own & paste below code. After that click a option there in the bottom "Run snippet everywhere" and press Save/Active. That's all you need to do. Enjoy... ``` add_action('user_profile_update_errors...
184,880
<p>I try to get the current post index number and echo the number of this lesson(post)in a series of lessons(category).</p> <p>I'm inside the loop on single.php page</p> <p>my code looks like this:</p> <pre><code>$args = array( 'cat' =&gt; 22, ); $query = new WP_Query( $args ); echo $query-&gt;current_post; echo...
[ { "answer_id": 184884, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>What you are seeing is totally expected as you are trying to get the value of <code>$current_post</code>...
2015/04/21
[ "https://wordpress.stackexchange.com/questions/184880", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39259/" ]
I try to get the current post index number and echo the number of this lesson(post)in a series of lessons(category). I'm inside the loop on single.php page my code looks like this: ``` $args = array( 'cat' => 22, ); $query = new WP_Query( $args ); echo $query->current_post; echo $query->post_count; ``` the "$q...
What you are seeing is totally expected as you are trying to get the value of `$current_post` outside the loop. Before and after the loop, the value of `$current_post` will always be set to `-1`. To get the proper value, you need to check `$current_post` inside the loop, the first post will be `0` and this will increa...
184,993
<p>I have over 4000 posts. I am trying to query all the posts and get the count of tags each post has and sum up posts count based on number of tags the post has in dashboard. The posts count shows up properly when post_per_page is less than 2000 but beyond 2000 , the query timesout . It just shows '0' for all.</p> <p...
[ { "answer_id": 184996, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 4, "selected": true, "text": "<p>I addressed <a href=\"https://wordpress.stackexchange.com/a/184562/1685\">a similar problem</a> not long ag...
2015/04/22
[ "https://wordpress.stackexchange.com/questions/184993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37899/" ]
I have over 4000 posts. I am trying to query all the posts and get the count of tags each post has and sum up posts count based on number of tags the post has in dashboard. The posts count shows up properly when post\_per\_page is less than 2000 but beyond 2000 , the query timesout . It just shows '0' for all. Code `...
I addressed [a similar problem](https://wordpress.stackexchange.com/a/184562/1685) not long ago - it's all in the memory: ``` $post_ids = get_posts( array( 'posts_per_page' => -1, 'post_status' => 'publish', 'fields' => 'ids', // Just grab IDs instead of pulling 1000's of objects into memo...
185,004
<p>For a specific section on my website I loop through some categories and get the three latest posts in that categorie and list them. Like so:</p> <pre><code>&lt;?php $categories = get_categories(array('exclude' =&gt; '1, 4, 9, 10, 2899')); ?&gt; &lt;?php foreach ($categories as $category) : ?&gt; &lt;div class=...
[ { "answer_id": 185010, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 0, "selected": false, "text": "<p>Your category is ID being changed at every loop iteration and you are setting a common transient, which gives t...
2015/04/22
[ "https://wordpress.stackexchange.com/questions/185004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16574/" ]
For a specific section on my website I loop through some categories and get the three latest posts in that categorie and list them. Like so: ``` <?php $categories = get_categories(array('exclude' => '1, 4, 9, 10, 2899')); ?> <?php foreach ($categories as $category) : ?> <div class="subject"> <h3><?php ech...
I don't think you need so many transients set, one for each category. You can only use one, that is enough. Transients are quite expensive to set as it requires additional db queries, so you would want to cut down on the use. As always, I like to keep my templates simple, short and sweet, so I tend to write custom fun...
185,011
<p>I am trying to exclude some categories from a for-loop.</p> <pre><code>&lt;?php $categories = get_categories(array('exclude' =&gt; 'apps, windows')); ?&gt; &lt;?php foreach ($categories as $category) : ?&gt; // the_loop &lt;?php endforeach; ?&gt; </code></pre> <p>Even though no error is thrown, it doesn't wor...
[ { "answer_id": 185014, "author": "impsart", "author_id": 65286, "author_profile": "https://wordpress.stackexchange.com/users/65286", "pm_score": 0, "selected": false, "text": "<p>There's a small error on your first line of code. You should separate 'each' category with quotes in the arra...
2015/04/22
[ "https://wordpress.stackexchange.com/questions/185011", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16574/" ]
I am trying to exclude some categories from a for-loop. ``` <?php $categories = get_categories(array('exclude' => 'apps, windows')); ?> <?php foreach ($categories as $category) : ?> // the_loop <?php endforeach; ?> ``` Even though no error is thrown, it doesn't work: all categories are used in the loop. How can...
As I already stated, straight from the [codex](https://codex.wordpress.org/Function_Reference/get_categories) > > **exclude** > > > (string) Excludes one or more categories from the list generated by wp\_list\_categories. This parameter takes a comma-separated list of categories by unique ID, in ascending order > ...
185,015
<p>I have been experiencing 404 errors in my Google webmaster tools reports, caused by Custom Post Type (CPT) feed URLs.</p> <p>I would like to completely deactivate the CPT feed URLs, so that the 404 errors don't appear anymore in my Google webmaster tools reports. In other words, I'd like to fix all these errors at o...
[ { "answer_id": 185014, "author": "impsart", "author_id": 65286, "author_profile": "https://wordpress.stackexchange.com/users/65286", "pm_score": 0, "selected": false, "text": "<p>There's a small error on your first line of code. You should separate 'each' category with quotes in the arra...
2015/04/22
[ "https://wordpress.stackexchange.com/questions/185015", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50943/" ]
I have been experiencing 404 errors in my Google webmaster tools reports, caused by Custom Post Type (CPT) feed URLs. I would like to completely deactivate the CPT feed URLs, so that the 404 errors don't appear anymore in my Google webmaster tools reports. In other words, I'd like to fix all these errors at once by de...
As I already stated, straight from the [codex](https://codex.wordpress.org/Function_Reference/get_categories) > > **exclude** > > > (string) Excludes one or more categories from the list generated by wp\_list\_categories. This parameter takes a comma-separated list of categories by unique ID, in ascending order > ...
185,047
<p>I have a custom database in my WordPress site where I want to save multiple values to one row.</p> <p>Let's say I have an entry:</p> <ul> <li>id: auto increment</li> <li>pageid: id of current page</li> <li>time: text (is an array created with implode)</li> </ul> <p>Example:</p> <pre><code>id pageid time 1 1 ...
[ { "answer_id": 185027, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Use <code>$wpdb-&gt;base_prefix . 'table_name'</code> as a table name when you want to create a table for the whole ne...
2015/04/22
[ "https://wordpress.stackexchange.com/questions/185047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71025/" ]
I have a custom database in my WordPress site where I want to save multiple values to one row. Let's say I have an entry: * id: auto increment * pageid: id of current page * time: text (is an array created with implode) Example: ``` id pageid time 1 1 121212,121314,121415 2 2 121212,121314 ``` W...
Use `$wpdb->base_prefix . 'table_name'` as a table name when you want to create a table for the whole network, or when you want to run queries on it. `$wpdb->base_prefix` is always the prefix for the current network’s main table.
185,075
<p>For the past two days I've been trying to debug an issue with <code>WP_Query()</code> and Pagination. </p> <p>A website I'm a dev for uses a Wordpress theme (Salient by ThemeNectar) that includes the visual composer plugin. My job is essentially to make sure the site is just functional, so a while ago I wrote an ex...
[ { "answer_id": 185775, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>I'm not quite sure what do you mean by you have extended the visual composer, but I do have a couple of ...
2015/04/23
[ "https://wordpress.stackexchange.com/questions/185075", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71045/" ]
For the past two days I've been trying to debug an issue with `WP_Query()` and Pagination. A website I'm a dev for uses a Wordpress theme (Salient by ThemeNectar) that includes the visual composer plugin. My job is essentially to make sure the site is just functional, so a while ago I wrote an extension for the visua...
I'm not quite sure what do you mean by you have extended the visual composer, but I do have a couple of concerns here. * [SoC](http://en.m.wikipedia.org/wiki/Separation_of_concerns) -> From your code I detect that you are using a shortcode, which should have its own separate class. You should not extend the class to t...
185,115
<p>I am trying to add pagination for my Archive. I want to show 12 posts per page and then show the 'next' / 'previous' buttons.</p> <p>When I manually change the value of the $paged variable, the 1 into a 2 it works. When I click the Next button on the archive page, it loads a very weird theme page. The url looks lik...
[ { "answer_id": 185775, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>I'm not quite sure what do you mean by you have extended the visual composer, but I do have a couple of ...
2015/04/23
[ "https://wordpress.stackexchange.com/questions/185115", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49106/" ]
I am trying to add pagination for my Archive. I want to show 12 posts per page and then show the 'next' / 'previous' buttons. When I manually change the value of the $paged variable, the 1 into a 2 it works. When I click the Next button on the archive page, it loads a very weird theme page. The url looks like: '/page/...
I'm not quite sure what do you mean by you have extended the visual composer, but I do have a couple of concerns here. * [SoC](http://en.m.wikipedia.org/wiki/Separation_of_concerns) -> From your code I detect that you are using a shortcode, which should have its own separate class. You should not extend the class to t...
185,126
<p>I'm creating a form plugin to handle forms that can be hooked into using actions/filters by developers.</p> <p>My plug-in needs to be able to handle different forms with different sets of filters and I see 2 ways of doing this.</p> <h2>Method 1</h2> <p>Fire of specific hooks for each form.</p> <p>So code like th...
[ { "answer_id": 185127, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Make the hook name specific to what it does, not where it is called. Do not pass multiple parameters, because that is...
2015/04/23
[ "https://wordpress.stackexchange.com/questions/185126", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18340/" ]
I'm creating a form plugin to handle forms that can be hooked into using actions/filters by developers. My plug-in needs to be able to handle different forms with different sets of filters and I see 2 ways of doing this. Method 1 -------- Fire of specific hooks for each form. So code like this could be called form ...
Method 1 is much more robust and extendable, in my opinion. **Method 1:** To add or remove forms, or other functionality, you just add or remove functions. In particular, you can do this from other files, such as separate modules of your plugin or other external plugins. I think this is the main argument in its favor...
185,148
<p>I am having problems with my form. When the submit button is clicked a 404 error is spit out. If anyone has any suggestions I'd be grateful.</p> <p>Ajax handling of form. Going into theme's js.</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery('#BookingForm').submit(ajaxSubmit); function ajaxSub...
[ { "answer_id": 185158, "author": "Trang", "author_id": 70868, "author_profile": "https://wordpress.stackexchange.com/users/70868", "pm_score": 0, "selected": false, "text": "<p>You cannot use Ajax on Wordpress that way. There are many tutorial about using Ajax on wordpress. I think the s...
2015/04/23
[ "https://wordpress.stackexchange.com/questions/185148", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71081/" ]
I am having problems with my form. When the submit button is clicked a 404 error is spit out. If anyone has any suggestions I'd be grateful. Ajax handling of form. Going into theme's js. ``` <script type="text/javascript"> jQuery('#BookingForm').submit(ajaxSubmit); function ajaxSubmit(){ var BookingF...
Your attempt to send your AJAX requests to *wp-admin/admin-ajax.php* is correct but it will be better to create a javascript global variable using [wp\_localize\_script()](https://codex.wordpress.org/Function_Reference/wp_localize_script) to make any data available to your script in functions.php that you can normally ...
185,203
<pre><code>register_post_type("butik", [ "labels" =&gt; [ "name" =&gt; "Butik", "singular_name" =&gt; "Butik" ], "show_ui" =&gt; true, 'public' =&gt; true, 'rewrite' =&gt; [ 'slug' =&gt; 'butik' ], "supports" =&gt; [ "title", "editor", "thumbna...
[ { "answer_id": 185205, "author": "Webimetry Solutions", "author_id": 71060, "author_profile": "https://wordpress.stackexchange.com/users/71060", "pm_score": 2, "selected": true, "text": "<p>That is not the way to register a Taxonomy.Please find the code below to register a Taxonomy for a...
2015/04/24
[ "https://wordpress.stackexchange.com/questions/185203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71110/" ]
``` register_post_type("butik", [ "labels" => [ "name" => "Butik", "singular_name" => "Butik" ], "show_ui" => true, 'public' => true, 'rewrite' => [ 'slug' => 'butik' ], "supports" => [ "title", "editor", "thumbnail" ], 'taxonomies' => ...
That is not the way to register a Taxonomy.Please find the code below to register a Taxonomy for a custom post type :- ``` $args = array( "label" => "Butik Categories", "singular_label" => "Butik Category", 'public' => true, 'hierarchical' ...
185,212
<p>I want to make an AJAX request on every select value change to update the real value from database. I'm coding inside a shortcode on <code>functions.php</code>. I have a <code>select</code> element like this one below,</p> <pre><code>echo '&lt;select name="changeValue" onchange="changeValue(' . $user-&gt;ID . ', th...
[ { "answer_id": 185407, "author": "Ahmed Mostafa", "author_id": 71196, "author_profile": "https://wordpress.stackexchange.com/users/71196", "pm_score": 1, "selected": false, "text": "<p>What a type you work with response \nIf you work with json</p>\n\n<pre><code>$.post( ajaxurl , data , f...
2015/04/24
[ "https://wordpress.stackexchange.com/questions/185212", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51091/" ]
I want to make an AJAX request on every select value change to update the real value from database. I'm coding inside a shortcode on `functions.php`. I have a `select` element like this one below, ``` echo '<select name="changeValue" onchange="changeValue(' . $user->ID . ', this.options[this.selectedIndex])">' ``` A...
What a type you work with response If you work with json ``` $.post( ajaxurl , data , function(res){ // your code },'json'); ``` Remove wp\_die() and replace with die()
185,231
<p>I have 7 services in a page. All 7 services have featured images. I want to show all the 7 images and content in a slideshow.</p> <pre><code> $args = array( 'post_type' =&gt; 'page', 'post__in' =&gt; $myarray ); // The Query&lt;br&gt; $the_query = new WP_Query( $args ); </code></pre> <p>How can I show ...
[ { "answer_id": 185246, "author": "Webimetry Solutions", "author_id": 71060, "author_profile": "https://wordpress.stackexchange.com/users/71060", "pm_score": 0, "selected": false, "text": "<p>You will need to create a WP query to grab posts and then put them in a Slider like Flex Slider t...
2015/04/24
[ "https://wordpress.stackexchange.com/questions/185231", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71122/" ]
I have 7 services in a page. All 7 services have featured images. I want to show all the 7 images and content in a slideshow. ``` $args = array( 'post_type' => 'page', 'post__in' => $myarray ); // The Query<br> $the_query = new WP_Query( $args ); ``` How can I show the featured image in the slide show. ...
this is a fairly broad question since there are multiple solutions depending on your exact needs. My method might involve: * Setup normal 'Loop' * in each iteration grab the featured image using: wp\_get\_attachment\_image\_src( get\_post\_thumbnail\_id( post->ID ), 'large' ); * build an unordered list of images * Use...
185,271
<p>I would like to add new tab to upload manager and inside list images from </p> <pre><code>theme_folder/images/patterns </code></pre> <p>I tried something like this to add a tab but it does not work for me since it is adding tabs on the side of media manager but on image upload that tab is not visible. </p> <pre><...
[ { "answer_id": 190580, "author": "sarath", "author_id": 74204, "author_profile": "https://wordpress.stackexchange.com/users/74204", "pm_score": -1, "selected": false, "text": "<pre><code> function axcoto_genify_media_menu($tabs) {\n $newtab = array('genify' =&gt; __('Axcoto...
2015/04/24
[ "https://wordpress.stackexchange.com/questions/185271", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67176/" ]
I would like to add new tab to upload manager and inside list images from ``` theme_folder/images/patterns ``` I tried something like this to add a tab but it does not work for me since it is adding tabs on the side of media manager but on image upload that tab is not visible. ``` function custom_media_upload_tab...
According to WordPress [Codex](http://codex.wordpress.org/Function_Reference/wp_iframe) you can add custom tab in media uploader like this: ``` // add the tab add_filter('media_upload_tabs', 'my_upload_tab'); function my_upload_tab($tabs) { $tabs['mytabname'] = "My Tab Name"; return $tabs; } // call the new t...
185,287
<p>I use wp-load() to load the basic WP environment and then read some info from the DB without any problem.</p> <p>But now i need to render the full header for a page, including the <a href="https://yoast.com/wordpress/plugins/seo/" rel="nofollow">Yoast SEO</a> plugin. After calling wp-load() and getting my data from...
[ { "answer_id": 185288, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 2, "selected": false, "text": "<p>You are looking for the function <code>get_header()</code>.</p>\n\n<p><code>wp_head()</code> is the internal f...
2015/04/24
[ "https://wordpress.stackexchange.com/questions/185287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34517/" ]
I use wp-load() to load the basic WP environment and then read some info from the DB without any problem. But now i need to render the full header for a page, including the [Yoast SEO](https://yoast.com/wordpress/plugins/seo/) plugin. After calling wp-load() and getting my data from the DB, i call wp\_head() to render...
You are looking for the function `get_header()`. `wp_head()` is the internal function of WordPress for doing things inside the head section (listing scripts, styles, metadata etc.). The real HTML output comes from the function `get_header()`, which includes your theme's `header.php`. I suppose that you do not really...
185,289
<p>Just updated my local and live installs for a side project to 4.2 in order to take advantage of the newly added Emoji features. Emoji are working just fine on my local machine, but they seem to not be working as comments on the live version.</p> <p><strong>Local</strong></p> <ul> <li>emoji in post title - working<...
[ { "answer_id": 185288, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 2, "selected": false, "text": "<p>You are looking for the function <code>get_header()</code>.</p>\n\n<p><code>wp_head()</code> is the internal f...
2015/04/24
[ "https://wordpress.stackexchange.com/questions/185289", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5019/" ]
Just updated my local and live installs for a side project to 4.2 in order to take advantage of the newly added Emoji features. Emoji are working just fine on my local machine, but they seem to not be working as comments on the live version. **Local** * emoji in post title - working * emoji in post content - working ...
You are looking for the function `get_header()`. `wp_head()` is the internal function of WordPress for doing things inside the head section (listing scripts, styles, metadata etc.). The real HTML output comes from the function `get_header()`, which includes your theme's `header.php`. I suppose that you do not really...
185,299
<p>As a WordPress admin newbie, I just went through my first non-automatic WordPress upgrade.</p> <p>I upgraded five different WordPress installs from 4.1.3 to 4.2.</p> <p>They all refer to different web sites hosted on the same web host as one main domain and four addon domains.</p> <p>On each of the websites, I us...
[ { "answer_id": 185303, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>Unless a plugin states it's compatible, the only reliable way to find out is to create a local multisite ins...
2015/04/24
[ "https://wordpress.stackexchange.com/questions/185299", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68808/" ]
As a WordPress admin newbie, I just went through my first non-automatic WordPress upgrade. I upgraded five different WordPress installs from 4.1.3 to 4.2. They all refer to different web sites hosted on the same web host as one main domain and four addon domains. On each of the websites, I use the following plug-ins...
There are two types of multisite compatibility: 1. Passive compatibility: doing nothing multisite specific, just works without breaking anything. 2. Active compatibility: changing or extending multisite specific behavior. I guess you are out for 1. See my [slides from WordCamp Prague 2015](http://slides.wpkrauts.com...
185,313
<p>Trying to make a custom 'read more' link for different custom post types. </p> <p>Tried this code but does not work as expected. Fairly certain the if/else logic is amiss.</p> <p>Using a Genesis theme if that makes a difference.</p> <pre><code>function excerpt_read_more_link($output) { global $post; if ($...
[ { "answer_id": 185303, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>Unless a plugin states it's compatible, the only reliable way to find out is to create a local multisite ins...
2015/04/24
[ "https://wordpress.stackexchange.com/questions/185313", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54058/" ]
Trying to make a custom 'read more' link for different custom post types. Tried this code but does not work as expected. Fairly certain the if/else logic is amiss. Using a Genesis theme if that makes a difference. ``` function excerpt_read_more_link($output) { global $post; if ($post->post_type = 'speaker')...
There are two types of multisite compatibility: 1. Passive compatibility: doing nothing multisite specific, just works without breaking anything. 2. Active compatibility: changing or extending multisite specific behavior. I guess you are out for 1. See my [slides from WordCamp Prague 2015](http://slides.wpkrauts.com...
185,315
<p>I am working on a custom theme using ACF. I would like to check if the plugin is active or not. I am using this code:</p> <pre><code>&lt;?php include_once( ABSPATH . 'wp-content/plugins/advanced-custom-fields-pro/acf.php' ); if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) { echo "hi"; } ?&gt; </c...
[ { "answer_id": 185330, "author": "Behzad", "author_id": 70359, "author_profile": "https://wordpress.stackexchange.com/users/70359", "pm_score": 5, "selected": true, "text": "<p>Try to check <strong>class_exists</strong>: </p>\n\n<pre><code>&lt;?php \n if( class_exists('acf') ) {\n ...
2015/04/25
[ "https://wordpress.stackexchange.com/questions/185315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21245/" ]
I am working on a custom theme using ACF. I would like to check if the plugin is active or not. I am using this code: ``` <?php include_once( ABSPATH . 'wp-content/plugins/advanced-custom-fields-pro/acf.php' ); if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) { echo "hi"; } ?> ``` However, I am get...
Try to check **class\_exists**: ``` <?php if( class_exists('acf') ) { echo "hi"; } ?> ```