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
232,884
<p>I'm trying to add some custom HTML to specific WooCommerce products for my client. I successfully learned to add this custom HTML to all product pages at once (more specifically to their descriptions, overriding short-description.php) but I only need products A, B and C to contain this HTML bit and the rest to stay ...
[ { "answer_id": 232879, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 4, "selected": true, "text": "<p>First off, it's always good to register shortcode during <code>init</code> versus just in your general <code...
2016/07/21
[ "https://wordpress.stackexchange.com/questions/232884", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98727/" ]
I'm trying to add some custom HTML to specific WooCommerce products for my client. I successfully learned to add this custom HTML to all product pages at once (more specifically to their descriptions, overriding short-description.php) but I only need products A, B and C to contain this HTML bit and the rest to stay wit...
First off, it's always good to register shortcode during `init` versus just in your general `functions.php` file. At the very least `add_shortcode()` should be in `init`. Anyway, let's begin! Whenever you use [`add_shortcode()`](https://codex.wordpress.org/Function_Reference/add_shortcode) the first parameter is going...
232,891
<p>My error log is showing many instances of: PHP Warning: Invalid argument supplied for foreach() in \wp-admin\includes\plugin.php on line 1415</p> <p>How do I go about determining which plugin (and which page/line of that plugin) is causing this? Is there a mechanism in place, or do I have to trial and error it?</...
[ { "answer_id": 232897, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>In your <a href=\"https://codex.wordpress.org/Debugging_in_WordPress\" rel=\"nofollow\"><code>wp-config.php</c...
2016/07/21
[ "https://wordpress.stackexchange.com/questions/232891", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98734/" ]
My error log is showing many instances of: PHP Warning: Invalid argument supplied for foreach() in \wp-admin\includes\plugin.php on line 1415 How do I go about determining which plugin (and which page/line of that plugin) is causing this? Is there a mechanism in place, or do I have to trial and error it?
In your [`wp-config.php`](https://codex.wordpress.org/Debugging_in_WordPress) make sure to include; ``` define( 'WP_DEBUG', true ); define( 'WP_DEBUG_DISPLAY', true ); ``` Sometimes your environment will do a better job at outputting the stack trace. If that doesn't work, you can go that line in WP core and add; `...
232,893
<p>I would like to swap out image URLs upon post submission on both <code>content editor</code> field and a custom field <code>cover_image</code> of a custom post type <code>article</code>.</p> <p>For example, the original content may contain image url such as:</p> <pre><code>&lt;img src="http://original-domain.com/g...
[ { "answer_id": 232896, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 1, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/reference/hooks/image_send_to_editor/\" rel=\"nofollow\"><code>image...
2016/07/22
[ "https://wordpress.stackexchange.com/questions/232893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92505/" ]
I would like to swap out image URLs upon post submission on both `content editor` field and a custom field `cover_image` of a custom post type `article`. For example, the original content may contain image url such as: ``` <img src="http://original-domain.com/gallery/2016/01/01/filename.jpg"> ``` I would like to sw...
`save_post` didn't work for me. What works in my situation is using [content\_save\_pre](https://codex.wordpress.org/Plugin_API/Filter_Reference/content_save_pre) filter or the content processing before save. Since I'm using `Advanced Custom Field` plugin for my `cover_image` field, and I ended up using `acf/save_pos...
232,901
<p>Hey WordPress friends,</p> <p>I’m using the Disqus comment system plugin, which is working fine. My homepage is just a collection if recent posts and therefore not having the option to leave a comment (as desired).</p> <p>Unfortunately, I still see that the Disqus plugin is rendering JavaScript output within the h...
[ { "answer_id": 232907, "author": "Kevin Bronsdijk", "author_id": 98737, "author_profile": "https://wordpress.stackexchange.com/users/98737", "pm_score": 0, "selected": false, "text": "<p>Solved it by altering the file disqus.php. First find function</p>\n\n<pre><code>function dsq_output_...
2016/07/22
[ "https://wordpress.stackexchange.com/questions/232901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98737/" ]
Hey WordPress friends, I’m using the Disqus comment system plugin, which is working fine. My homepage is just a collection if recent posts and therefore not having the option to leave a comment (as desired). Unfortunately, I still see that the Disqus plugin is rendering JavaScript output within the homepage and would...
You should deregister it. Add this function into your functions.php: ``` add_action( 'wp_enqueue_scripts', 'disqus_scripts' ); function disqus_scripts() { if(is_front_page()) { wp_deregister_script('disqus_count'); } } ```
232,934
<p><strong>Update</strong> i have fix the first problem by changing the strectures in sending datas to database, now my problem is that when i select multiple choices and click submit only one of the choices is updated in database (exactly the first one ordering by id) my new Code is belew my old code, by the way i hav...
[ { "answer_id": 232907, "author": "Kevin Bronsdijk", "author_id": 98737, "author_profile": "https://wordpress.stackexchange.com/users/98737", "pm_score": 0, "selected": false, "text": "<p>Solved it by altering the file disqus.php. First find function</p>\n\n<pre><code>function dsq_output_...
2016/07/22
[ "https://wordpress.stackexchange.com/questions/232934", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98757/" ]
**Update** i have fix the first problem by changing the strectures in sending datas to database, now my problem is that when i select multiple choices and click submit only one of the choices is updated in database (exactly the first one ordering by id) my new Code is belew my old code, by the way i have add ``` echo ...
You should deregister it. Add this function into your functions.php: ``` add_action( 'wp_enqueue_scripts', 'disqus_scripts' ); function disqus_scripts() { if(is_front_page()) { wp_deregister_script('disqus_count'); } } ```
233,003
<p>I tried to create a table output with the content of a custom post.</p> <p>I can echo my city properly:</p> <pre><code>&lt;span style="font-weight: bold;"&gt;city: &lt;/span&gt; &lt;?php echo get_post_meta($post-&gt;ID, 'ptn_plaats', true);?&gt; </code></pre> <p>But with this next line I get echo me ARRAY instead...
[ { "answer_id": 233004, "author": "Emran", "author_id": 98806, "author_profile": "https://wordpress.stackexchange.com/users/98806", "pm_score": 2, "selected": true, "text": "<p>You got ARRAY echos because you saved array on post meta,</p>\n\n<p>Just check array values of meta data like:</...
2016/07/23
[ "https://wordpress.stackexchange.com/questions/233003", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98731/" ]
I tried to create a table output with the content of a custom post. I can echo my city properly: ``` <span style="font-weight: bold;">city: </span> <?php echo get_post_meta($post->ID, 'ptn_plaats', true);?> ``` But with this next line I get echo me ARRAY instead one of the options !! ``` <span style="font-weight: ...
You got ARRAY echos because you saved array on post meta, Just check array values of meta data like: ``` print_r( get_post_meta($post->ID, 'ptn_systeem', true) ); ``` and echo it like: ``` foreach( (array) get_post_meta($post->ID, 'ptn_systeem', true) as $option): echo $option . "<br>"; endforeach; ```
233,008
<p>I have a problem with a loop that I try to put into a custom Page template. I would like to display posts with conditions, but whatever I put in my WP_query parameters, it is not taking in consideration.</p> <p>Here is all my template code:</p> <pre><code>&lt;?php /* Template Name: Trends */ get_header(); ?&gt; ...
[ { "answer_id": 233004, "author": "Emran", "author_id": 98806, "author_profile": "https://wordpress.stackexchange.com/users/98806", "pm_score": 2, "selected": true, "text": "<p>You got ARRAY echos because you saved array on post meta,</p>\n\n<p>Just check array values of meta data like:</...
2016/07/23
[ "https://wordpress.stackexchange.com/questions/233008", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98764/" ]
I have a problem with a loop that I try to put into a custom Page template. I would like to display posts with conditions, but whatever I put in my WP\_query parameters, it is not taking in consideration. Here is all my template code: ``` <?php /* Template Name: Trends */ get_header(); ?> <section id="top"> <?p...
You got ARRAY echos because you saved array on post meta, Just check array values of meta data like: ``` print_r( get_post_meta($post->ID, 'ptn_systeem', true) ); ``` and echo it like: ``` foreach( (array) get_post_meta($post->ID, 'ptn_systeem', true) as $option): echo $option . "<br>"; endforeach; ```
233,035
<p>I have a XML file that consist of product information.</p> <p>Format of XML file : </p> <pre><code>&lt;product&gt; &lt;name&gt;Product-1&lt;/name&gt; &lt;description&gt;this is product 1 description&lt;/description&gt; &lt;category&gt;Category-1&lt;category&gt; &lt;merchant&gt;1234&lt;/merchant&gt;...
[ { "answer_id": 233037, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>I've checked and WordPress does, by default, retrieve &amp; cache all post meta along with the ma...
2016/07/23
[ "https://wordpress.stackexchange.com/questions/233035", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64614/" ]
I have a XML file that consist of product information. Format of XML file : ``` <product> <name>Product-1</name> <description>this is product 1 description</description> <category>Category-1<category> <merchant>1234</merchant> <price>12</price> <instock>1<instock> <stockstatus>45</stockst...
I've checked and WordPress does, by default, retrieve & cache all post meta along with the main query's posts, so you're perfectly fine storing a product's additional fields as standard post meta. You might want to store Brands (merchants? manufacturers?) as a custom taxonomy so that you can take advantage of built-i...
233,065
<p>Normally when you set a custom image size using hard crop - e.g. <code>add_image_size( 'custom-size', 400, 400, true );</code> - you get the following results:</p> <ul> <li>#1 Uploaded image: 600x500 > Thumbnail: 400x400.</li> <li>#2 Uploaded image: 500x300 > Thumbnail: 400x300.</li> <li>#3 Uploaded image: 300x200 ...
[ { "answer_id": 233067, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 2, "selected": false, "text": "<p>You're right that it just doesn't work like that.</p>\n\n<p>If it's OK to think of your question ...
2016/07/24
[ "https://wordpress.stackexchange.com/questions/233065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91352/" ]
Normally when you set a custom image size using hard crop - e.g. `add_image_size( 'custom-size', 400, 400, true );` - you get the following results: * #1 Uploaded image: 600x500 > Thumbnail: 400x400. * #2 Uploaded image: 500x300 > Thumbnail: 400x300. * #3 Uploaded image: 300x200 > Thumbnail: 300x200. However what I'd...
You're right that it just doesn't work like that. If it's OK to think of your question the other way around though, you can get the right outcome in modern browsers using a selection of image sizes and responsive images. If you use code like this: ``` add_image_size( 'custom-size-small', 200, 200, true ); add_image_...
233,086
<p>I have custom table like this:</p> <p><strong>useraw</strong></p> <pre><code>1. id (Primary*) 2. user_ip 3. post_id 4. time </code></pre> <p>I am inserting data in the table using </p> <pre><code>$wpdb-&gt;insert($table_name , array('user_ip' =&gt; $user_ip, 'post_id' =&gt; $postID, 'time' =&gt; $visittime),arra...
[ { "answer_id": 233089, "author": "hosker", "author_id": 87687, "author_profile": "https://wordpress.stackexchange.com/users/87687", "pm_score": 0, "selected": false, "text": "<p>You indicate MYSQLi in your question, but label and refer to MySQL in your question. If you are using MySQL th...
2016/07/24
[ "https://wordpress.stackexchange.com/questions/233086", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68328/" ]
I have custom table like this: **useraw** ``` 1. id (Primary*) 2. user_ip 3. post_id 4. time ``` I am inserting data in the table using ``` $wpdb->insert($table_name , array('user_ip' => $user_ip, 'post_id' => $postID, 'time' => $visittime),array('%s','%d', '%d') ); ``` There are four rows I inserted using this...
**To fetch data from database table** ``` $results = $wpdb->get_results( "SELECT * FROM $table_name"); // Query to fetch data from database table and storing in $results if(!empty($results)) // Checking if $results have some values or not { echo "<table width='100%' border='0'>"; // Addi...
233,093
<p><strong>Fail #1:</strong> The hook, <code>genesis_after_content</code>, allows me to add content directly after the <code>&lt;main&gt;</code> tag and before the <code>&lt;aside&gt;</code> tag. So in a content first, sidebar second configuration, it would look like this:</p> <pre><code>&lt;div class="content-sidebar...
[ { "answer_id": 235040, "author": "GaryJ", "author_id": 44505, "author_profile": "https://wordpress.stackexchange.com/users/44505", "pm_score": 2, "selected": true, "text": "<p>If you look in <code>lib/structure/layout.php</code>, towards the bottom, you'll see:</p>\n\n<pre><code>add_acti...
2016/07/25
[ "https://wordpress.stackexchange.com/questions/233093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64943/" ]
**Fail #1:** The hook, `genesis_after_content`, allows me to add content directly after the `<main>` tag and before the `<aside>` tag. So in a content first, sidebar second configuration, it would look like this: ``` <div class="content-sidebar-wrap"> <main></main> <div class="custom-content"></div> <aside...
If you look in `lib/structure/layout.php`, towards the bottom, you'll see: ``` add_action( 'genesis_after_content', 'genesis_get_sidebar' ); /** * Output the sidebar.php file if layout allows for it. * * @since 0.2.0 * * @uses genesis_site_layout() Return the site layout for different contexts. */ function genes...
233,109
<p>I have a meta key which I would like to use to get all post meta data for a post where that one meta key matches a specific value, in one go.</p> <p>Example: <code>Post 1</code> has a <code>meta_key</code> called <code>unique_number</code>. I want to query for all the occurences where <code>unique_number</code> is ...
[ { "answer_id": 233110, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 2, "selected": true, "text": "<p>When you call get_posts WP will also retrieve and cache all the post meta, so your later calls to ...
2016/07/25
[ "https://wordpress.stackexchange.com/questions/233109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43933/" ]
I have a meta key which I would like to use to get all post meta data for a post where that one meta key matches a specific value, in one go. Example: `Post 1` has a `meta_key` called `unique_number`. I want to query for all the occurences where `unique_number` is a specific value, and then get all the meta data for t...
When you call get\_posts WP will also retrieve and cache all the post meta, so your later calls to get the meta data shouldn't cause any more database queries.
233,111
<p>In my loop, I have ten posts with the following categories (slug): group-a, group-a-first and group-b. The loop/query looks like this:</p> <ul> <li>Post (group-a)</li> <li>Post (group-b)</li> <li>Post (group-a-first)</li> </ul> <p>What's the best way to check if those posts has a specific category?</p> <p>I've tr...
[ { "answer_id": 233121, "author": "Muhammad Junaid Bhatti", "author_id": 98900, "author_profile": "https://wordpress.stackexchange.com/users/98900", "pm_score": -1, "selected": false, "text": "<p><code>is_category()</code> tests to see if you are displaying a category archive, but you are...
2016/07/25
[ "https://wordpress.stackexchange.com/questions/233111", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8049/" ]
In my loop, I have ten posts with the following categories (slug): group-a, group-a-first and group-b. The loop/query looks like this: * Post (group-a) * Post (group-b) * Post (group-a-first) What's the best way to check if those posts has a specific category? I've tried `<?php if(in_category('group-a')) ;?>`, it do...
You can just run through the loop and set a flag: ``` if ( $query->have_posts() ) : $any_in_cat = false; while ( $query->have_posts() ) : $query->the_post(); if ( in_category( 'first-major' ) ) : $any_in_cat = true; endif; endwhile; $query->rewind_posts(); /* if $any_in...
233,127
<p>I would like to change the priority/menu order of the "Media" admin page. Is there a way to change that via apply_filter?</p> <p>Is there a way to change only "Media" page priority without having to list all pages within menu_order?</p> <p>Thanks</p>
[ { "answer_id": 233129, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 4, "selected": true, "text": "<p>There's a combination of two filters, <code>menu_order</code> does the job, but you also use <code...
2016/07/25
[ "https://wordpress.stackexchange.com/questions/233127", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46037/" ]
I would like to change the priority/menu order of the "Media" admin page. Is there a way to change that via apply\_filter? Is there a way to change only "Media" page priority without having to list all pages within menu\_order? Thanks
There's a combination of two filters, `menu_order` does the job, but you also use `custom_menu_order` to enable `menu_order`. ``` function wpse_233129_custom_menu_order() { return array( 'index.php', 'upload.php' ); } add_filter( 'custom_menu_order', '__return_true' ); add_filter( 'menu_order', 'wpse_233129_custo...
233,140
<p>I'm creating a plugin and I want to get the list of all scripts and CSS used by other plugins.</p> <p>This is my function:</p> <pre><code>function crunchify_print_scripts_styles() { $result = []; $result['scripts'] = []; $result['styles'] = []; // Print all loaded Scripts global $wp_script...
[ { "answer_id": 233142, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 5, "selected": true, "text": "<p><code>do_action</code> doesn't quite work like that. When you call <code>do_action('crunchify_pri...
2016/07/25
[ "https://wordpress.stackexchange.com/questions/233140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51540/" ]
I'm creating a plugin and I want to get the list of all scripts and CSS used by other plugins. This is my function: ``` function crunchify_print_scripts_styles() { $result = []; $result['scripts'] = []; $result['styles'] = []; // Print all loaded Scripts global $wp_scripts; foreach( $wp_s...
`do_action` doesn't quite work like that. When you call `do_action('crunchify_print_scripts_styles')` WP looks at its list of registered actions and filters for any that are attached to a hook called `crunchify_print_scripts_styles` and then runs those functions. And you probably want to remove this: ``` add_action( ...
233,151
<p>I'm using this technique: <a href="https://stackoverflow.com/questions/27323460/how-to-label-payments-in-gravity-forms-paypal-pro">https://stackoverflow.com/questions/27323460/how-to-label-payments-in-gravity-forms-paypal-pro</a></p> <p>To add comments to the paypal comments field from a gravity form. However, it's...
[ { "answer_id": 233142, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 5, "selected": true, "text": "<p><code>do_action</code> doesn't quite work like that. When you call <code>do_action('crunchify_pri...
2016/07/25
[ "https://wordpress.stackexchange.com/questions/233151", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78660/" ]
I'm using this technique: <https://stackoverflow.com/questions/27323460/how-to-label-payments-in-gravity-forms-paypal-pro> To add comments to the paypal comments field from a gravity form. However, it's a multisite configuration. I'd like to modify it so the filter only triggers on blog\_id 2 What's the proper method...
`do_action` doesn't quite work like that. When you call `do_action('crunchify_print_scripts_styles')` WP looks at its list of registered actions and filters for any that are attached to a hook called `crunchify_print_scripts_styles` and then runs those functions. And you probably want to remove this: ``` add_action( ...
233,170
<p>I'm having an issue saving post meta on all post types, both default and custom. I'm hooking in to <strong>save_post</strong> to run my function, and what's happening is that the post meta gets added, but then immediately deleted. This is what I have right now:</p> <pre><code>function saveSidebarMeta($postId) { ...
[ { "answer_id": 233174, "author": "stoi2m1", "author_id": 10907, "author_profile": "https://wordpress.stackexchange.com/users/10907", "pm_score": 1, "selected": false, "text": "<p>Are you outputting the saved data to the edit post page before saving the post? If not you may be getting a e...
2016/07/25
[ "https://wordpress.stackexchange.com/questions/233170", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34129/" ]
I'm having an issue saving post meta on all post types, both default and custom. I'm hooking in to **save\_post** to run my function, and what's happening is that the post meta gets added, but then immediately deleted. This is what I have right now: ``` function saveSidebarMeta($postId) { $toAdd = $_POST['collecti...
Are you outputting the saved data to the edit post page before saving the post? If not you may be getting a empty $\_POST['collection-topics'] data and then saving empty or null data. I would do a check before doing `add_post_meta()` ``` if ( empty($_POST['collection-topics']) ) return; ```
233,184
<p>I know this question has been asked many times. I even spent the entire day yesterday getting things to work but to no avail. I am pretty sure I am missing out on something small//silly but I am unable to figure it out.</p> <p>So, here is my question: I have purchased the Identity-vcard theme from Envato and I want...
[ { "answer_id": 233185, "author": "ngearing", "author_id": 50184, "author_profile": "https://wordpress.stackexchange.com/users/50184", "pm_score": 2, "selected": false, "text": "<p>You are using <code>get_stylesheet_uri()</code> which links directly to your stylesheet, then your adding /s...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98954/" ]
I know this question has been asked many times. I even spent the entire day yesterday getting things to work but to no avail. I am pretty sure I am missing out on something small//silly but I am unable to figure it out. So, here is my question: I have purchased the Identity-vcard theme from Envato and I want to make s...
You are using `get_stylesheet_uri()` which links directly to your stylesheet, then your adding /style.css which is resulting in an invalid url. So you need to remove the `/style.css`. Or use `get_stylesheet_directory_uri()` and leave the `/style.css` on there.
233,193
<p>My site has recently been compromised. If I restore the full database, google says there is hacked content on my site. The hacker has created many new garbage posts in my site - which already got listed on google SERP. </p> <p>Is there a way how I can restore only my actual posts one by one on the freshly installe...
[ { "answer_id": 233201, "author": "johncarter", "author_id": 26536, "author_profile": "https://wordpress.stackexchange.com/users/26536", "pm_score": -1, "selected": false, "text": "<p>You can restore the <strong>full database</strong> and use <a href=\"https://en-gb.wordpress.org/plugins/...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67533/" ]
My site has recently been compromised. If I restore the full database, google says there is hacked content on my site. The hacker has created many new garbage posts in my site - which already got listed on google SERP. Is there a way how I can restore only my actual posts one by one on the freshly installed WordPress...
Take a copy of your data file and store it safely just in case you mess up - it's easily done. Make sure it is labelled as hacked so you can't accidentally use it anywhere. Look in your SQL for a section starting with: ``` INSERT INTO `wp_posts` VALUES ``` and eventually ending with a semicolon. This is all of you...
233,199
<p>I've created a custom field in user profile where upload a profile image. It's very simple.</p> <p>To create fields I've used:</p> <pre><code>add_action( 'show_user_profile', 'cover_image_function' ); add_action( 'edit_user_profile', 'cover_image_function' ); function cover_image_function( $user ) { &lt;h3&gt;...
[ { "answer_id": 233202, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 1, "selected": false, "text": "<p>Not sure it will make a difference, but as you just want one value you can get <code>get_var</code> instead of...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233199", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93927/" ]
I've created a custom field in user profile where upload a profile image. It's very simple. To create fields I've used: ``` add_action( 'show_user_profile', 'cover_image_function' ); add_action( 'edit_user_profile', 'cover_image_function' ); function cover_image_function( $user ) { <h3>Cover Image</h3> <style...
I've finally solved! The problem was that simply using ``` update_user_meta( $user_id, 'mycoverimage', $_POST[ 'mycoverimage' ] ); ``` The image was saved without generating attachment metadata. In fact, checking my table, it got only `usermeta id` which is not the attachment id. So I had to change a bit my uploadin...
233,256
<p>I want to create a code snippet for expiration of post after x days from the post published date, I tried with this code but I always displays the true condition, what am I doing wrong?</p> <pre><code>$pfx_date = get_the_date('d/m/Y'); $datacorrente = date('d/m/Y', strtotime("-5 days")); if ( $pfx_date &lt...
[ { "answer_id": 233258, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 2, "selected": false, "text": "<p>You're comparing strings. For dates this will only ever work out if you use a yyyymmdd format or ...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233256", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86112/" ]
I want to create a code snippet for expiration of post after x days from the post published date, I tried with this code but I always displays the true condition, what am I doing wrong? ``` $pfx_date = get_the_date('d/m/Y'); $datacorrente = date('d/m/Y', strtotime("-5 days")); if ( $pfx_date <= $datacorrente ...
You're comparing strings. For dates this will only ever work out if you use a yyyymmdd format or similar.
233,269
<p>I'm trying to add a local variable to my URL. </p> <p>As an example I have this URL:</p> <pre><code>mysite.com/my-page-name/ </code></pre> <p>And I want to add 'en' variable into it and leave the page working properly:</p> <pre><code>mysite.com/en/my-page-name/ </code></pre> <p>I tried to deal with it using <c...
[ { "answer_id": 233258, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 2, "selected": false, "text": "<p>You're comparing strings. For dates this will only ever work out if you use a yyyymmdd format or ...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233269", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24891/" ]
I'm trying to add a local variable to my URL. As an example I have this URL: ``` mysite.com/my-page-name/ ``` And I want to add 'en' variable into it and leave the page working properly: ``` mysite.com/en/my-page-name/ ``` I tried to deal with it using `add_rewrite_tag()` and `add_rewrite_rule()` but it isn't ...
You're comparing strings. For dates this will only ever work out if you use a yyyymmdd format or similar.
233,283
<p>I'm using a Using modal window with + form to change the profile avatar. Like the following (functions.php):</p> <pre><code>add_action('change_avatar', 'edit_avatar_function'); function edit_avatar_function($uid, $pid) { $av = get_user_meta($uid, 'avatar_' . 'project', true); $avatar = wp_get_attachment_im...
[ { "answer_id": 233285, "author": "scott", "author_id": 93587, "author_profile": "https://wordpress.stackexchange.com/users/93587", "pm_score": 0, "selected": false, "text": "<p>First, I would make sure the <code>update_avatar()</code> function can read the form data. Maybe the function n...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233283", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93927/" ]
I'm using a Using modal window with + form to change the profile avatar. Like the following (functions.php): ``` add_action('change_avatar', 'edit_avatar_function'); function edit_avatar_function($uid, $pid) { $av = get_user_meta($uid, 'avatar_' . 'project', true); $avatar = wp_get_attachment_image_src( $av, ...
You can try to use `new FormData()` instead of `new FormData($('form#change-avatar')[0])`. Also, after `processData:false` you should add `contentType: false` since jQuery will set it [incorrectly otherwise](https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax/5976031#5976031), and fo...
233,284
<p>crafting a theme from finished html/css markup and wonder how to wrap <code>a</code> tags in my custom class? With <code>ul</code> wrapper this is works:</p> <pre><code> wp_nav_menu( array('menu' =&gt; 'menu-header', 'menu_class' =&gt; 'list',) ); </code>...
[ { "answer_id": 233285, "author": "scott", "author_id": 93587, "author_profile": "https://wordpress.stackexchange.com/users/93587", "pm_score": 0, "selected": false, "text": "<p>First, I would make sure the <code>update_avatar()</code> function can read the form data. Maybe the function n...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233284", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98996/" ]
crafting a theme from finished html/css markup and wonder how to wrap `a` tags in my custom class? With `ul` wrapper this is works: ``` wp_nav_menu( array('menu' => 'menu-header', 'menu_class' => 'list',) ); ``` but how to deal with menu items, and with c...
You can try to use `new FormData()` instead of `new FormData($('form#change-avatar')[0])`. Also, after `processData:false` you should add `contentType: false` since jQuery will set it [incorrectly otherwise](https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax/5976031#5976031), and fo...
233,292
<p>I am trying to filter the loop to find posts that have a <code>meta_key</code> with a specific <code>meta_value</code>. I've looked at the Codex, and I've tried the following with no luck:</p> <pre><code>// No results $args = array( 'post_type' =&gt; 'cqpp_interventions', 'posts_per_page' =&gt; '-1', 'm...
[ { "answer_id": 233294, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": 0, "selected": false, "text": "<p>From the reference of your first $args</p>\n\n<pre><code>$args = array(\n 'post_type' =&gt; 'cqpp_interventi...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10501/" ]
I am trying to filter the loop to find posts that have a `meta_key` with a specific `meta_value`. I've looked at the Codex, and I've tried the following with no luck: ``` // No results $args = array( 'post_type' => 'cqpp_interventions', 'posts_per_page' => '-1', 'meta_query' => array( 'relation...
You could try this: ``` $args = array( 'post_type' => 'cqpp_interventions', 'posts_per_page' => '-1', 'meta_query' => array( array( 'key' => 'priority', 'value' => '80' ) ) ); ``` The real issue with your query is because you are passing `meta_key` and `meta_va...
233,293
<p>So wp_get_themes() returns an array of objects :</p> <pre><code>Array ( [WpAngular] =&gt; WP_Theme Object ( [update] =&gt; [theme_root:WP_Theme:private] =&gt; /home/love/Web/web/app/themes [headers:WP_Theme:private] =&gt; Array ( [...
[ { "answer_id": 233295, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": -1, "selected": false, "text": "<p>Here theme names that are displayed from <code>wp_get_themes()</code> stores private information, as you can s...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86684/" ]
So wp\_get\_themes() returns an array of objects : ``` Array ( [WpAngular] => WP_Theme Object ( [update] => [theme_root:WP_Theme:private] => /home/love/Web/web/app/themes [headers:WP_Theme:private] => Array ( [Name] => WpAngular ...
Correct the `wp_get_themes()` function has most of the information inaccessible to the public which requires you to pull the info out using the `$theme->get( 'Name' );` format. You can build a simple array like so. ``` // Build new empty Array to store the themes $themes = array(); // Loads theme data $all_themes = w...
233,298
<p>I've inherited a website which has a menu structure that is not working. he developer built a site at huge expense but has then left them with a partially working site. It is a WooCommerce site with a custom template. I cannot understand how this is supposed to work - any help much appreciated. :-)</p> <p>The menu...
[ { "answer_id": 233305, "author": "Gary", "author_id": 99006, "author_profile": "https://wordpress.stackexchange.com/users/99006", "pm_score": 0, "selected": false, "text": "<p>From the explanation you have posted it sounds like your webserver does not have permission to execute the PHP s...
2016/07/26
[ "https://wordpress.stackexchange.com/questions/233298", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64011/" ]
I've inherited a website which has a menu structure that is not working. he developer built a site at huge expense but has then left them with a partially working site. It is a WooCommerce site with a custom template. I cannot understand how this is supposed to work - any help much appreciated. :-) The menu in questio...
So, when I looked at the .htaccess file it had the following: ``` <FilesMatch "\.(?i:php)$"> <IfModule !mod_authz_core.c> Order allow,deny Deny from all </IfModule> <IfModule mod_authz_core.c> Require all denied </IfModule> </FilesMatch> ``` I removed that and the menu works correctly. This may o...
233,327
<p>I have this code in my custom template file:</p> <pre><code>&lt;?php /* Template Name: custom-template-view */ ob_start(); get_header(); function assignPageTitle(){ return "my page title"; } add_filter('wp_title', 'assignPageTitle');// not working add_filter('the_title', 'assignPageTitle'); // not working ?&g...
[ { "answer_id": 233328, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 0, "selected": false, "text": "<p>Why don't you just echo you custom post title? For example:</p>\n\n<pre><code>if (some_conditional...
2016/07/27
[ "https://wordpress.stackexchange.com/questions/233327", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85769/" ]
I have this code in my custom template file: ``` <?php /* Template Name: custom-template-view */ ob_start(); get_header(); function assignPageTitle(){ return "my page title"; } add_filter('wp_title', 'assignPageTitle');// not working add_filter('the_title', 'assignPageTitle'); // not working ?> <div>MY CONTENT</d...
Template files are not the right place to add in functions like that. The template file isnt loaded until late in the hook/filter process. Your function should be in functions.php. This way it can be added in before your tempalte files load, and functions that are in use in them can be altered. Often times `wp_title()...
233,338
<p>I am writing a plugin for the first time, and I have a problem.</p> <p>I am using AJAX in my plugin. My JavaScript file is in the folder <code>../wp-content/plugins/myplugin/js/</code> , and in it I am trying to call a PHP file, which is in the folder <code>../wp-content/plugins/myplugin/</code></p> <pre><code>jQu...
[ { "answer_id": 233340, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 3, "selected": false, "text": "<p>First of all, you shouldn't call your own PHP file. You should use <code>admin-ajax</code> endpoin...
2016/07/27
[ "https://wordpress.stackexchange.com/questions/233338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97806/" ]
I am writing a plugin for the first time, and I have a problem. I am using AJAX in my plugin. My JavaScript file is in the folder `../wp-content/plugins/myplugin/js/` , and in it I am trying to call a PHP file, which is in the folder `../wp-content/plugins/myplugin/` ``` jQuery.ajax({ url: "/wp-content/plugins/my...
First of all, you shouldn't call your own PHP file. You should use `admin-ajax` endpoint. [Documentation](https://codex.wordpress.org/AJAX_in_Plugins) On admin side, you could use ajaxurl to get URL for AJAX calls. On front side you have to declare by yourself variable with url. This is written in documentation: > >...
233,344
<p>I have one site that is built with <code>html</code>, <code>css</code> and <code>javascript</code> and has no CMS. It looks great and my client would like that site to have wordpress in the background so he can easily modify the content. So, I'm a little bit stuck here.</p> <p>I know that there are plugins for impo...
[ { "answer_id": 233350, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": true, "text": "<p>WordPress has a perfect wrapper for HTML > Theme conversion: The theme itself. All information can be found <a href...
2016/07/27
[ "https://wordpress.stackexchange.com/questions/233344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/89803/" ]
I have one site that is built with `html`, `css` and `javascript` and has no CMS. It looks great and my client would like that site to have wordpress in the background so he can easily modify the content. So, I'm a little bit stuck here. I know that there are plugins for importing well written html, and they work like...
WordPress has a perfect wrapper for HTML > Theme conversion: The theme itself. All information can be found [in the Codex page](https://codex.wordpress.org/Theme_Development). It is enough to add a folder to your `wp-content/themes` directory (or whatever directory you registered in addition to that), and add the foll...
233,354
<p>I've searched Google and can find no mention of how to change Wordpress image captions to wrap the caption in a H2 or H3.</p> <p>How do we wrap image captions inside H2, H3 tags?</p> <p>Thanks.</p>
[ { "answer_id": 233362, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 3, "selected": true, "text": "<p>You can hook into the filter <code>img_caption_shortcode</code> and replace the whole captioned im...
2016/07/27
[ "https://wordpress.stackexchange.com/questions/233354", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I've searched Google and can find no mention of how to change Wordpress image captions to wrap the caption in a H2 or H3. How do we wrap image captions inside H2, H3 tags? Thanks.
You can hook into the filter `img_caption_shortcode` and replace the whole captioned image. Here I've copied the caption shortcode function from WP4.5, left the version used if your theme declares HTML5 support as it is (using figcaption) and modified the non-HTML5 version to use h2. ``` function wpse_233354_img_capti...
233,357
<p>I want to apply different styles for a <em>second page</em> in <code>single.php</code> or posts. How can I do this?</p> <p>I have the following code in <code>single.php</code> to split the page in two parts:</p> <pre><code>&lt;!--nextpage--&gt; </code></pre> <p>If there is a different method to add another "tab" ...
[ { "answer_id": 233367, "author": "Michae Pavlos Michael", "author_id": 87826, "author_profile": "https://wordpress.stackexchange.com/users/87826", "pm_score": 0, "selected": false, "text": "<p>If you know the post ID, you can target that specific body with custom CSS. For example, if you...
2016/07/27
[ "https://wordpress.stackexchange.com/questions/233357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99036/" ]
I want to apply different styles for a *second page* in `single.php` or posts. How can I do this? I have the following code in `single.php` to split the page in two parts: ``` <!--nextpage--> ``` If there is a different method to add another "tab" to post or the like, I am grateful for any help… I just want to add ...
WordPress already adds classes to the body for you to handle this, as long as your theme correctly uses the body\_class template tag. On the 2nd page of Page, your body will have these additional classes: `paged`, `paged-2` & `page-paged-2`, so you can see that you can make changes to styles to suit: ``` body.page { ...
233,387
<p>I have a function I wrote in my functions.php page for a gallery to display on certain pages. It displays on custom templates, but now I need it to display on index.php Here is the code from my functions.php file:</p> <pre><code>if ( 'templates/awards.php' == $template || 'templates/events.php' == $template ) { ...
[ { "answer_id": 233367, "author": "Michae Pavlos Michael", "author_id": 87826, "author_profile": "https://wordpress.stackexchange.com/users/87826", "pm_score": 0, "selected": false, "text": "<p>If you know the post ID, you can target that specific body with custom CSS. For example, if you...
2016/07/27
[ "https://wordpress.stackexchange.com/questions/233387", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99056/" ]
I have a function I wrote in my functions.php page for a gallery to display on certain pages. It displays on custom templates, but now I need it to display on index.php Here is the code from my functions.php file: ``` if ( 'templates/awards.php' == $template || 'templates/events.php' == $template ) { $meta[] = ar...
WordPress already adds classes to the body for you to handle this, as long as your theme correctly uses the body\_class template tag. On the 2nd page of Page, your body will have these additional classes: `paged`, `paged-2` & `page-paged-2`, so you can see that you can make changes to styles to suit: ``` body.page { ...
233,398
<p>I am following a Wordpress book and am trying to create a plugin and have got an option page showing.</p> <p>In this page I have two text fields (which values are stored in one array). I am trying to add custom validation (for example if empty). The validation is set in the third argument in the register_setting fu...
[ { "answer_id": 233367, "author": "Michae Pavlos Michael", "author_id": 87826, "author_profile": "https://wordpress.stackexchange.com/users/87826", "pm_score": 0, "selected": false, "text": "<p>If you know the post ID, you can target that specific body with custom CSS. For example, if you...
2016/07/27
[ "https://wordpress.stackexchange.com/questions/233398", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40956/" ]
I am following a Wordpress book and am trying to create a plugin and have got an option page showing. In this page I have two text fields (which values are stored in one array). I am trying to add custom validation (for example if empty). The validation is set in the third argument in the register\_setting function. ...
WordPress already adds classes to the body for you to handle this, as long as your theme correctly uses the body\_class template tag. On the 2nd page of Page, your body will have these additional classes: `paged`, `paged-2` & `page-paged-2`, so you can see that you can make changes to styles to suit: ``` body.page { ...
233,402
<p>I am attempting to loop through all sites on my <code>multisite network</code> blog. However, when I attempt to use <code>get_pages</code> it ignores the fact that the blog has switched via <code>switch_to_blog</code>.</p> <pre><code>$sites = wp_get_sites( array( 'limit' =&gt; 1000 ) ); foreach ( $sites as $site ) ...
[ { "answer_id": 233367, "author": "Michae Pavlos Michael", "author_id": 87826, "author_profile": "https://wordpress.stackexchange.com/users/87826", "pm_score": 0, "selected": false, "text": "<p>If you know the post ID, you can target that specific body with custom CSS. For example, if you...
2016/07/27
[ "https://wordpress.stackexchange.com/questions/233402", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83247/" ]
I am attempting to loop through all sites on my `multisite network` blog. However, when I attempt to use `get_pages` it ignores the fact that the blog has switched via `switch_to_blog`. ``` $sites = wp_get_sites( array( 'limit' => 1000 ) ); foreach ( $sites as $site ) { $blog_id = intval( $site['blog_id'] ); i...
WordPress already adds classes to the body for you to handle this, as long as your theme correctly uses the body\_class template tag. On the 2nd page of Page, your body will have these additional classes: `paged`, `paged-2` & `page-paged-2`, so you can see that you can make changes to styles to suit: ``` body.page { ...
233,447
<p>In the admin backend we use a query arg that is left in the URL and keeps getting used whether it is supposed to or not.</p> <p>Our plugin has an array with values that can be toggled via the custom backend page. Against the option that should be toggled there is a link titled 'Activate' or 'Deactivate', pressing t...
[ { "answer_id": 233464, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 0, "selected": false, "text": "<p>If you are using the Settings API for the Save Changes, you are probably using a nonce field with it (if not i...
2016/07/28
[ "https://wordpress.stackexchange.com/questions/233447", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82822/" ]
In the admin backend we use a query arg that is left in the URL and keeps getting used whether it is supposed to or not. Our plugin has an array with values that can be toggled via the custom backend page. Against the option that should be toggled there is a link titled 'Activate' or 'Deactivate', pressing that link r...
This might be useful: there is a filter called [removable\_query\_args](https://developer.wordpress.org/reference/hooks/removable_query_args/). You get an array of argument names to which you can append your own argument. Then WP will take care of removing all of the arguments in the list from the URL. ``` function ad...
233,450
<p>I would like to be able add the same custom colours to the swatches at bottom of colour picker panels that appear in the WYSIWYG editors across the site, to make it easier for clients to keep consistent in their styling.</p> <p>The swatches I refer to are the bottom row in the screenshot.</p> <p>I would like to d...
[ { "answer_id": 233452, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 5, "selected": true, "text": "<p>Click on the <code>Custom...</code> text and the color picker will pop up. Pick the color of your choice and...
2016/07/28
[ "https://wordpress.stackexchange.com/questions/233450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76241/" ]
I would like to be able add the same custom colours to the swatches at bottom of colour picker panels that appear in the WYSIWYG editors across the site, to make it easier for clients to keep consistent in their styling. The swatches I refer to are the bottom row in the screenshot. I would like to do this without ins...
Click on the `Custom...` text and the color picker will pop up. Pick the color of your choice and press `OK`. Chosen color will appear as a custom swatch for later use. **Note!** The solution above is not a solution. See comments and edit below. **Edit:** Here is a function which replaces the entire default palette ...
233,498
<p>I need to turn this code: </p> <pre><code>&lt;?php if ( function_exists( 'echo_ald_crp' ) ) echo_ald_crp(); ?&gt; </code></pre> <p>into a shortcode. Can someone help me do this? I have researched but am just lost to be honest. Thanks!</p>
[ { "answer_id": 233499, "author": "Christine Cooper", "author_id": 24875, "author_profile": "https://wordpress.stackexchange.com/users/24875", "pm_score": 1, "selected": false, "text": "<p>Do you mean something like this (untested):</p>\n\n<pre><code>// function for your shortcode\nfuncti...
2016/07/28
[ "https://wordpress.stackexchange.com/questions/233498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99146/" ]
I need to turn this code: ``` <?php if ( function_exists( 'echo_ald_crp' ) ) echo_ald_crp(); ?> ``` into a shortcode. Can someone help me do this? I have researched but am just lost to be honest. Thanks!
Init your shortcode ``` add_shortcode('shortcode_ald_crp', 'myshortcode_echo_ald_crp'); ``` The function what you want: ``` function myshortcode_echo_ald_crp() { ob_start(); if ( function_exists( 'echo_ald_crp' ) ) echo_ald_crp(); return ob_get_clean(); } ``` you call you shortcode in a post like thi...
233,503
<p>When i use the <strong>"get_template_part();" inside a loop</strong>, does it search for that template file <strong>every cycle</strong> of the loop (each post) <strong>or</strong> does it search for the file <strong>once</strong> and then reuse it every cycle of the loop?</p>
[ { "answer_id": 233499, "author": "Christine Cooper", "author_id": 24875, "author_profile": "https://wordpress.stackexchange.com/users/24875", "pm_score": 1, "selected": false, "text": "<p>Do you mean something like this (untested):</p>\n\n<pre><code>// function for your shortcode\nfuncti...
2016/07/28
[ "https://wordpress.stackexchange.com/questions/233503", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43619/" ]
When i use the **"get\_template\_part();" inside a loop**, does it search for that template file **every cycle** of the loop (each post) **or** does it search for the file **once** and then reuse it every cycle of the loop?
Init your shortcode ``` add_shortcode('shortcode_ald_crp', 'myshortcode_echo_ald_crp'); ``` The function what you want: ``` function myshortcode_echo_ald_crp() { ob_start(); if ( function_exists( 'echo_ald_crp' ) ) echo_ald_crp(); return ob_get_clean(); } ``` you call you shortcode in a post like thi...
233,513
<blockquote> <p>This is a continuing question from <a href="https://wordpress.stackexchange.com/questions/232029/merging-a-complex-query-with-post-rewind-and-splitting-posts-into-two-columns">Merging a complex query with post_rewind and splitting posts into two columns</a></p> </blockquote> <p>Hi, I need help with m...
[ { "answer_id": 233514, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>Run through the loop with % for the left side first, then rewind the loop and start in on the right side. </p>...
2016/07/28
[ "https://wordpress.stackexchange.com/questions/233513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8049/" ]
> > This is a continuing question from [Merging a complex query with post\_rewind and splitting posts into two columns](https://wordpress.stackexchange.com/questions/232029/merging-a-complex-query-with-post-rewind-and-splitting-posts-into-two-columns) > > > Hi, I need help with my loop. What is does is split posts...
You could always try to create 2 arrays of titles, say $left and $right, $odd and $even, or $tom and $jerry, and fill them with the titles during your loop, and print them after the loop has ended like so: Create array ``` $left = $right = array(); ``` Then unleash your loop [edited the below to reflect the comment...
233,515
<p>I think I might be able to parse the URL for the <code>replytocom</code> parameter and get the comment ID from that. However, it would mean that my plugin would not be fully compatible with other plugins that can remove this parameter (most notably <em>Yoast SEO</em>). Plus, it feels a bit hacky. Is there another w...
[ { "answer_id": 233528, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": true, "text": "<p>Here are few ideas:</p>\n\n<ul>\n<li><p>It's possible to inject custom HTML or data attributes via the <a href...
2016/07/28
[ "https://wordpress.stackexchange.com/questions/233515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98026/" ]
I think I might be able to parse the URL for the `replytocom` parameter and get the comment ID from that. However, it would mean that my plugin would not be fully compatible with other plugins that can remove this parameter (most notably *Yoast SEO*). Plus, it feels a bit hacky. Is there another way? Endgoal: I need t...
Here are few ideas: * It's possible to inject custom HTML or data attributes via the [`comment_reply_link`](https://developer.wordpress.org/reference/functions/comment_reply_link/) filter, but I think it would be better to keep it unobtrusive. * One could try to get the comment parent value from the reply comment form...
233,526
<p>I have a problem understanding the behavior of the Attachment Page Permalinks Into Setting-->Permalinks I have set <a href="http://www.example.com/sample-post/" rel="nofollow">http://www.example.com/sample-post/</a> as the preferred setting.</p> <p>When I upload an image a permalink for the Attachment Page is auto...
[ { "answer_id": 233537, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 0, "selected": false, "text": "<p>The \"attachment page\" is just a post type, like \"page\" or \"post\" are.</p>\n\n<p>The slug in the URL for...
2016/07/29
[ "https://wordpress.stackexchange.com/questions/233526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99157/" ]
I have a problem understanding the behavior of the Attachment Page Permalinks Into Setting-->Permalinks I have set <http://www.example.com/sample-post/> as the preferred setting. When I upload an image a permalink for the Attachment Page is automatically created. Example: * I'm into Service (a page) and I upload land...
To provide an answer to your first question and for future reference to tackle the problem you described with the slug already being in use when you first uploaded an attachment to the same parent. The following code will get rid of this 'annoying' thing *(annoying in some use cases)*. This code rewrites the slug of t...
233,533
<p>I have tried searching, and tried a few options, but I'm not able to remove the H1 / title / Underscore for specific pages.</p> <p>I don't want use CSS. I would like to remove it via <code>functions.php</code> or in <code>content.php</code>.</p> <p>I'm not good in PHP, so the Codex didn't help me too much.</p> <p...
[ { "answer_id": 233534, "author": "Devender Narwal", "author_id": 99170, "author_profile": "https://wordpress.stackexchange.com/users/99170", "pm_score": 0, "selected": false, "text": "<p>WordPress has the predefined function <code>is_page()</code>, which looks like this:</p>\n\n<pre><cod...
2016/07/29
[ "https://wordpress.stackexchange.com/questions/233533", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86748/" ]
I have tried searching, and tried a few options, but I'm not able to remove the H1 / title / Underscore for specific pages. I don't want use CSS. I would like to remove it via `functions.php` or in `content.php`. I'm not good in PHP, so the Codex didn't help me too much. I need something like this: ``` if > page sl...
The way I would do this is to create a separate page template that lacks the H1 code, and then manually select that template (in the Page Attributes box on the page editor screen) for each desired page.
233,535
<p>I am creating a Super Admin role in wordpress Roles.</p> <pre><code>$capabilities=array(); add_role('Administrator', 'Administrator', $capabilities ); add_role('Super Admin', 'Super Admin', $capabilities) ); </code></pre> <p>So while adding a new user I got the Role Option Super Admin. So I added a Super User .<...
[ { "answer_id": 233534, "author": "Devender Narwal", "author_id": 99170, "author_profile": "https://wordpress.stackexchange.com/users/99170", "pm_score": 0, "selected": false, "text": "<p>WordPress has the predefined function <code>is_page()</code>, which looks like this:</p>\n\n<pre><cod...
2016/07/29
[ "https://wordpress.stackexchange.com/questions/233535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86281/" ]
I am creating a Super Admin role in wordpress Roles. ``` $capabilities=array(); add_role('Administrator', 'Administrator', $capabilities ); add_role('Super Admin', 'Super Admin', $capabilities) ); ``` So while adding a new user I got the Role Option Super Admin. So I added a Super User . Now When I login to wp-ad...
The way I would do this is to create a separate page template that lacks the H1 code, and then manually select that template (in the Page Attributes box on the page editor screen) for each desired page.
233,543
<p>I know that I can use the following function to remove the version from all <code>.css</code> and <code>.js</code> files:</p> <pre><code>add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 ); add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 ); function sdt_remove_ver_css_js( $src ) { if ...
[ { "answer_id": 233548, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>You can check for the current <em>handle</em> before removing the version. </p>\n\n<p>Here's an example (untes...
2016/07/29
[ "https://wordpress.stackexchange.com/questions/233543", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70882/" ]
I know that I can use the following function to remove the version from all `.css` and `.js` files: ``` add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 ); add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 ); function sdt_remove_ver_css_js( $src ) { if ( strpos( $src, 'ver=' ) ) $...
You can check for the current *handle* before removing the version. Here's an example (untested): ``` add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999, 2 ); add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999, 2 ); function sdt_remove_ver_css_js( $src, $handle ) { $handles_with_version...
233,559
<p>I'm using a function in a custom theme which auto-populates the navigation with all the child pages of each parent. I found the code on <a href="https://wordpress.stackexchange.com/questions/100841/add-child-pages-automatically-to-nav-menu">this site</a></p> <p>This works well but the only thing this function doesn...
[ { "answer_id": 233561, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 0, "selected": false, "text": "<p><code>$items</code> which are passed to this function are already sorted (see <a href=\"https://co...
2016/07/29
[ "https://wordpress.stackexchange.com/questions/233559", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99182/" ]
I'm using a function in a custom theme which auto-populates the navigation with all the child pages of each parent. I found the code on [this site](https://wordpress.stackexchange.com/questions/100841/add-child-pages-automatically-to-nav-menu) This works well but the only thing this function doesn't do for me is order...
I eventually found the fix for anyone who has the same issue: ``` /** * auto_child_page_menu * * class to add top level page menu items all child pages on the fly * @author Ohad Raz <admin@bainternet.info> */ class auto_child_page_menu { /** * class constructor * @author Ohad Raz <...
233,562
<p>By seeing the wordpress core I understand that plugin.php is being loaded way before plugins are loaded. But yet some plugins are loading it again. Any advantage of reloading the plugin.php? </p> <p>And does'nt PHP through errors for including the same file with function definitions?</p>
[ { "answer_id": 233561, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 0, "selected": false, "text": "<p><code>$items</code> which are passed to this function are already sorted (see <a href=\"https://co...
2016/07/29
[ "https://wordpress.stackexchange.com/questions/233562", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64811/" ]
By seeing the wordpress core I understand that plugin.php is being loaded way before plugins are loaded. But yet some plugins are loading it again. Any advantage of reloading the plugin.php? And does'nt PHP through errors for including the same file with function definitions?
I eventually found the fix for anyone who has the same issue: ``` /** * auto_child_page_menu * * class to add top level page menu items all child pages on the fly * @author Ohad Raz <admin@bainternet.info> */ class auto_child_page_menu { /** * class constructor * @author Ohad Raz <...
233,565
<p>I'm not an expert in PHP but would like to customize the pagination of my posts.</p> <p>Instead of having : prev 1, 2, 3, 4, next</p> <p>I would like : Prev 1 of 4 Next</p> <p>It seems I have to modify my single.php file and these lines : </p> <pre><code>&lt;?php wp_link_pages(array('before' =&gt; '&lt;div c...
[ { "answer_id": 233571, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>You could try combining these:</p>\n\n<h2>Buttons</h2>\n\n<pre><code>next_posts_link( 'Prev' );\nprevious_posts_l...
2016/07/29
[ "https://wordpress.stackexchange.com/questions/233565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99193/" ]
I'm not an expert in PHP but would like to customize the pagination of my posts. Instead of having : prev 1, 2, 3, 4, next I would like : Prev 1 of 4 Next It seems I have to modify my single.php file and these lines : ``` <?php wp_link_pages(array('before' => '<div class="pagination">', 'after' => '</div>', 'link_...
You could try combining these: Buttons ------- ``` next_posts_link( 'Prev' ); previous_posts_link( 'Next' ); ``` Current page ------------ ``` echo (get_query_var('paged')) ? get_query_var('paged') : 1; ``` Total pages ----------- ``` wp_count_posts(); ``` In HTML ------- ``` <?php next_posts_link( 'Prev' )...
233,598
<p>I'm not familiar with working outside the loop so forgive me if this question has been asked already. </p> <p>How do I get a featured image of a post that's outside the loop? I did a <code>print_r</code> and I didn't see anything related to a featured image.</p> <p>Any ideas on what to do next?</p> <p><strong>Upd...
[ { "answer_id": 233571, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>You could try combining these:</p>\n\n<h2>Buttons</h2>\n\n<pre><code>next_posts_link( 'Prev' );\nprevious_posts_l...
2016/07/30
[ "https://wordpress.stackexchange.com/questions/233598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8049/" ]
I'm not familiar with working outside the loop so forgive me if this question has been asked already. How do I get a featured image of a post that's outside the loop? I did a `print_r` and I didn't see anything related to a featured image. Any ideas on what to do next? **Update:** I was able to get it working but I...
You could try combining these: Buttons ------- ``` next_posts_link( 'Prev' ); previous_posts_link( 'Next' ); ``` Current page ------------ ``` echo (get_query_var('paged')) ? get_query_var('paged') : 1; ``` Total pages ----------- ``` wp_count_posts(); ``` In HTML ------- ``` <?php next_posts_link( 'Prev' )...
233,612
<p>I have a post with something like this:</p> <pre><code>[code] $foo = &lt;&lt;&lt;EOT .... EOT; [/code] </code></pre> <p>It gets converted to this by <code>do_shortcodes_in_html_tags()</code>:</p> <pre><code>[code] $foo = &lt;&lt;&lt;EOT .... EOT; &amp;#91;/code&amp;#q3; </code></pre> <p>Therefore, the shortc...
[ { "answer_id": 233617, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>A workaround might be:</p>\n\n<pre><code>[code]\n$foo = &amp;lt;&amp;lt;&amp;lt;EOT\n ....\nEOT;\n[/code]\n<...
2016/07/30
[ "https://wordpress.stackexchange.com/questions/233612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23538/" ]
I have a post with something like this: ``` [code] $foo = <<<EOT .... EOT; [/code] ``` It gets converted to this by `do_shortcodes_in_html_tags()`: ``` [code] $foo = <<<EOT .... EOT; &#91;/code&#q3; ``` Therefore, the shortcode doesn't run. Is there a way to make this shortcode work correctly?
A workaround might be: ``` [code] $foo = &lt;&lt;&lt;EOT .... EOT; [/code] ``` where we change `<<<` to `&lt;&lt;&lt;`. We could do this automatically before `do_shortcode` filters the content and then replace it again afterwards. I tested this version: ``` [code] $foo = <<<EOT .... EOT;<!----> [/code] ``` and...
233,616
<p>I have created a page template where I need current page URL</p> <p>I have tried </p> <pre><code>get_site_url(); </code></pre> <p>and</p> <pre><code>get_permalink(); </code></pre> <p>but it shows nothing. </p> <p>Let me know is anything missing in code.</p>
[ { "answer_id": 233618, "author": "Misha Rudrastyh", "author_id": 85985, "author_profile": "https://wordpress.stackexchange.com/users/85985", "pm_score": 3, "selected": true, "text": "<p>if you're using a page template, then if you want to get the current page URL you could try to use thi...
2016/07/30
[ "https://wordpress.stackexchange.com/questions/233616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/95126/" ]
I have created a page template where I need current page URL I have tried ``` get_site_url(); ``` and ``` get_permalink(); ``` but it shows nothing. Let me know is anything missing in code.
if you're using a page template, then if you want to get the current page URL you could try to use this function: ``` get_permalink(); ``` or ``` echo get_permalink(); ``` if you want to print the result
233,667
<p>I want to hide an item from a menu if a user is logged out.</p> <p>I am currently using the below code that achieves this using two separate menus, but to save duplication, I would like to only have to manage one nav menu.</p> <pre><code>function my_wp_nav_menu_args( $args = '' ) { if ( is_user_logged_in() ) ...
[ { "answer_id": 233671, "author": "MD Sultan Nasir Uddin", "author_id": 86834, "author_profile": "https://wordpress.stackexchange.com/users/86834", "pm_score": -1, "selected": true, "text": "<p>Find the class or id of the menu item that you want to hide.\nsuppose the class of that menu is...
2016/07/31
[ "https://wordpress.stackexchange.com/questions/233667", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99257/" ]
I want to hide an item from a menu if a user is logged out. I am currently using the below code that achieves this using two separate menus, but to save duplication, I would like to only have to manage one nav menu. ``` function my_wp_nav_menu_args( $args = '' ) { if ( is_user_logged_in() ) { $args['men...
Find the class or id of the menu item that you want to hide. suppose the class of that menu is `logged-in-menu` Then in header.php file of your theme before closing head tag use the below code ``` <style> <?php if(! is_user_logged_in() ) : ?> .logged-in-menu{ display: none; } <?php endif; ?> </style> ...
233,681
<p>I have a custom post type "book", and a taxonomy "language" with terms "php" , "java" ,"c", "python". I want to count "book" posts not having terms "java" &amp; "c".. such that posts with only "java" or "c" should be counted but posts with both "java" and "c" should not be counted. I tried tax_query of WP_QUERY usin...
[ { "answer_id": 233688, "author": "Luis Sanz", "author_id": 81084, "author_profile": "https://wordpress.stackexchange.com/users/81084", "pm_score": 1, "selected": false, "text": "<p>There is not a <code>NAND</code> operator for the <a href=\"https://codex.wordpress.org/Class_Reference/WP_...
2016/07/31
[ "https://wordpress.stackexchange.com/questions/233681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86197/" ]
I have a custom post type "book", and a taxonomy "language" with terms "php" , "java" ,"c", "python". I want to count "book" posts not having terms "java" & "c".. such that posts with only "java" or "c" should be counted but posts with both "java" and "c" should not be counted. I tried tax\_query of WP\_QUERY using ope...
There is not a `NAND` operator for the [`tax_query` of `WP_Query`](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters). If I understood correctly, what you intend can be rewritten this way: 1. Get all the posts without the term `c`. 2. Get all the posts without the term `java`. 3. Exclude the pos...
233,724
<p>hey i am developing a plugin and i am almost near to close the plugin but i am facing a small problem in displaying the code <code>&lt;?php global $options; $options = get_option('p2h_theme_options'); ?&gt;</code> below the <code>&lt;?php wp_head(); ?&gt;</code> in the header. i tried using echo but no use it is di...
[ { "answer_id": 233688, "author": "Luis Sanz", "author_id": 81084, "author_profile": "https://wordpress.stackexchange.com/users/81084", "pm_score": 1, "selected": false, "text": "<p>There is not a <code>NAND</code> operator for the <a href=\"https://codex.wordpress.org/Class_Reference/WP_...
2016/08/01
[ "https://wordpress.stackexchange.com/questions/233724", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97802/" ]
hey i am developing a plugin and i am almost near to close the plugin but i am facing a small problem in displaying the code `<?php global $options; $options = get_option('p2h_theme_options'); ?>` below the `<?php wp_head(); ?>` in the header. i tried using echo but no use it is displaying in string rather of code. bel...
There is not a `NAND` operator for the [`tax_query` of `WP_Query`](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters). If I understood correctly, what you intend can be rewritten this way: 1. Get all the posts without the term `c`. 2. Get all the posts without the term `java`. 3. Exclude the pos...
233,757
<p>This is a very common issue, but all the answers I read don't relate to what's happening in my case.</p> <p>I'm writing a custom plugin that reads and writes/updates data to a custom database table (it's very simple).</p> <p>However, when an update is made, I wish to redirect to the main page, and then display a s...
[ { "answer_id": 233769, "author": "bosco", "author_id": 25324, "author_profile": "https://wordpress.stackexchange.com/users/25324", "pm_score": 4, "selected": true, "text": "<h2>Background</h2>\n<p>The infamous &quot;<strong>Headers already sent</strong>&quot; error rears it's ugly head i...
2016/08/01
[ "https://wordpress.stackexchange.com/questions/233757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47505/" ]
This is a very common issue, but all the answers I read don't relate to what's happening in my case. I'm writing a custom plugin that reads and writes/updates data to a custom database table (it's very simple). However, when an update is made, I wish to redirect to the main page, and then display a success admin noti...
Background ---------- The infamous "**Headers already sent**" error rears it's ugly head in circumstances where something attempts to modify the HTTP headers for the server's response *after* they have already been dispatched to the browser - that is to say, when the server should only be generating the *body* of the ...
233,760
<p>I'm trying get a list of all parent posts, based on a current taxonomy. It seems to work, but the list is repeating 5 times again. </p> <p>This means, when there should be 3 posts in a list, I get 15 posts. Is there something I did wrong with the loop ?</p> <pre><code> &lt;ul&gt; &lt;?php $terms = get_terms('t...
[ { "answer_id": 233764, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p><code>the_title()</code> is a template tag which relies on global state. Specifically <code>$post</code> global var...
2016/08/01
[ "https://wordpress.stackexchange.com/questions/233760", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99035/" ]
I'm trying get a list of all parent posts, based on a current taxonomy. It seems to work, but the list is repeating 5 times again. This means, when there should be 3 posts in a list, I get 15 posts. Is there something I did wrong with the loop ? ``` <ul> <?php $terms = get_terms('taxonomy-name'); foreach($terms...
`the_title()` is a template tag which relies on global state. Specifically `$post` global variable, holding current post instance. While you *query* a set of posts, you never set up that global state for template tag to use. Though in case you started with `get_posts()` it might be more convenient to leave global sta...
233,765
<p>In the "posts -> all posts" admin page, I would like to search and see only posts with some element in their url (for example, the character "-3" to indicate they are a duplicate post).</p> <p>How can this be done?</p>
[ { "answer_id": 233773, "author": "kovshenin", "author_id": 1316, "author_profile": "https://wordpress.stackexchange.com/users/1316", "pm_score": 1, "selected": false, "text": "<p>You can't really perform that kind of query from the admin UI without explicitly coding it in a theme or plug...
2016/08/01
[ "https://wordpress.stackexchange.com/questions/233765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161/" ]
In the "posts -> all posts" admin page, I would like to search and see only posts with some element in their url (for example, the character "-3" to indicate they are a duplicate post). How can this be done?
Here's one way to support searching for **post slugs** in the backend. Let's invoke this kind of search by the `slug:` string in the search term. **Example** To search for slugs that end in `-2` we want to be able to search for: ``` slug:*-2 ``` where \* is the wildcard. **Demo Plugin** Here's a demo plugin t...
233,780
<p>I am trying to figure out to fire a hook for a custom post type called "bananas" when a new bananas post is published.</p> <p>Requirements:</p> <ul> <li>Can't use $_POST </li> <li>Need to be able to get post statuses so I can prevent code from running again later and check if its already published</li> <li>Need to...
[ { "answer_id": 233785, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 0, "selected": false, "text": "<p>Have you checked <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post\" rel=\"n...
2016/08/01
[ "https://wordpress.stackexchange.com/questions/233780", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49017/" ]
I am trying to figure out to fire a hook for a custom post type called "bananas" when a new bananas post is published. Requirements: * Can't use $\_POST * Need to be able to get post statuses so I can prevent code from running again later and check if its already published * Need to be able to get\_post\_meta The ac...
The following worked for me. I hooked my meta saving and retrieving to the same action (post\_transition\_status), but with different priorities. ``` //Save Your Custom Meta Meta, but hook it to transition_post_status instead of save_post, with a priority of 1 function save_yourpost_meta(){ global $post; if($p...
233,793
<p>i'm currently using this code to display a custom tag:</p> <pre><code>&lt;?php echo get_the_term_list( $post-&gt;ID, 'region', 'Region: ', ', ', '&lt;br&gt;' ); ?&gt; </code></pre> <p>The output of this looks like this:</p> <pre><code>Region: USA </code></pre> <p>What i want to do is display a flag instead of th...
[ { "answer_id": 233797, "author": "Nate Allen", "author_id": 32698, "author_profile": "https://wordpress.stackexchange.com/users/32698", "pm_score": 3, "selected": true, "text": "<p>A clean and semantic way to do it would be with CSS.</p>\n\n<p>First, the PHP:</p>\n\n<pre><code>&lt;div cl...
2016/08/02
[ "https://wordpress.stackexchange.com/questions/233793", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77283/" ]
i'm currently using this code to display a custom tag: ``` <?php echo get_the_term_list( $post->ID, 'region', 'Region: ', ', ', '<br>' ); ?> ``` The output of this looks like this: ``` Region: USA ``` What i want to do is display a flag instead of the words USA, EUR, JPN, etc like so: Region: [![enter image desc...
A clean and semantic way to do it would be with CSS. First, the PHP: ``` <div class="entry-meta"> <span class="term-links"> <?php foreach ( get_the_terms( $post->ID, 'region') as $term ) : ?> <a href="<?php echo esc_url( get_term_link( $term->term_id ) ) ?>">Region: <span class="<?php echo $te...
233,841
<p>So I have a Custom Post Type with some Custom Taxonomies.</p> <p>On the <code>archive</code> page where I list all the Custom Post Types I have an refine search in the sidebar which allows you to tick a Taxonomy Term and then search for Post Types with that Term. (Image Below)</p> <p><a href="https://i.stack.imgur...
[ { "answer_id": 233871, "author": "Newtype", "author_id": 99352, "author_profile": "https://wordpress.stackexchange.com/users/99352", "pm_score": 1, "selected": false, "text": "<p>I have solved this. I just needed to add a title to the custom link in the options BEFORE adding it to the me...
2016/08/02
[ "https://wordpress.stackexchange.com/questions/233841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85776/" ]
So I have a Custom Post Type with some Custom Taxonomies. On the `archive` page where I list all the Custom Post Types I have an refine search in the sidebar which allows you to tick a Taxonomy Term and then search for Post Types with that Term. (Image Below) [![Redefine Search](https://i.stack.imgur.com/BIe6p.png)](...
I have solved this. I just needed to add a title to the custom link in the options BEFORE adding it to the menu. How stupid is that?
233,878
<p>I'm trying to count the number of live comments on each post. I would like to extract them on a custom page like <code>http://example.com/count.php</code> and have them output like this:</p> <pre><code>http://example.com/the-post-url-with-3-comments/ 3 http://example.com/the-post-url-with-no-comments/ 0 http:/...
[ { "answer_id": 233859, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>It is totally essential to use <code>utf8mb4</code> for your site to be secure and bug free in all wordpr...
2016/08/02
[ "https://wordpress.stackexchange.com/questions/233878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99382/" ]
I'm trying to count the number of live comments on each post. I would like to extract them on a custom page like `http://example.com/count.php` and have them output like this: ``` http://example.com/the-post-url-with-3-comments/ 3 http://example.com/the-post-url-with-no-comments/ 0 http://example.com/the-post-url...
It is totally essential to use `utf8mb4` for your site to be secure and bug free in all wordpress versions since 4.2 and probably before that. You need to upgrade your mysql software to a newer version, or change whatever is need in its configuration to support it.
233,886
<p>I am making a Wordpress theme with a custom admin page. What I did to make it save the settings was this:</p> <pre><code>&lt;form method="post" action="options.php"&gt; </code></pre> <p>When I hit the submit button, I got an error message saying that "options.php" was not found. I attempted to change the general ...
[ { "answer_id": 233896, "author": "Shrikant D", "author_id": 74746, "author_profile": "https://wordpress.stackexchange.com/users/74746", "pm_score": 0, "selected": false, "text": "<p>Replace your form code as:</p>\n\n<p><code>&lt;form name=\"form1\" method=\"POST\" action=\"options.php\"&...
2016/08/03
[ "https://wordpress.stackexchange.com/questions/233886", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99390/" ]
I am making a Wordpress theme with a custom admin page. What I did to make it save the settings was this: ``` <form method="post" action="options.php"> ``` When I hit the submit button, I got an error message saying that "options.php" was not found. I attempted to change the general settings and it worked. It was j...
Like @LupuAndrei said, we lack of details, especially the code where you call you form from. But I suspect, again like @LupuAndrei said, you might not be calling the `settings_fields`, `do_settings_fields` or `do_settings_sections` correctly. On the function where you build your form, try something like this ``` <fo...
233,900
<p>I am in the process of adding an additional column to the Users admin screen to display the company for each user. I have been successful in getting this column to show in the table, but I am really struggling with making it sortable alphabetically.</p> <p>The column header does seem to be activated as sortable, bu...
[ { "answer_id": 233918, "author": "mmm", "author_id": 74311, "author_profile": "https://wordpress.stackexchange.com/users/74311", "pm_score": 2, "selected": false, "text": "<p>the action <code>request</code> works with post. for user it's <code>pre_get_users</code> : </p>\n\n<pre><code>ad...
2016/08/03
[ "https://wordpress.stackexchange.com/questions/233900", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91798/" ]
I am in the process of adding an additional column to the Users admin screen to display the company for each user. I have been successful in getting this column to show in the table, but I am really struggling with making it sortable alphabetically. The column header does seem to be activated as sortable, but if i cli...
This is my code which adds a sortable custom column (called **Vendor ID**) to the users table: ``` function fc_new_modify_user_table( $column ) { $column['vendor_id'] = 'Vendor ID'; return $column; } add_filter( 'manage_users_columns', 'fc_new_modify_user_table' ); function fc_new_modify_user_table_row( $val,...
233,903
<p>When I run &quot;themes check&quot; , it recommends not to use CDN. I am using Bootstrap CDN this way</p> <pre><code>function underscore_bootstrap_wp_scripts() { /* bootstrap and font awesome and animate css */ wp_enqueue_style( 'bootstrap_cdn', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min....
[ { "answer_id": 233913, "author": "daniyalahmad", "author_id": 69626, "author_profile": "https://wordpress.stackexchange.com/users/69626", "pm_score": 4, "selected": true, "text": "<p>Your theme should not depends on any external link library. There is no guarantee when that library can b...
2016/08/03
[ "https://wordpress.stackexchange.com/questions/233903", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98256/" ]
When I run "themes check" , it recommends not to use CDN. I am using Bootstrap CDN this way ``` function underscore_bootstrap_wp_scripts() { /* bootstrap and font awesome and animate css */ wp_enqueue_style( 'bootstrap_cdn', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' ); wp_enqueue_styl...
Your theme should not depends on any external link library. There is no guarantee when that library can be taken down. That's the reason all of your theme assets should be package with theme, to prevent the future risk.
235,031
<p>I'm searching for a way to display the current taxonomy slug in a post.</p> <p>Edited to make it more clearer here a more accurate example.</p> <p>I have the CPT activites. I have more than 200 article posts about activities, and I want to categorize these into different areas (taxonomy) and different kind of acti...
[ { "answer_id": 233945, "author": "Nicole", "author_id": 99424, "author_profile": "https://wordpress.stackexchange.com/users/99424", "pm_score": 0, "selected": false, "text": "<p>Rather than going an integrated plugin route, in my opinion, it'd be easier to just modify your robots.txt to ...
2016/08/04
[ "https://wordpress.stackexchange.com/questions/235031", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99035/" ]
I'm searching for a way to display the current taxonomy slug in a post. Edited to make it more clearer here a more accurate example. I have the CPT activites. I have more than 200 article posts about activities, and I want to categorize these into different areas (taxonomy) and different kind of activites. To get mor...
> > Each one creates an HTML sitemap of the Magento store without any reference to blog or posts whatsoever. > > > I think you are misunderstanding what is happening here. XML plugins for WP would not go and create arbitrary HTML sitemap. That's just not what they are meant to do. Since you have two different thi...
235,039
<p>I'm building a site with two separate CPTs <code>nominees</code> and <code>winners</code></p> <p>The idea is that we have a user submit a nomination in one of 7 categories ( <code>taxonomy</code> ) on the front end, and editors go in and approve nominations for display on the website.</p> <p>Once every quarter, a ...
[ { "answer_id": 235054, "author": "Armstrongest", "author_id": 37479, "author_profile": "https://wordpress.stackexchange.com/users/37479", "pm_score": 0, "selected": false, "text": "<p>Someone else posted a link to <a href=\"https://wordpress.org/support/view/plugin-reviews/post-type-swit...
2016/08/04
[ "https://wordpress.stackexchange.com/questions/235039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37479/" ]
I'm building a site with two separate CPTs `nominees` and `winners` The idea is that we have a user submit a nomination in one of 7 categories ( `taxonomy` ) on the front end, and editors go in and approve nominations for display on the website. Once every quarter, a selection of 7 nominees ( one from each category )...
You can update a posts type using `wp_update_post`: ``` $my_post = array( 'ID' => $post_id, 'post_type' => 'winner', ); $result = wp_update_post( $my_post, true ); // check if it failed and tell the user why if ( is_wp_error( $result ) ) { $errors = $result->get_error_messages(); foreach ( $err...
235,057
<p>how to check if the post id has a new comment? </p> <p>this is something goes on my mind</p> <pre><code>if (hasnewcomment(post-&gt;id)){ //echo something } </code></pre> <p>any suggestion or help will do. using get the total comment or anything</p> <p>please help</p> <p>thankyou</p>
[ { "answer_id": 235054, "author": "Armstrongest", "author_id": 37479, "author_profile": "https://wordpress.stackexchange.com/users/37479", "pm_score": 0, "selected": false, "text": "<p>Someone else posted a link to <a href=\"https://wordpress.org/support/view/plugin-reviews/post-type-swit...
2016/08/04
[ "https://wordpress.stackexchange.com/questions/235057", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
how to check if the post id has a new comment? this is something goes on my mind ``` if (hasnewcomment(post->id)){ //echo something } ``` any suggestion or help will do. using get the total comment or anything please help thankyou
You can update a posts type using `wp_update_post`: ``` $my_post = array( 'ID' => $post_id, 'post_type' => 'winner', ); $result = wp_update_post( $my_post, true ); // check if it failed and tell the user why if ( is_wp_error( $result ) ) { $errors = $result->get_error_messages(); foreach ( $err...
235,071
<p>I have a custom post type that I want to use an if/elseif/else statement with. If post count of post type is equal to 1 do X, elseif post count is greater than 1 do Y, else do Z.</p> <p>This is the code I've come up with so far, but when I add in the count post type the_content and the_title start to pull in normal...
[ { "answer_id": 235073, "author": "Annapurna", "author_id": 98322, "author_profile": "https://wordpress.stackexchange.com/users/98322", "pm_score": 1, "selected": false, "text": "<p>Can you just print_r( $loop ) &amp; print_r( $count_posts ) and see what the output is.</p>\n" }, { ...
2016/08/05
[ "https://wordpress.stackexchange.com/questions/235071", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62370/" ]
I have a custom post type that I want to use an if/elseif/else statement with. If post count of post type is equal to 1 do X, elseif post count is greater than 1 do Y, else do Z. This is the code I've come up with so far, but when I add in the count post type the\_content and the\_title start to pull in normal pages, ...
`WP_Query` provides some useful properties. There are two of them which you could use: * `$post_count` - The number of posts being displayed (if you not pass `posts_per_page` argument to WP\_Query construct it will return at most 5 posts) * `$found_posts` - The total number of posts found matching the current query pa...
235,087
<p>I would like the create a link that point to the comment part. So when reader click on my link, it will scroll down to the place that they can leave a reply. </p> <p>I have read some tutorial which teach how to create tag #id for headings in a post. However, I don't know how to do this for the comment part.</p> <p...
[ { "answer_id": 235089, "author": "Stephen", "author_id": 85776, "author_profile": "https://wordpress.stackexchange.com/users/85776", "pm_score": 4, "selected": true, "text": "<p>The code below should be something similar to what you're looking for</p>\n\n<p>Inside the <code>loop template...
2016/08/05
[ "https://wordpress.stackexchange.com/questions/235087", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83156/" ]
I would like the create a link that point to the comment part. So when reader click on my link, it will scroll down to the place that they can leave a reply. I have read some tutorial which teach how to create tag #id for headings in a post. However, I don't know how to do this for the comment part. Please help! Tha...
The code below should be something similar to what you're looking for Inside the `loop template` you use for listing blogs (like `index.php`) you need something like this ``` <a href="<?php the_permalink(); ?>/#respond"> <!-- The blog permalink with the anchor ID after --> <i class="fa fa-comments-o"></i> Leave a...
235,088
<p>I have a custom post type called Portfolio. It is associated with three custom taxonomies. This is all working fine.</p> <p>For the archive page, however, I need to add a few custom settings. Due to a limitation in the project, I can't write a plugin—all changes have to be done in the theme.</p> <p>I've got the se...
[ { "answer_id": 235093, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 0, "selected": false, "text": "<p>This should do the trick. Change</p>\n\n<pre><code>function rushhour_projects_archive_save_options...
2016/08/05
[ "https://wordpress.stackexchange.com/questions/235088", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83386/" ]
I have a custom post type called Portfolio. It is associated with three custom taxonomies. This is all working fine. For the archive page, however, I need to add a few custom settings. Due to a limitation in the project, I can't write a plugin—all changes have to be done in the theme. I've got the settings sub menu p...
Ok, so I got annoyed with it not working and decided to just rewrite it. I'm not *sure* what the solution was, but I suspect two things: the wrong endpoint for the form (should be *options.php*) and the wrong `$option_group` and `$option_name` (they were probably not matched correctly). For posterity, I'll leave my re...
235,103
<p>Currently I'm using the the_excerpt on my frontpage which works perfectly. When the visiter goes to the post it first needs to read the first part of the story, see a featured image and then load the rest of the content.</p> <p>Currently I have this:</p> <pre><code>&lt;?php the_excerpt(); ?&gt; &lt;?php the_post_t...
[ { "answer_id": 235105, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 2, "selected": true, "text": "<p>You could do this without having to code anything special. Enter your first piece of text into th...
2016/08/05
[ "https://wordpress.stackexchange.com/questions/235103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20548/" ]
Currently I'm using the the\_excerpt on my frontpage which works perfectly. When the visiter goes to the post it first needs to read the first part of the story, see a featured image and then load the rest of the content. Currently I have this: ``` <?php the_excerpt(); ?> <?php the_post_thumbnail( 'blog-full', array(...
You could do this without having to code anything special. Enter your first piece of text into the Excerpt field in the admin edit screen for the post. Enter only the remaining text into the visual editor. That way you can have the excerpt text on the site's front page and the "rest" of the text after the thumbnail o...
235,120
<p>I created an external script to import json data into a custom post type that uses wp-load.php. Everything works fine but after every update I get the message </p> <pre><code>Notice: map_meta_cap was called incorrectly. The post type EXAMPLE is not registered, so it may not be reliable to check the capability "edit...
[ { "answer_id": 310409, "author": "Bjorn", "author_id": 83707, "author_profile": "https://wordpress.stackexchange.com/users/83707", "pm_score": 1, "selected": false, "text": "<p>Today i got exactly the same behaviour when adding a custom post type. I also noticed some admin post search to...
2016/08/05
[ "https://wordpress.stackexchange.com/questions/235120", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47348/" ]
I created an external script to import json data into a custom post type that uses wp-load.php. Everything works fine but after every update I get the message ``` Notice: map_meta_cap was called incorrectly. The post type EXAMPLE is not registered, so it may not be reliable to check the capability "edit_post" against...
Today i got exactly the same behaviour when adding a custom post type. I also noticed some admin post search tools stopped working. My debug\_log showed exactly the same notice. The problem turned out to be some text before the `<?php` opening tag (top file) were I register the CPT. Example ``` some text here<?php...
235,135
<p>So on this Custom Post Type list page there is a list of Properties.</p> <p>I have a custom search feature where they can search for Properties with certain Taxonomy Terms - but they can also search for Multiple Taxonomy Terms.</p> <p><strong>Question</strong>: If someone selects 2 terms then the only Properties t...
[ { "answer_id": 235283, "author": "Nefro", "author_id": 86801, "author_profile": "https://wordpress.stackexchange.com/users/86801", "pm_score": 1, "selected": false, "text": "<p>Try change operator to <code>'operator' =&gt; 'IN'</code>, or try use code something like this:</p>\n\n<pre><c...
2016/08/05
[ "https://wordpress.stackexchange.com/questions/235135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85776/" ]
So on this Custom Post Type list page there is a list of Properties. I have a custom search feature where they can search for Properties with certain Taxonomy Terms - but they can also search for Multiple Taxonomy Terms. **Question**: If someone selects 2 terms then the only Properties that should display in the list...
**Query Arguments:** If `$input_terms` is the input array of term slugs, then you should be able to use (if I understand the question correctly): ``` $property = [ 'post_type' => 'properties', 'paged' => $paged, 'tax_query' => [ [ 'taxonomy' => 'features', ...
235,165
<p>I want to add thumbnail to WordPress default recent posts widget, and I want to do it using any available filter. Is there any filter know to this subject/topic</p>
[ { "answer_id": 235166, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<p>Here's one way to do it through the <code>the_title</code> filter. We can limit the scope to the <em>Recent P...
2016/08/06
[ "https://wordpress.stackexchange.com/questions/235165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100562/" ]
I want to add thumbnail to WordPress default recent posts widget, and I want to do it using any available filter. Is there any filter know to this subject/topic
Here's one way to do it through the `the_title` filter. We can limit the scope to the *Recent Posts* widget, by initialize it within the `widget_posts_args` filter and then remove it again after the loop. ``` /** * Recent Posts Widget: Append Thumbs */ add_filter( 'widget_posts_args', function( array $args ) { ...
235,200
<p>I understand Wordpress concept "primary category", but <strong>I do not understand how to fetch the name of the highest category in the hierarchy</strong> for a specific post?</p> <p>Having this code:</p> <pre><code>$category_obj = get_the_category( $post_id ); $category_name = $category_obj[0]-&gt;cat_name; ...
[ { "answer_id": 235202, "author": "bestprogrammerintheworld", "author_id": 38848, "author_profile": "https://wordpress.stackexchange.com/users/38848", "pm_score": 0, "selected": false, "text": "<p>I figured this out. I couldn't find any core functionaliy for this in Wordpress, but to retr...
2016/08/07
[ "https://wordpress.stackexchange.com/questions/235200", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38848/" ]
I understand Wordpress concept "primary category", but **I do not understand how to fetch the name of the highest category in the hierarchy** for a specific post? Having this code: ``` $category_obj = get_the_category( $post_id ); $category_name = $category_obj[0]->cat_name; ``` would fetch the c...
Another idea (which heavily depends on what you are viewing [single or archive] and also your taxonomy-structure) is to look for the term parent. Maybe this can help you aswell ... You were asking about "highest category in the hierarchy for a specific post". Example: A post is associated with **3 terms** of an t...
235,227
<p>I'm kinda stuck. I want to show 3 sections on an author page. Section one shows all uploaded images by author based on tag Tattoo. Section two shows all uploaded images by author based on tag Piercing. Section three shows all uploaded images by author based on tag Modification. So far so good. This is the code I'm u...
[ { "answer_id": 235229, "author": "guido", "author_id": 98339, "author_profile": "https://wordpress.stackexchange.com/users/98339", "pm_score": 3, "selected": true, "text": "<p>You can use the function <a href=\"https://codex.wordpress.org/Function_Reference/wp_list_pluck\" rel=\"nofollow...
2016/08/07
[ "https://wordpress.stackexchange.com/questions/235227", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9442/" ]
I'm kinda stuck. I want to show 3 sections on an author page. Section one shows all uploaded images by author based on tag Tattoo. Section two shows all uploaded images by author based on tag Piercing. Section three shows all uploaded images by author based on tag Modification. So far so good. This is the code I'm usin...
You can use the function [wp\_list\_pluck](https://codex.wordpress.org/Function_Reference/wp_list_pluck) to get the ID of the posts retrieved from the query. Just move the query before the h2 element and get the posts ID's: ``` // Set a bool to know if at least one post has post thumbnail. $has_thumb = false; $firs...
235,241
<p>Code:</p> <pre><code>&lt;?php do_action('post_footer'); ?&gt; </code></pre> <p><a href="https://developer.wordpress.org/reference/functions/do_action/" rel="nofollow">Based on some reading</a>, this appears to call a hook action. So, I went through all of the PHP files in the <code>Editor</code> and I don't find ...
[ { "answer_id": 235248, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 0, "selected": false, "text": "<p>Anywhere within the code that WordPress runs to generate a page, <code>do_action()</code> and <co...
2016/08/07
[ "https://wordpress.stackexchange.com/questions/235241", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100605/" ]
Code: ``` <?php do_action('post_footer'); ?> ``` [Based on some reading](https://developer.wordpress.org/reference/functions/do_action/), this appears to call a hook action. So, I went through all of the PHP files in the `Editor` and I don't find `post_footer` anywhere. I also noticed it call these hooks elsewhere, ...
Hooks/actions are better thought of as events. When you run this code: ``` add_action( 'post_footer', 'toms_footer_stuff' ); ``` You're saying that when the `post_footer` event happens, run the `toms_footer_stuff` function. These functions take the form of: ``` add_action( name_of_action, php_callable ); ``` A ...
235,245
<p>I am trying to have multiple separate style sheets load for each page (page specific) for a WordPress website. I am converting an HTML website to a WordPress website for a client. For example; <code>home.css</code> &amp; <code>consol.css</code> for the home page (<code>home.php</code>) and <code>pricing-hours.css</c...
[ { "answer_id": 235248, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 0, "selected": false, "text": "<p>Anywhere within the code that WordPress runs to generate a page, <code>do_action()</code> and <co...
2016/08/07
[ "https://wordpress.stackexchange.com/questions/235245", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100619/" ]
I am trying to have multiple separate style sheets load for each page (page specific) for a WordPress website. I am converting an HTML website to a WordPress website for a client. For example; `home.css` & `consol.css` for the home page (`home.php`) and `pricing-hours.css` & `consoltwo.css` for `pricing-hours.php`. I a...
Hooks/actions are better thought of as events. When you run this code: ``` add_action( 'post_footer', 'toms_footer_stuff' ); ``` You're saying that when the `post_footer` event happens, run the `toms_footer_stuff` function. These functions take the form of: ``` add_action( name_of_action, php_callable ); ``` A ...
235,277
<p>I'm using a Custom Theme to re-design our website. However, I'm getting an issue where the Menu jumps around and shows all links, before quickly collapsing them under the parent options, in the menu. </p> <p>Here is the staging site: <a href="http://volocommerce.staging.wpengine.com/" rel="nofollow noreferrer">htt...
[ { "answer_id": 235248, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 0, "selected": false, "text": "<p>Anywhere within the code that WordPress runs to generate a page, <code>do_action()</code> and <co...
2016/08/08
[ "https://wordpress.stackexchange.com/questions/235277", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94390/" ]
I'm using a Custom Theme to re-design our website. However, I'm getting an issue where the Menu jumps around and shows all links, before quickly collapsing them under the parent options, in the menu. Here is the staging site: <http://volocommerce.staging.wpengine.com/> However, this is the code I'm using: ``` ...
Hooks/actions are better thought of as events. When you run this code: ``` add_action( 'post_footer', 'toms_footer_stuff' ); ``` You're saying that when the `post_footer` event happens, run the `toms_footer_stuff` function. These functions take the form of: ``` add_action( name_of_action, php_callable ); ``` A ...
235,288
<p>There are quite a few threads going on regarding this but they all seem to say the same thing (which I tried) but I keep getting a redirect loop. I already tried changing the WordPress Address (URL) and Site Address (URL) in the General settings (my admin panel is already on https)</p> <p>My .htaccess looks like:</...
[ { "answer_id": 235302, "author": "Tejas Dixit", "author_id": 80791, "author_profile": "https://wordpress.stackexchange.com/users/80791", "pm_score": -1, "selected": false, "text": "<p>Can you try this?</p>\n\n<pre>\n# BEGIN WordPress\n\nRewriteEngine On\n\n# start https redirect\nRewrite...
2016/08/08
[ "https://wordpress.stackexchange.com/questions/235288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98525/" ]
There are quite a few threads going on regarding this but they all seem to say the same thing (which I tried) but I keep getting a redirect loop. I already tried changing the WordPress Address (URL) and Site Address (URL) in the General settings (my admin panel is already on https) My .htaccess looks like: ``` # BEGI...
I'd steer clear on editing the `.htaccess` if you're just updating your website from HTTP to HTTPS. Try an alternative route: First, revert your `.htaccess` back to the default settings: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_...
235,298
<p>I have a search page where if the main search returns 0 results then the following query will be used.</p> <p>The code is </p> <pre><code>$num_res = $wp_query-&gt;post_count; $get_search_term = get_search_query(); if($num_res == 0) { $args = array( 'post_type' =&gt; 'resources', 'meta_key...
[ { "answer_id": 235302, "author": "Tejas Dixit", "author_id": 80791, "author_profile": "https://wordpress.stackexchange.com/users/80791", "pm_score": -1, "selected": false, "text": "<p>Can you try this?</p>\n\n<pre>\n# BEGIN WordPress\n\nRewriteEngine On\n\n# start https redirect\nRewrite...
2016/08/02
[ "https://wordpress.stackexchange.com/questions/235298", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96815/" ]
I have a search page where if the main search returns 0 results then the following query will be used. The code is ``` $num_res = $wp_query->post_count; $get_search_term = get_search_query(); if($num_res == 0) { $args = array( 'post_type' => 'resources', 'meta_key' => 'resource_txt', ...
I'd steer clear on editing the `.htaccess` if you're just updating your website from HTTP to HTTPS. Try an alternative route: First, revert your `.htaccess` back to the default settings: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_...
235,331
<p>I installed BuddyPress which created additional user roles but even after deleting BuddyPress those roles are still there. How can I delete these roles? I have tried the <code>remove_role()</code> command but it did not work.</p>
[ { "answer_id": 235339, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 3, "selected": true, "text": "<pre><code>$wp_roles = new WP_Roles(); // create new role object\n$wp_roles-&gt;remove_role('name_of_role');\n<...
2016/08/08
[ "https://wordpress.stackexchange.com/questions/235331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100572/" ]
I installed BuddyPress which created additional user roles but even after deleting BuddyPress those roles are still there. How can I delete these roles? I have tried the `remove_role()` command but it did not work.
``` $wp_roles = new WP_Roles(); // create new role object $wp_roles->remove_role('name_of_role'); ``` If you need to check the **name\_of\_role** use ``` $wp_roles->get_names(); ``` you will get an array of **name\_of\_role** => **Nicename of Role** Alternatively, you could use the global object **$wp\_roles** ...
235,349
<p>I need a way not to load the comments form when previewing a post, is there a way to achieve this? How?</p> <p>If you need a reason to help: I use disqus and it generates a url for the "discussion" the first time the comment form loads, if this is the preview then it will look something like site.com/?post_type=foo...
[ { "answer_id": 235353, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 3, "selected": true, "text": "<p>I took a quick peek at the disqus plugin. This works in disabling the option before the plugin decides to pr...
2016/08/08
[ "https://wordpress.stackexchange.com/questions/235349", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77283/" ]
I need a way not to load the comments form when previewing a post, is there a way to achieve this? How? If you need a reason to help: I use disqus and it generates a url for the "discussion" the first time the comment form loads, if this is the preview then it will look something like site.com/?post\_type=food&p=41009...
I took a quick peek at the disqus plugin. This works in disabling the option before the plugin decides to print out the form. ``` add_filter( 'pre_option_disqus_active', 'wpse_conditional_disqus_load' ); function wpse_conditional_disqus_load( $disqus_active ) { if( is_preview() ){ return '0'; } return $dis...
235,368
<p>Ok so I have this code to Query posts from a certain ID: </p> <pre><code> &lt;?php $valid_post_types = array ('agencies','pro-awards-winners','marcawards','topshops'); $args = array( 'post_type' =&gt; $valid_post_types, 'post_status' =&gt; 'publish', 'pagename' =&gt; 210639, ...
[ { "answer_id": 235353, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 3, "selected": true, "text": "<p>I took a quick peek at the disqus plugin. This works in disabling the option before the plugin decides to pr...
2016/08/08
[ "https://wordpress.stackexchange.com/questions/235368", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99056/" ]
Ok so I have this code to Query posts from a certain ID: ``` <?php $valid_post_types = array ('agencies','pro-awards-winners','marcawards','topshops'); $args = array( 'post_type' => $valid_post_types, 'post_status' => 'publish', 'pagename' => 210639, 'posts_per_page' => -1 ...
I took a quick peek at the disqus plugin. This works in disabling the option before the plugin decides to print out the form. ``` add_filter( 'pre_option_disqus_active', 'wpse_conditional_disqus_load' ); function wpse_conditional_disqus_load( $disqus_active ) { if( is_preview() ){ return '0'; } return $dis...
235,379
<p>Got stuck trying to remove the post format slug, so i could have i.e. example.com/video for the video section instead of example.com/type/video.</p> <p>Usually it's done like this:</p> <pre><code>add_action( 'init', 'custom_format_permalinks', 1 ); function custom_format_permalinks() { $taxonomy = 'post_format'...
[ { "answer_id": 235620, "author": "David", "author_id": 31323, "author_profile": "https://wordpress.stackexchange.com/users/31323", "pm_score": 2, "selected": false, "text": "<p>In your last code example, you're returning a wrong type for the <code>post_format_rewrite_base</code>. It shou...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235379", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70333/" ]
Got stuck trying to remove the post format slug, so i could have i.e. example.com/video for the video section instead of example.com/type/video. Usually it's done like this: ``` add_action( 'init', 'custom_format_permalinks', 1 ); function custom_format_permalinks() { $taxonomy = 'post_format'; $post_format_rew...
Excellent answer above, well worth the bounty. For the record, this is what it led to: ``` add_filter( 'post_format_rewrite_rules', 'no_format_base_rewrite_rules' ); function no_format_base_rewrite_rules( $format_rewrite ) { $format_rewrite = array(); $formats = get_post_format_slugs(); foreach($formats...
235,406
<p>I have written a plugin in which you have a small chat icon in the bottom right corner, however I want the user to be able to choose an image as the icon from the <code>Media Library</code>. How can I do this with the Wordpress API? The image is a setting in the plugin (only changable by the admin)</p>
[ { "answer_id": 235977, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>Since you want the icon to be different for every user, you will have to store the image in the user profile. Th...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235406", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99302/" ]
I have written a plugin in which you have a small chat icon in the bottom right corner, however I want the user to be able to choose an image as the icon from the `Media Library`. How can I do this with the Wordpress API? The image is a setting in the plugin (only changable by the admin)
You should use `wp.media` to use the WordPress Media Manager dialog. First, you need to enqueue the scritps: ``` // As you are dealing with plugin settings, // I assume you are in admin side add_action( 'admin_enqueue_scripts', 'load_wp_media_files' ); function load_wp_media_files( $page ) { // change to the $page ...
235,411
<p>I know how to add a custom field to WP register form via register_form hook. But this adds the new field at the end of the form. How would I go about moving this field at the beginning of the form? </p> <p>Example:</p> <pre><code>function mytheme_register_form() { $first_name = ( ! empty( $_POST['first_name']...
[ { "answer_id": 235413, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 2, "selected": true, "text": "<p>You can't, because of <code>wp-login.php</code> structure. Here is code with <code>register_form</c...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65585/" ]
I know how to add a custom field to WP register form via register\_form hook. But this adds the new field at the end of the form. How would I go about moving this field at the beginning of the form? Example: ``` function mytheme_register_form() { $first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST[...
You can't, because of `wp-login.php` structure. Here is code with `register_form` hook: ``` <form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate"> <p> <label for="user_login"><?php _e('Us...
235,419
<p>I am a new WordPress developer and I want to build a custom interval for a function. </p> <p>I have seen how to execute a script every one or five minutes, but I do not understand how an interval is calculated.</p>
[ { "answer_id": 235420, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 2, "selected": false, "text": "<p>Unfortunately, you cannot run script on every 12 December. WP Cron can be only defined as interval...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100701/" ]
I am a new WordPress developer and I want to build a custom interval for a function. I have seen how to execute a script every one or five minutes, but I do not understand how an interval is calculated.
Unfortunately, you cannot run script on every 12 December. WP Cron can be only defined as interval from first execution of script, so you have to execute script on 12 December with one year interval to do exactly what you want. I will suggest you to create WP Cron job with daily interval and check in script if today i...
235,426
<p>I have this error coming up on my wp_debug log file: [09-Aug-2016 11:05:05 UTC] PHP Warning: Invalid argument supplied for foreach() in ...wp-content/themes/mytheme/custom-post-types/cpts.php on line 23</p> <p>I cannot seem to see why this would give that that error...</p> <p>The code in question is as follows <...
[ { "answer_id": 235428, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 2, "selected": true, "text": "<p>Theme files are included by functions so you also need to declare <code>global $cpts</code> where ...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235426", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100706/" ]
I have this error coming up on my wp\_debug log file: [09-Aug-2016 11:05:05 UTC] PHP Warning: Invalid argument supplied for foreach() in ...wp-content/themes/mytheme/custom-post-types/cpts.php on line 23 I cannot seem to see why this would give that that error... The code in question is as follows ``` $cpts = arra...
Theme files are included by functions so you also need to declare `global $cpts` where you assign it. It won't be global automatically.
235,438
<p>This is probably a typical Dutch issue where you have a last name which can contain multiple words. For example Robin van Persie or Mark de Jong.</p> <p>Currently I have a list of users ordered by last name, which is the default for <code>get_users</code>. This works fine most of the time but fails when a user has ...
[ { "answer_id": 235439, "author": "Florian", "author_id": 10595, "author_profile": "https://wordpress.stackexchange.com/users/10595", "pm_score": 0, "selected": false, "text": "<p>I am guessing that your real question is \"How can I achieve this result?\".</p>\n\n<p>I would get all users,...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235438", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28103/" ]
This is probably a typical Dutch issue where you have a last name which can contain multiple words. For example Robin van Persie or Mark de Jong. Currently I have a list of users ordered by last name, which is the default for `get_users`. This works fine most of the time but fails when a user has a last name containin...
This should do it: ``` usort($users, 'wpse_235438_sort_users' ); function wpse_235438_sort_users( $a, $b ) { $a_last_name = array_pop( explode( ' ', $a->last_name ) ); $b_last_name = array_pop( explode( ' ', $b->last_name ) ); return strnatcasecmp( $a_last_name, $b_last_name ); } ``` [`explode()`](http:...
235,442
<p>I have written a simple author subscription plugin. Basically, it shows a subscribe button similar to YouTube. When a (logged in) user clicks on it, they subscribe to that author, and will get notified by their posts.</p> <p>I'm using AJAX to make the button not refresh the page, and a data-attribute to send the au...
[ { "answer_id": 235445, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 0, "selected": false, "text": "<p>Data attributes can be easly overriden, for example by jQuery function <code>data</code>. I would ...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235442", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22588/" ]
I have written a simple author subscription plugin. Basically, it shows a subscribe button similar to YouTube. When a (logged in) user clicks on it, they subscribe to that author, and will get notified by their posts. I'm using AJAX to make the button not refresh the page, and a data-attribute to send the author ID to...
When dealing with submit forms, even if they are sent with AJAX, you must play by the ***[Never trust user's input](https://www.owasp.org/index.php/Don't_trust_user_input)*** rule. Every `data-attribute` can be changed, edited via Inspector. Your only trusted validation should be on the server side, as you did with: ...
235,463
<h3>Here's the TLDR: Is is possible to get all meta keys from a specific CPT without a database hit for each post?</h3> <h1>If so, how can I do this the Wordpress way?</h1> <p>This seems like a simple thing to do ( at least from a database perspective ) but I'm looking for the Wordpress way to get multiple post_meta va...
[ { "answer_id": 235445, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 0, "selected": false, "text": "<p>Data attributes can be easly overriden, for example by jQuery function <code>data</code>. I would ...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37479/" ]
### Here's the TLDR: Is is possible to get all meta keys from a specific CPT without a database hit for each post? If so, how can I do this the Wordpress way? =========================================== This seems like a simple thing to do ( at least from a database perspective ) but I'm looking for the Wordpress way...
When dealing with submit forms, even if they are sent with AJAX, you must play by the ***[Never trust user's input](https://www.owasp.org/index.php/Don't_trust_user_input)*** rule. Every `data-attribute` can be changed, edited via Inspector. Your only trusted validation should be on the server side, as you did with: ...
235,466
<p>I want to hide Add to Cart button on woocommerce Product description page of a particular product with product id, say, 1234. </p> <p>Following code hides Add to Cart button on woocommerce Product description pages of ALL the products:</p> <pre><code>function remove_product_description_add_cart_button(){ remov...
[ { "answer_id": 235474, "author": "Max", "author_id": 78380, "author_profile": "https://wordpress.stackexchange.com/users/78380", "pm_score": 2, "selected": true, "text": "<p>You are applying your hook to early. Wordpress is perfectly fine with removing that action, however it doesn't kno...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235466", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/95187/" ]
I want to hide Add to Cart button on woocommerce Product description page of a particular product with product id, say, 1234. Following code hides Add to Cart button on woocommerce Product description pages of ALL the products: ``` function remove_product_description_add_cart_button(){ remove_action( 'woocommerc...
You are applying your hook to early. Wordpress is perfectly fine with removing that action, however it doesn't know what product/post ID is yet. You can rewrite the last line of your code like that: ``` add_action('wp','remove_product_description_add_cart_button'); ``` Wordpress actions chronologically - <https://co...
235,483
<p>I followed the install instructions at wp-cli.org and am unable to connect to database. I am using a newly installed (this morning) version of MAMP PRO.</p> <pre><code>which php /usr/bin/php echo $WP_CLI_PHP /Applications/MAMP/bin/php/php5.5.14/bin/php wp --info PHP binary: /usr/bin/php PHP version: 5.5.1...
[ { "answer_id": 235496, "author": "Graham Lutz", "author_id": 100738, "author_profile": "https://wordpress.stackexchange.com/users/100738", "pm_score": 2, "selected": false, "text": "<p>Alright - so here's what I figured out.</p>\n\n<p><code>~/.bash_profile</code> should look like this:</...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100738/" ]
I followed the install instructions at wp-cli.org and am unable to connect to database. I am using a newly installed (this morning) version of MAMP PRO. ``` which php /usr/bin/php echo $WP_CLI_PHP /Applications/MAMP/bin/php/php5.5.14/bin/php wp --info PHP binary: /usr/bin/php PHP version: 5.5.14 php.ini used:...
I noticed a typo in the original answer, but it did work for me in my .zshrc file. The typo was the end of the last line, it was missing the final `/` between the php version and bin directory ``` #MAMP Madness export PATH=/Applications/MAMP/Library/bin:$PATH PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | ta...
235,488
<p>My website receives this error when going to the home page: Parse error: syntax error, unexpected 'endif' (T_ENDIF) in /home/wha2wearco/wha2wear.com/wp-content/themes/pro-blogg/index.php on line 63</p> <p>But I don't see that error on line 63. Actually, I don't see any error. Can anyone check the code for me, plea...
[ { "answer_id": 235496, "author": "Graham Lutz", "author_id": 100738, "author_profile": "https://wordpress.stackexchange.com/users/100738", "pm_score": 2, "selected": false, "text": "<p>Alright - so here's what I figured out.</p>\n\n<p><code>~/.bash_profile</code> should look like this:</...
2016/08/09
[ "https://wordpress.stackexchange.com/questions/235488", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91761/" ]
My website receives this error when going to the home page: Parse error: syntax error, unexpected 'endif' (T\_ENDIF) in /home/wha2wearco/wha2wear.com/wp-content/themes/pro-blogg/index.php on line 63 But I don't see that error on line 63. Actually, I don't see any error. Can anyone check the code for me, please: ``` ...
I noticed a typo in the original answer, but it did work for me in my .zshrc file. The typo was the end of the last line, it was missing the final `/` between the php version and bin directory ``` #MAMP Madness export PATH=/Applications/MAMP/Library/bin:$PATH PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | ta...
235,501
<p>How can I fetch a <code>div</code> content from a post?</p> <p>Using <code>the_content()</code> can fetch all the data but instead of that, I need specific content from the <code>div</code> only. So far, all I could do was get the link of the post as the <code>div</code> content. </p> <p>Here is was I am trying to...
[ { "answer_id": 235503, "author": "lucian", "author_id": 70333, "author_profile": "https://wordpress.stackexchange.com/users/70333", "pm_score": 1, "selected": false, "text": "<p>You'd have to get all the content out and then trim it down to that specific div. But why would you want to do...
2016/08/10
[ "https://wordpress.stackexchange.com/questions/235501", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99340/" ]
How can I fetch a `div` content from a post? Using `the_content()` can fetch all the data but instead of that, I need specific content from the `div` only. So far, all I could do was get the link of the post as the `div` content. Here is was I am trying to do: ``` <?php while (have_posts()) : the_post(); ?> <li st...
Using [DOMDocument](http://php.net/manual/en/class.domdocument.php) and [DOMXPath](http://php.net/manual/en/class.domxpath.php) you could try this. ``` <?php while (have_posts()) : the_post(); ob_start(); // run the_content() through the Output Buffer the_content(); $html = ob_get_clean(); // Store the formatted HTM...
235,538
<p>I have a archive page which is running under <code>https</code>. It doesn't loading any images within the post as all the image urls with <code>http</code>.</p> <p>It is giving an error like bellow,</p> <pre><code>Blocked loading mixed active content "http://www.example.com/wp-content/uploads/image.jpg" </code></p...
[ { "answer_id": 235542, "author": "Amarendra Kumar", "author_id": 98677, "author_profile": "https://wordpress.stackexchange.com/users/98677", "pm_score": 0, "selected": false, "text": "<p>For Load images with http urls follow below steps:</p>\n\n<ol>\n<li>Go to phpmyadmin export database ...
2016/08/10
[ "https://wordpress.stackexchange.com/questions/235538", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68403/" ]
I have a archive page which is running under `https`. It doesn't loading any images within the post as all the image urls with `http`. It is giving an error like bellow, ``` Blocked loading mixed active content "http://www.example.com/wp-content/uploads/image.jpg" ``` How should I avoid that errors and load the ima...
simply used the `str_replace` function to convert the urls to `https` ``` $content = get_the_content(); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]&gt;', $content ); $content = str_replace("http://example.com/", "https://example.com/", $content); echo $content; ``` event y...
235,563
<p>I have to make a site where i have to assign posts to users.</p> <p>Want i already did:</p> <p>1: made new user roles with only 'read' enabled</p> <p>But i can't seem to figure out how to assign a certain post to a specific user/user role. So that when there logged in they will only see the post that is assigned ...
[ { "answer_id": 235542, "author": "Amarendra Kumar", "author_id": 98677, "author_profile": "https://wordpress.stackexchange.com/users/98677", "pm_score": 0, "selected": false, "text": "<p>For Load images with http urls follow below steps:</p>\n\n<ol>\n<li>Go to phpmyadmin export database ...
2016/08/10
[ "https://wordpress.stackexchange.com/questions/235563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44597/" ]
I have to make a site where i have to assign posts to users. Want i already did: 1: made new user roles with only 'read' enabled But i can't seem to figure out how to assign a certain post to a specific user/user role. So that when there logged in they will only see the post that is assigned to them, instead of seei...
simply used the `str_replace` function to convert the urls to `https` ``` $content = get_the_content(); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]&gt;', $content ); $content = str_replace("http://example.com/", "https://example.com/", $content); echo $content; ``` event y...
235,570
<p>I have a category template which displays some posts and some content generated by a plugin template, which uses <code>the_permalink()</code> to refer to the current url. The category template looks like this (<code>category.php</code>):</p> <pre><code>&lt;?php $categoryQuery = get_the_category(); ?&gt; &lt;?php $p...
[ { "answer_id": 235542, "author": "Amarendra Kumar", "author_id": 98677, "author_profile": "https://wordpress.stackexchange.com/users/98677", "pm_score": 0, "selected": false, "text": "<p>For Load images with http urls follow below steps:</p>\n\n<ol>\n<li>Go to phpmyadmin export database ...
2016/08/10
[ "https://wordpress.stackexchange.com/questions/235570", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36778/" ]
I have a category template which displays some posts and some content generated by a plugin template, which uses `the_permalink()` to refer to the current url. The category template looks like this (`category.php`): ``` <?php $categoryQuery = get_the_category(); ?> <?php $parentCategory = get_term_by('id', $categoryQu...
simply used the `str_replace` function to convert the urls to `https` ``` $content = get_the_content(); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]&gt;', $content ); $content = str_replace("http://example.com/", "https://example.com/", $content); echo $content; ``` event y...
235,571
<p>In the action <code>user_new_form</code>, the parameter <code>$user</code> returns a string <code>add-new-user</code>.</p> <p>I've used <code>esc_attr( get_the_author_meta( '_typeuser', $user-&gt;ID ) );</code> but I get an error.</p> <p>Another <a href="https://wordpress.stackexchange.com/questions/174386/having-...
[ { "answer_id": 235542, "author": "Amarendra Kumar", "author_id": 98677, "author_profile": "https://wordpress.stackexchange.com/users/98677", "pm_score": 0, "selected": false, "text": "<p>For Load images with http urls follow below steps:</p>\n\n<ol>\n<li>Go to phpmyadmin export database ...
2016/08/10
[ "https://wordpress.stackexchange.com/questions/235571", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99064/" ]
In the action `user_new_form`, the parameter `$user` returns a string `add-new-user`. I've used `esc_attr( get_the_author_meta( '_typeuser', $user->ID ) );` but I get an error. Another [question](https://wordpress.stackexchange.com/questions/174386/having-an-add-action-user-new-form) on the topic is non-response at t...
simply used the `str_replace` function to convert the urls to `https` ``` $content = get_the_content(); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]&gt;', $content ); $content = str_replace("http://example.com/", "https://example.com/", $content); echo $content; ``` event y...