Skip to content

Instantly share code, notes, and snippets.

@hakikz
Last active July 23, 2019 11:11
Show Gist options
  • Save hakikz/4df833923c87c1e5522d8fd7acf74b67 to your computer and use it in GitHub Desktop.
Save hakikz/4df833923c87c1e5522d8fd7acf74b67 to your computer and use it in GitHub Desktop.
WordPress Tweaks
<?php
function rename_header_to_logo( $translated, $original, $domain ) {
$strings = array(
'Electro' => 'Ecommerce Theme', // 'The Existing Name' => 'Desired Name'
'Custom Header' => 'Custom Ecommerce Theme'
);
if ( isset( $strings[$original] ) && is_admin() ) {
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'rename_header_to_logo', 10, 3 );
?>
<?php
add_action( 'admin_menu', 'nstrm_remove_admin_submenus', 999 );
function nstrm_remove_admin_submenus() {
remove_submenu_page( 'themes.php', 'pt-one-click-demo-import' ); // ('themes.php', 'themes.php?page=pt-one-click-demo-import')
}
?>
<?php
function wps_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->remove_node('theme_options');
//Inspect the Top Menu from browsers and get the ID and set it with example ('theme_options'). Done
/*
If need to remove only from front end just use this condition
_____________________________________________________________
if (is_blog_admin()) {
$wp_admin_bar->remove_node('theme_options');
}
_____________________________________________________________
others are same.
*/
}
add_action( 'wp_before_admin_bar_render', 'wps_admin_bar' );
?>
/***************************************
Query and Pagination Code For Custom Taxonomy (taxonomy.php
***************************************/
/*
After Apply These Code-
1. Please refresh the permalink from settings
2. And keep same the 'posts_per_page' => 10 and Settings > Readings> Blog pages show at most
*/
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 10, 'paged' => $paged,);
if ( have_posts() ) :
while ( have_posts() ) : the_post();
?>
<h4><?php the_title(); ?></h4>
<p><?php the_content(); ?></p>
<?php
endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
) );
wp_reset_postdata();
endif;
?>
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment