Tag Info

New answers tagged

1

You could do this like so: <?php $next_post_link = get_next_post_link( '%link', 'Article Précédent', TRUE ); $previous_post_link = get_previous_post_link( '%link', 'Article Suivant', TRUE ); ?> <?php if ( $next_post_link || $previous_post_link ) : ?> <div class="article_single_prev_next"> <div class="article_prev"> ...


0

If you are looking for user only comments then you could try this one ( http://codex.wordpress.org/Function_Reference/wp_set_auth_cookie). This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead. Sets the authentication cookies based User ID. The $remember parameter increases the time that the ...


0

You can use the following in your themes functions.php file: function is_blog () { global $post; $posttype = get_post_type($post ); return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ; } And then put this in the file you are checking: <?php if ...


0

For whatever reason, Alexander Bird's routine didn't quite work for me. I modified it a little to use wp_set_post_tags instead of wp_set_object_terms: function untag_post($post_ids, $tags) { global $wpdb; if(! is_array($post_ids) ) { $post_ids = array($post_ids); } if(! is_array($tags) ) { $tags = array($tags); } ...


0

You need to do the following in a child theme, do not make changes to the theme itself. Copy the content.php file to your child theme. In line 31, the excerpt is called to display the content. You will need to make this conditional with conditional tags to show the_excerpt() for all pages except on archive.php where the_content() will be shown You can do ...


0

You can use wp_trim_words to trim the_content(). Here is a nice small function function wpse_custom_content($limit) { return wp_trim_words(get_the_content(), $limit, '<a href="'. esc_url( get_permalink() ) . '">' . '&nbsp;&hellip;' . __( 'Read more &nbsp;&raquo;', 'wpse' ) . '</a>'); } You can simply just call echo ...


0

Check out the Wordpress Codex reference page for the_excerpt() as it is a built-in way of doing what you're looking to accomplish: http://codex.wordpress.org/Function_Reference/the_excerpt EDIT: it also has an example for shortening the excerpt beyond the default length.


3

Yes, the plugin @Squideyes suggests you, is perfectly fine, and should do the trick. However, I don't like the link-to-plugin only answers, so here the mine. If you upload the file to a subfolder of the WordPress uploads folder (by default wp-content/uploads, but can be easily changed) than convert a file from there to an attachment post is pretty easy via ...


0

Give this plugin a go: http://wordpress.org/plugins/add-from-server It allows you to upload the file via an FTP and then import it via admin. The plugin registers the media file to the database.


0

The problem is not version_compare, the problem is that register_activation_hook is just a shortcut for add_action( 'activate_' . $file, $function ); where $file is plugin_basename( __FILE__ ); and __FILE__ is your main plugin file absolute path. So, what your code does is to call dw_deactivate_theme_options() when the action 'activate_' . $plugin is ...


1

Opcache is transparent for WordPress (as it is to any PHP application). However if you had been using APC for object cache (key/value store) via plugin — that function is not available in new bundled Zend cache, it only does opcode caching. You would need to replace object cache with something different (APCu/Memcache/Redis/etc).


1

You can use the awesome WP_Admin_Bar & hook in with admin_bar_menu: /** * Add a "Log out" link directly to the admin bar. * * @link http://wordpress.stackexchange.com/q/141446/1685 * * @param WP_Admin_Bar $wp_admin_bar */ function wpse_141446_admin_bar_logout( $wp_admin_bar ) { if ( is_user_logged_in() ) { ...


0

your problem is in your use 'menu_class' and 'items_wrap' not synchronized. You can edit : wp_nav_menu( array( 'theme_location' => 'header-menu', 'container' => '', 'echo' => '0', 'menu_class' => 'nav-menu horiz-menu container sixteen columns', 'items_wrap' => ...


4

Is there more efficient ways to validate the quotes using the WordPress api? I think you should set a nonce for the form You also should check if current user has capability to save quote To get properly sanitize values form $_POST look at filter_input and/or filter_input_array I don't see performance issues on validation, but a possible ...


0

Lead dev of Redux here. If you declare global $redux_global in your header.php file, it will be accessible by all other template files within your theme. You can also use $GLOBALS['redux_global']['css-block'] to bypass the need for $global $redux_global.


0

In order for it to save the data you need to hook your validate_dw_quote() onto to an action, such as admin_init or init. add_action('admin_init', 'validate_dw_quote');


1

The question is light on detail but I'd lean toward a custom Walker: class My_Page_Walker extends Walker_Page { function end_el( &$output, $page, $depth = 0, $args = array() ) { $output .= '<span>After the Anchor</span></li>'; } } $args = array( 'walker' => new My_Page_Walker ); wp_list_pages( $args ); That should ...


0

This occurs because you do the explode() call inside the next() call. The reason I think is, by strict standards you shouldn't pass a function to a function like this, because, like @AndrewBartel said, of reference, which would be missing. Doing it like shown below should work and would be correct: $nval = explode( '/themes/', $stylesheet_directory_uri ); ...


0

I will suggest Wordpress Duplicator, It is best tool for copying your site to any other host/localhost, and its free, I have used it many times and it works every-time with different server settings. Please note that I haven't affiliated with it in any way.


0

Its stored in a single file called quote.php Assuming that means that your plugin is stored in wp-content/plugins/quote.php, then the problem is that your code is hard-coded to submit to wse140202.php-- presumably you cribbed some code from another question here. In other words, this line: add_menu_page('Quotes Settings', 'Quotes Styling', ...


2

You will transfer your db a couple of time from and to your live and dev site, so I would suggest downloading and installing a plugin called Velvet Blues Update URL's. This will take care of all the rewriting for you. This is how to use it. Once installed and activated, go to 'Tools >> Update URL's. This will open the following screen In the 'Old URL' ...


2

COMPLETE GUIDE TO EXCERPTS I've recently answered a few questions regarding excerpts, so I' going to give a detailed explanation covering as much as I can. HTML TAGS/FORMATTING the_excerpt() first of all doesn't except any parameters, so nothing can be passed to it. In is a fact that the_excerpt() trims the content to 55 words, and all html tags are ...


0

Here is what I do. Use login form to create login https://codex.wordpress.org/Function_Reference/wp_login_form Below are the login logout redirects and login error handling. This will help you with login issue. /** Login Redirect * Redirect user after successful login. * * @param string $redirect_to URL to redirect to. * @param string $request URL the ...


0

Thanks for posting your link. I'm sorry to say, but the theme you bought is no good, and you should really contact the author for a refund. Your scripts are loaded in the <body> tag, and some scripts even load before the jquery library. It is no use to even try and salvage the theme. You will end up mad. Here is a screenshot of the html Original ...


0

Your queries are showing the same output, because they are identical Here is your first queries arguments: $args = array( 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 5, 'paged' => get_query_var('paged'), 'tax_query' => array( array( 'taxonomy' => 'store-category', 'field' ...


0

For starters, the WordPress Codex has a wealth of information on this very topic. For the sake of brevity that should take care of most of it; however, there are some relievant points that should be made: If you do not wish WordPress (essentially PHP) to have access to the file system with the exception of dynamic static assets such as images or cache then ...


0

I understand this isn't exactly what you're looking for but these hackers are most likely bots and redirecting them won't matter at all. I suppose you could modify the below code if you reallllly wanted to but this will redirect anybody looking for an author back to your homepage. RewriteCond %{REQUEST_URI} ^/$ RewriteCond %{QUERY_STRING} ...


1

It's a pretty simple solution - WP_Query utilizes the name variable for posts and custom post type posts. It utilizes pagename for pages, hence why ?name=product1-faqs is not working. Use this instead: add_rewrite_rule('product1/faqs/?', 'index.php?pagename=product1-faqs', 'top');


1

From performance point of view what takes time is matching URL against generated (and stored persistently so it's not rebuilt continuously) list of regular expressions. Since URLs are (most of the time) insignificantly short in text volume the amount of those regular expression rules has most impact on performance. Unless you generate unreasonably many ...


0

The first thing to check with a 'headers already sent by...' error is that you have no white space at the very start or the end of your php file. Check your images-options.php file and remove any errant space at the very start or the end of your code.


1

It was just a missed line of code since it's a new WP_Query: Needed to add 'posts_per_page' => -1 to $the_query = new WP_Query(array( 'post_type' => 'projects' ));


1

Please try with `ignore_sticky_posts` instead of `caller_get_posts` which is deprecated.


0

I recently had a similar issue. How did you go about moving your website? Did you move all the files to the root folder, or did you simply redirect your site URL in the wordpress dashboard? Did you have a look at the wordpress guide: Giving_WordPress_Its_Own_Directory ? Have you checked your database that the site and home urls are now correct? Does your ...


1

Read the wpdb docs and don't forget to protect your query: global $wpdb; $table_name = $wpdb->prefix . "item"; $login_name = sanitize_user( $_POST['login_name'] ); //assuming you're dealing with username $prepare = $wpdb->prepare( "SELECT * FROM $table_name WHERE uname = %s", $login_name ); $myrows = $wpdb->get_results( $prepare ); //output ...


0

I would store the array to the options able as a serialized value. update_option('dw_quotes', serialize($quotes)); and retrieve with: $quotes = get_option('dw_quotes', null); if ($quotes !== null) { $quotes = unserialize($quotes); } Other things to consider: Add handling in case the quotes option does not exist. Also add handling to delete quotes ...


0

take a look here: http://codex.wordpress.org/Function_Reference/wp_localize_script First add Data in your php file // Register the script first. wp_register_script( 'some_handle', 'path/to/myscript.js' ); // Now we can localize the script with our data. $translation_array = array( 'some_string' => __( 'Some string to translate' ), 'a_value' => '10' ); ...


1

You need to add your function in the template_redirect hook. You need to first wait for wordpress to finish loading pages before you can add your hook to remove wpautop, otherwise your hook will simply get run over. So your funtion will look like this function pietergoosen_remove_wpautop() { if ( is_page ( 'services' ) ) { remove_filter( 'the_content', ...


0

Here's what I've found based off this question at Stack Overflow You'll have to remove wpautop entirely then add it back in whenever needed, which I agree in the linked comment, is unfortunate: remove_filter('the_content', 'wpautop'); remove_filter('the_excerpt', 'wpautop'); /** Change How The Content Works **/ function no_content_autop($content){ ...


2

You can use wp_add_inline_style(). Let's assume you enqueue your css like so add_action( 'wp_enqueue_scripts', 'add_my_style' ); function add_my_style() { wp_enqueue_script( 'my_style', get_template_directory_uri() . '/mystyle.css' ); } Then you can change the function like so: function add_my_style() { wp_enqueue_script( 'my_style', ...


0

You can just use a relative path. For example, if your stylesheet is in /wp-content/themes/mytheme/css/mystyles.css and your image is in /wp-content/themes/mytheme/images/nav-divider.png, then your path would be ../images/nav-divider.png.


1

You should remove the link from the anchor tag: <a class="button" href="#" style="background-color:white;color:black;"> <strong>Submit</strong> </a> Then your jQuery part should be: $('a.button').click(function(event){ event.preventDefault(); //your ajax gets here: jQuery.ajax({ type:"post", ...


2

It's certainly possible but you're probably looking at doing an ajax request on the image click which in turn executes the short code and returns the output. This involves three distinct steps, binding the ajax request to an action, executing the ajax request and handling the response, and actually writing the script that will process the request. This ...


0

If you want your posts based on different categories you should use category_name or cat as category id. For example; <?php $test = new WP_Query('cat=1&showposts=1'); // where 1 is the id of your cat ?> Or <?php $test = new WP_Query('category_name=errands&showposts=1'); ?> Also, you need to call wp_reset_postdata(); after each ...


0

Not sure if you are asking how to do this, but it's a setting in Settings > Permalinks. You would select the Day and Name option. This should automatically format your Post articles in this format.


-1

Another option is to use wordpress json api. As bueltge mentioned the rss feed is one way to get your content but json api couldbe better in this case :) Option one is to use http://wordpress.org/plugins/json-api/ option two would be the jetpack json api.


1

If you really want to execute code stored in a database, a quick google search reveals that you can use the eval() function to do just that. However, many people do say that Eval is Evil... Instead of storing the entire PHP code of an option in the database, try storing a simple boolean flag for your option and then test whether to get your template's ...


0

Something like this should work but you haven't stated where you want to display the CPT pages for games. function display_games_archive( $query ) { if ( !is_admin() || $query->is_main_query() && is_post_type_archive( 'portcat' ) ) { $query->set( 'category__in', 'games' ); return; } } add_action( 'pre_get_posts', ...


0

There are two types of translations in the WordPress website: Label Translation in WordPress Core and Theme, for that gettext technique is useful (as mentioned by you .po and .mo files) Content Translations for that you will need to add multi-lingual plugin to handle such feature. Good Example of such plugin are: http://wordpress.org/plugins/qtranslate/ ...


2

As @gate_engineer already stated, your problem is a plain PHP problem where you are trying to access an Object as Array. To not only state that, but help you a bit further, the correct check for a proper response object is checking against the return value of wp_remote_retrieve_response_code() and wp_remote_retrieve_response_message(): $response = ...


1

References: wp_remote_post() The WP_Error Class Stopping the Fatal Error: The error that you're receiving above is due to the fact that wp_remote_post() returns a WP_Error object if a request to the remote web server failed. When the script executes the next expression on line 63: if ( $response['response']['code']!='200' ) ...PHP gets confused as to ...



Top 50 recent answers are included