question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I need to be able to add a feature image to a post as a link. The link is good, it's green check. And no i cannot upload the file and insert into post dont do anything good. I have the link to the image i just whant feature image to use it. Why i dont what ti upload it, it's because my gallery is completely OUTSIDE awf... | Yes, you've guessed it right. You will need to use Custom Fields in order to define the URL for the Image that you wish to use as Featured Image for the post. Next part is to tell the Wordpress to use the Image from URL you've in Custom Field as Featured Image. Here, you can use filter called "post_thumbnail_html". The... | MIssing feature image link function | wordpress |
I have a page called 'home' which is set to be the front of my site, but I'd like it to show the most recent blog post or two at the bottom. I have some PHP that will do this from another site <code> <?php query_posts('showposts=1'); while (have_posts()): the_post(); ?> <h2><a href="<?php the_permalin... | Since you are saying it's a "Page", I believe you should try <code> is_page </code> instead of <code> is_home </code> : <code> <?php if ( is_page( 'about' ) ) { // Code to be shown on Page whose slug is "about" } ?> </code> OR for the way your code is, this should do: <code> <?php if ( is_page( 'about' ) ) { ?... | How to include custom code on a page that's set to act as homepage? | wordpress |
I want to create font size and background change buttons, which i know how to do it. The problem is with remember it, so if user will go to a different page, background and font will stay the same. How can i do it? I was thinking about saving this in cookies. What do you think about that? Is anyone can write an example... | Here is how you can sett a cookie whit a variable: Now it saves for one day. <code> $settings = $mybackground; setcookie('background',$settings,time() + (86400)); // 86400 = 1 day </code> Print it in the body like an img whit this: <code> echo $_COOKIE['background']; </code> | background/font size change and remember | wordpress |
I am probably being a little dumb here, but can anyone point me in the right direction. I am trying simply display the authors first name as a link in my loop. But the doesnt seem to be any options with the <code> get_author </code> tag. This is what I got so far. <code> Posted by <a href="<?php echo esc_url( get... | You can use <code> get_the_author_meta( 'first_name' ); </code> (see Codex for <code> get_the_author_meta </code> ) | Get author's first name | wordpress |
I'm trying to create a custom page 2 template that's different from the main index.php. For example, the main index page would display the latest news + a lot of features like a magazine. When readers click to read on to page 2, 3, 4 etc of the news posts, they are taken to a more regular news page. Kinda like somethin... | I would use the <code> is_paged() </code> conditional inside <code> index.php </code> to load two separate templates containing your layouts. Something like this: <code> if ( is_paged() ): get_template_part( 'content', 'first-page' ); else: get_template_part( 'content', 'paged' ); endif; </code> Assuming you have two t... | Custom /page/2/ template (different from index.php) | wordpress |
I created a custom taxonomy as category and display it by wp_nav_menu. The problem is, so far there are some terms in the custom taxonomy has no post attached to it, but it still show in the menu. So when people click on the menu link, they will got to a Nothing Found page. How do I display the menu/term that only has ... | Okay, I figure it out. Instead of using wp_nav_menu, I use wp_list_categories which has more parameters that we can control. So to not display empty menu, I use: <code> <?php wp_list_categories(array('taxonomy' => 'custom_tax','hide_empty' => '1','title_li' => '')); ?> </code> the <code> hide_empty </cod... | How to Display a menu only if it has Posts in Custom Menu? | wordpress |
We have ten blogs running on a little EC2 instances, we want to see if all the blogs can share the same wordpress php code so When I update the Wordpress, all the blogs get updated Save memory in Apache/mod_php as no duplicated scripts or bytecode in the cache (in case of APC). We cant use MU as we need all the blogs i... | Assuming all the installs are on the same instance and thus can have the same files shared between them, then the main thing you need to do is to have all the custom content stuff live outside of the main WordPress folders. So first, you're going to want a fresh copy of WordPress somewhere, untouched (and untouchable, ... | How to share WordPress core library | wordpress |
In my <code> functions.php </code> file I would like to remove the below filter, but I'm not sure how to do it since it's in a class. What should <code> remove_filter() </code> look like? <code> add_filter('comments_array',array( &$this, 'FbComments' )); </code> It's on line 88 here. | That’s a very good question. It goes down to the dark heart of the plugin API and best programming practices. For the following answer I created a simple plugin to illustrate the problem with easy to read code. <code> <?php # -*- coding: utf-8 -*- /* Plugin Name: Anonymous OOP Action */ if ( ! class_exists( 'Anonymo... | How to remove a filter that is an anonymous object? | wordpress |
Simple question. When pagination is activated, the URL changes to <code> "site.com/page/2" </code> . For my site, this should be <code> "site.com/paggetto/2" </code> . How can I change that rewrite rule? I also want to change <code> "author" </code> and other variables. | For some sites in German I use the following plugin to translate <code> page </code> to <code> seite </code> (the German word for <code> page </code> ): <code> <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Page to Seite * Description: Ersetzt <code>/page/</code> durch <code>/seite/</code&g... | Change the "page" slug in pagination | wordpress |
As of wordpress 3.4 we're supposed to use wp_get_theme to return theme data. <code> $theme = wp_get_theme(); //var_dump($theme); echo $theme->Author; </code> despite the var_dump indicating the correct string, $theme-> Author always returns a hyperlink with the author's name, but linked to the author's site. how can... | Do not use just the header string, call <code> display() </code> instead and set the second parameter to <code> FALSE </code> to suppress markup. <code> // FALSE for no markup $theme->display( 'Author', FALSE ); </code> What you see in your <code> var_dump() </code> are private properties. If you print <code> $theme... | use wp_get_theme() to get theme author name | wordpress |
I installed the library jscrollpane , and its working fine but i need to disable it in the #content that is in frontpage template // <code> jQuery.noConflict(); jQuery(document).ready(function($) { //tells WP to recognize the $ variable //paste your jquery code here $('#content').jScrollPane(); }); //end document ready... | this should work- <code> $('#content').not('body.home #content').jScrollPane(); </code> | disable jscrollpane in specfic div | wordpress |
I'm trying to show the most popular (recent) posts on my blog. I have made a special formula for this. I am querying for these posts like so: <code> $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' => '_post_popularity', 'meta_query' => array( array( 'key' => 'post_date', 'val... | As you've discovered, meta queries only work with the post meta table, it is indeed looking for a meta key of <code> post_date </code> . You can't do timespan queries with a simple query, but we can accomplish this with a combination of a query for the meta key, and a <code> posts_where </code> filter directly on the S... | Query Posts By Post Publish Date, but sort by Custom Meta Key | wordpress |
How can I echo the value of a meta select box into my template? Here is how I have setup my meta boxes: <code> // Add the Meta Box function add_custom_meta_box() { add_meta_box( 'custom_meta_box', // $id 'Custom Meta Box', // $title 'show_custom_meta_box', // $callback 'post', // $page 'normal', // $context 'high'); //... | <code> <?php echo get_post_meta($post->ID, 'custom_meta_box', true);?> </code> | echo the value of a a meta select box | wordpress |
I would like to put up a splash page and have all site links (posts, pages, etc.) to redirect to this splash. I know there are a number of ways to create a splash (i.e. page template in WordPress and set the front page as this template or even create an index.html file at the root of my WordPress install and rename the... | I'd usually use the the Maintenance Mode plugin which also includes some nice headers features and is easy to activate/deactive. Using the settings, if you want a custom splash page, you just put a 503.php file in the active theme and then set the plugin to use that as the redirect landing page. | How do I put up a splash page and have all WordPress links redirect to this page? | wordpress |
I'm trying to create a private type of community ... and the current <code> Capabilities </code> are great, except for the fact that I don't want users of a certain <code> Role </code> being able to see anything that someone else has created (posts, pages, etc) I'd love to be able to create some new <code> Capabilities... | User Role Editor plugin allows you to create custom roles easily, and if you wish, change any standard WordPress user role (except administrator) as well. This plugin is very well maintained. But just in case you haven't, I would like to suggest that you first consider reading about the various pre-defined Roles in Wor... | Role Capabilities: Add New Ones? | wordpress |
At times, I need to return the output of a loop (usually with <code> WP_Query </code> like in this example) for use in a shortcode or with a filter on <code> the_content </code> . The following code that uses object buffering works, but I've read in other places that buffering can be inefficient. I've seen HEREDOC too,... | There are replacements that return pure strings for all parts, no need to print anything into an output buffer. I like <code> sprintf() </code> and would write your example like this: <code> <?php if ( $cms_pl_pages->have_posts() ) { $content = '<section class="cms-pl-gallery">'; while ( $cms_pl_pages->h... | How to return loop contents | wordpress |
Im currently using WP-Memory-Usage plugin on my wordpress multisite network to monitor my memory usage. The memory usage displays 39.1 MByte . Does it mean 39.1 MByte per blog? | No, this has to do with each page load and uses PHP's memory_get_usage() plugin. Every page load will have a slightly different memory usage. Disabling plugins will decrease it, as the plugin doesn't have to load on that page. This means that the usage will be different on every blog, and possibly on different pages in... | Memory question on Wordpress Multisite | wordpress |
I'm working on implementing a WP feature that shows the most commented posts from the last X days (e.g. lat 2 days). I've used the following code I found on the web (and here on SO), which does the job: <code> <ul> <?php function filter_where($where = '') { //posts in the last 30 days $where .= " AND post_date... | Try removing the filter after your query, so it does not affect other queries around your page. <code> //.. your loop... endwhile; wp_reset_query(); remove_filter( 'posts_where', 'filter_where' ); </code> | WordPress most commented posts of last X days | wordpress |
i'm trying to replace news system on my website with posts from wordpress site. I have main site in (example) /var/www/site and working Wordpress blog on /var/www/site/blog Tried to do that: http://codex.wordpress.org/Integrating_WordPress_with_Your_Website and neither wp-load nor wp-blog-header are working. I'm gettin... | Providing this will work if it's all on the same server. This is the PHP I use at the top of non-wordpress site. <code> define('WP_USE_THEMES', false); require('/home/sites/example.co.uk/www/wp/wp-load.php'); </code> Obviously you just need to put your server path to the <code> wp-load.php </code> file. Just write your... | Trying to integrate wordpress query on other website - getting redirection to wp-install | wordpress |
I'm using the following code to generate tags <code> <?php if( has_tag() ): ?> <?php echo '<div id="tagWrapper">'?><p>Tags</p><?php the_tags('<ul class="tags"><li class="tag-body olive">','</li><li>','</li></ul>'); ?><?php echo '</div>' ?&... | The function <code> get_the_tags(); </code> is probably what you are looking for. The following code displays a list of tags with links to each one and a specific class for each tag: <code> <?php $tags = get_the_tags(); $html = '<div class="post_tags">'; foreach ($tags as $tag){ $tag_link = get_tag_link($tag-&... | Apply class to the a tag link generated in post tag links | wordpress |
I have wondered about the web and came across this beautiful piece of code: <code> if(has_post_thumbnail()){ the_post_thumbnail(); }else{ echo '<img src="' . get_bloginfo('template_directory') . '/images/default_post_thumb.jpg" />'; } </code> What it does, is adds a default thumbnail to every single post. That's ... | The code below shows the "post-thumbnail" aka the featured image if the post has one, if not depending on the category, the default thumbnail is shown (with the comments, the code should be self-explanatory): <code> <?php // If the post has a featured image defined use it if( has_post_thumbnail() ) { the_post_thumbn... | Display thumbnails for certain category posts | wordpress |
I would like to be able to conditionally hide the author's name on the Single.php if the Category name is equal to "News" and otherwise if the category is something else hide it. How do I go about doing this? The code I have below does not seem to work: <code> <!-- header.php --> <?php get_header(); ?> <... | <code> is_category </code> returns true if the current page being viewed is a category term page (i.e. a list of posts belonging to some term) and false otherwise. So inside <code> single.php </code> it will always return false. If you want to check if a the current post in the Loop belongs to some category term, then ... | How to conditionally hide author name on Single.php if category is "news", otherwise if category is something else display author name? | wordpress |
While you can view the full file here , here's the function that enqueues the JavaScript file(s) needed by the plugin: <code> function ippy_bcq_add_scripts() { $options = get_option('ippy_bcq_options'); $valuebb = $options['bbpress']; $valueco = $options['comments']; $ippy_bcq_bbp_fancy = get_option( '_bbp_use_wp_edito... | Finally, got it to work. Add this in functions.php: <code> add_action('wp_enqueue_scripts','aahank_register_script'); function aahank_register_script(){ //Re-register quicktags script wp_deregister_script('quicktags'); wp_register_script('quicktags', 'http://static-content.com/wp-includes/js/quicktags.js', false, false... | Deregistering and registering javascript breaks plugin | wordpress |
To start... I am new to Wordpress and developing themes. I've got a main menu which I've placed in my header using the following code: <code> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'topNav', 'after' => '<span> </span>' ) ); ?> </code> I've also defined my men... | If your developing this theme with your own html mark up and css then should be fairly easy... <code> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'topNav', 'after' => '<span> </span>' ) ); ?> </code> You will notice this menu PHP generates a unordered list with yo... | Automatically Display Sub Menu | wordpress |
when I create a gallery I get this code generated yet I can;t find out how <code> <img width="150" height="150" src="http://localhost/wp2/wp-content/uploads/2012/06/28_0120-150x150.jpg" class="attachment-thumbnail" alt="_28_0120" title="_28_0120"> </code> What function generates the thumbnail URL and how does the... | The thumbnail size is based on the dimensions defined in WordPress Dashboard > Settings > Media , unless your theme overrides it. how can I make my theme override it? To change default post-thumbnail size, you need to use <code> set_post_thumbnail_size </code> . Add this in your functions.php file: <code> if ( function... | How do I get gallery thumbnail URL and change the default thumbnail size? | wordpress |
When trying to click the "Add New Equipment Type" button for my custom taxonomy, it simply moves the DOM element up into the list of entries and fails to add the actual term. Here is my taxonomy code: <code> $labels = array( 'name' => _x( 'Equipment Types', 'taxonomy general name' ), 'singular_name' => _x( 'Equip... | I just had this exact problem, and it came down to a bizarre naming issue that I can't explain. I have a post type <code> event </code> and I created a taxonomy <code> event_tag </code> . It exhibited the behavior you describe, as did any tax name beginning with <code> event </code> . Changing it to anything that didn'... | Clicking Add New button for custom taxonomy only moves element | wordpress |
all. Just trying out switch_to_blog() as a way to have a child site get some news items from the parent site. Problem is, the parent site--first tables in database--doesn't have a number, i.e., tables are like www_posts--there's no number to put in the parentheses, 0 doesn't work, empty doesn't work. How can I referenc... | <code> switch_to_blog(1); </code> to switch to the root (primary) blog and pull post info. <code> restore_current_blog(); </code> to switch back. | switch_to_blog() for parent theme | wordpress |
I do not want my clients to select a parent page from the drop down list, when creating a child page, so I would like to create a link on the dashboard which links to "add new page" - but with a preselected parent page. Is this possible? And if not, then is there a way to change the default parent from "(no parent)" to... | welcome to WPSE! stackexchange-url ("This answer") from Mike Schinkel was useful to find a solution * for stackexchange-url ("Get QueryString values with jQuery"). <code> * </code> (not used anymore, a simple <code> $_GET </code> does it) It's also worth noting that, in that same answer, Mike also links to this other i... | Add new page with preselected parent | wordpress |
I am trying to pull out all post ID's that have the same post title. This is in a custom post type called 'course-manager'. Here is what I have so far: <code> $pages = array(); $args1 = array( 'post_type' => 'course-manager', 'posts_per_page' => -1, ); query_posts( $args1 ); $page = get_page_by_title( $current_po... | Just change the <code> $args </code> array to this: <code> //Let's say you're searching the posts with the title 'The searched post': $pages = array(); $args1 = array( 's' => 'The searched post', 'post_type' => 'course-manager', 'posts_per_page' => -1 ); query_posts( $args1 ); </code> Your <code> query_posts <... | Getting all ID's matching a title in a custom post type | wordpress |
I am using the following code to output a list of items in my 'documents' Custom Post type by Year and Month. <code> <ul> <?php $post_type = 'documents'; global $wpdb; /**/ $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = '".$post_ty... | Thanks SickHippie. This is what I ended up with: <code> <?php $args = array( 'posts_per_page' => -1, 'post_type' => 'documents', 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'download-category', 'field' => 'slug', 'terms' => 'cascade-campus-docs' ) ) ); $my_query = null... | Custom $wpdb Query for Custom Post Type by Category | wordpress |
I've recently been forced to edit the core files of a plugin. I've updated the title of said plugin to indicate that its been edited. My question is will the plugin still get update notifications? If so, I'll likely disable the updates for this plugin, to prevent someone forgetting about my updates and overwriting. Ide... | As SickHippie says and AFAIK, you can't have both. I'm adding an answer with the info I collected in this Stack. stackexchange-url ("Disable update notification for individual plugins") Bainternet in a Comment: Simply open up the plugin file and change the version number to something like 9.9.9 Hameedullah Khan's Answe... | If I rename a plugin (in its main php file) do I still get update notifications? | wordpress |
Quick, simple. I have <code> front-page.php </code> working in Wordpress, and these loops over the main loop for my latest posts. The problem is the pagination template. When I get to <code> site.com/page/2 </code> , it shows the same file template <code> front-page.php </code> , but with the second round of posts. Wha... | Add a filter to <code> frontpage_template </code> and check the <code> paged </code> query var, adding your own template when it's beyond the first page. I use <code> paged.php </code> in this example: <code> function wpa56889_template_filter( $templates = '' ){ $paged = get_query_var( 'paged' ); if( $paged > 1 ) : ... | Template hierarchy about pagination after front-page.php | wordpress |
How to query posts from single post format on Genesis framework? I want to just show posts from gallery post format only. I tried this query: <code> <?php $recent = new WP_Query( "taxonomy=post-format&field=slug&terms=post_format-link&posts_per_page=5" ); while($recent->have_posts()) : $recent->t... | The taxonomy should be <code> post_format </code> and term should be <code> post-format-link </code> . Also simple taxonomy queries are deprecated since 3.1 in favor of <code> tax_query </code> : <code> $args = array( 'posts_per_page' => 5, 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' =>... | How to query posts from single post format on Genesis framework | wordpress |
I want to display the current archives name, so for the url below I could do something like this <code> <h1><?php echo "answer" ?></h1> </code> which would output something like this <code> <h1>News</h1> </code> or better yet <code> <h1>News: supplierName</h1> </code> http://ww... | This is probably what you need: <code> <?php if (is_category()) { // Show only on Category archive pages ?> <h1><?php echo single_cat_title('News: '); ?></h1> <?php } elseif (is_tag()) { // Show only on Tag archive pages ?> <h1><?php echo single_tag_title('News: '); ?></h1&g... | Display an archives name | wordpress |
Lets say on my WordPress website I navigate to: www.example.com/media-centre/news/17/an-example-news-post In this case I am looking at a post in a CPT called <code> News </code> . What I want to do is get the page ID thats closest to that URL. I know the closest page ID can be found at: www.example.com/media-centre/new... | Got there myself with the aid from Stephen Harris and some PHP help over at SO. <code> $page = get_closest_page(); // echo $page->ID; function get_closest_page( $url = false ) { global $wp; if( ! $url ) $url = $wp->request; $page = get_page_by_path( $url ); if( $page ) return $page; $url = dirname( $url ); return... | Get closest page ID from URL | wordpress |
I tend to place my wp_enqueue_scripts hooks on my functions.php but this ends up piling up scripts across my site. Which makes more sense? 1: <code> function load_slider(){ global $post; if($post->ID == 11746){ // Load slider on home page wp_register_script('start-slidorion', get_bloginfo('stylesheet_directory') . '... | method two won't work because no page is loaded yet and $post isn't set when your if check runs. with method one again $post is not yet set at that point, but this method will work if you use WordPress conditionals : <code> function load_slider(){ if( is_page(11746) ){ // Load slider on home page wp_register_script('st... | Loading scripts on specific page | wordpress |
I have bought a WP theme from a huge provider (themeforest). But it has a lot of bugs. The support asked me to send my WP Admin Login/Password. What risk does this have? I know the supportstaff will have full access to the WP installation, with the WP admin credentials. this is ok for me. But what about the server this... | If you give the provider full admin, they can technically do anything to your server that PHP would be able to do (by using the editor part of a given theme to add whatever commands they like). PHP is capable of running command line scripts, just to name one scary permission they would inherit. Depending on what user (... | Can someone (Support of my themeprovider) get access to my server If I send them my admin login? | wordpress |
After searching several hours, I've decided to crowd-source this one. I have a client who uses Wordpress very frequently, they often have to create a link to a certain page for collecting donations - the issue is they always get the link wrong (long story, but they always screw it up!). I've been searching for a plugin... | You can make a button to the Tinymce editor that adds a pre defined link like this youtube button: Put this in your functions.php theme file: <code> // Hook into WordPress add_action('init', 'mylink_button'); // Create Our Initialization Function function mylink_button() { if ( ! current_user_can('edit_posts') &&am... | Is there a plugin to insert pre-defined link into editor? | wordpress |
I'm using the Plugin List Category to show a list of posts and I use it with the parameters: <code> [catlist name=talleres thumbnail=yes thumbnail_size=52,52 excerpt=yes customfield_display=featured] </code> But it doesn't show anything for the custom fields. I tried with different parameters, still nothing. Does anyon... | still don't know what exactly fixed it. but now it's all right. i have also found another way to show custom fields: if you want to show a specific field in a specific place, in the CartListDisplayer.php, add to the function lcp_build_post anywhere you like: $lcp_display_output .= get_post_meta($single-> ID, 'featured'... | Plugin List Category: post custom field doesn’t show anything | wordpress |
I created a theme, and I created a page for the theme, and now I want to associate posts to the page. I read this article: http://codex.wordpress.org/Pages Look under the section "Examples of Pages and Templates", there is this code: <code> <div id="content" class="widecolumn"> <?php if (have_posts()) : while ... | You can use <code> wp_query </code> with different arguments to list the posts that you want to appear on that specific page (i.e. all the post that are assigned to the X category or all the post that belong to Y author a.s.o). You can find on the Wordpress Codex a detailed presentation and examples on how to use wp_qu... | associate posts to a page | wordpress |
My user post a new custom type "artprim_item" and it doesn't work unless I remove permalinks. The item is created, but the permalink links to "item not found". More importantly, if I open the item with my admin account and update it, the permalink works at last. Since I only want him to see "artprim_item" and no "page,... | Found that it works if I add the <code> edit_posts </code> capacity. But <code> Posts </code> is now visible in Admin :( At the same time, it also fixed a problem I had with Media upload: the user could never edit right after the upload. | Custom role can't create permalink | wordpress |
Can someone please help me, I'm looking for a way to find the main parent product category of a WooCommerce product? Say, the product is marked under Gadgets, but the main parent of them all is Electronics. I want this per post, as I want to add a class to each post signifying its main parent <code> product_cat </code>... | I wrote my own function to go all the way up the "chain". My recursive might not be the best implementation you've seen, but it works. <code> function get_parent_terms($term) { if ($term->parent > 0) { $term = get_term_by("id", $term->parent, "product_cat"); if ($term->parent > 0) { get_parent_terms($ter... | Get main parent categories for a product | wordpress |
I am making a mobile site, and I want to serve higher resolution images to devices with high pixel density, and normal image to the rest, is there a Wordpress functionality or plugin to help me do that? I'm not looking for non-wordpress libraries/plugins. | Here are some plugins that may be just what you're looking for: http://wordpress.org/extend/plugins/wp-retina-2x/ http://wordpress.org/extend/plugins/wp-responsive-data-image/ .. also take a look at this post: http://wordpress.org/support/topic/adaptive-images https://github.com/JorgenScott/WP-Resolutions | Is there a way to serve different resolution images to different devices? | wordpress |
Is it possible to set a CSS stylesheet or a theme for articles that were published before X date? The reason I ask is that we've just redesigned our website and some pages have images that are wider than the page size now. | I php you can create an anchor class based on the desired date. I haven't tested it, but it should be something like this: <code> // your relevant html parent element <div class="<?php echo getOlderPostsClassName( '5/5/2012',the_time() ); ?>"> function getOlderPostsClassName($untilDate, $wordpressPostDate) ... | Date based CSS/theme | wordpress |
I'd like to have the first paragraph/sentence of my posts in their single.php page styled differently - say... bold. How do I go about doing that in the most efficient way? | In the end, this is the function that worked for me: <code> add_filter('the_content', 'first_line_bold'); function first_line_bold($content) { if (!is_page()) { $pattern = "/<p.*?>([^`]*?)<\/p>/"; $match = "<span style=\"font-weight:bold;font-size:16px;\">$1</span>"; $content = preg_replace($pat... | How to format the first line of a post differently? | wordpress |
I am currently converting this page into a wordpress site. Now as you can see on the page I linked to, I need some sort of way to organize the data on the site. I have already looked for a plugin for the job but I can´t find the right thing. can someone suggest a plugin that could do the job? things that the plugin sho... | I found a good plugin afterall: post index this plugin makes it easy to create a list with an alphaindex from articels from a specific category. just make a new page, put the shortcode from the plugin which specifies the category on it and its done. all article from that category are now added to the list. the article ... | plugin to organize data | wordpress |
I'm using the buddypress hovercards plugin and Im dislaying some profile info as well as the latest status update. If a user posts a long status, it will run out of the hovercard div field. How can I properly truncate this? <code> <div class="update"> <strong><?php _e("Last update", 'bp-hovercards'); ?&g... | You can filter <code> 'bp_get_activity_latest_update_excerpt' </code> . Sample code, not tested, you will need my utf8_truncate() </code> : <code> add_filter( 'bp_get_activity_latest_update_excerpt', 'wpse_56860_trim_buddypress_excerpt' ); function wpse_56860_trim_buddypress_excerpt( $excerpt ) { // Number of character... | Truncate latest activity in buddypress | wordpress |
I am trying to preview a NextGen gallery on my main page (and category pages) to show a single image from the gallery on the main page next to the text from the post that normally shows up. I have found examples of PHP that get the images from a gallery given a gallery ID. In my loop I have a current post. What I canno... | I have found a solution. After a bunch of searching around I found some code that determines if a post has a specific short code in it. That code also has some attempt to parse the parameters to the short code. Which is good because I want the gallery ID. There were some issues with the code as posted so I tweaked it. ... | How do I get the attributes of a short code from a post? | wordpress |
Does anyone know how to override the BuddyPress logout URL with a custom one? | That’s the same as the regular WordPress logout URL. So you can use the same filter: <code> 'logout_url' </code> . Sample code, not tested: <code> add_filter( 'logout_url', 'wpse_56866_logout_url' ); function wpse_56866_logout_url() { // set your URL here return 'http://example.com'; } </code> | How to create a customized logout URL in BuddyPress | wordpress |
I am building an add-on to an events module that checks for availability, since there wasn't a function for that in that module. Now that I have built the logic, there are three emails I will need to send: One if the post is being submitted for the first time (ie 'New appointment') One if the post has been published by... | edit_post </code> to catch changes. And take a look at <code> wp_transition_post_status() </code> which is called on inserts and updates: <code> function wp_transition_post_status($new_status, $old_status, $post) { do_action('transition_post_status', $new_status, $old_status, $post); do_action("{$old_status}_to_{$new_s... | Check if post is being published for the first time, or is an already published post being updated | wordpress |
I searched a lot of thread regarding my problem, but unfortunately I found nothing works, and this my final option. I want to add some custom fields on my comment form. How can I do that? | Here you go: stackexchange-url ("Adding Custom Fields to WordPress Comment Forms?") And another awesome post on this: http://wpengineer.com/2214/adding-input-fields-to-the-comment-form/ Functions are available to add/update, delete comment meta, similar to post and user meta. Edit: Here's an example to give you a start... | Add Comment Custom Field | wordpress |
On the page where we list all posts made: <code> example.domain.com/wp-admin/edit.php </code> There is a Screen Options tab in the upper right corner. Upon clicking this, a menu slides down. Contained within this slide down menu, are check boxes. When checking or unchecking these check boxes, certain columns in the pos... | What you need is to modify the <code> $columns </code> variable that is used during list display which you can modify using the <code> 'manage_posts_columns' </code> and <code> 'manage_pages_columns' </code> hooks for <code> post_type='post' </code> and <code> post_type='page' </code> , respectively. If you want to ign... | How to Remove Certain Screen Options and Table Columns from post type in wp_list_table? | wordpress |
I have this Table of Contents class below that will find all <code> <h2> </code> <code> <h3> </code> and <code> <h4> </code> tags in a wordpress post and it will create a Table of Contents out of them, it adds an ID to each heading so when you click a link it will take you to that part of the page. He... | The easiest way would be to replace <code> $content = $toc . $content; </code> with <code> $content = str_replace( '[toc]', $toc, $content ); </code> This would do a search for the string [toc] and replace it with the table of contents. It might be more complicated due to how the plugin would work, but on paper it is s... | Table of Contents with a shortcode | wordpress |
I'm working on a website with lots of tutorials/pages. I have made a stackexchange-url ("separate rss feed") for the pages - works fine. But then I had to create a sitemap (a page), and it shows up in my "pages" rss feed! My Question: How can I remove a specific post/page from a feed? | The quick and dirty way is set the published date a year or so in the past, past the oldest posts in the feed. There's also a nice plugin for this - Stealth Publish - where you set a flag in a custom field to exclude it from feeds and the home page feed. | Remove specific page/post from feed | wordpress |
Bulding off of stackexchange-url ("this") response from @kaiser about being able to filter by post types on a search page, I wanted to be able to automatically add-in all of the public post types available. So, after some help with @kaiser, I came up with: <code> function sw_custom_post_type_includes($query) { $args = ... | To clear up some confusion in previous answers, pre_get_posts isn't a filter so you don't need to return anything. Your only problem that I see is the if: <code> if ( !is_search() && !in_array( get_post_type(), $post_types ) ) return; </code> Basically get_post_type() is going to return false during pre_get_pos... | $query-> query_var['post_type'] not set for pages | wordpress |
In my theme, I registered a taxonomy by the name of <code> tax_groups </code> for a custom post type named <code> custom_items </code> . So the following URL was returning the lastest <code> custom_items </code> http://website.com/custom_items/ The Search widget was also working perfectly fine but not Tag and Taxonomy ... | I had to modify queries before they run. So the best practice was to add the following code to function.php: <code> if (!function_exists('my_theme_filter')) { function my_theme_filter( $query ){ if ( $query->is_main_query() ) if ( $query->get( 'tag' ) OR is_search() ) $query->set( 'post_type', array( 'artprim_... | Tags and Taxonomy links not working for Custom Post Types | wordpress |
I am currently hooking on <code> the_content() </code> but that goes through the Wordpress loop too. How can I only hook on the Single.php page? Also, is there a way to only look on the first X posts in the Wordpress loop? By the way, I am creating a plugin | This will handle appending the content to single posts: <code> function yourprefix_add_to_content( $content ) { if( is_single() ) { $content .= 'Your new content here'; } return $content; } add_filter('the_content', 'yourprefix_add_to_content') </code> | How to only hook on Single.php after content? | wordpress |
On my custom tab, I copied media-form from media_upload_gallery_form, only changed form id and action-url to reflect my tab's name. The form displayed as expected, but after click "Save All Changes", the post data is not saved. Please note unlike custom fields that we add filter to "attachment_field_save", this time it... | Just figured out this one-- in the function that load the iframe, add this: <code> if ( !empty($_POST) ) { $return = media_upload_form_handler(); if ( is_string($return) ) return $return; if ( is_array($return) ) $errors = $return; } </code> Then, all the form data get saved as normal. | How to save media-form on custom tab | wordpress |
I got a Drupal site, and I must install WordPress in it. If I install WordPress to "www.mysdrupalsite/wordpress/", will it work as a standard WordPress installation ? THANKS ! | If your are trying to make them run independent from each other, your suggestion should work fine. (Assuming you mean "www.mysdrupalsite.com/wordpress/".) Just make sure you create a separate database for this new wordpress installation. If you have only one database and it is already in use, you can install WordPress ... | WordPress in Drupal | wordpress |
On Firefox I get the following below the footer `Performance Optimization WordPress Plugins by W3 EDGE Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /somedirectories/wordpress/wp-includes/plugin.php on line 405` On Chrome it work... | This is not an error, it is a warning. You can make this go away by: Fixing the warning Write errors to the error log instead of the screen ( best practice ) To fix the error, I recommend looking at what's hooking into wp_footer etc, or using a PHP debugger | Wordpress Site footer on Firefox displays a error | wordpress |
I'm developing a WordPress plugin that will display a publicly accessible noticeboard on a page. I've been asked to add the means to delete existing posts from the noticeboard using the WordPress admin interface, and I've used this tutorial for guidance on creating the table to hold the details of each entry. It's work... | Figured this out myself after kaiser pointed me towards the appropriate entry on the Codex, specifically the part at http://codex.wordpress.org/Class_Reference/WP_List_Table#Notice:_Sortable_Columns which I'd managed to miss. Problem was with the get_sortable_columns method, which should look like this: <code> public f... | Problem with sorting entries in a plugin's admin interface table | wordpress |
Does anyone know of a plugin that has a like feature or thumbs up down etc which stores these likes as custom meta data? Not a facebook like. I'm currently using WTI Likes which stores the data in a new database table. I need a way to sort posts by these likes and it seems the easiest right now is to find a plugin whic... | If you still use the plugin WTI Likes you can get the values direkt from the table that the plugin creates instead of saving values to the post meta. Add this code where you want your list. Now it prints all post that have been liked. From most to least. <code> <?php global $wpdb; $query = "SELECT post_id, SUM(value... | Plugin that lets visitors Like a post (not facebook) and stores likes in custom meta? | wordpress |
Any idea why when I'm on post.php of my custom post type page I no longer see the Preview Changes button? I have checked on an old installation and it shows on WordPress version 3.3 but not 3.4. The custom post page has this HTML: A normal post page has: Why is my custom post page missing the div preview-action in the ... | I run through exact same issue. Later I come to know that custom post type I created was not public and hence it does not have 'Preview Changes' button visible. Prior version of Wordpress was displaying that button but it seems they have fixed it now. To fix it, make sure you set ' public ' to ' true ' in array of argu... | Preview Changes button missing on custom post type page since updating to 3.4 | wordpress |
I was searching WP Ecommerce documentation, trying to find what function to use to add category to WPEC, but no luck. Is there some function or piece of code that can do this? | You can use <code> wp_insert_term </code> to add terms to the <code> wpsc_product_category </code> taxonomy: <code> <?php $args = array( 'description'=> 'term description.', 'slug' => 'my-term' ); wp_insert_term( 'My term', 'wpsc_product_category', $args ); ?> </code> | WP E-Commerce creating categories programmaticaly | wordpress |
Very odd behavior in BuddyPress. When we enter various pieces of information in the About Me textbox on the members profile data in BP, some content is getting hyperlinked as <code> ../members/?s=my content </code> Has anyone seen that? How can I correct it or shut off the hyper-linking? Thanks. | <code> // 2012-07-11 -- turns off hyperlinking of content on Members Profile remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 ); </code> | Certain BuddyPress Member Profile Data Getting Hyperlinked | wordpress |
The WordPress Codex clearly states that if your website is served from <code> example.com </code> , for the sake of performance, you can have the cookies served from <code> www.example.com </code> by adding this to your wp-config.php: <code> define('COOKIE_DOMAIN', 'www.example.com'); </code> Problem: The cookies are s... | Looks like I mis-interpreted what's said in the codex. So, here's the thing... This is what WordPress does by default: <code> define('COOKIE_DOMAIN', '.example.com'); </code> — which means, cookies are sent with all the sub-domains, including <code> example.com </code> itself, even if your WordPress website itself is h... | Serving Cookies From A Different Domain or Sub-Domain | wordpress |
I'm wanting to make a version of my blog on my home computer that I can work on offline. I set up LAMP on my computer (running Ubuntu) and copied all of my files from my server (000 Webhost) with FileZilla. But when I try to access my site on my localhost, I get "Error establishing a database connection." I think I've ... | Did you change your database settings in <code> wp_config.php </code> and copy your database to your local machine? You'll also need to use a text editor to search a dump of your database for any URLs pointing to the live site before importing it locally if you haven't done so already. | Error establishing a database connection when migrating site to localhost | wordpress |
I was wondering what hook i would use to geo-locate a custom post type when it is saved? I have a Custom post type of Restaurant and I want to geolocate the address using googles api and then save it into another field(s) | On post save the 'save_post' action is run. You could hook your function that geolocates to that. | Geolocate Custom Post Type on Save | wordpress |
So I am using a custom post type to create a listing of businesses. Each post made, contains information about each business. The title of each post is the name of the business. When I go to the menu created by the custom post type, I receive a standard listing of posts. (or in this particular case, a listing of busine... | You should use <code> pre_get_posts </code> : <code> add_action('pre_get_posts','wpse56753_businesses_default_order'); function wpse56753_businesses_default_order( $query ){ if( 'business' == $query->get('post_type') ){ if( $query->get('orderby') == '' ) $query->set('orderby','title'); if( $query->get('orde... | How to sort posts in a custom post type by title in ascending order by default? | wordpress |
In the Comments page ( <code> /wp-admin/edit-comments.php </code> ), every logged in user can see all the site comments. I'd like the users to see only his/her own comments and the comments that are left to his/her posts. How can I filter this? | Either of these 3 will help you: <code> //Before getting the comments, on the WP_Comment_Query object for each comment add_action('pre_get_comments', 'wpse56652_filt_comm'); //Applied on the comments SQL Query, you can modify the 'Where' part of the query add_filter('comments_clauses', 'wpse56652_filt_comm'); //After t... | Filtering the Admin Comments List to Show Only Comments from the Current User? | wordpress |
I'm working on a custom wordpress plugin, but I can't seem to figure out how to create the database when installing the plugin. (Or when updating) When searching around this is what I came up with, but this doesn't seem to do anything. <code> function to_install() { global $wpdb; $sql = "CREATE TABLE to_issues ( id int... | Your SQL command is invalid. The error says: WordPress database error: [Incorrect table definition; there can be only one auto column and it must be defined as a key] CREATE TABLE to_issues ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(125) NOT NULL ) Try: <code> $sql ="CREATE TABLE {$wpdb->prefix}to_issues ( i... | Create database on installation | wordpress |
I would like to create a template file and put there a login code, register code and widget code. I can do it for a widget, but I do not know how to do such thing for login and register. Any advice how to accomplish that? | There's <code> wp_register() </code> which displays either a link to the registration or a login link. Then you got <code> wp_loginout() </code> that has either a login or logout link - depending on the login status of the user. Another thing you could do is just adding a <code> wp_login_form() </code> . You can also u... | How to put Login, Register and newsletter widget on the same page? | wordpress |
No matter what, I CANNOT figure out why WP_Query pulls in all posts, and completely ignores <code> posts_per_page </code> ... I only want to show one post. <code> <?php $args = array( 'post_type' => 'post', 'orderby' => 'date', 'order' => 'ASC', 'posts_per_page' => -1 ); // The Query $the_query = new WP_... | Change <code> posts_per_page </code> to <code> 1 </code> only, not <code> -1 </code> . Like this: <code> 'posts_per_page' => 1 </code> <code> -1 </code> means all. | WP_Query only ONE post, won't work | wordpress |
I'm using the following code in my functions.php file to redirect users who are not logged in to a particular landing page <code> <?php if(!is_user_logged_in()) { wp_redirect( 'http://www.mysite.com/landingpage', 301 ); exit; } </code> The problem is I cannot access my wp-login or wp-admin anymore. Every url redirec... | something like: <code> if ( !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) && !is_admin() && !is_user_logged_in() ) { wp_redirect('http://www.mysite.com/landingpage', 301); exit; } </code> should do it. see http://codex.wordpress.org/Function_Reference/is_admin & stackexcha... | Wordpress redirect to landing page if not logged in | wordpress |
WP uses <code> $allowedtags </code> to limit the set of allowable tags for comments.However, comments from administrators are unfiltered. What's the easiest way to ensure admin comments are also constrained to the tags contained in <code> $allowedtags </code> ? | <code> kses_init </code> is hooked onto the <code> init </code> hook with default priority, and (after first removing any of the kses filters) adds filters which strip out tags ( <code> wp_filter_post_kses </code> for posts and <code> wp_filter_kses </code> for comments) if the user does not have the capability 'unfilt... | Make WordPress process admin group comments using $allowedtags | wordpress |
I am developin a theme in php using wordpress.I want to display images on the website . so my question is what will be the best practise 1)store the image itself in a table using an "image" or "binary data" data type of the database server. or 2)store the images as a file in the file system and create a record in a tab... | Its never a good idea to store binary data in your database, take a look at this post: stackexchange-url ("stackexchange-url and this post: stackexchange-url ("stackexchange-url In my opinion, its far faster to use the file system and here's why: The image URL can be stored in a custom field by wordpress - this is very... | images in wordpress themes | wordpress |
I want to redirect all 404 pages to a specific page (not the homepage). Is there any plugin that does that? | Just create a 404.php template file in the themes folder. All 404 redirects should be using this template file from then onwards. | Plugin to redirect all 404 pages to a specific page | wordpress |
The WordPress Codex points to an extremely simple way to change the URL of the wp-content directory, which is, adding this in wp-config.php: <code> define( 'WP_CONTENT_URL', 'http://example.com/wp-content'); </code> And that does the job of serving most of the JavaScript and CSS files on my website from the different d... | Okay, I've tried numerous (literally) codes and methods, and failed miserably. So, like I said in the question, the only safe way seems to be re-registering (unregistering and enqueuing) the scripts. The Scripts: <code> http://mywebsite.com/wp-includes/js/comment-reply.js http://mywebsite.com/wp-includes/js/quicktags.j... | Serving wp-includes (front-end) javascript from a different domain? | wordpress |
I'm developing a WordPress widget following Dave Clements tutorial . It works well. Now I want to add some styles to it. I want the styles to be in an extra css file which will be loaded during runtime. I'm calling this function <code> function myprefix_add_my_stylesheet() { wp_register_style( 'myprefix-style', plugins... | <code> wp_enqueue_scripts </code> is called way before WordPress processes the widget content, so just as in stackexchange-url ("this post"), you've missed the boat :). Instead, just call <code> wp_enqueue_style </code> directly: <code> function widget($args, $instance) { wp_enqueue_style( 'myprefix-style', plugins_url... | How do I register a stylesheet inside a WordPress widget? | wordpress |
I have my website working from www.xyz.com/wordpress, but customers should not need to type it all. If they just type www.xyz.com it should take them to www.xyz.com/wordpress. | To redirect <code> http://www.xyz.com/ </code> to <code> http://www.xyz.com/wordpress/ </code> add these rules to your .htaccess file: <code> RewriteEngine On RewriteCond %{HTTP_HOST} ^(www.)?xyz.com$ RewriteRule ^(/)?$ wordpress [L] </code> That answers the first part of your question. The rest of it is totally vague ... | Redirect all www.xyz.com to www.xyz.com/wordpress? | wordpress |
I have buddypress installed. All URL goes under BP's URL structure. If an attachment belongs to a document in a group, the URL is: <code> http://domain.com/groups/group-name/docs/doc-name/attachment-name </code> I would like to learn how to change the attachment URL to: <code> http://domain.com/?attachment_id=123 </cod... | The attachment URL is created in <code> wp-includes/link-template.php </code> in function <code> get_attachment_link() </code> . And there is a filter for you, passing the WordPress URL and the post id for the attachment. You can hook into that filter and return the URL you need: <code> add_filter( 'attachment_link', '... | How to remove parent section from attachment URL? | wordpress |
While a specific use-case, I believe this may benefit others. I am using TurboCSV to mass-import a number of posts into WordPress (which it is doing wonderfully so far). Within that import, I am specifying custom fields to be used in conjunction with Advanced Custom Fields to store/output the data. The post_meta table ... | Have you seen wpshell ? It's a command line tool for wordpress. Basically, it's a Wordpress environment that lets you run arbitrary php - so you could set up a <code> WP_Query </code> that pulls all posts, loop through them, and fire that command on each one. Sort of what I had in mind, untested. Using <code> wp_update... | Faking the "onSave" event | wordpress |
As far as cookies privacy policy has been change, i need to make a script which allow to accept (or not) cookies by user for this domain (website) only. Is there a way to do this for one website only. Second thing is this popup window should be displayed only if user came from different domain (so each page have to che... | If your question is regarding the new EU cookie policy, you only have to worry about third party tracking cookies that track between sites, WordPress cookies don't fall within that category. | Accept or deny cookies - how to? | wordpress |
Saving extra fields that were added to a taxonomy. I want the most proper & efficient way of doing so. Where should I save the new fields? 2 possible solutions are to 1) Use the Wordpress options table as described here... Add Custom Fields to Custom Taxonomies . This is admittedly "not clean" and assumed not to be... | Option 2 is the cleanest method - which I've also used a number of times. Unfortunately, there is no default term_metadata table in WordPress yet. This post also covers the same approach, http://shibashake.com/wordpress-theme/add-term-or-taxonomy-meta-data And of course, there's a plugin for that too :) http://wordpres... | How to Add Custom Fields to Custom Taxonomies in Wordpress CLEANLY | wordpress |
I am using contact form 7 as a plugin in wordpress but i dont know how to sent different email separetly when i click on different email ids | The documentation for Contact 7 is pretty clear about how to do this - you just need to create a separate mail template for each form and edit the basic header fields http://contactform7.com/setting-up-mail/ | In wordpress how to sent different email separetly when i click on different email ids | wordpress |
I am trying to create a custom field for a custom taxonomy. update_post_meta works great with posts. Taxonomies are not posts so this won't work. <code> <?php update_post_meta($post_id, $meta_key, $meta_value, $prev_value); ?> </code> How would I save a custom field within a custom taxonomy? Other solutions inclu... | <code> update_metadata() </code> great post on Adding Custom Fields to Taxonomy . The solution outlined does require creating an additional database table but it does the job perfectly. | Saving custom fields to a custom taxonomy | wordpress |
Firstly, hi all! I am new to worpress stackexchange. I have been trying to build my own google map to show the location of all my posts. But I don't seem to be able to get the markers to display on the map. Edit: I have changed the code a bit since my origional post, I am now returning data but with errors. This is the... | I have managed to find the problem. Basically calling the google API from the footer was causing the maps to break and not function properly. | Using the loop to set locations for all posts on a single google map | wordpress |
I have a registration form and I would like to make it ajax, is there such plugin or how can I adjust the standard wordpress registration page to be ajax without reloading page. Thanks in advance. | Login With Ajax is a very actively developed plugin that enables AJAX Login / Registration without refreshing your screen. It has a number of other features as well, take a look. | How to make registration form ajax? | wordpress |
I have made website in wordpress, and now client wants to know do this website use cookies? I dont know too much about it becouse i never use it, but i need to be sure. If I make websites i use session, and I quess the same is in wordpress, but as I said, dont know too much about it and client need this information. I ... | Yes, any WordPress site does uses cookies. By default, WordPress uses cookies to verify who the user is, i.e. if the user is logged-in (registered user) or is a commenter on the site. ( More Info. ) Plugins and theme's may set cookies. For example, Cookies for Comments plugin uses cookies to prevent comment spam. Cooki... | Do I use cookies? | wordpress |
How to display the content for given page ID withot the <code> <p></p> </code> wrapper? The method I'm currently using is: <code> <?php $id=21; $post = get_page($id); $content = apply_filters('the_content', $post->post_content); echo $content; ?> </code> For example <code> page ID = 21 </code> has ... | You can add this in your functions.php file for instance, <code> remove_filter ('the_content', 'wpautop'); </code> Which will remove the paragraph formatting from <code> the_content </code> template tag in all cases. Should you have a need for it in the future, you can write; <code> <?php wpautop(the_content());? </... | How to display the content for given page ID withot the wrapper? | wordpress |
For the most part the plugin List Category Posts works great. I just have one problem with it: when I try to show the title and excerpt of a post it shows all translations at the same time, rather than just the translation relative to the selected languages. I'm using qTranslate for the languages. I'm not sure how to f... | I found a hint towards the solution exactly where you advised me. I think the solution was a bit outdated, but with a bit of digging, I made the following change: in file <code> include/CartListDisplayer.php </code> , in <code> function get_post_title() </code> I added the following code in first line before anything e... | Multilanguage Post Titles not Translating with List Category Posts Plugin | wordpress |
I want to know is there any hook to remove the <code> Restore </code> link in the edit page - trash page? <code> /wp-admin/edit.php?post_status=trash </code> I know I can hide it with a css/jquery trick, but I prefer to use a hook for this. | This will do: <code> add_filter('post_row_actions', 'wpse_56560_remove_untrash', 10, 2); add_filter('page_row_actions', 'wpse_56560_remove_untrash', 10, 2); function wpse_56560_remove_untrash( $actions, $post ) { if( !isset( $actions['untrash'] ) ) return $actions; // If NOT administrator, remove Untrash if( !current_u... | How to Remove the "Restore" Link in Quick Edit? | wordpress |
I would like to display two images in my header. functions.php: <code> define('BP_DTHEME_DISABLE_CUSTOM_HEADER', true); //add support for featured images with post type of header image add_theme_support( 'post-thumbnails', array('header_image') ); add_action( 'init', 'create_post_type' ); function create_post_type() { ... | I think you should be using the WordPress <code> loop </code> instead of a foreach, since you're using WP_Query. <code> <?php if( $header_images->have_posts() ) { while( $header_images->have_posts() ) { $header_images->the_post(); ?> <div class="header-image"> <?php echo get_the_post_thumbnail( ... | display two images in theme header.php file | wordpress |
I need opposite of this: <code> <?php if ( get_post_meta($post->ID, 'price_list_category1', true) ) : ?>style="display:none;"<?php endif; ?> </code> In other words I want <code> style="display:none;" </code> only when meta data doesn't exist. I thought it would be straightforward like <code> if ( get_pos... | You could use the <code> empty </code> function inside your <code> if </code> as such : <code> <?php if( empty( get_post_meta( $post->ID, 'price_list_category1', true ) ) ) : ?>style="display:none;"<?php endif; ?> </code> The above returns an error, you should assign the return value to a variable. See m... | if get_post_meta is empty do something | wordpress |
The European Union has introduced a directive requiring that websites obtain permission for setting all 'non-essential' cookies. In the UK (where my site is based), the appropriate detail is explained by the ICO . As I understand it, with a 'vanilla' WordPress site the only cookies set are: Those for logged in users to... | That is actually dead simple. Cookies are set by <code> wp_set_comment_cookies() </code> and this function is hooked into <code> 'set_comment_cookies' </code> . Just remove the function from the action: <code> <?php # -*- coding: utf-8 -*- /* Plugin Name: No Comment Cookies */ remove_action( 'set_comment_cookies', '... | Disable saving comment details (name, e-mail) in cookie? | wordpress |
In my Wordpress permalink settings I have set the <code> Tag-Base </code> to "". So <code> /tag/whatever </code> is the current-url structure for my tag-page. However I do have a <code> custom-post-type </code> with a <code> custom-taxonomy </code> that is also using this as <code> rewrite_slug </code> . <code> registe... | If you hook into the 'rewrite_rules_array' filter, do a print_r on $rules, and you'll see the huge preg-match key-value pairs. <code> add_filter( 'rewrite_rules_array','mess_with_rewrite_rules' ); function mess_with_rewrite_rules( $rules ) { print_pre($rules); return $rules; } </code> See where your rule is in the stac... | Permalinks: custom structure for taxonomy - tags? | wordpress |
I'm not sure why this script is not loading or producing any load errors via Firebug. Here is my plugin script: <code> class AV_Slideshow{ function __construct(){ $this->hooks(); } function hooks(){ add_action('wp_head', array( $this, 'load_av_slider' )); } function load_av_slider(){ wp_register_script('av-slideshow... | The class constructor method isn't called until your shortcode handler is (i.e. when WordPress is searching the post content for shortcodes). This is done after <code> wp_head </code> is called, so you're missing the boat. However, you don't need to enqueue scripts on your <code> wp_head </code> - and doing so for shor... | Script won't load via plugin class | wordpress |
I'm working in wordpress multi site, but this question is relevant for regular use in wordpress. How can I hide certain sidebars from certain user groups (e.g. editors or admins) ? I have already tried the trivial: <code> if(is_admin() && user_can(...)){ register_sidebar... } </code> But this doesn't hide the s... | I am assuming you mean to limit access to edit a sidebar in the admin interface, not to remove it on the theme. Without getting to deep into how the widgets/sidebar framework functions behind the scenes, your best bet is going to be to fiddle with the <code> $wp_registered_sidebars </code> global. However, the key is w... | How can I hide certain sidebars from some users? | wordpress |
<code> { $ad_code = str_replace("xxxx",$_SESSION['user_id'],$resultset->description); $ad_code = str_replace("XXXX",$_SESSION['user_id'],$ad_code); echo '<tr>'; echo '<td class="col2"><strong>'.$resultset->name.'</strong></td>'; echo '<td><textarea cols=65 rows=5>'; echo ... | After taking a look at the code for the plugin, it doesn't look like there's an easy way to do this. Affiliates are stored in one table that has no direct relationship to your WP users table - this means you can have users who aren't affiliates and you can have affiliates who aren't users. That's why there's a big "Imp... | Echo user id of users in seperate table | wordpress |
Now, when you add or edit a particular post within your desired post type, there are more screen options as well. Although, these Screen Options are showing/hiding meta boxes. I would like to be able to programmatically obtain a list of all of these registered Screen Options of meta boxes, so that I can again check if ... | What you need is in global <code> $wp_meta_boxes </code> indexed by <code> get_current_screen()->id </code> . Removing the screen options will also remove the metaboxes which you can do just before screen options are displayed using the <code> 'in_admin_header' </code> hook. So let's assume you want to get rid of th... | How to Remove Certain Screen Options and Meta Boxes from add/edit post type? | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.