Tag Info

New answers tagged

-1

I's struggling for this issue, and found no guaranteed solution, one works in one project, then breaks in another, may be a code conflict. Anyways, the _s (underscores - a community-driven starter theme by Ian Stewart) uses simply: wp_register_script('gallery-script', MALEFICENT_PATH . '/js/jquery.bxslider.min.js', array('jquery'), null, true); According ...


1

The jQuery library packed with WordPress, operates under noConflict mode. Means you can not use $ in your jQuery snippet/code. Either use jQuery instead of $. or use noConflict wrapper like this. <script type="text/javascript"> <!-- jQuery(document).ready(function($) { // your jquery function, you can use $ here. }); // ...


0

I have tried the answer from the @Rarst, but in fact it is not very stable solution to the problem. If you try to var_dump the $meta var above, you will notice that there is at least one another meta field _oembed_time_xxxxxxxxxxxx which is probably for cache busting. And also, when I removed the oEmbed link from the content of the post, the cached eEmbed ...


0

You can use add_group to put the new items at the end of the menu Example, also I merged the functions for you: function my_add_admin_nodes( $wp_admin_bar ) { if ( is_admin() || ! current_user_can( 'edit_users' ) ) { return; } $args = array( 'id' => 'my-group', 'parent' => 'site-name', 'meta' => ...


1

You actually have already answered your question, that it's not enclosed in a function that's why it's not working. The codex says: The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site. You can use it to call functions, both PHP and built-in WordPress, and to define your own functions. And if ...


0

It is possible if you shape your meta query to look for the serialized string like this, assuming your array value is always an integer: $params = array( 'meta_query' => array( array( 'key' => 'mediSHOP_product_extras', 'value' => 's:11:"is_featured";i:1;', 'compare' => 'LIKE' ) ) ...


0

How about post meta ? if ( ! update_post_meta (7, 'sent', '1') ) { add_post_meta(7, 'sent', '1', true ); }; add_post_meta Or options table or custom table


0

looks like your elseif statement isn't correct. try something like : if ( is_single() || is_page() ) { echo get_the_title(); } elseif ( is_home() || is_front_page() ) { echo "Predefined Name"; } else { echo wp_title; } http://php.net/manual/en/control-structures.elseif.php


1

As this line of code is hardcoded in the index.php file rather than called via a function you only really have two options: Write your own function to call this code (with your chosen read more text), then replace the relevant section in the child theme's index.php file with a call to this function. The function would go in your child theme's functions.php ...


0

From the Codex: add_filter( 'the_content_more_link', 'modify_read_more_link' ); function modify_read_more_link() { return '<a class="more-link" href="' . get_permalink() . '">Your Read More Link Text</a>'; } Add this to the child theme's functions.php.


0

I found it. After a lot of research I found the way to hook into logout and get user data, and as i was looking for that i found the exact answer i was looking for. function users_last_login() { $cur_login = current_time('mysql'); $userinfo = wp_get_current_user(); update_user_meta( $userinfo->ID, 'last_login', $cur_login ); } ...


1

You are right in assuming that $post->post_content contains tags and other not textual entities like shortcodes. You can use strip_tags to get rid of the tags but you will probably want to expand the shortcodes first. resulting in something like $count = strlen(strip_tags(do_shortcode($post->post_content)); And it will still give you the wrong ...


3

You can use this function wp_strip_all_tags. strlen( wp_strip_all_tags($post->post_content)); With that you get rid of all the HTML tags. Just a little extra detail, you might want to strip the shortcodes, too. You can use this function strip_shortcodes You will end up with something like this: strlen( ...


0

You second function, last_login references the $userloginfo variable which is not within the function's scope. Try the following: function last_login($login) { global $userlogininfo; update_usermeta($userlogininfo->ID, 'last_login', current_time('mysql')); }


0

if it is "a very complex theme," then there's probably some hook into template_redirect malfunctioning. as @TomJNowell mentioned, using home.php or front-page.php should allow you to override page.php, but that's not always preferred (I rarely use them myself), and will not necessarily fix the problem. you don't need to assign a blog page in order for there ...


1

Just because you think that you have to do it doesn't remove the fact that it is very not smart to do it. The plugin code is built to be used as a plugin and not as a theme, and while you can copy parts of the code and use them in the theme there can not be any simple way to make sure there is no dependency left somewhere in the code. The easiest way to do ...


1

Install plugin: https://wordpress.org/plugins/force-regenerate-thumbnails/ and regenerate all thumbnails. Or steps: Create new dimension for images: add_image_size ('thumb-cropped', 227, 133, true); // Set necessary sizes (true = cropped) Get images with the sizes in you function. get_the_post_thumbnail($post->ID); fix to: ...


2

The $post global variable is set by $wp_query->the_post() (WP_Post) inside the loop and is accessible during the loop. $post holds the post data from the current post. When you are inside the loop, you don't need to call the $post global, as it is already accessible. When you are outside the loop, and you need to access post data, you need to make use ...


5

In the tutorial (Example 1), he has to declare the global $post so that he can access the post_parent from it. In a function like that, the $post is not a global variable unless he makes it so. In the codex (Example 2), it is declared global because the sample code is just a sample, explicitly trying to tell you that the $post variable is a global one. ...


0

Figured out the answer! It turns out that in ACF, if you're using radio buttons and have key set for each value, the keys CAN in fact contain spaces! By matching the keys to the values (case-insensitive) I was able to get the conferences to display on the single-team posts.


0

What was the error that it "hiccups and spits"? I can also suggest, assuming it's an error with the include_once or require_once functions and without knowing what type of error you are encountering, that you ensure that the path you are providing is a directory path: require_once( plugin_dir_path( __FILE__ ) . "subfolder/*.php" ); And not a URI: ...


1

All actions are actually filters internally. So yes, you can do things in a filter hook. However, be mindful of which filters and what you're doing. Some filters are ran everywhere, and doing expensive operations on them may lead to massive slowdowns. Also beware of recursion. If your expensive operation triggers the very filter you've hooked on to..


1

It means Wordpress is outputting something to the browser too early. The file indicated seems to be your own session file (php stores user sessions in small text files in the tmp directory). Check first the wp-config.php file. Remove the final closing php tag. Make sure you're not outputting anything in that file (look for print_r, var_dump, echo, print, ...


0

I'm making some brief assumption based on the way you have typed your question.. "After moving the plugin to the theme folder" Meaning you have taken the plugin from the plugin directory to your wp-content/themes/THEME_FOLDER. If this is the case then calling plugin_dir_path( __FILE__ ) will be unsuccessful in finding your file. You would need to use ...


0

<link href="<?php bloginfo('stylesheet_url');?>"rel="stylesheet" type="text/css"/> Just Copy and Paste above code.


0

Use page templates, an overview can be found here: http://codex.wordpress.org/Page_Templates Edit for those afraid of dying links: A page template file should be placed in the theme folder, with any name you like. In its header, it should have <?php /* * Template Name: My Custom Page * Description: A Page Template with a darker design. */ // Code ...


0

Add the following to your wp-config.php define( 'WP_SITEURL', 'www.amandabarise.com/singer' ); define('WP_HOME', 'www.amandabarise.com/singer'); That should make the site work again, but try to correct the values, and read this


0

You can get the data from user meta with the below code $pastids = get_user_meta($user_id, $key); $pastids will be an array automatically. Now we can change its structure in any format. if we pass an array to add_user_meta() it will save it in serialized format and when we get it using get_user_meta() it return save data in array format.


1

Take a look at PHP's array_values function. Alternatively, you could typecast. Note that if the array is in serialized form as you have put it above, you will have to unserialize it first, in either case. $numerical_array = array_values( unserialize( 'a:1:{s:8:"post-134";s:3:"134";s:8:"post-136";s:3:"136";}' ) ); or $numerical_array = ...


0

You need to include the post type in the pre_get_post filter: (Not sure about global $user_ID;, just reproduce that part of your code) function content_for_current_author($query) { if($query->is_admin) { global $user_ID; $query->set('author', $user_ID); $query->set( 'post_type', array('acf', 'another-custom-pot', ...


1

Traditionally, sidebars were implemented as lists. Each sidebar "box" is an LI, so the sidebar as a whole would need to be inside a UL tag. However, this is entirely a choice on the part of the theme author. The register_sidebar call can override the before_widget and after_widget parameters to be divs or anything else that the theme like, really. The ...


0

Please, post your code because the problem is not the one you guessed. Actually, $wpdb is available very early: it is inited by the function require_wp_db() located in the file wp_settings.php at line #79. The hook 'plugins_loaded' is fired in the same wp_settings.php file, but at line #237, so pretty after $wpdb is available.


0

Just add another AND (&&) clause to the end of it. <?php if ( is_woocommerce_activated() && isset( $woo_options['woocommerce_header_cart_link'] ) && 'true' == $woo_options['woocommerce_header_cart_link'] && sizeof( $woocommerce->cart->cart_contents ) !== 0) {...} Probably best to take a look at some of the PHP ...


2

wp_loaded is too early, the request hasn't been parsed yet - use the action wp instead (called at the end of WP::main(), once the request has been parsed and posts have been queried). To get the user object, just use $author = get_queried_object();


0

You need to learn how the WordPress template hierarchy works. It is very important for any individual who wants to learn WordPress or take their current WordPress experience to the next level to know of and understand all of the different aspects of the WordPress Template Hierarchy. If you plan on consolidating, or organizing the content on your WordPress ...


2

You can make use of WP_User_Query to retrieve a list of all user's ID's and then pass that to get_userdata to retrieve a user's registration date. You can then sort and exclude users from that according to a specific date and time. Here is my idea <?php $user_query = new WP_User_Query( array( 'fields' => 'ID', ) ); $users = ...


3

Method #1: The pre_user_query hook: There are not many filters available, but you can try the pre_user_query hook: // Add filter: add_action( 'pre_user_query', 'wpse_filter_by_reg_date' ); // Query: $query = new WP_User_Query( $args ); // Remove filter: remove_action( 'pre_user_query', 'wpse_filter_by_reg_date' ); where the filter callback is: /** ...


0

See, if your files are just simple php files (not hooked in WordPress by any way), the WordPress functions will not be accessible in those files. If you want to create different pages with different structure/layout, you should first create templates into your theme/child theme, add new pages from admin dashboard and then assign them the template that you ...


2

in content.php change <?php the_excerpt(); ?> with <?php the_content(); ?> Or use this content.php file instead. I made changes in your content.php <?php /** * The default template for displaying content * * Used for both single and index/archive/search. * * @package WordPress * @subpackage AsperTheme * @since AsperTheme 1.0 */ ...


0

array_intersect() is not a good choice when you need a partial match. Go through each class, and apply both checks before you remove a class. Example, not tested: function remove_menu_classes( $classes ) { // List of allowed menu classes $allowed = array ( 'current-menu-item', 'current-menu-ancestor', ...


0

If the person commenting is already logged in you could capture the user object like so $user = wp_get_current_user(); and then simply grab the username like $user->user_login. Once you have this it shouldn't be too hard to add in to the creation of a comment so its only asking for the username alone and only once logged in.


0

Doing anything without a "page-load" most definitely requires Javascript because your now venturing into the A-Synchronous (AJAX) territory and JQuery is a great library to use for this stuff. The most simple and straight forward of which is the $.post(...) method. You could then attach this send and receive AJAX call to either a shim of Javascript that ...


0

Actually WordPress render uploaded images. So if you upload a animated gif then it will not stay animated. Read this article on how to overcome these issue. I haven't read it through but as Howdy_McGee said, you will have to use a plugin for that. Essential WordPress Plugins for Working With Animated GIFs


1

@Xeoncross, You write in your WP Dev profile You may notice that some of my questions run very deep into the heart of certain issues because I strive for the highest optimization that is possible in my apps. That's all well and good for an App, your App or an App that you're working on; or your own programming philosophy and techniques. But ...


2

I wanted to restrict my website except a specific page. This is my solution: function restrict_access_if_logged_out(){ global $wp; if (!is_user_logged_in() && !is_home() && ($wp->query_vars['pagename'] != 'name-of-page') ){ $redirect = home_url() . '/wp-login.php?redirect_to=' . esc_url($_SERVER["HTTP_HOST"] . ...


0

function restrict_access_if_logged_out(){ if (!is_user_logged_in() || !is_home()){ $redirect = home_url() . '/wp-login.php?redirect_to=' . esc_url($_SERVER["HTTP_HOST"] . urlencode($_SERVER["REQUEST_URI"])); wp_redirect( $redirect ); exit; } } add_action( 'wp', 'restrict_access_if_logged_out', 3 ); Rather than && use || with your ...


-2

Here is a workaround: Create a menu named Category Menu register_nav_menu( 'category-menu', "Category Menu ); Now your client can configure the menu as he pleases. All you have to do is paste the code below where you want it to be displayed and voila wp_nav_menu('category-menu');


1

I think the most sane way and easiest way of doing this is to unset the first value in the returned array, and then adding it back at the end of the returned array before your foreach loop For this to work, you will need to sort your categories by ID as you need to take category ID 1 and add that to the back. Something like this will work <?php $args = ...


1

From the info you have given in your post, I believe you are using a custom page.php template here Here is the the reasons you get the output as stated: The main query executes on each and every page that is loaded. The main query is very specific for every type of template. $wp_query is the super global used by the main query To test the how unique the ...


1

Because the global $wp_query represents the query for the current page (the "main" query) and is completely separate from your custom $author_query. If you want to use pagination functions, you can "fake it" by temporarily setting $wp_query to your custom query, and then resetting afterwards: global $wp_query, $wp_the_query; $wp_query = $author_query; // ...



Top 50 recent answers are included