Tag Info

New answers tagged

0

Posts that aren't attached have no parent, and posts with no parent have a parent of 0. So this: if ( is_attachment() && isset( $post->post_parent ) && is_numeric( $post->post_parent ) && ( $post->post_parent != 0 ) ) { becomes this: if ( is_attachment() && ( $post->post_parent == 0 ) ) {


2

Linux users have nothing to do with WordPress users. WordPress maintains its own user database, with its own permissions. The linux user PHP is running as is determined by the server setup, usually whatever user that Apache/Nginx/etc are running as. If your PHP can access the entire file system then you have a serious security issue and should contact your ...


1

You can include this code by creating a new custom plugin which help you to stop this when you deactivate the plugin. wp_schedule_event(time(), 'daily', 'my_dailyClearOut'); function my_clearOldUsers() { global $wpdb; $query = $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE datediff(now(), user_registered) > 7"); if ($oldUsers = ...


1

Here is a great example. How to display featured post thumbnails in WordPress feeds paste this code snippet in your theme functions.php file // display featured post thumbnails in WordPress feeds function wcs_post_thumbnails_in_feeds( $content ) { global $post; if( has_post_thumbnail( $post->ID ) ) { $content = '<p>' . ...


0

For serializing and unserializing Data in Wordpress, you can use maybe_unserialize and maybe_serialize. If you want to handle the data and add/change values, you could use something like this: $metaarray = maybe_unserialize(get_post_meta($post_id,'_ait-dir-item',TRUE)); //now $metaarray has an array, if it is serialized. If not, $metaarray has a string. ...


0

You should first run the wp_insert_post() which will return the post ID. Then use that post ID to add your custom fields. Use add_post_meta() to add the custom fields. $post_id = wp_insert_post( $args ); add_post_meta( $post_id, 'longitude', $my_long ); add_post_meta( $post_id, 'latitude', $my_lat );


0

If you post your header.php code then I could help you better. But I cannot comment as I do not have 50 rep. But referring to your website I checked the code and there is this tag from where this is coming from. If you modify your h1 tag and add your logo in it the logo should appear. <h1 class="site-title"><a href="<?php echo esc_url( home_url( ...


0

You can go to the theme editor, open the header.php model and replace the content <div id="header-text"> <h1 id="site-title"> <a href="http://www.physics4all.com/" title="Physics for All" rel="home">Physics for All</a> </h1> <h2 id="site-description"></h2><!-- ...


0

Ok. Then you can use template_redirect hook and wp_is_mobile() conditional tag. wp_is_mobile() will work on device only. If you resize the window then it will not work. Now you can try this kind of code in your functions.php file add_action('template_redirect', 'redirecting_to_mobile_site'); function redirecting_to_mobile_site(){ if( wp_is_mobile() ){ ...


-1

Use this for admin <div class="updated"><p><strong><?php _e('Total 12 Records Saved.' ); ?></strong> </p></div>


-2

is this page in front-end or within wp-admin? If the latter you can easily use admin_notices for that: admin_notices


0

Depending on what you really need, the usual way of activating user registration in the settings and giving your users a link to http://www.yoursite.com/wp-register.php (for registering) and http://www.yoursite.com/wp-login.php (for logging in after registration) might be all you need, as described by Josh Mountain. If you want a fully fledged community, ...


0

You can enable user registration in Settings->General and checking the box for Anyone can register. You then can provide your users links to /wp-register.php and /wp-login.php. If you are looking to build a social network I would look into the BuddyPress plugin: https://buddypress.org/


1

Use get_permalink (which returns the URL) instead of the_permalink (which prints the URL). Try: foreach ( $categories as $category ) { $link = get_term_link( $category ); $html .= "<li><a href='{$link}' data-filter='{$category->category_nicename}'>{$category->cat_name}</a></li>"; }


4

You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce. <?php if ( class_exists( 'WooCommerce' ) ) { // code that requires WooCommerce } else { // you don't appear to have WooCommerce activated } ?>


0

There are a few things going on with your functions.php file that may be the issue. You should be using wp_enqueue_scripts action to enqueue your script. The first parameter of wp_localize_script() should match the id of the file you've enqueued. You also need to add a no_priv version for your Ajax call if it needs to work for non-logged in users. Have a ...


0

@import is not good solution AFAIK it takes a bit more time to download @import link and then process it, so you gonna have a little bit of network bottleneck. I'd go with default style.css file where you have all wordpress required meta data and then renamed diginomics.com/css/style.css to gobal.css and linked it with absolute link. Such semantic naming is ...


1

If you want an example of how to do the dropdown filtering using ajax, then if you factor out your taxonomy dropdown into your "functions.php": function my_dropdown_categories( $taxonomy, $current_selected = '', $include = null ) { // Get all terms of the chosen taxonomy $terms = get_terms($taxonomy, array('orderby' => 'name')); // our ...


0

I found the solution. I Changed enctype="text/plain" to enctype="application/x-www-form-urlencoded" and that worked.


0

Use jQuery action on first dropdown .. this is the code from your mentioned url .. You can populate the arrays using php functions ... function dynamic1(parent,child) { var parent_array = new Array(); // This is the default value parent_array[''] = ['Please select a manufacturer']; // All other elements // parent_array['PARENT NAME'] = ...


0

If you're using an absolute reference like that, you'd want to include the full file path, like http://diginomics.com/wp-content/themes/THEMENAME/css/style.css I believe any time you call the functions like get_stylesheet_directory() or get_stylesheet_directory_uri() it will return the path for the current theme. Just keep in mind that all themes need a ...


0

This is an old problem I had forgotten about. The problem here is that an old database was selected in the left hand menu of phpMyAdmin(read: I'm new to database management). The table was already in use and therefore populated - this error message is because phpMyAdmin tried to write to the first line, couldn't(already held data) and then quit. Simply ...


0

This has something to do with the HTML of a media object. I copy/pasted code from another image imported from the media gallery and it worked. Use this function to insert the content: http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent tinyMCE.activeEditor.setContent('<span>some</span> html');


0

is_page( array ( 'About us', 'blog', 'contact', 'Services') ) Actually my mistake is as @PieterGoosen said, I have missed a ' after contact. Also, I have mentioned some parse error which is because of ; at the end of the statement.


1

You should get yourself a proper syntax highlighter. You are missing a ' after the word contact. Your code should be is_page( array ( 'About us', 'blog', 'contact', 'Services') ) These errors are quite specific, so you should read them carefully EDIT Apparently there where another syntax error that was not mentioned and no context was given to support ...


-1

is_page( 'About us' ) || is_page('contact') || is_page('blog') || is_page('Services') By using the above condition, i can view my desired widget on these pages


0

Yes and No. WordPress, Out-of-the-Box isn't really going to accommodate your needs. With some plugins WordPress is definitely capable of handling these tasks. Depending on what is out there, you may be looking at developing custom plugins.


0

The problem is that you are passing a comma separated list of terms, not an array of term. For example, if you enter 'army,navy,airforce' in the custom field: $related = array ( get_post_meta($post->ID, 'related_categories', true) ); //$related = array('army,navy,airforce'); //What you need is //$related = array('army','navy,'airforce'); You need to ...


0

$wpdb->query() returns number of rows affected by the query. It's returning NULL indicates that there is an error in your query. The problem with your query is that you are updating $wpdb->posts table, but the condition depends on $wpdb->postmeta table. You have to join these tables for the query to work. Another problem is that you have to place ...


0

I finally figured this out. What ended up working is putting the script portion in a .js file within the theme directory, calling it using the functions.php in my child theme, and having the HTML input field and div tag in the body of the page. Hopefully this can spare others the same pain I went through.


0

Use get_post_format() inside your loop: if (have_posts()) : while (have_posts()) : the_post(); $format = get_post_format(); if (false === $format) { get_template_part('content', get_post_format()); } endwhile; twentyfourteen_paging_nav(); else : get_template_part('content', 'none'); endif;


1

I would look into using HyperDB instead. This would allow you to pull data from several databases while one is replicated as the "master" database. http://wordpress.org/plugins/hyperdb/ From the description page of the plugin: It supports: Read and write servers (replication) Configurable priority for reading and writing Local and remote ...


0

OMG, finally, as the code runs from the plugin, the current working directory is set to wp-admin whereas when i run it manually it set for /wp-content/plugins... hope this post will help others.


0

Please note that if you have lessons that are in multiple chapters you will create duplicate content. If you want an easy way to connect these post types you can use a free plugin called Post Connector: http://wordpress.org/plugins/post-connector/


0

@s_ha_dum is right, the ajax plugin api is the way to go. I ran into this issue myself with a dynamic js file I was generating a little while ago. Basically you would enqueue your style as follows: wp_enqueue_style('dynamic-css', admin_url('admin-ajax.php').'?action=dynamic_css', $deps, $ver, $media); ...


4

The Automatic Sponsor Posts Injector: Here's one idea based on my answer for the question: How to show Y number of custom posts after every X normal posts? I hopefully made it a little bit more useful here on Github, but it may be refined much more (future work). The SponsorPostsInjector class will help you to automatically inject the sponsor posts into ...


1

has_term must be used inside the loop. If you use it outside the loop you have to pass the post ID or post object you want to check. In the single.php file put your code inside the loop to check the current post: <?php get_header(); while(have_post) { the_post(); ?> <div class="non-home-parallax product-listing-parallax" style=" ...


0

As indicated in the comments, you should return the string, not echo it: add_shortcode('yt', 'getYoutubeDetails'); function getYoutubeDetails($atts) { extract(shortcode_atts(array( 'video' => '' ), $atts)); // Get YouTube data via the API $JSON = file_get_contents("https://gdata.youtube.com/feeds/api/videos?q=$video&alt=json"); ...


0

Your functions have nothing to do with each other. Is all you want a button that when clicked adds [tooltips class="top_tooltip" title="Your Tooltip here"] Text here [/tooltip] to the editor? -- This is currently what your doing -- First Function: function tooltip( $button ) is adding your tooltip shortcode Second Function: mce_tooltip( $button ) is ...


1

The second one is revision. It means the changes that you made, but didn't save. Wordpress saves that as revision post. There might be more than one revision post if you make more changes without updating the post. You don't need to worry about that. It's all in background and won't affect you in any way.


1

WordPress as a project has extreme commitment to backwards compatibility. Whatever new things you add the old things need to work still. Whatever things you change still need to work in old way as well. So regardless of how WP started as non–MVC application, it cannot become one without retaining all of its non–MVC ways. Which makes it pretty pointless ...


-2

I prefer to keep my PHP inline when possible to avoid scattering its start or end tags and possibly miss one. It's closer to the OP's original attempt and imo reads cleaner/clearer: <?php if(get_field('website') || get_field('emailaddress')) : ?> <footer> <?php if(get_field('website')) : ?> <a href="<?php ...


2

I believe you are on the right track with your second idea there, but you have some syntax errors with your conditional. In PHP all of your logic should be wrapped inside one set of ( ) for your conditional. Try this: <?php if ( get_field('website') || get_field('emailaddress') ) { ?> <footer> <?php if ( ...


2

Hiding part of the title with CSS clipping (as the OP requested in the original unedited title) is almost certainly not the best way to accomplish this. Here is how to do this in the template file. If all of your titles will be formatted the same way (with a space, a hyphen, and a space), you can do something like this to get just the second part of the ...


0

The global $wp object contains the current request, which can be used to get the current URL anywhere on the site. A helper function like the following demonstrates how this works: function wp157715_current_url() { global $wp; $current_url = trailingslashit( home_url( $wp->request ) ); return $current_url; }


0

you can use bloginfo('url') but also can use get_option function, check documentation: http://codex.wordpress.org/Function_Reference/get_option and by the way we cannot access your localhost :)


0

As posed in question the way to retrieve the current URL to the root of the site would be home_url() for site's front-end. However there are multiple functions that deal with URLs to specific kinds of pages. It's not clear what you are linking to (post? page? archive?), but there are likely specific URL-forming function for it which should be used over ...


1

bloginfo('url') should get you the URL for the installation. EDIT: I guess you could also use get_permalink()


1

You're not adding HTML code to your file, you're adding invalid PHP. To recap, in PHP everything between <?php and ?> is PHP code. So this is valid PHP: <?php echo 'hello world';! ?> This is also valid: <b><?php echo 'hello world'; ?></b> This is not valid: <?php <b> echo 'hello world'; </b> ?> Why? ...


2

You are including HTML elements without closing the php tags. Also, the last one should be endif, not endwhile. <?php if (have_posts()) : ?> <ul> <?php // Start the Loop. while (have_posts()) : the_post(); /* * Include the post format-specific template for the content. If you want to ...



Top 50 recent answers are included