prevent display duplicate titles on main page

Your code should look like this to exclude duplicate titles <ul> <?php // Initial counter for displayed posts. $counter = 1; // Initial empty array of displayed titles. $titles = []; $portfolio = new WP_Query([ ‘post_status’ => ‘publish’, ‘post_type’ => ‘post’, ‘cat’ => ” . $link1 . ”, // Because we don’t know the number … Read more

Nav menu custom html:

WordPress themes can be set up in many different ways, which is both a blessing (you can do things however you like) and a curse (there’s not always a single file you need to look at to make a particular change). You’re on the right track, looking into the theme. What you’ll need to do … Read more

How could I add load more posts to my theme? [closed]

You can add a load more button using a variety of WordPress plugins, just pick one and follow the instructions. I like this one: https://wordpress.org/plugins/ajax-load-more-anything/ Yes, it is possible to add it without using the REST API but the REST API is a great use for this type of activity. To provide a concrete example … Read more

Limit user access to installing/configuring a plugin?

WP doesn’t have a built-in way to restrict permissions this granularly. You can either install plugins, or not. For settings, it depends on where the plugin surfaces its settings. For example, if the settings are under the “Settings” menu, then by default only users with role “administrator” will be able to access and adjust them. … Read more

Dashboard Menu settings

Try this code: add_action(‘admin_menu’, ‘custom_menu_page’); function custom_menu_page(){ add_menu_page( ‘Pages’, ‘Pages’, ‘manage_options’, ‘Pages’, ‘page_callback_function’, ‘dashicons-media-spreadsheet’, 26 ); add_submenu_page( ‘Pages’, ‘All Pages’, ‘All Pages’, ‘manage_options’, ‘all-pages-list’, ‘subpage_callback_function’ ); }

How to check if the postID is in an array? [closed]

As Sally highlights, you can use in_array() like this (untested): // target ids $ids = array(123, 321, 213); if (!empty($post->ID) && is_numeric($post->ID) && in_array((int)$post->ID, $ids)) { // do jazz } else { // do stuff }

How do I get information about a page, such as featured image, except, and title?

When you save a selected page in the Customiser you’re just saving the post ID of the page, which means you can just pass that value to any function that accepts a post ID as a parameter: $mytheme_f_page[1] = get_theme_mod( ‘mytheme_featured_page_1’ ); echo get_the_title( $mytheme_f_page[1] ); echo get_the_excerpt( $mytheme_f_page[1] ); echo get_the_post_thumbnail( $mytheme_f_page[1] ); The … Read more