question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
What is the best php method to extract all IDs from a query string and display them in a comma separated list? I have a function that grabs specific posts from the database and am trying to enter those ID's into a new wp_query loop. <code> Array ( [0] =&gt; stdClass Object ( [ID] =&gt; 162 [post_author] =&gt; 1 [post_d...
<code> $string </code> will contain a comma separated list of IDs: <code> $ids = array(); foreach( $array as $post ) { if( !in_array( $post-&gt;ID, $ids ) ) { $ids[] = $post-&gt;ID; } } $string = implode( ', ', $ids ); </code> Note: This uses basically no wordpress, other than the post object...which is really just an ...
How to extract all ID variables from a query string?
wordpress
Today I tried to make the Permalinks of my Wordpress site more SEO friendly. I got it working for all links, except the ones linking to a custom post type page. I Googled the problem and found out that it's a common, in my eyes not-so-easy-to-solve-type problem. That's why I wanted to use the default permalink structur...
There are probably more problems with your question than with WordPress. To get an insightful answer, it'd help to get us a clear idea about your setup. Don't be shy about hiding your website link and it's structure. This can help us figure it out. To get the rewrite rules of your blog <code> add_action ('template_redi...
Permalinks all messed up, I am helpless
wordpress
I'm looking to insert a string of JavaScript variables AFTER the in_footer enqueued scripts. When I write the string via the wp_footer hook, they occur before the in_footer scripts. Is there another hook I can tie into that happens after those enqueued scripts have been written.
If you change the priority on the hook to <code> wp_footer </code> you should be able to shift when it's called in reference to the enqueue functions. Example: <code> add_action('wp_footer', 'my_footer_hook', PHP_INT_MAX); </code>
Hook for writing text string after footer scripts
wordpress
How can I automate the installation of wordpress in a subdomain? Example: Upon registration user1 would get automatically wordpress on user1.domain.com. Then, upon registration user2 would get his own wordpress on user2.domain.com, etc. I can program a little bit PHP, but I would rather avoid any programming and would ...
Ok, thanks to m0r7if3, I found the two pieces of information I was looking for: wordpress multisite "Automatically create a new WordPress site in your Network associated with the user that is created." -> http://www.gravityforms.com/add-ons/user-registration/
How to automate wordpress installation in subdomain
wordpress
I was just wondering if there was anyway to customize individual parts of the lists. So for instance if you go to my site at www.r3entertainment.org and check out the Features page, if you look at the top where it says Gaming's Most Memorable Moments.. is there a way for JUST the title link to be underlined and the aut...
You should be able to do it with only a CSS modification: <code> .lcp_catlist a { text-decoration: underline; } </code>
Customize individual parts of the list - List Category Posts plugin
wordpress
Can you explain the hooks or filters WordPress applies when saving a post which remove an absolute URL and makes it a relative URL? Background My site consumes an RSS feed, that I pay for, which includes a tracking pixel at the end of each post. The tracking pixel is in an IMG tag with a bunch of parameters after it - ...
Regarding the HTML editor, if you want to use a different path, without all the functions/ hooks that I will list below, you should use the UPLOAD FROM URL tab, and not the UPLOAD FROM COMPUTER .. that will keep the original URL. I am not sure about the tracking pixel, how you get it in the RSS (format) or other variab...
Why is WordPress automatically modifying image URLs? (Tracking pixel from RSS)
wordpress
Is there a plugin out there similar to wordpress.com like button? http://en.support.wordpress.com/likes/
Yes, there is. Please check out Gravatar Like .
Wordpress.com Like Button
wordpress
the Easy FancyBox WP-Plugin works fine for me. Just the script will be placed in the header of my source, like other plugin, too. I´d like to push it down to the footer of my website (incl. the inline-script) below jquery-library. Can i fixed it? Thanks Ingo
You can ask the plugin author to update the plugin so scripts go in the footer rather than the header. Or you can look in the plugin code and see this: <code> wp_enqueue_script('jquery.fancybox', plugins_url(FANCYBOX_SUBDIR.'/fancybox/jquery.fancybox-'.FANCYBOX_VERSION.'.pack.js', __FILE__), array('jquery'), FANCYBOX_V...
Javascript from Easy-Fancybox place into footer
wordpress
I have one page for each author, but if the author doesn't have any posts I can't get its variables, because the loop is empty. The page returns empty, no avatar, no info and stuff, the whole site is empty. How do I get WordPress to pull out the author variable if there are no posts (what makes no author, but i am on t...
To access the author user object outside of the loop on an author archive, you can do the following: <code> global $curauth; $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); echo 'This is the author page of '.$curauth-&gt;display_name; </code>
Show author archive pages for authors with no posts
wordpress
Does anyone know how I automatically add the URL of the uploaded image to a custom field? In other words, When I upload a image I want the url to the image to get a custom field variable automatically so I dont have to add the URL manually to the custom field all the time. I need a seamless integration to make is user-...
Here is the final code that adds the thumbnail url to a custom field named Image. <code> function w_thumbnail_src() { if (has_post_thumbnail()) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'emphasis'); return $thumb[0]; // thumbnail url } else { return ''; // or a default thumbnail url } } add_action...
Add image URL automatically to custom field?
wordpress
I wanna show the blog URL instead of the whole post URL in my loop. The reason is that I use Wordpress multiblog with sitewide tags, so on my front-page of the main blog I'm showing the 10 last posts globally. I wanna show the blogdomain the post is coming from. the_permalink works if I wanna show the whole post-url bu...
Use <code> parse_url() </code> : <code> echo parse_url( get_permalink(), PHP_URL_HOST ); </code>
How to show only blog-domain instead of the whole permalink in the loop
wordpress
I'm using twitter bootstrap in my theme. I'm trying to use bootstrap menu in my theme. But it use custom attributes like <code> data-toggle </code> . Here is the full code. <code> &lt;ul class="nav"&gt; &lt;li class="active"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/l...
For a copy paste solution check this custom Walker out: http://goodandorgreat.wordpress.com/2012/01/12/update-2-using-twitter-bootstrap-dropdown-menus-with-wordpress/ It's missing one or two things like <code> data-toggle="dropdown" </code> and <code> &lt;b class="caret"&gt;&lt;/b&gt; </code> . It should be quite easy ...
wordpress nav menu using twitter bootstrap
wordpress
I am writing a plugin and I decided to have multiple pages for different options of the plugin (for clarity's sake). Doing a single option was a piece of cake, but I'm encountering difficulties when having multiple pages. All of my options are in an array registered as: <code> register_setting( 'plugin_options', 'optio...
Ok, after searching a while, I've found out that the "easy" solution to my problem would be to start by creating tabs (like in the appearence menu) and option sections. While I'm still no expert in that matter, I followed this 3 part guide that explains pretty much everything related to the matter. I just had to adjust...
Multiple options pages validation for a plugin
wordpress
I have written a custom walker that I am using with <code> wp_nav_menu </code> but I need to iterate through 4 custom classes, and I'm not sure how to do this. Basically, each menu-item <code> &lt;li&gt; </code> needs to be given a class of <code> color1 </code> , <code> color2 </code> , <code> color3 </code> or <code>...
Use a class variable to keep the 'index' of the colour you wish to display. Increment each time it's used, and check if it goes over, in which case set it back to 1. <code> class Salamander_Advent_Walker extends Walker_page { private $color_idx = 1; function start_el(&amp;$output, $item, $depth, $args) { if ( $depth ) ...
Incrementing a class in a custom walker
wordpress
I am trying to use the same image fader in two different spots on my testing site . The one in the top banner works, and the one in the furthest right sidebar kind of works They both now do not work. However I believe that the answer below is more or less on the right track and it is a Wordpress "quirk" that is at a fa...
Based off of stackexchange-url ("stackexchange-url here is the code that eventually got it to work PHP Top Banner <code> &lt;div id="top" class="rotator"&gt; &lt;ul&gt; &lt;li class="show"&gt;&lt;a href="1"&gt;&lt;img src="http://173.247.253.180/~andrewba/images/banners/40779.gif" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&...
Multiple jQuery conflict unsure of why
wordpress
Quite a pesky problem here. I've taken over a site that contains multiple information, serialised, within a custom field. For example: <code> if ($new_query-&gt;have_posts()) : while ($new_query-&gt;have_posts()) : $new_query-&gt;the_post(); $ids[] = get_post_custom( get_the_ID() ); print_r($product_custom_fields['item...
I would write a converter and separate all of these data once . There is just no way to build a really fast query against serialized data.
Order by value in serialized custom field
wordpress
It is possible to search for posts with a specific term by appending the URL with: <code> ?&amp;term=abc </code> Is it possible to do the opposite and search excluding a specific term? Something like: <code> ?&amp;term=NOTabc </code>
The basic explanation You have a template tag that is called <code> is_search() </code> to determin if you're on a search page or not. This then calls <code> get_search_template() </code> which basically is a wrapper function for <code> get_query_template('search') </code> . When you look into the last function, then y...
Exclude Specific Term from Search
wordpress
I'm migrating a Typepad subdirectory install to a Wordpress subdomain install, and most of the links will be broken. The rewrites work so that; <code> http://mainsite.com/blogs is rewritten to http://blogs.mainsite.com </code> If a full link with article information is passed, it is rewritten as such; <code> http://mai...
You can try a plugin to do this: http://wordpress.org/extend/plugins/smart-404/ Reads the page URL and tries to find a page/post that it might match and redirect to it. Found out about this plugin from: http://www.aebeta.com/web-hosting/seo/7-seo-friendly-404-plugin-for-wordpress.html
Turning broken link into search term?
wordpress
I am wanting to create a page template file to display posts from a custom content type. I was working with this code I found from this site , but it renders nothing. Does anyone know what the problem is? <code> &lt;?php /* Template Name: Custom Post Type Archive */ get_header(); ?&gt; &lt;?php global $query_string; qu...
You don't need to use a query, just create your tample and name single-YOURCUSTOMPOSTNAME.php, for more references take a look at: http://codex.wordpress.org/Post_Types#Template_Files
How do I create a page template to display a custom post type?
wordpress
I am building an "advent calendar" for a client and they are wanting a combination of specific pages and custom posts appearing on the front page, in a specific order. Things that need to be retrieved are Title, Excerpt (or Content up to ), Permalink, Featured Image and Custom Fields... What's the best way to go about ...
I ended up specifying the posts, pages and custom posts in a custom Navigation menu, and created a Custom Walker to output the right information.
Querying both pages and posts
wordpress
What are the options for creating URLs like: site.com/category-name/post-name Where, "category-name" is the first category that the post was assigned to (in the event that the post is assigned to multiple categories) Note: if the post is assigned to "uncategorized", I don't want to display the category name in the URL,...
By default, the category with lowest ID is used. If you want control over what the category is, you can try the Hikari Category Permalink plugin, which allows you to choose which post category is used for the permalink. http://wordpress.org/extend/plugins/hikari-category-permalink/
How to include first assigned category in the post URL?
wordpress
I have a website that has Wordpress installed in the root directory <code> / </code> I have another website, that's contents is within that root directory, <code> /seperatesite/ </code> that stores a separate, small, splash page type website, with a separate domain pointing to it. I want to setup another Wordpress inst...
Have you considered setting your main site to a multisite setup? This would allow you to use the same wordpress files from the root and serve a wordpress site under the <code> /seperatesite/ </code> directory without the need for duplicating files. take a look at: http://codex.wordpress.org/Create_A_Network If you need...
Installing WP twice in same Directory?
wordpress
After pulling my hair trying to find out stackexchange-url ("why my Main Sidebar disappeared"), I performed as a last act of desperation a stackexchange-url ("complete wipeout of the database") and the entire wordpress directory, then I restored them from the earliest backup of my totally fresh install of WordPress, wh...
Can the Twenty Eleven theme have a Main Sidebar at all? Twenty Eleven Theme does display a sidebar on the homepage, but not on the single posts and individual pages as you can see from the demo of Twenty Eleven . If so, what am I doing wrong? What's your website URL?
Can the Twenty Eleven theme have a Main Sidbar at all?
wordpress
I have a custom search, one database out of WP, I store the page in wordpress admin panel: http://localhost/wp/wp-admin/post.php?post=96&amp;action=edit&amp;message=1 Then the page's url looks like <code> http://localhost/wp/directory/view?search=moto&amp;number=12 </code> Now I want to modify it into <code> http://loc...
Your rewriterule should be: <code> add_rewrite_rule('^directory/view/(.+)/(\d+)/', 'index.php?pagename=directory/view&amp;search=$matches[1]&amp;number=$matches[2]', 'top'); </code> Remember to flush your rewriterules after every edit (go to settings > permalinks). EDIT added complete code example. <code> function add_...
custom url rewrite
wordpress
This Q is stackexchange-url ("a follow up to this answer") on the Q: stackexchange-url (""How to exclude a specific term for the search?""). 4 ways to filter out posts that have a specific term <code> Type | Pro | Contra -------------------------------------------------------- Run a new query | Easy to implement | Add....
You can set the taxonomy query for the main query using pre_get_posts: <code> add_action( 'pre_get_posts', 'my_exclude_terms_from_query' ); function my_exclude_terms_from_query( $query ) { if ( $query-&gt;is_main_query() /* &amp;&amp; whatever else */ ) { $tax_query = array ( array( 'taxonomy' =&gt; 'category', 'terms'...
How-to exclude terms from the main query the most performant way?
wordpress
If I have a post in multiple categories, what defines what category shows up in the URL? Assuming I have permalinks setup as <code> /%category%/%postname% </code> is it the ID or the name?
WordPress always use the category with lowest ID. You can use plugins such as the Hikari Category Permalink plugin to change that however. http://wordpress.org/extend/plugins/hikari-category-permalink/
What Defines What Category A Post Picks (if in multiple)
wordpress
I have created two custom taxonomies i.e states and provinces but am unable to save the data in custom build meta boxes in wp-admin: <code> &lt;?php function custom_meta_box() { remove_meta_box( 'tagsdiv-states', 'post', 'side' ); remove_meta_box( 'tagsdiv-provinces', 'post', 'side' ); add_meta_box( 'tagsdiv-states', '...
Rather than 'returning' on a failure of authentication check, die with an appropriate message: For example: <code> if ( !wp_verify_nonce( $_POST['states_noncename'], plugin_basename( __FILE__ ) ) ) wp_die("Nonce-check failure"); </code> This will indicate on what check (if any) that you are failing. In most cases, I wo...
unable to save custom taxonomy terms in a custom-built metabox in wp-admin
wordpress
I registered a sidebar widget, then modified the registration which included changing the registered name of the widget. Now the widget does not show at all. Below are the steps I took. I registered a sidebar widget in my functions.php file. <code> if (function_exists('register_sidebar') ){ register_sidebar( array('nam...
If you don't need the others settings from register_sidebar, that's fine. That's not fine. :) To render your sidebar you need to call <code> dynamic_sidebar($index); </code> In your case it would be: <code> dynamic_sidebar('Right Sidebar'); </code> see the codex page for dynamic sidebar http://codex.wordpress.org/Funct...
Sidebar widget not displaying after simple code update.
wordpress
I have a WordPress website that has a category with two subcategories. Now, how is it possible to show the content (the subcategories items/content) on the parent category?
One possibility: <code> &lt;?php $sub_cats = get_categories('parent=' . get_query_var('cat')); if( $sub_cats ) : foreach( $sub_cats as $sub_cat ) : $sub_query = new WP_Query( array( 'category__in' =&gt; array( $sub_cat-&gt;term_id ), 'posts_per_page' =&gt; -1) ); if ( $sub_query-&gt;have_posts() ) : while( $sub_query-&...
How can I show the subcategories content on the parent category page?
wordpress
I am trying to put together some functions in wordpress which will allow me to add a custom post type and associate a default category and post on the posts page. So far I have been able to create a custom post type, and as far as I can tell I am associating a default category. However, the posts do not show up in the ...
The problem with 'save_post' is that it gets called when you actually change something on the post edit page, if you just click the update button without changing anything, it doesn't get called. So, i would say use 'pre_post_update' action hook instead of 'save_post' or use both. Also for debugging try put some test c...
How can I set a default category for a custom post type in wordpress?
wordpress
My Dad has a website based on wordpress, he went into the wordpress dashboard and modified the home page incorrectly appending an extra level to it, then when he exited it made changes resulting in website being messed up and more importantly the login to wordpress has disappeared not allowing him to change it back. I ...
See Changing The Site URL « WordPress Codex for recovery instructions.
Trying to regain access to a wordpress based website
wordpress
I have a client that wants the ability to remove or add a special offer from the front page of her website. I thought of creating a custom loop using a featured image etc, which would display the latest special offer. Her site is a PHP site right now without any WP functionality. What is the minimum installation that w...
You can require the wp-load.php file in the existing page... <code> &lt;?php require('wp-load.php') ?&gt; </code> This will basically load the WordPress installation and allow you to access each of the functions (and the loop) as you normally would.
Minimal WordPress Functionality on Existing Website
wordpress
We are planning to change the domain name of our website.We are not changing the host but creating a new domain and will close/redirect all traffic to new domain (there will be not update on the old domain). Since most of the database still will be same as we need old post so i am wondering how best we can handle this ...
I've written a very simple script that is built to do exactly what you're talking about. Here's the basic process you'll want to follow. On the old server, log-in to PHPmyAdmin and export the database. On the new server, log-in to PHPmyAdmin and create your database. You may need to create a new MySQL user as well, but...
Migrating WP site to another URL
wordpress
I have many custom templates for different post types, and I am manually inserting a social share bar inside the 'entry-meta' footer in each of those templates. I need a simple centralized way to disable the social share bar without hacking into the plugin. Basically I have this setup so far: In functions.php : <code> ...
It's a bad practice to update an option on every page load. You should use a constant instead. <code> define('SHOW_SOCIAL_BAR', true); //functions.php if(SHOW_SOCIAL_BAR){ //Do Something } </code>
implementing a centralized content "show-do-not-show" toggle?
wordpress
I'm trying to do some simple split testing on a category page, but W3 Cache is causing some issues. To do the split testing, I randomly select a layout (either grid or horizontal), then I store it in a $_SESSION variable so that the page is the same for that user while they're on the site. Then on the category-slug.php...
I ended up just putting variables to denote the layout in the conversion link. For example, if the layout is a grid, the url is http://site.com/page-name/?g It doesn't consistently let me switch layouts between users, but at least the data isn't being skewed by a $_SESSION variable reporting something differently than ...
Split Testing with W3 Cache Enabled?
wordpress
I used to have the drag &amp; drop Widgets on Main Sidebar working but for some reason it no longer works. That is, whatever I place there (on the back-end) is no longer visible on the front-end. In my attempts to troubleshoot this, I uninstalled completely the only 2 plugins I had: " Contact Form With Captcha " " WP f...
After much search I found an explanation to the mystery: With the new <code> Twenty Eleven </code> theme (from WordPress 3.2 and up), the sidebar is gone in the single post page .
Main Sidebar Dispappeared - What could possibly cause this?
wordpress
So yeah, I'm a genius. I managed delete all my admin capabilities (thank you very much Membership plugin). I could restore them, ...if I had admin access, lol. Anywhoo, how can I give all my capabilities back to admin? I have access to the database via PHPMyAdmin but have no idea where or what to add back to the DB. An...
Ok, sorry for asking. I figured it out. But for future people, here's a suggestion. Step 1 (BACKUP!!!!) - backup your database, if the next step screws you over and you don't have a backup it's your own fault. Step 2 - Use PHPMyAdmin or similar tool to access your DB, find the wp_usermeta table and then sort by user_id...
How can I restore admin capabilities?
wordpress
And which one should I use? What's the difference between Options API and Setings API? I have a theme with over 100 admin options, how should I register &amp; store them? At this moment I'm using Options API but I'm not too happy with it, every single option is being registered separately so they create a lot of databa...
The Options API is primarily a database API, allowing you to get and store values in the options table of the database easily. The Settings API is an interface API. It allows you to build settings screens in a manner that will adapt with future changes to the WordPress interface, as well as to handle security (nonces a...
What's the difference between Options & Settings?
wordpress
I'm attempting to use actions to override function calls I currently have throughout a template (to make updating certain replicated sections easier). For example, in <code> archives.php </code> I have the following: <code> &lt;?php get_header(); ?&gt; &lt;?php roots_content_before(); ?&gt; &lt;?php $page_for_posts = g...
No, you don’t need output buffering in this case. As a rule of thumb: Don’t use output buffering unless you really have to. Just imagine what happens if someone else uses output buffering too from a plugin and it crosses with yours: <code> // plugin ob_start(); // later, you in your theme ob_start(); // you call a func...
Proper use of Output Buffer
wordpress
I'm using the eCommerce plugin Dukapress for my WordPress website. I want to attach the invoice PDF to the admin's email, but I'm not sure how to go about this. I'm under the impression that the only way you can do this is through editing the php files contained in the plugins folder, wp_content/plugins/dukapress/dukap...
<code> function dpsc_pnj_send_mail($to, $from, $name, $subject, $msg, $attachment = FALSE) { global $wpdb; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $name . ' ' . $from . '' . "\r\n"; if ($attachment) { if ($dp_shopping_cart_setti...
How do I attach an invoice PDF to an email in the Dukapress plugin for Wordpress?
wordpress
I am using a Simple 301 Redirects plugin and I understand that this requires the redirect to be a permalink. Is there any way I can redirect to a post_id? That way I can move the post (or page in this case) and then I don't have to worry about rewriting the direct URL. Thanks.
The redirection plugin will automatically create a redirection rule when the postname is changed. If you use that (possibly in tandem with simple 301's, though you'd be creating some overhead that way), you can work around it. It should be noted that I have never used simple 301's, but I've used Redirection extensively...
Redirect to post_id?
wordpress
I'm trying to use a filter that limits the days ago loops pull posts from. My problem is that I need different day limits for certain loops on the index page and when I duplicate the filter over a second loop, I get an error saying "Cannot redeclare filter_where() (previously declared in ".) I remove the filter after t...
Define the filter_where function in your functions.php file in your theme. <code> &lt;?php function filter_where($where = '') { $where .= " AND post_date &gt; '" . date('Y-m-d', strtotime('-30 days')) . "'"; return $where; } </code>
Applying a filter to multiple loops for days ago
wordpress
From my understanding (and before trial and error), <code> wp_set_object_terms( 'post_id', 'add_this_term', 'in_this_taxonomy'); </code> But from the Codex, apparently adding the term will overwrite any other terms that are set for that post and that taxonomy? Is this right? What if the terms are nested?
<code> wp_set_object_terms() </code> has a fourth argument called <code> append </code> . Setting that to true during the call should add the term without unsetting the already set terms. <code> wp_set_object_terms( $post_id, 'add_this_term', 'in_this_taxonomy', true); </code>
wp_set_object_terms() -- prevent overwrite?
wordpress
I am using an image tagging plugin that creates galleries based on image tags, but does not link back to the original post, which is something I am hoping to do. I found this thread: 'stackexchange-url ("Get the post attached to an image attachment")', but it assumes I know the attachment ID. So I guess my question is:...
After some additional searching I was able to come across a function to generate the attachment ID here: http://pippinsplugins.com/retrieve-attachment-id-from-image-url/ : <code> // retrieves the attachment ID from the file URL function pippin_get_image_id($image_url) { global $wpdb; $prefix = $wpdb-&gt;prefix; $attach...
How do I link an image to the post it is attached to?
wordpress
So you know how Drupal has functions in modules like Devel that allow you to output arrays in a nice format like <code> dsm($array) </code> or <code> krumo($array) </code> ... Does WordPress have an equivalent or a nice way of displaying <code> print_r($array) </code> ?
I created a Kint plugin that works really well. I also integrates with the Debug Bar plugin. You can download it at: http://wordpress.org/extend/plugins/kint-debugger/ There are a few functions to help you out with WordPress specific globals: <code> dump_wp_query() </code> <code> dump_wp() </code> <code> dump_post() </...
Nice way to print_r arrays
wordpress
I installed a plugin named " Contact Form With Captcha " via the Admin's back-end, and as soon as I activated and configured it, my entire customized theme disappeared! Because my last backup was from yesterday night, I ended up losing many precious hours of customizations... But before trying to re-do the work I lost,...
Do WordPress plugins have permissions to delete entire directories? (it's a Linux based host) WordPress plugins have permissions to do anything WordPress itself can do. It's all just code. There's no permissions model or sandboxing of any kind with plugins. Plugins and themes can do anything that PHP on your system can...
Can installing a plugin delete an entire theme directory?
wordpress
I'm trying to order the posts in the home page by modified date, and I put this code in the functions.php of my active child theme: <code> function orderby_last_modified() { return 'post_modified DESC'; } </code> If I add the filter in the same functions.php file it works: <code> add_filter('posts_orderby', 'orderby_la...
It doesn't work in your template because the query has already happened before the template is loaded. If you want to add your filter only under certain conditions, you need to hook an earlier action, like pre_get_posts , and check if the query is for the home page: <code> function add_my_orderby_filter( $query ) { if ...
add_filter() doesn't work in loop
wordpress
I'm writing code from within a plugin and I'm attempting to create a two-part registration form. I'm using POST to determine if the first part of the form was submitted or not. Unfortunately, though, the POST data is not coming through. Here is what my form looks like: <code> &lt;form action="&lt;?php echo $_SERVER['RE...
I found my own answer on this one (just now). The stupid plugin had javascript at the bottom of the page disabling all submit buttons from working - what a joke, sorry everyone.
Post data returning null
wordpress
I'm trying to re-format the gallery output a bit, change default columns and link setting, as well as exclude the featured image from the gallery images. I can use *add_filter('post_gallery' ...)* in functions.php but that seems to overwrite any previous calls to this filter by the core and plugins. Example of this ove...
Add filter is not intended to replace fully the existing code, but rather to append it. In the case of <code> post_gallery </code> , if you return ANYTHING but <code> '' </code> , it will not do ANY of the default action. If you look on line 767 of <code> /wp-includes/media.php </code> , you can see where the hook is a...
How to filter 'post_gallery' after all other filters/plugins etc
wordpress
I'm using wordpress multiste 3.3.1 I'm not gonna update it in the future. So I disabled all upgrade functions. I want to remove the wordpress admin bar from both frontend as well as dashboard. I can remove it from frontend using this code. <code> add_action( 'init', 'disable_admin_bar', 1 ); function disable_admin_bar(...
<code> if (!function_exists('disableAdminBar')) { function disableAdminBar(){ remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); function remove_admin_bar_style_backend() { echo '&lt;style&gt;body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }&lt;/style&gt;'; } add_filter('a...
Removing admin bar from wordpress dashboard
wordpress
Without boring you with the details of "why" to keep a long story short, I need to change the domain that my site uses when it sends pings. I went and searched the WP source for where this gets set, and I see the domain is set in weblog_ping() in wp-includes/comment.php . Unfortunately this has no filters or actions, s...
Here's what I came up with to accomplish this. I'm not naive enough to think this is the best way, but it works. Again, still interested to know if others have any better ideas. Ultimately, the reason why I needed to do this was because I use the domain mapping plugin, and I have it set to redirect admin requests to th...
How to change domain used when pinging sites
wordpress
Each of our posts are reviews for individual games and we occasionally have to 'pause' the game by changing it from published to pending review. The problem is if the page is indexed by search engines, anyone trying to visit the link will get a 404, which is obviously not desired. I'd like to instead redirect to a list...
<code> post_status </code> is part of the <code> $post </code> object which you can use to determine if it is published, a draft, pending, etc. <code> if( $post-&gt;post_status == 'pending' ) // do stuff </code>
Check if post is in draft or pending review?
wordpress
I don't want to accidentally select Administrator role. So is there a way to remove it from <code> Settings -&gt; General -&gt; New User Default Role </code> ?
Okay, this looks tricky, but I think it's possible. The <code> user-new.php </code> file calls <code> wp_dropdown_roles() </code> to output the list of roles. The <code> wp_dropdown_roles() </code> function calls <code> get_editable_roles() </code> to get the list of roles to output. The <code> get_editable_roles() </c...
How to remove administrator role in settings -> general -> New User Default Role?
wordpress
Could someone help me write a custom shortcode to simply display the latest post anywhere in Wordpress? I've seen a lot of ways how to do this in pure PHP in a custom page template, but if I try to convert it, I always get problems (double display) or completely nothing. It should be just one post (not page) of any kin...
In functions.php file : <code> function my_recent_post() { global $post; $html = ""; $my_query = new WP_Query( array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; 1 )); if( $my_query-&gt;have_posts() ) : while( $my_query-&gt;have_posts() ) : $my_query-&gt;the_post(); $html .= "&lt;h2&gt;" . get_the_title() . "&lt;/...
Shortcode to display the latest news article within a page
wordpress
I am trying to use the following line of PHP code in one of my pages: <code> &lt;input name="from" id="from" value="&lt;?php echo $_GET['from'];?&gt;" type="text" /&gt; </code> But instead of displaying an empty "from" input field (before typing anything into it), it displays <code> &lt;?php echo $_GET['from']; </code>...
You can't use PHP in the WordPress back-end editor. Maybe with a plugin you can, but not out of the box. The easiest solution for this is creating a shortcode. Then you can use something like <code> [input type="text" name"from"] </code> in your editor. <code> function input_func( $atts ) { extract( shortcode_atts( arr...
Can a page contain php code?
wordpress
What i want to do I want some content (could be stored any where in a post or custom field) to load only when the user clicks for it to load. This content could be any thing (text,images,html etc) and this may be accomplished through any way (eg ajax, shortcode) i don't mind. Specification what i don't what to do is le...
You should really take a look at the AJAX in Plugins article. It gives examples of how to setup AJAX the proper way in WordPress. Here's the basic workflow of using AJAX in WordPress: Create an enqueue your custom JavaScript file that uses jQuery.post or jQuery.get or jQuery.ajax Create a callback for the wp_ajax actio...
grab or load text on demand
wordpress
all <code> As per my html theme structure i do not want to add my menu &lt;ul&gt;&lt;li&gt; under &lt;div&gt;. </code> I am using <code> &lt;?php wp_nav_menu( array( 'menu_class' =&gt; 'tlm', 'theme_location' =&gt; 'primary-menu' ) ); ?&gt; </code> By default this wrap my menu with div. like <code> &lt;div class="menu-...
Set the container to be empty. :) <code> wp_nav_menu( array( 'menu_class' =&gt; 'tlm', 'theme_location' =&gt; 'primary-menu', 'container' =&gt; '' ) ); </code> Please refer to the function reference to review all the arguments that you can pass to wp_nav_menu().
How to remove div container in custom menu?
wordpress
I need to "unhook" jQuery from my <code> wp_footer() </code> ... it's being called automatically and I'm looking for something I can add to functions.php which prevents it from being called a second time in the footer (since I need to call it in the header) please no editorial comments about why calling in the footer i...
You don't want to unregister the script; that would make it unavailable to be enqueued. Rather, you want to dequeue the script. You have two choices: If you know the callback function through which <code> wp_enqueue_script( 'jquery' ) </code> is called, you can simply call <code> remove_action( 'wp_footer', 'callback_f...
How do I "unhook" / de-register jQuery so that it's not called as part of wp_footer();?
wordpress
I installed Wordpress to my own domain and it was working just fine. I then, downloaded a new Wordpress theme and uploaded it into the wp-content/themes/ folder directory. The name of the folder is theme43 with an images folder and various php files within it (just like the automatically installed twentyten and twentye...
You can add the WP_HOME and WP_SITEURL constants in your wp-config.php file to manually override the database options. Scenario one: You want to surface WordPress from your blog folder. <code> define('WP_HOME','http://example.com/blog'); define('WP_SITEURL','http://example.com/blog'); </code> Scenario Two: You've moved...
Blog shows up without Theme/CSS styles
wordpress
I am developing one project and in this project i have to display all the posts related to particular category name. I have searched a lot but i haven't got any idea to implement this. How can i do this so that i can display all the posts from particular category/term
Just use <code> WP_Query() </code> to generate your custom query, using the category parameters. Assuming you know (or know how to get ) the ID of the specific category, as <code> $catid </code> : <code> &lt;?php $category_query_args = array( 'cat' =&gt; $catid ); $category_query = new WP_Query( $category_query_args );...
How to get all posts related to particular category name?
wordpress
I am using the_excerpt() method to display some wordings from the blog posts. I have read the post from this link. http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length But my situation is different. I am displaying some wordings from the posts in two places. In the first place I want to display 20 word...
The top answer to stackexchange-url ("this question") handles dynamically altering the length of your excerpt using a custom excerpt function.
How to change the length of excerpt() method?
wordpress
After creating a child theme which is made of <code> style.css </code> only (base on <code> twentyeleven </code> ), the time has come to replace the images. I found stackexchange-url ("this great tip") for accomplishing this by hacking the functions in <code> twentyeleven </code> but my main concern is minimizing work ...
I am never sure about 'optimal approach' - however, I am using this in the functions.php in a child theme of Twenty Eleven <code> //deregister the header images of Twenty Eleven, and register a few new RAW header images// add_action( 'after_setup_theme', 'raw_theme_header_images', 11 ); function raw_theme_header_images...
Optimal approach for replacing the 8 header images in a child theme?
wordpress
I'm trying to pull a custom post type name/title out for use in the breadcrumb of a single-[cpt].php template file. In the archive-[cpt].php I can use post_type_archive_title() and it echo the name. How would I get this same title in a single view? Thanks! I've trawled though the codex and haven't seen a function, but ...
There doesn't appear to be one, but the following should work: <code> //Get post type $post_type_obj = get_post_type_object('my-cpt'); //Get post type's label $title = apply_filters('post_type_archive_title', $post_type_obj-&gt;labels-&gt;name ); </code> But I can't see why you shouldn't simply hard-code the title insi...
Need post_type_archive_title function but in 'single'
wordpress
I am writing a custom plugin that sends an email to users from admin/front end section. I am using wp_email() to send emails and emails are being sent fine. I am testing this on a plain WP installation with only my plugin installed and hostgator as my hosting server. Whenever the email is sent, the email is sent from x...
The correct way is to apply a filter to wp_mail_from and wp_mail_from_name. You would think that using the $headers would work and normally it would but there are many plugins that filter and then don't take off their filter when they have sent their email which then leaves those details on the email for the next send....
Setting Custom Email From name and email address in wp_email()
wordpress
I'm using this code to list child pages of the current page and similar code to get child pages of all ancestors to use in a sidebar contextual hierarchical nav menu: <code> $pageset = get_posts('numberposts=0&amp;post_type=page&amp;post_parent='.$wp_query-&gt;post-&gt;ID); </code> For some reason, both iterations are ...
It might be because you are using <code> numberposts=0 </code> If you want to return all posts then you need to use <code> -1 </code> not <code> 0 </code>
Why would get_posts be ignoring posts with 2-digit ids?
wordpress
Code in question here: http://pastebin.com/PN29WKNq It worked on the HTML page I tested it on. Its supposed to add "display: none" to the content divs and then add "display: block" when the appropriate tab is clicked. But it just changes to "display: none" and never changes.
WordPress automatically loads jQuery in "no conflict" mode so that it will be compatible with other libraries. This means the <code> $ </code> variable isn't used for jQuery within WordPress. Rewrite your code to use the full jQuery keyword when you begin your closure like this: <code> jQuery(document).ready(function($...
Why Won't my jQuery Play Nice with Wordpress?
wordpress
I am using the twenty eleven theme in my wordpress site. In posts, I have two categories. One is blogs and other is News. The monthly archive displays the posts of all categories while I want that the monthly archive should only display the posts of blogs category. How will I do this? I have also installed the wp_pagen...
There are two ways of doing it: You can use a filter to alter the query when viewing an archive page. You will need to find the ID of your category 'blogs' (you can obtain it from the slug using <code> get_term_by </code> ). Alternatively you can exclude a particular category by ID. <code> add_action( 'pre_get_posts', ...
How to hide a specific category posts in my monthly archive?
wordpress
I am using this code to display custom post type. <code> $gabquery = new WP_Query(); $gabquery-&gt;query('showposts='.$showpostbotleft.'&amp;post_type=courses' ); </code> How to edit it to limit number of posts and specific taxonomy name of this custom post type.
I prefer using using the array form... <code> $gabquery = new WP_Query(array( 'post_type'=&gt;'courses',//The name of the post type 'posts_per_page'=&gt;5, //Use this rather than showposts 'tax_query'=&gt;array( array( 'taxonomy'=&gt;'my-custom-tax', //Your custom taxonomy name 'operator' =&gt; 'IN',//NOT IN &amp; AND ...
Display custom post type
wordpress
What I'm Doing I have a cities category and normal categories. Right now I have them filtering by category, then when the user clicks a city it will filter by category AND city <code> query_posts(array( 'category__and' =&gt; array($city, $category)) </code> The Problem That works - no problem. The problem comes when I ...
<code> category__and </code> is exclusive, so it will not work for your application, if you use <code> tax_query </code> and setup your query as follows, it should work: <code> $args = array( 'tax_query' =&gt; array( 'relation' =&gt; 'AND', array( 'taxonomy' =&gt; 'category', 'field' =&gt; 'id', 'terms' =&gt; $city, //...
Custom Queries - Child Categories not showing up
wordpress
So I have a review plugin that is automatically sorting all my site based on the score rating. It seems here are the filters the plugin is applying globally: <code> //Post sorting $sort = get_option('rs_sort'); if ($sort == 'rating') { add_filter('posts_fields', 'rs_weighted_fields'); add_filter('posts_join', 'rs_weigh...
How about doing <code> remove_filter( 'posts_orderby', 'rs_weighted_orderby' ); </code> ? If that doesn't work, you could apply your own filters with higher priorities...but that's sorta hackey, and I would avoid it if possible.
How to remove a plugin filter's priority on specific loops (custom queries)?
wordpress
I am trying to count my custom post type called 'appointments' that match two meta data values . The meta data keys are 'location' and 'timestamp' So in english my query is: How many appointments are scheduled at Location at Time How can this be done?
<code> $args = array( 'post_type' =&gt; 'appointments', 'meta_query' =&gt; array( 'relationship' =&gt; 'AND', array( 'key' =&gt; 'location', 'value' =&gt; $place //set this somewhere ), array( 'key' =&gt; 'timestamp', 'value' =&gt; $time //set this somewhere ) ) ); $posts = new WP_Query( $args ); </code> Docs: <code> W...
Count custom post type based on two meta data
wordpress
I'm having a problem with updating the post_date in a custom function I've written. I'm trying to change the "post_date" to my custom "meta_date" value. Here is the function: <code> function cfc_reset_postdate( $data, $postarr ) { // If it is our form has not been submitted, so we dont want to do anything if(defined('D...
The issue is that you are using <code> get_post_meta() </code> , but since you're hooking <code> wp_insert_post_data </code> you have not set the post meta yet (because the hook fires before the post is inserted into the database. You should be pulling from the metadata submission, and running through any filters you u...
Why do I have to press the "Update" button twice to save my meta box values?
wordpress
I want develop a plugin that add boxes and menus in WordPress backed. What I have to keep in mind to make it compatible with WordPress RTL installations? Any idea or suggestion will be appreciated. Thanks
You can use <code> is_rtl() </code> to check if the user is setup for RTL or not, then you would just need to register and enqueue the RTL styles instead of the LTR styles.
Compatibility with RTL installations
wordpress
I'm editing this site http://www.millermusicproductions.com/ currently and I am trying to get rid of the login in the upper-right corner. I go to plugins and deactivate a plugin called "Login with AJAX", then I refresh the page and only the page's header displays. Anyone know what I'm doing wrong?
My best guess is that the function for showing the Ajax login is still in the theme header.php You can look for the function login_with_ajax() in your themes header.php and remove it, if it's there. If an undefined function is called you get a fatal error and the script will stop. So it only displays until the function...
Trouble Removing Plugin
wordpress
I've been working on a custom post type meta-box implementation that allows me to change the post_date to match the value in my "date" meta-box. The function works perfectly except when I try to add a new custom post, I receive a blank page! I know it's this function because if I remove it, I can create a new post no p...
Awesome - I got it working! Thanks everybody for your help and comments. Turns out the function had a problem because it was taking the $data in, but never returning it, because I had "return $data" in my if statement! Another problem was with the "WPSearch 2" plugin", it was breaking my "New Post" functionality - stra...
Having trouble with custom post type / meta box
wordpress
I'm making a plugin that loads a specific template depending on a certain query var being passed, in effect creating a page for the plugin on the front end, as outlined in this post: stackexchange-url ("Create a page without adding a page in the Database") - the first answer by Brian Fegter So if I head to mysite.com/f...
I resolved this myself. The problem being: <code> add_rewrite_rule('^foobar?','index.php?is_foobar_page=1','top'); </code> Which prevents any other query_vars from being created. To resolve this, a slightly more complicated rewrite rule combo is set up: <code> add_rewrite_rule('^foobar?$','index.php?is_foobar_page=1','...
$paged always 0 on plugin's custom page
wordpress
My word press admin area looks like the image linked below. I have tried reinstalling word press using the option in the <code> Updates </code> panel. But I cannot get it to revert. Has anybody had a similar problem and knows the solution? My guess is that it's css but shouldn't have reinstalling WP sorted that out? Ne...
In your screenshot I can see at least 3 menu items that were added by a plugin. Standard practice when WP breaks after an update is to: Disable all plugins (You can rename the <code> /wp-content/plugins </code> directory to turn them all off at once). Revert to the default (TwentyEleven) theme Then you can re-enable yo...
Wordpress admin section appears broken
wordpress
I have checked and read lot of post about one single issue that is far more complicated than it seems. I have a website that uses a lot of videos taken from wwebsite as on the internet ^^ (services like youtube, vimeo, videobuzzy, etc) and we would like to generate on the fly a thumbnail of the embedded video. Each ser...
You can use the oEmbed functionality baked into WordPress. Typically any video host on this list will return a thumbnail to you using oembed. Here is a list of default providers that WordPress uses for auto embedding in the content area. I've included non-video sources as well for the convenience of others. http://www....
Generating Thumbnails for video
wordpress
I like to have a nice website for my client. I will do it with WordPress. But that client will manage a database, much like Excel or Lotus or Access or FileMaker. I like to offer the same style of database interaction (add, modify, query) with ans private access to wordpress... can i do that and how ? Thanks in advance
Forget that kind of interaction... drupal ? IDK
Database interaction (private-public)
wordpress
I'm wondering how I'd be able to set a custom field within my Wordpress posts. I want to have a field available to add an image via the Post dashboard - that has a max width &amp; max height set, I want the image to always float to the left within the posts (Text wrapping around via the right). Can anyone recommend a p...
You should use the post thumbnail feature. Add support for this feature with this line in your functions.php file: <code> add_theme_support( 'post-thumbnails' ); </code> You can also set a new thumbnail size that will be cropped on new added photos to use this in your theme. Add this code to set a new thumbnail size (a...
Adding Custom Fields for Img in Posts
wordpress
I've recently moved my fishkeeping "species profiles" over from a custom DB to a customised WordPress custom post type. I did this by creating a PHP file which accessed the former database, extracted the appropriate information and inserted it into the WP database. This has worked for all of the profiles and all attach...
See my comment on your question above. I just realized that if you're ending up with those special characters in the database, most likely you're not sanitizing the data before saving it into the database. Try running <code> htmlentities() </code> over all the values that you're saving into that serialized array, and s...
Problem with serialized arrays in custom meta
wordpress
It is possible to create registration process with contact from 7. i want all the features of contact from 7 in my registration from. my registration from is in popup on my site. if possible with contact from 7 then tell me how or give me some other idea for registration process. Thanks
Try using the plugin contact form 7 to Database Extension and then follow the directions at this post: http://geektastical.com/2011/05/how-to-create-a-pop-up-wordpress-email-contact-form/
registration process with contact from 7?
wordpress
Steps to reproduce: Create a PNG-8 with a transparent background. Upload to WordPress 3.3.1. View original PNG in any browser, Chrome, Firefox, IE, etc. Notice that it retains transparency as it should. View a resized version of that PNG in any browser. Observe that the transparent portions of the PNG are now black. Ex...
I'd try saving it as a PNG 24 first. If that doesn't work have a look at these: http://www.akemapa.com/2008/07/10/php-gd-resize-transparent-image-png-gif/ stackexchange-url ("stackexchange-url
PNG with transparent background turns black when uploaded and resized
wordpress
Pastebin of the html prototype and my attempt at the wp function -> http://pastebin.com/91zBv8sk I want a simple notation so its easy for new users to use. So something like this: [tabs] [tab title="tab title"]Content of the first tab[/tab] [tab title="second tab title"]Content of the second tab[/tab] [/tabs] I underst...
Try This: <code> function defaulttab( $atts, $content = null ) { $GLOBALS['tab_count'] = 0; do_shortcode($content) if( is_array( $GLOBALS['tabs'] ) ){ $i = 1; foreach( $GLOBALS['tabs'] as $tab ){ $tabs[] = '&lt;li&gt;&lt;a class="tab" href="#"&gt;'.$tab['title'].'&lt;/a&gt;&lt;/li&gt;'; $panes[] = '&lt;div class="tab'....
jQuery Tabs in Shortcode API
wordpress
I have set default property page so in the property url it shows /lima-investments/property-name. But I want to remove /lima-investments from the url. I want to change following url http://example.com/lima-investments/miraflores-apartment-for-rent-terrace/ to http://example.com/miraflores-apartment-for-rent-terrace/ Pl...
Used Custom permalink plugin and it worked.
Change permalink in wp-property
wordpress
Is there a good way to add a class of "parent" to list items that have children using wp_nav_menu? I've found a couple of solutions online but non seem to have the desired effect.
This may not be the ideal solution, depending on what you need the class for, but you could add a "parent" class via JavaScript. The line below uses the jQuery <code> :has() </code> selector: <code> $('#nav-id').find('li:has(ul)').addClass('parent'); </code>
Add "parent" class to parent menu items
wordpress
I have very little experience with WordPress. I am exploring it as a potential solution for our needs. I would like to implement an autocomplete search box (a bit like jQuery's) where users could type, say, the name of an ingredient and jump automatically to that ingredient's page. We would fill the possible values of ...
You could use the autocompleter plugin . It does exactly what you describe: it autocompletes half-typed tags and categories. You'd just need to tag your recipes with their ingredients.
Is there a wordpress plugin enabling an autocomplete search box, then jump to page?
wordpress
Using a self-hosted install updated to 3.3.1, when I go to the edit post screen, the editor is set to a height of 89953px. When I view source, I see the following lines in the markup for the post editor: <code> &lt;iframe id="content_ifr" src='javascript:""' frameborder="0" allowtransparency="true" title="Rich Text Are...
Well, as it turns out, the "size of the post box" setting under Writing Settings had been changed to 5000 lines. Putting it back at a sane number has fixed the issue.
Post editor is 89953px tall. How to fix?
wordpress
So I know that setting up custom post types ranges from just registering them to adding custom permalinks, custom sorting, customizing columns in the admin, etc. I was wondering if anyone had a template or framework that they use regularly to set up custom post types in projects? Do you start from scratch every time or...
The Custom Post Type Demos by toscho hold some nice basic classes, that you can use. I'd recommend taking a look at this source (as he's a trusted author and a pretty good coder).
Does anyone have any frameworks to setup custom post types and related actions/filters?
wordpress
XMLRPC is great for remote publishing to WordPress, but there has been many security issues attributed to it. How do it make it more secure? More specifically, only user from the intranet will be publishing through XMLRPC. WP is currently running on Lighttpd and php5.3.
XMLRPC is as secure as the rest of WordPress. All of the requests need to be authenticated with username and password credentials that exist on your site already. That means, if someone has a login for your site, they can use the XMLRPC interface (if it's turned on). But anonymous users can't get in. The only potential...
How to secure WordPress XMLRPC?
wordpress
I've been looking for a way to add a button to wrap text in <code> for the WYSIWYG editor in Wordpress 3.3.1. I tried this: function enable_more_buttons($buttons) { $buttons[] = 'code'; return $buttons; } add_filter("mce_buttons_3", "enable_more_buttons"); </code> But that did not work as expected. It did display a but...
I finally found a plugin that did just what I wanted - a button for in the WYSIWYG editor: WYSIWYG Inline Code Command
Adding a <code> button to the WYSIWYG editor?
wordpress
I'm running a site that only communicates over SSL/https so if I embed a youtube video using http I will get an error message saying the site is'nt fully secure. Is it possible to rewrite something so that WordPress accepts https and still auto embeds youtube links added to the content area? Cause now, when I try to em...
http://core.trac.wordpress.org/ticket/18719 has a working patch now. Edit: Plugin code to do similar until patch gets in: <code> wp_oembed_add_provider('#https://(www\.)?youtube.com/watch.*#i', 'http://youtube.com/oembed?scheme=https', true); wp_oembed_add_provider('https://youtu.be/*', 'http://youtube.com/oembed?schem...
How do I embed youtube videos with https instead of http in the URL?
wordpress
In my application a user needs to 1stlogin and is then able to access the website. There are 3 different user roles in use on my site administrator editor contributor User can login from <code> http://example.com/wordpress/wp-login.php </code> No login from any theme template. I have found this code, but it doesn't wor...
You're using the filter wrong . If you got more than one <code> @param </code> , then you have to state them when adding the filter. <code> function wpse40745_redirect_on_login( $redirect_to, isset( $_REQUEST['redirect_to'] ), $user ) { # uncomment the following line if it's not working and replace $user-&gt;roles[0] w...
WordPress Login redirection according to user role
wordpress
In my plugin I want to display an add_meta_box under the WYSISWYG in the new post page, which is no problem and works fine. But the box should only appear when a specific category (example: category with id = 5) is selected, otherwise it is not visible. How can this be achieved? Edit as requested in the comments here i...
You could try this: get the ID's of the attached categories and wrap your add_meta_box function inside a simple test against your defined cat ID. <code> add_action('add_meta_boxes', 'is_in_cat_example'); function is_in_cat_example() { global $post; $category = '5'; // can be an array of ID's as well if ( in_category( $...
Show add_meta_box by selecting a specific category
wordpress
I've got an "event" custom post type, with a meta field is used for the event date. I've successfully created archive pages (year and month) based on the answer on a previous question (stackexchange-url ("here")). Now, I'm trying to create a listing of the archives, sort of like wp_get_archives would work. Example: 201...
Have you looked at PHP's date function ? A quick example : <code> $dates = $wpdb-&gt;get_col( /*your sql*/ ); if( $dates ) { $archive_year = ""; foreach( $dates as $date ) { $the_date = strtotime( $date ); $year = date( 'Y', $the_date ); //4 digit year, ex 1999 $month = date( 'F', $the_date ); //Full textual month, ex ...
Create an archive listing based on meta array
wordpress
I am having a problem that's very similar to the one described here , except that the solution that worked for him (text encoding) didn't work for me. I even tried applying <code> unix2dos -o style.css </code> from the command line (which definitely changed the file from LF to CRLF, as I could see that the file increas...
Found the cause of the problem - and fixed it! It turns out that LF vs. CRLF is not an issue at all on a LAMP based webhost. The problem in my particular case was that I copied the original theme's <code> style.css </code> verbatim , and it was missing a very critical line in the comment section: <code> Template: twent...
How to make WP admin recognize a newly created child theme?
wordpress
Is there a way I can give each wordpress children (subcategory UL lists) unique ID's? I'm creating a dropdown list for subcategories and I want to position them but <code> :nth-child </code> isn't supported by everything yet.
as far as I know, all menu items already have unique ID´s ("menu-item-XX"), may they be first or second level. the UL itself has a different class : <code> menu </code> for first level and <code> sub-menu </code> for second. hence , in css for example <code> .menu li </code> and <code> .sub-menu li </code> will give yo...
Give Children Unique ID's
wordpress
Is there a way to backdate posts on WordPress? The reason is that I am migrating content over from another site and want to keep their original publishing dates. Edit The content is being migrated manually from a non-wordpress website
To manually edit publish date, click the Edit link in the Publish box when editing a post and set the date to whatever you'd like.
Is there a way to backdate posts?
wordpress
I'm having a problem with updating the post_date in a custom function I've written. I'm trying to change the "post_date" to my custom "meta_date" value. Here is the function: <code> function cfc_reset_postdate( $data, $postarr ) { // If it is our form has not been submitted, so we dont want to do anything if(defined('D...
A Note: Actions and Filters are not really interchangeable: Filters typically must return the passed data or it's going to break something. Building off of what m0r7if3r said, <code> wp_insert_post_data </code> is a filter, so you should be modifying the post's $data and returning it at the end of the function. (Altern...
Change the post date from a meta box
wordpress
I have some code showing an image attached to a post, an image in a li list, works fine shows the image as its should. I need the image to link through its main single post though and have tried the code below. <code> &lt;?php $args = array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; -1, 'post_status' =&gt; nu...
Jez, unpatient Jez :) <code> &lt;?php $args = array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; -1, 'post_status' =&gt; null, 'post_parent' =&gt; $post-&gt;ID ); $attachments = get_posts( $args ); if ( $attachments ) { foreach ( $attachments as $attachment ) { echo '&lt;li&gt; &lt;a href="'. get_permalink($att...
Echo Permalink in Attachment outside of loop?
wordpress