Articles of customization

Pagination Not working on Home Page with 2 Query

I have two loops in home page (index.php) <?php $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3, ); $another_query = new WP_Query($args); if( $another_query->have_posts() ) { $i = 0; while ($another_query->have_posts()) : $another_query->the_post(); ?> <?php if($i == 0) { ?> <div class=”col s8″> <?php get_template_part( ‘template-parts/content-magazine-grid-big’, get_post_format() ); ?> </div> <?php } ?> <?php […]

How to cancel an action hooked to untrash_post? or any hook

I want to do the following in a plugin: – hook to untrash_postwith a custom function – do some checking inside custom function – cancel actual post restoring (untrashing) I’ve tried with remove_action but doesn’t seem to work. Can you point me into the right direction? Code sample: add_action( ‘untrash_post’, array( __CLASS__, ‘static_untrash_handler’ ) ); […]

How to use a WP_Customize_Control outside of the Customizer?

I have a few custom WP_Customize_Control classes that are shown within the standard WordPress Customizer area. These are working fine. Is it possible to pull some of these out of the customizer and show them in a dedicated plugin page? I don’t need the live preview etc.. just need the customizer element to function and […]

Reusable code that I can store in the function.php and apply to other templates as need. Dry Code

I am trying to apply reusable code to some single-posttype template and I was wonder if I can store the code somehow in the function.php and include it where i want to. Here is the code if (!empty( get_field(‘social_title’) )): $socialTitle = get_field(‘social_title’); $socialContent = get_field(‘social_content’); $link = get_field(‘social_link’); $cleanString = strip_tags($socialContent); $cleanTitle = strip_tags($socialTitle); […]

Media Upload not working after hiding some elements from functions.php

I have put the below code in functions.php. (It’s used to hide some options from client.) But the problem is, after adding these codes, images are not uploading, can’t even even uploaded photos from library or while creating a new post. Someone pls help echo ‘<style> #toplevel_page_wpcf7, #wp-admin-bar-wp-logo, #screen-meta-links, #menu-tools, #wp-admin-bar-wpseo-menu, #footer-upgrade, #toplevel_page_wpfront-user-role-editor-all-roles,#toplevel_page_vc-general, #menu-settings,#toplevel_page_wpseo_dashboard, #toplevel_page_revslider, […]

WordPress Count posts within a custom post type

How to WordPress count post within this code. <?php query_posts(‘showposts=6’); ?> <?php $posts = get_posts(‘numberposts=6&offset=0’); foreach ($posts as $post) : start_wp(); ?> <?php static $count1 = 0; if ($count1 == “6”) { break; } else { ?> <div class=”col-md-4 com-xs-12 pannel”> <div class=”pannel-news”> <?php the_post_thumbnail(); ?> <div class=”sidebar-color”> <strong><a href=”<?php the_permalink(); ?>”><?php the_title( ‘<h4>’, ‘</h4>’ […]

Update if post with specific title exists

I am trying to create a post, if it does not exist and update the post by its title if it exists. The title is unique, because its the users username. However, the update functionality does not work. A new post gets created all the time. The following code creates and should update the post: […]

How to add custom 'layout' buttons to wordpress editor?

I’d like to modify the editor by adding some ‘layout’ buttons. Ideally, I’d like to add the ability to add some html ‘partial’ by simply clicking a button. This is to help my client to create pre-coded pieces of page by himself, since he can’t code html markup. So, I would pre-program some micro-templates and […]

How to display page ids as page slug names?

REF: how to get page id of a page using page slug I checked out the above answers but when I pasted any of the code into my child theme’s function php file it didn’t change anything. Here is the code I used: <?php // For this theme only – not the standard way of […]

Add custom columns in custom post type browse page

I made a plugin which adds a “member” custom post type. I customized the edit view (with the editor hook) to get only the fields I want and store them in the database. I have fields like “name, surname, birthdate…” What I want now is to make some of these fields appear in the “browse […]