Articles of functions

update_post_meta is Updating with two page id

I am writing a code to count the number of views of post. For that I am using update_post_meta and passing appropriate parameter. I am calling a function on add_action(‘wp’, ‘function_name’); in functions.php. My problem is, whenever I am loading the page in Chrome, it works fine. But when I am loading the page in […]

Must filter functions receive all arguments passed to them?

I’m writing a filter function to redirect logins: function my_filter_func( $redirect_to, $requested_redirect_to, $user) { // My code. } add_filter( ‘login_redirect’, ‘my_filter_func’, 10, 3 ); The filter hook in the template file is: $redirect_to = apply_filters( ‘login_redirect’, $redirect_to, $requested_redirect_to, $user ); As you can see, $redirect_to, $requested_redirect_to, $user are passed to my filter function. My filter […]

how to enqueque code in a php file from functions.php

Im building a website with wordpress, using a child theme. there is a file in the main theme folders, called entry.php that is where I need to add a bit of php at the bottom of this document. I don’t want to touch the parent theme files, to avoid problems when I update the theme. […]

Writing editor content to a file

I have a project I’m working on where I need to write the content of the post editor to a physical file on the web server when a post is saved or updated. I’ll be parsing and manipulating the content before writing, but I’m having trouble just getting it loaded into a variable. Is there […]

How to get rid of Ellipsis on Woocommerce Theme

As the picture says I am trying to remove the three dots that follow the end of the blue sentence (shown in the photo). I am also trying to increase the numbers of characters it can reveal. Furthermore, for some reason, the blue text shows “&” and “&nspb” symbols at the end of some excerpts, […]

Custom Taxonomy Select Menu: Setting default option value?

I’m creating a series of select drop down menus that pull data from various taxonomies. I got this PHP script working for a WooCommerce attribute of color: function get_color_dropdown($taxonomies, $args){ $myterms = get_terms($taxonomies, $args); $output =”<select onChange=’window.location.href=this.value’>”; foreach($myterms as $term){ $root_url = get_bloginfo(‘url’); $term_taxonomy=$term->taxonomy; $term_slug=$term->slug; $term_name =$term->name; $link = $root_url.’/’.$term_taxonomy.’/’.$term_slug; $output .=”<option value='”.$link.”‘>”.$term_name.”</option>”; } $output […]

widgets not working

I pasted my siderbar widget code in widgets.php file function right_sidebar_widget() { register_sidebar( array( ‘name’ => ‘Right Siderbar’, ‘id’ => ‘right-siderbar’, ‘description’ => ‘Right Sidebar’, ‘before_widget’ => ”, ‘after_widget’ => ”, ‘before_title’ => ‘<h3 class=”widget-title”>’, ‘after_title’ => ‘</h3>’, ) ); } add_action( ‘after_setup_theme’, ‘right_sidebar_widget’ ); included widgets.php file to functions.php file using include_once ‘includes/widgets.php’; But […]

How to convert raw url to hyperlink?

I have a custom field with raw urls and I want to convert them to hyperlinks. So I used this code: <?php $text = get_post_meta( get_the_ID(), ‘Links’, TRUE ); echo make_clickable( $text ); ?> The problem with this code is it doesn’t work with urls that contains spaces in them. How can I make it […]

Extract and display user infromation on an automatically created page

Is there a way to get the block of code below to extract a list of given user information as it creates the page for the new user. It creates new page for new user as supposed but I’d like it to alos extract and display some information from the user profile. function my_create_page($user_id){ $the_user […]

Twitter Product Cards

I am trying to show twitter product cards. I have this function in my functions.php . I validated the twitter card and everything looks good except the product data. I am trying to display it for only the post type shops. function add_twitter_cards() { is_singular( ‘shops’ ); { $tc_url = get_permalink(); $tc_title = get_the_title(); $tc_description […]